aboutsummaryrefslogtreecommitdiff
path: root/sys/base/bufio/get.c
blob: 9f10c88a3ae3abeed9203d344e4b7d1bf6b0fa9d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include "internal.h"
#include "refill.h"

int
bufio·getbyte(io·Buffer *buf)
{
getbyte:
    if(buf->pos < buf->end)
        return *buf->pos++;

    memmove(buf->buf, buf->end - bufio·ungets, bufio·ungets);

    if(refill(buf) <= 0)
        return bufio·eof;

    goto getbyte;
}