projects
/
profile
/
ivi
/
syslinux.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
1e0fa46
)
Actually decrement counter; return string if EOF after reading characters
author
hpa
<hpa>
Sun, 21 Aug 2005 22:36:30 +0000
(22:36 +0000)
committer
hpa
<hpa>
Sun, 21 Aug 2005 22:36:30 +0000
(22:36 +0000)
(i.e. partial line at end of file)
com32/lib/fgets.c
patch
|
blob
|
history
diff --git
a/com32/lib/fgets.c
b/com32/lib/fgets.c
index
88a145a
..
593bea3
100644
(file)
--- 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';