diff --git a/edef.h b/edef.h index a8df99c..a33271d 100644 --- a/edef.h +++ b/edef.h @@ -30,9 +30,9 @@ extern int execlevel; /* execution IF level */ extern int eolexist; /* does clear to EOL exist? */ extern int revexist; /* does reverse video exist? */ extern int flickcode; /* do flicker supression? */ -extern char *modename[]; /* text names of modes */ -extern char *mode2name[]; /* text names of modes */ -extern char modecode[]; /* letters to represent modes */ +extern const char *modename[]; /* text names of modes */ +extern const char *mode2name[]; /* text names of modes */ +extern const char modecode[]; /* letters to represent modes */ extern int gmode; /* global editor mode */ extern int gflags; /* global control flag */ extern int gfcolor; /* global forgrnd color (white) */ diff --git a/estruct.h b/estruct.h index 9863a1e..97247e2 100644 --- a/estruct.h +++ b/estruct.h @@ -481,7 +481,7 @@ struct buffer { #define BFTRUNC 0x04 /* buffer was truncated when read */ /* mode flags */ -#define NUMMODES 10 /* # of defined modes */ +#define NUMMODES 11 /* # of defined modes */ #define MDWRAP 0x0001 /* word wrap */ #define MDCMOD 0x0002 /* C indentation and fence match */ @@ -492,6 +492,8 @@ struct buffer { #define MDMAGIC 0x0040 /* regular expresions in search */ #define MDCRYPT 0x0080 /* encrytion mode active */ #define MDASAVE 0x0100 /* auto-save mode */ +#define MDUTF8 0x0200 /* utf8 mode */ +#define MDDOS 0x0400 /* CRLF eol mode */ /* * The starting position of a region, and the size of the region in diff --git a/file.c b/file.c index 1c6ede3..1715c5e 100644 --- a/file.c +++ b/file.c @@ -296,6 +296,9 @@ int readin(char *fname, int lockfl) ++nline; } eoltype = ftype ; + if( ftype == FTYPE_DOS) + curbp->b_mode |= MDDOS ; + ffclose(); /* Ignore errors. */ strcpy(mesg, "("); if (s == FIOERR) { @@ -512,7 +515,8 @@ int writeout(char *fn) lp = lforw(curbp->b_linep); /* First line. */ nline = 0; /* Number of lines. */ while (lp != curbp->b_linep) { - if ((s = ffputline(&lp->l_text[0], llength(lp))) != FIOSUC) + s = ffputline( &lp->l_text[0], llength(lp), curbp->b_mode & MDDOS) ; + if( s != FIOSUC) break; ++nline; lp = lforw(lp); diff --git a/fileio.c b/fileio.c index f67889d..0ec25b9 100644 --- a/fileio.c +++ b/fileio.c @@ -87,7 +87,7 @@ int ffclose(void) * and the "nbuf" is its length, less the free newline. Return the status. * Check only at the newline. */ -int ffputline(char *buf, int nbuf) +int ffputline( char *buf, int nbuf, int dosflag) { int i; #if CRYPT @@ -107,7 +107,9 @@ int ffputline(char *buf, int nbuf) fputc(buf[i] & 0xFF, ffp); #endif - fputc( '\r', ffp) ; + if( dosflag) + fputc( '\r', ffp) ; + fputc('\n', ffp); if (ferror(ffp)) { diff --git a/fileio.h b/fileio.h index d722d47..70ade7b 100644 --- a/fileio.h +++ b/fileio.h @@ -11,7 +11,7 @@ extern int ftype ; int fexist( const char *fname) ; int ffclose( void) ; int ffgetline( void) ; -int ffputline( char *buf, int nbuf) ; +int ffputline( char *buf, int nbuf, int dosflag) ; int ffropen( const char *fn) ; int ffwopen( const char *fn) ; diff --git a/globals.c b/globals.c index c9f684a..e96b22f 100644 --- a/globals.c +++ b/globals.c @@ -11,15 +11,15 @@ int execlevel = 0; /* execution IF level */ int eolexist = TRUE; /* does clear to EOL exist */ int revexist = FALSE; /* does reverse video exist? */ int flickcode = FALSE; /* do flicker supression? */ -char *modename[] = { /* name of modes */ +const char *modename[] = { /* name of modes */ "WRAP", "CMODE", "SPELL", "EXACT", "VIEW", "OVER", - "MAGIC", "CRYPT", "ASAVE", "UTF-8" + "MAGIC", "CRYPT", "ASAVE", "UTF-8", "DOS" }; -char *mode2name[] = { /* name of modes */ +const char *mode2name[] = { /* name of modes */ "Wrap", "Cmode", "Spell", "Exact", "View", "Over", - "Magic", "Crypt", "Asave", "utf-8" + "Magic", "Crypt", "Asave", "utf-8", "Dos" }; -char modecode[] = "WCSEVOMYAU"; /* letters to represent modes */ +const char modecode[] = "WCSEVOMYAUD"; /* letters to represent modes */ int gmode = 0; /* global editor mode */ int gflags = GFREAD; /* global control flag */ #if PKCODE & IBMPC