fix broken shgetc limiter logic (wasn't working)
This commit is contained in:
parent
2ac580fdfe
commit
f007bb854b
2 changed files with 5 additions and 2 deletions
|
|
@ -13,7 +13,10 @@ void __shlim(FILE *f, off_t lim)
|
||||||
int __shgetc(FILE *f)
|
int __shgetc(FILE *f)
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
if (f->shcnt >= f->shlim) return EOF;
|
if (f->shlim && f->shcnt >= f->shlim) {
|
||||||
|
f->shend = 0;
|
||||||
|
return EOF;
|
||||||
|
}
|
||||||
c = __uflow(f);
|
c = __uflow(f);
|
||||||
if (f->shlim && f->rend - f->rpos > f->shlim - f->shcnt - 1)
|
if (f->shlim && f->rend - f->rpos > f->shlim - f->shcnt - 1)
|
||||||
f->shend = f->rpos + (f->shlim - f->shcnt - 1);
|
f->shend = f->rpos + (f->shlim - f->shcnt - 1);
|
||||||
|
|
|
||||||
|
|
@ -6,4 +6,4 @@ int __shgetc(FILE *);
|
||||||
#define shcnt(f) ((f)->shcnt + ((f)->rpos - (f)->rend))
|
#define shcnt(f) ((f)->shcnt + ((f)->rpos - (f)->rend))
|
||||||
#define shlim(f, lim) __shlim((f), (lim))
|
#define shlim(f, lim) __shlim((f), (lim))
|
||||||
#define shgetc(f) (((f)->rpos < (f)->shend) ? *(f)->rpos++ : __shgetc(f))
|
#define shgetc(f) (((f)->rpos < (f)->shend) ? *(f)->rpos++ : __shgetc(f))
|
||||||
#define shunget(f) ((f)->rend ? (void)(f)->rpos-- : (void)0)
|
#define shunget(f) ((f)->shend ? (void)(f)->rpos-- : (void)0)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue