| OLD | NEW |
| 1 #include "shgetc.h" | 1 #include "shgetc.h" |
| 2 | 2 |
| 3 void __shlim(FILE *f, off_t lim) | 3 void __shlim(FILE* f, off_t lim) { |
| 4 { | 4 f->shlim = lim; |
| 5 » f->shlim = lim; | 5 f->shcnt = f->rend - f->rpos; |
| 6 » f->shcnt = f->rend - f->rpos; | 6 if (lim && f->shcnt > lim) |
| 7 » if (lim && f->shcnt > lim) | 7 f->shend = f->rpos + lim; |
| 8 » » f->shend = f->rpos + lim; | 8 else |
| 9 » else | 9 f->shend = f->rend; |
| 10 » » f->shend = f->rend; | |
| 11 } | 10 } |
| 12 | 11 |
| 13 int __shgetc(FILE *f) | 12 int __shgetc(FILE* f) { |
| 14 { | 13 int c; |
| 15 » int c; | 14 if ((f->shlim && f->shcnt >= f->shlim) || (c = __uflow(f)) < 0) { |
| 16 » if ((f->shlim && f->shcnt >= f->shlim) || (c=__uflow(f)) < 0) { | 15 f->shend = 0; |
| 17 » » f->shend = 0; | 16 return EOF; |
| 18 » » return EOF; | 17 } |
| 19 » } | 18 if (f->shlim && f->rend - f->rpos > f->shlim - f->shcnt - 1) |
| 20 » if (f->shlim && f->rend - f->rpos > f->shlim - f->shcnt - 1) | 19 f->shend = f->rpos + (f->shlim - f->shcnt - 1); |
| 21 » » f->shend = f->rpos + (f->shlim - f->shcnt - 1); | 20 else |
| 22 » else | 21 f->shend = f->rend; |
| 23 » » f->shend = f->rend; | 22 if (f->rend) |
| 24 » if (f->rend) f->shcnt += f->rend - f->rpos + 1; | 23 f->shcnt += f->rend - f->rpos + 1; |
| 25 » if (f->rpos[-1] != c) f->rpos[-1] = c; | 24 if (f->rpos[-1] != c) |
| 26 » return c; | 25 f->rpos[-1] = c; |
| 26 return c; |
| 27 } | 27 } |
| OLD | NEW |