File tree 2 files changed +25
-4
lines changed
2 files changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -94,8 +94,8 @@ AC_PROG_GCC_TRADITIONAL
94
94
AC_FUNC_MMAP
95
95
96
96
AC_FUNC_WAIT3
97
- AC_CHECK_FUNCS ( strerror strtol lstat setrlimit sigrelse sighold sigaction \
98
- sysconf setsid sigsetjmp )
97
+ AC_CHECK_FUNCS ( strerror strtol lseek lstat setrlimit sigrelse sighold \
98
+ sigaction sysconf setsid sigsetjmp )
99
99
100
100
AC_CACHE_CHECK ( for an abused getenv , es_cv_abused_getenv ,
101
101
AC_RUN_IFELSE ( [ AC_LANG_SOURCE ( [ [
Original file line number Diff line number Diff line change @@ -405,8 +405,29 @@ PRIM(read) {
405
405
freebuffer (buffer );
406
406
buffer = openbuffer (0 );
407
407
408
- while ((c = read1 (fd )) != EOF && c != '\n' )
409
- buffer = bufputc (buffer , c );
408
+ #if HAVE_LSEEK
409
+ if (lseek (fd , 0 , SEEK_CUR ) < 0 ) {
410
+ #endif
411
+ while ((c = read1 (fd )) != EOF && c != '\n' )
412
+ buffer = bufputc (buffer , c );
413
+ #if HAVE_LSEEK
414
+ } else {
415
+ int n ;
416
+ char * p ;
417
+ char s [BUFSIZE ];
418
+ c = EOF ;
419
+ while ((n = eread (fd , s , BUFSIZE )) > 0 ) {
420
+ c = 0 ;
421
+ if ((p = strchr (s , '\n' )) == NULL )
422
+ buffer = bufncat (buffer , s , n );
423
+ else {
424
+ buffer = bufncat (buffer , s , (p - s ));
425
+ lseek (fd , 1 + ((p - s ) - n ), SEEK_CUR );
426
+ break ;
427
+ }
428
+ }
429
+ }
430
+ #endif
410
431
411
432
if (c == EOF && buffer -> current == 0 ) {
412
433
freebuffer (buffer );
You can’t perform that action at this time.
0 commit comments