1
0
mirror of https://github.com/rfivet/uemacs.git synced 2024-12-30 04:56:23 -05:00

Force buffer in view mode when reading mixed eol file.

This commit is contained in:
Renaud 2013-06-12 10:41:28 +08:00
parent 423c45f2cc
commit c7d2d30ab3

56
file.c
View File

@ -31,6 +31,22 @@
#define MAXNLINE 10000000 #define MAXNLINE 10000000
#endif #endif
typedef enum {
EOL_NONE,
EOL_UNIX,
EOL_DOS,
EOL_MAC,
EOL_MIXED
} eoltype ;
static const char *eolname[] = {
"NONE",
"UNIX",
"DOS",
"MAC",
"MIXED"
} ;
/* /*
* Read a file into the current * Read a file into the current
* buffer. This is really easy; all you do it * buffer. This is really easy; all you do it
@ -263,7 +279,7 @@ int readin(char *fname, int lockfl)
struct window *wp; struct window *wp;
struct buffer *bp; struct buffer *bp;
int s; int s;
int eoltype ; eoltype found_eol ;
int nbytes; int nbytes;
int nline; int nline;
char mesg[NSTRING]; char mesg[NSTRING];
@ -330,9 +346,25 @@ int readin(char *fname, int lockfl)
if( s == FIOERR) if( s == FIOERR)
mlwrite( "File read error") ; mlwrite( "File read error") ;
eoltype = ftype ; switch( ftype) {
if( ftype == FTYPE_DOS) case FTYPE_DOS:
found_eol = EOL_DOS ;
curbp->b_mode |= MDDOS ; curbp->b_mode |= MDDOS ;
break ;
case FTYPE_UNIX:
found_eol = EOL_UNIX ;
break ;
case FTYPE_MAC:
found_eol = EOL_MAC ;
break ;
case FTYPE_NONE:
found_eol = EOL_NONE ;
break ;
default:
found_eol = EOL_MIXED ;
curbp->b_mode |= MDVIEW ; /* add view mode as we have lost
** information */
}
ffclose(); /* Ignore errors. */ ffclose(); /* Ignore errors. */
strcpy(mesg, "("); strcpy(mesg, "(");
@ -349,23 +381,7 @@ int readin(char *fname, int lockfl)
strcat(mesg, "s"); strcat(mesg, "s");
strcat( mesg, ", eol = ") ; strcat( mesg, ", eol = ") ;
switch( eoltype) { strcat( mesg, eolname[ found_eol]) ;
case FTYPE_DOS:
strcat( mesg, "DOS") ;
break ;
case FTYPE_UNIX:
strcat( mesg, "UNIX") ;
break ;
case FTYPE_MAC:
strcat( mesg, "MAC") ;
break ;
case FTYPE_NONE:
strcat( mesg, "NONE") ;
break ;
default:
strcat( mesg, "MIXED") ;
}
strcat(mesg, ")"); strcat(mesg, ")");
mlwrite(mesg); mlwrite(mesg);