summaryrefslogtreecommitdiff
path: root/src/internal/shgetc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/internal/shgetc.c')
-rw-r--r--src/internal/shgetc.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/internal/shgetc.c b/src/internal/shgetc.c
index ebd5fae7..7455d2f0 100644
--- a/src/internal/shgetc.c
+++ b/src/internal/shgetc.c
@@ -22,7 +22,8 @@ int __shgetc(FILE *f)
off_t cnt = shcnt(f);
if (f->shlim && cnt >= f->shlim || (c=__uflow(f)) < 0) {
f->shcnt = f->buf - f->rpos + cnt;
- f->shend = 0;
+ f->shend = f->rpos;
+ f->shlim = -1;
return EOF;
}
cnt++;
@@ -31,6 +32,6 @@ int __shgetc(FILE *f)
else
f->shend = f->rend;
f->shcnt = f->buf - f->rpos + cnt;
- if (f->rpos[-1] != c) f->rpos[-1] = c;
+ if (f->rpos <= f->buf) f->rpos[-1] = c;
return c;
}