summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhpa <hpa>2005-08-21 22:36:30 +0000
committerhpa <hpa>2005-08-21 22:36:30 +0000
commit1ee8eee7896f4b2790a1791c57cb320c54d659e2 (patch)
tree3455b834206ebf0fb0b229e527eac28e18403daa
parent1e0fa46ba463d8eb671dde70a9ccff878132ad31 (diff)
downloadsyslinux-3.10-pre18.tar.gz
Actually decrement counter; return string if EOF after reading characterssyslinux-3.10-pre18
(i.e. partial line at end of file)
-rw-r--r--com32/lib/fgets.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/com32/lib/fgets.c b/com32/lib/fgets.c
index 88a145a6..593bea36 100644
--- a/com32/lib/fgets.c
+++ b/com32/lib/fgets.c
@@ -17,11 +17,12 @@ char *fgets(char *s, int n, FILE *f)
ch = getc(f);
if ( ch == EOF ) {
*p = '\0';
- return NULL;
+ return (p == s) ? NULL : s;
}
*p++ = ch;
if ( ch == '\n' )
break;
+ n--;
}
if ( n )
*p = '\0';