From: Chris Allegretta Date: Sat, 22 Sep 2001 04:20:25 +0000 (+0000) Subject: Added mac file support too X-Git-Tag: v1.1.2~57 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=8fa1e2868167042b2292a643b75c5c20b4ddca37;p=nano.git Added mac file support too git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@774 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/ChangeLog b/ChangeLog index 5c0260f4..cf015979 100644 --- a/ChangeLog +++ b/ChangeLog @@ -14,6 +14,8 @@ CVS code - new code in read_line and write_file. New cmdline flag (-D --dos) to automatically write the file in DOS format, regardless of the original format. + - Mac file writing supported too. Flag -M, --mac. No toggle + as of yet. - nano.c: main() - Added vars oldcurrent and oldcurrent_x to check whether cursor diff --git a/Makefile.in b/Makefile.in index ec5298e5..57b35c99 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated automatically by automake 1.4 from Makefile.am +# Makefile.in generated automatically by automake 1.4-p4 from Makefile.am # Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation @@ -155,7 +155,7 @@ all: all-redirect .SUFFIXES: .SUFFIXES: .S .c .dvi .info .o .ps .s .texi .texinfo .txi $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) - cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile + cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status cd $(top_builddir) \ @@ -164,7 +164,7 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(ACLOCAL_M4): configure.in cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) -config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) +config.status: $(srcdir)/configure.in $(CONFIG_STATUS_DEPENDENCIES) $(SHELL) ./config.status --recheck $(srcdir)/configure: $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES) cd $(srcdir) && $(AUTOCONF) @@ -324,7 +324,7 @@ uninstall-info: else ii=; fi; \ list='$(INFO_DEPS)'; \ for file in $$list; do \ - test -z "$ii" \ + test -z "$$ii" \ || install-info --info-dir=$(DESTDIR)$(infodir) --remove $$file; \ done @$(NORMAL_UNINSTALL) @@ -531,7 +531,7 @@ distdir: $(DISTFILES) @for file in $(DISTFILES); do \ d=$(srcdir); \ if test -d $$d/$$file; then \ - cp -pr $$/$$file $(distdir)/$$file; \ + cp -pr $$d/$$file $(distdir)/$$file; \ else \ test -f $(distdir)/$$file \ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ diff --git a/aclocal.m4 b/aclocal.m4 index 5ffb9773..a9a9d423 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1,4 +1,4 @@ -dnl aclocal.m4 generated automatically by aclocal 1.4 +dnl aclocal.m4 generated automatically by aclocal 1.4-p4 dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation diff --git a/config.h.in b/config.h.in index 02ba1537..7fcb8da2 100644 --- a/config.h.in +++ b/config.h.in @@ -1,4 +1,4 @@ -/* config.h.in. Generated automatically from configure.in by autoheader 2.13. */ +/* config.h.in. Generated automatically from configure.in by autoheader. */ /* Define if using alloca.c. */ #undef C_ALLOCA diff --git a/files.c b/files.c index 6f08a100..d31fcdc5 100644 --- a/files.c +++ b/files.c @@ -184,7 +184,11 @@ int read_file(int fd, char *filename, int quiet) /* Read the entire file into file struct */ while ((size = read_byte(fd, filename, input)) > 0) { linetemp = 0; - if (input[0] == '\n') { + if (input[0] == '\n' +#ifndef NANO_SMALL + || (ISSET(MAC_FILE) && input[0] == '\r') +#endif + ) { fileptr = read_line(buf, fileptr, &line1ins); num_lines++; buf[0] = 0; @@ -1125,10 +1129,12 @@ int write_file(char *name, int tmp, int append, int nonamechange) #endif } #ifndef NANO_SMALL - if (ISSET(DOS_FILE)) + if (ISSET(DOS_FILE) || ISSET(MAC_FILE)) write(fd, "\r", 1); + + if (!ISSET(MAC_FILE)) #endif - write(fd, "\n", 1); + write(fd, "\n", 1); fileptr = fileptr->next; lineswritten++; @@ -1151,13 +1157,17 @@ int write_file(char *name, int tmp, int append, int nonamechange) return -1; } } + + if (!ISSET(MAC_FILE)) #endif - size = write(fd, "\n", 1); - lineswritten++; - if (size == -1) { - statusbar(_("Could not open file for writing: %s"), + { + size = write(fd, "\n", 1); + lineswritten++; + if (size == -1) { + statusbar(_("Could not open file for writing: %s"), strerror(errno)); - return -1; + return -1; + } } } } diff --git a/nano.c b/nano.c index efd9c034..cb8a8aa2 100644 --- a/nano.c +++ b/nano.c @@ -412,6 +412,11 @@ void usage(void) (_ (" -F --multibuffer Enable multiple file buffers\n")); #endif +#ifndef NANO_SMALL + printf + (_ + (" -M --mac Write file in Mac format\n")); +#endif #ifdef HAVE_REGEX_H printf(_ (" -R --regexp Use regular expressions for search\n")); @@ -476,6 +481,9 @@ void usage(void) #endif #ifdef ENABLE_MULTIBUFFER printf(_(" -F Enable multiple file buffers\n")); +#endif +#ifndef NANO_SMALL + printf(_(" -M Write file in Mac format\n")); #endif printf(_(" -T [num] Set width of a tab to num\n")); printf(_(" -R Use regular expressions for search\n")); @@ -2416,6 +2424,7 @@ int main(int argc, char *argv[]) #ifndef NANO_SMALL {"cut", 0, 0, 'k'}, {"dos", 0, 0, 'D'}, + {"mac", 0, 0, 'M'}, {"autoindent", 0, 0, 'i'}, #endif {"tempfile", 0, 0, 't'}, @@ -2458,11 +2467,11 @@ int main(int argc, char *argv[]) #endif /* ENABLE_NANORC */ #ifdef HAVE_GETOPT_LONG - while ((optchr = getopt_long(argc, argv, "h?DFRT:Vabcefgijklmo:pr:s:tvwxz", + while ((optchr = getopt_long(argc, argv, "h?DFMRT:Vabcefgijklmo:pr:s:tvwxz", long_options, &option_index)) != EOF) { #else while ((optchr = - getopt(argc, argv, "h?DFRT:Vabcefgijklmo:pr:s:tvwxz")) != EOF) { + getopt(argc, argv, "h?DFMRT:Vabcefgijklmo:pr:s:tvwxz")) != EOF) { #endif switch (optchr) { @@ -2477,7 +2486,11 @@ int main(int argc, char *argv[]) SET(MULTIBUFFER); break; #endif - +#ifndef NANO_SMALL + case 'M': + SET(MAC_FILE); + break; +#endif case 'T': tabsize = atoi(optarg); if (tabsize <= 0) { diff --git a/nano.h b/nano.h index b007450c..1f870293 100644 --- a/nano.h +++ b/nano.h @@ -141,6 +141,7 @@ typedef struct rcoption { #define MULTIBUFFER (1<<19) #define CLEAR_BACKUPSTRING (1<<20) #define DOS_FILE (1<<21) +#define MAC_FILE (1<<22) /* Control key sequences, changing these would be very very bad */