diff --git a/src/internal/stdio_impl.h b/src/internal/stdio_impl.h index 7cdf729..1f14809 100644 --- a/src/internal/stdio_impl.h +++ b/src/internal/stdio_impl.h @@ -84,10 +84,10 @@ void __ofl_unlock(void); #define ferror(f) ((f)->flags & F_ERR) #define getc_unlocked(f) \ - ( ((f)->rpos < (f)->rend) ? *(f)->rpos++ : __uflow((f)) ) + ( ((f)->rpos != (f)->rend) ? *(f)->rpos++ : __uflow((f)) ) #define putc_unlocked(c, f) \ - ( ((unsigned char)(c)!=(f)->lbf && (f)->wpos<(f)->wend) \ + ( ((unsigned char)(c)!=(f)->lbf && (f)->wpos != (f)->wend) \ ? *(f)->wpos++ = (c) : __overflow((f),(c)) ) /* Caller-allocated FILE * operations */ diff --git a/src/stdio/__overflow.c b/src/stdio/__overflow.c index 3bb3792..e65a594 100644 --- a/src/stdio/__overflow.c +++ b/src/stdio/__overflow.c @@ -4,7 +4,7 @@ int __overflow(FILE *f, int _c) { unsigned char c = _c; if (!f->wend && __towrite(f)) return EOF; - if (f->wpos < f->wend && c != f->lbf) return *f->wpos++ = c; + if (f->wpos != f->wend && c != f->lbf) return *f->wpos++ = c; if (f->write(f, &c, 1)!=1) return EOF; return c; } diff --git a/src/stdio/__stdio_exit.c b/src/stdio/__stdio_exit.c index 191b445..210e768 100644 --- a/src/stdio/__stdio_exit.c +++ b/src/stdio/__stdio_exit.c @@ -9,8 +9,8 @@ static void close_file(FILE *f) { if (!f) return; FFINALLOCK(f); - if (f->wpos > f->wbase) f->write(f, 0, 0); - if (f->rpos < f->rend) f->seek(f, f->rpos-f->rend, SEEK_CUR); + if (f->wpos != f->wbase) f->write(f, 0, 0); + if (f->rpos != f->rend) f->seek(f, f->rpos-f->rend, SEEK_CUR); } void __stdio_exit(void) diff --git a/src/stdio/__toread.c b/src/stdio/__toread.c index 35f67b8..faef8c2 100644 --- a/src/stdio/__toread.c +++ b/src/stdio/__toread.c @@ -3,7 +3,7 @@ int __toread(FILE *f) { f->mode |= f->mode-1; - if (f->wpos > f->wbase) f->write(f, 0, 0); + if (f->wpos != f->wbase) f->write(f, 0, 0); f->wpos = f->wbase = f->wend = 0; if (f->flags & F_NORD) { f->flags |= F_ERR; diff --git a/src/stdio/fflush.c b/src/stdio/fflush.c index 3f462c8..00fe06a 100644 --- a/src/stdio/fflush.c +++ b/src/stdio/fflush.c @@ -3,13 +3,13 @@ static int __fflush_unlocked(FILE *f) { /* If writing, flush output */ - if (f->wpos > f->wbase) { + if (f->wpos != f->wbase) { f->write(f, 0, 0); if (!f->wpos) return EOF; } /* If reading, sync position, per POSIX */ - if (f->rpos < f->rend) f->seek(f, f->rpos-f->rend, SEEK_CUR); + if (f->rpos != f->rend) f->seek(f, f->rpos-f->rend, SEEK_CUR); /* Clear read and write modes */ f->wpos = f->wbase = f->wend = 0; @@ -37,7 +37,7 @@ int fflush(FILE *f) for (f=*__ofl_lock(); f; f=f->next) { FLOCK(f); - if (f->wpos > f->wbase) r |= __fflush_unlocked(f); + if (f->wpos != f->wbase) r |= __fflush_unlocked(f); FUNLOCK(f); } __ofl_unlock(); diff --git a/src/stdio/fgetwc.c b/src/stdio/fgetwc.c index e455cfe..0c9faa1 100644 --- a/src/stdio/fgetwc.c +++ b/src/stdio/fgetwc.c @@ -12,7 +12,7 @@ static wint_t __fgetwc_unlocked_internal(FILE *f) size_t l; /* Convert character from buffer if possible */ - if (f->rpos < f->rend) { + if (f->rpos != f->rend) { l = mbrtowc(&wc, (void *)f->rpos, f->rend - f->rpos, &st); if (l+2 >= 2) { f->rpos += l + !l; /* l==0 means 1 byte, null */ diff --git a/src/stdio/fread.c b/src/stdio/fread.c index aef75f7..6f5ac01 100644 --- a/src/stdio/fread.c +++ b/src/stdio/fread.c @@ -13,7 +13,7 @@ size_t fread(void *restrict destv, size_t size, size_t nmemb, FILE *restrict f) f->mode |= f->mode-1; - if (f->rend - f->rpos > 0) { + if (f->rpos != f->rend) { /* First exhaust the buffer. */ k = MIN(f->rend - f->rpos, l); memcpy(dest, f->rpos, k); diff --git a/src/stdio/fseek.c b/src/stdio/fseek.c index b160b74..4b7030a 100644 --- a/src/stdio/fseek.c +++ b/src/stdio/fseek.c @@ -6,7 +6,7 @@ int __fseeko_unlocked(FILE *f, off_t off, int whence) if (whence == SEEK_CUR) off -= f->rend - f->rpos; /* Flush write buffer, and report error on failure. */ - if (f->wpos > f->wbase) { + if (f->wpos != f->wbase) { f->write(f, 0, 0); if (!f->wpos) return -1; } diff --git a/src/stdio/ftell.c b/src/stdio/ftell.c index bb62897..5ff2178 100644 --- a/src/stdio/ftell.c +++ b/src/stdio/ftell.c @@ -5,7 +5,7 @@ off_t __ftello_unlocked(FILE *f) { off_t pos = f->seek(f, 0, - (f->flags & F_APP) && f->wpos > f->wbase + (f->flags & F_APP) && f->wpos != f->wbase ? SEEK_END : SEEK_CUR); if (pos < 0) return pos; diff --git a/src/stdio/vfwscanf.c b/src/stdio/vfwscanf.c index 223aad4..1fd6b71 100644 --- a/src/stdio/vfwscanf.c +++ b/src/stdio/vfwscanf.c @@ -77,7 +77,7 @@ static int in_set(const wchar_t *set, int c) #if 1 #undef getwc #define getwc(f) \ - ((f)->rpos < (f)->rend && *(f)->rpos < 128 ? *(f)->rpos++ : (getwc)(f)) + ((f)->rpos != (f)->rend && *(f)->rpos < 128 ? *(f)->rpos++ : (getwc)(f)) #undef ungetwc #define ungetwc(c,f) \