summaryrefslogtreecommitdiff
path: root/src/stdio/fgets.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/stdio/fgets.c')
-rw-r--r--src/stdio/fgets.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/stdio/fgets.c b/src/stdio/fgets.c
index 6171f398..4a100b39 100644
--- a/src/stdio/fgets.c
+++ b/src/stdio/fgets.c
@@ -12,13 +12,14 @@ char *fgets(char *restrict s, int n, FILE *restrict f)
FLOCK(f);
- if (n--<=1) {
+ if (n<=1) {
f->mode |= f->mode-1;
FUNLOCK(f);
- if (n) return 0;
+ if (n<1) return 0;
*s = 0;
return s;
}
+ n--;
while (n) {
if (f->rpos != f->rend) {