1
0
mirror of https://github.com/rfivet/uemacs.git synced 2024-11-04 19:37:18 -05:00

DOS mode added to preserve eol termination.

This commit is contained in:
Renaud 2013-06-09 11:21:35 +08:00
parent 30b1b06acb
commit a3f3102013
6 changed files with 21 additions and 13 deletions

6
edef.h
View File

@ -30,9 +30,9 @@ extern int execlevel; /* execution IF level */
extern int eolexist; /* does clear to EOL exist? */ extern int eolexist; /* does clear to EOL exist? */
extern int revexist; /* does reverse video exist? */ extern int revexist; /* does reverse video exist? */
extern int flickcode; /* do flicker supression? */ extern int flickcode; /* do flicker supression? */
extern char *modename[]; /* text names of modes */ extern const char *modename[]; /* text names of modes */
extern char *mode2name[]; /* text names of modes */ extern const char *mode2name[]; /* text names of modes */
extern char modecode[]; /* letters to represent modes */ extern const char modecode[]; /* letters to represent modes */
extern int gmode; /* global editor mode */ extern int gmode; /* global editor mode */
extern int gflags; /* global control flag */ extern int gflags; /* global control flag */
extern int gfcolor; /* global forgrnd color (white) */ extern int gfcolor; /* global forgrnd color (white) */

View File

@ -481,7 +481,7 @@ struct buffer {
#define BFTRUNC 0x04 /* buffer was truncated when read */ #define BFTRUNC 0x04 /* buffer was truncated when read */
/* mode flags */ /* mode flags */
#define NUMMODES 10 /* # of defined modes */ #define NUMMODES 11 /* # of defined modes */
#define MDWRAP 0x0001 /* word wrap */ #define MDWRAP 0x0001 /* word wrap */
#define MDCMOD 0x0002 /* C indentation and fence match */ #define MDCMOD 0x0002 /* C indentation and fence match */
@ -492,6 +492,8 @@ struct buffer {
#define MDMAGIC 0x0040 /* regular expresions in search */ #define MDMAGIC 0x0040 /* regular expresions in search */
#define MDCRYPT 0x0080 /* encrytion mode active */ #define MDCRYPT 0x0080 /* encrytion mode active */
#define MDASAVE 0x0100 /* auto-save mode */ #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 * The starting position of a region, and the size of the region in

6
file.c
View File

@ -296,6 +296,9 @@ int readin(char *fname, int lockfl)
++nline; ++nline;
} }
eoltype = ftype ; eoltype = ftype ;
if( ftype == FTYPE_DOS)
curbp->b_mode |= MDDOS ;
ffclose(); /* Ignore errors. */ ffclose(); /* Ignore errors. */
strcpy(mesg, "("); strcpy(mesg, "(");
if (s == FIOERR) { if (s == FIOERR) {
@ -512,7 +515,8 @@ int writeout(char *fn)
lp = lforw(curbp->b_linep); /* First line. */ lp = lforw(curbp->b_linep); /* First line. */
nline = 0; /* Number of lines. */ nline = 0; /* Number of lines. */
while (lp != curbp->b_linep) { 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; break;
++nline; ++nline;
lp = lforw(lp); lp = lforw(lp);

View File

@ -87,7 +87,7 @@ int ffclose(void)
* and the "nbuf" is its length, less the free newline. Return the status. * and the "nbuf" is its length, less the free newline. Return the status.
* Check only at the newline. * Check only at the newline.
*/ */
int ffputline(char *buf, int nbuf) int ffputline( char *buf, int nbuf, int dosflag)
{ {
int i; int i;
#if CRYPT #if CRYPT
@ -107,7 +107,9 @@ int ffputline(char *buf, int nbuf)
fputc(buf[i] & 0xFF, ffp); fputc(buf[i] & 0xFF, ffp);
#endif #endif
fputc( '\r', ffp) ; if( dosflag)
fputc( '\r', ffp) ;
fputc('\n', ffp); fputc('\n', ffp);
if (ferror(ffp)) { if (ferror(ffp)) {

View File

@ -11,7 +11,7 @@ extern int ftype ;
int fexist( const char *fname) ; int fexist( const char *fname) ;
int ffclose( void) ; int ffclose( void) ;
int ffgetline( void) ; int ffgetline( void) ;
int ffputline( char *buf, int nbuf) ; int ffputline( char *buf, int nbuf, int dosflag) ;
int ffropen( const char *fn) ; int ffropen( const char *fn) ;
int ffwopen( const char *fn) ; int ffwopen( const char *fn) ;

View File

@ -11,15 +11,15 @@ int execlevel = 0; /* execution IF level */
int eolexist = TRUE; /* does clear to EOL exist */ int eolexist = TRUE; /* does clear to EOL exist */
int revexist = FALSE; /* does reverse video exist? */ int revexist = FALSE; /* does reverse video exist? */
int flickcode = FALSE; /* do flicker supression? */ int flickcode = FALSE; /* do flicker supression? */
char *modename[] = { /* name of modes */ const char *modename[] = { /* name of modes */
"WRAP", "CMODE", "SPELL", "EXACT", "VIEW", "OVER", "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", "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 gmode = 0; /* global editor mode */
int gflags = GFREAD; /* global control flag */ int gflags = GFREAD; /* global control flag */
#if PKCODE & IBMPC #if PKCODE & IBMPC