1
0
mirror of https://github.com/rfivet/uemacs.git synced 2024-12-18 07:16:23 -05:00

Rewrite ffputline to perform write at once when not encrypted.

This commit is contained in:
Renaud 2013-06-10 12:09:39 +08:00
parent 4bf4c48056
commit 45c67abc59
2 changed files with 21 additions and 24 deletions

View File

@ -89,37 +89,34 @@ fio_code 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.
*/ */
fio_code ffputline( char *buf, int nbuf, int dosflag) fio_code ffputline( unsigned char *buf, int nbuf, int dosflag) {
{
int i;
#if CRYPT #if CRYPT
char c; /* character to translate */ if( cryptflag) {
int i ;
if (cryptflag) { for( i = 0 ; i < nbuf ; i++) {
for (i = 0; i < nbuf; ++i) { unsigned char c ;
c = buf[i] & 0xff;
myencrypt(&c, 1); c = buf[ i] ;
fputc(c, ffp); myencrypt( &c, 1) ;
} fputc( c, ffp) ;
} else }
for (i = 0; i < nbuf; ++i) } else
fputc(buf[i] & 0xFF, ffp);
#else
for (i = 0; i < nbuf; ++i)
fputc(buf[i] & 0xFF, ffp);
#endif #endif
if( dosflag) fwrite( buf, 1, nbuf, ffp) ;
fputc( '\r', ffp) ;
if( dosflag)
fputc( '\r', ffp) ;
fputc('\n', ffp); fputc( '\n', ffp) ;
if (ferror(ffp)) { if( ferror( ffp)) {
mlwrite("Write I/O error"); mlwrite( "Write I/O error") ;
return FIOERR; return FIOERR ;
} }
return FIOSUC; return FIOSUC ;
} }
/* /*

View File

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