X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fstdio%2F__underflow.c;fp=src%2Fstdio%2F__underflow.c;h=0000000000000000000000000000000000000000;hb=e3cd6c5c265cd481db6e0c5b529855d99f0bda30;hp=b769f4e4133e6191a9977946b967abf123dee8e9;hpb=ea343364a719add2cd8adf8a50c15bb5f9400dd8;p=musl diff --git a/src/stdio/__underflow.c b/src/stdio/__underflow.c deleted file mode 100644 index b769f4e4..00000000 --- a/src/stdio/__underflow.c +++ /dev/null @@ -1,38 +0,0 @@ -#include "stdio_impl.h" - -int __underflow(FILE *f) -{ - ssize_t cnt; - - /* Read from buffer (Do we ever get called when this is true??) */ - if (f->rpos < f->rstop) return *f->rpos; - - /* Initialize if we're not already reading */ - if (!f->rstop) { - /* Fail immediately if unreadable, eof, or error state. */ - if (f->flags & (F_EOF|F_ERR|F_NORD)) return EOF; - - /* Set byte orientation -1,0=>-1; 1=>1 */ - f->mode |= f->mode-1; - - /* Flush any unwritten output; fail on error. */ - if (f->wpos > f->buf && __oflow(f)) return EOF; - - /* Disallow writes to buffer. */ - f->wstop = 0; - } - - /* Perform the underlying read operation */ - if ((cnt=f->read(f, f->buf, f->buf_size)) + 1 <= 1) { - /* Set flags and leave read mode */ - f->flags |= F_EOF | (cnt & F_ERR); - f->rpos = f->rend = f->rstop = 0; - return EOF; - } - - /* Setup buffer pointers for reading from buffer */ - f->rpos = f->buf; - f->rend = f->rstop = f->buf + cnt; - - return *f->rpos; -}