aboutsummaryrefslogtreecommitdiff
path: root/src/base/bufio/unget.c
blob: 1951384c5d1bf3a4900a3095029beae461e457d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include "internal.h"

int
bufio·ungetbyte(io·Buffer *buf, byte c)
{
    if(!(buf->state & bufio·rdr)) {
        errorf("attempted to unget on non-active reader");
        return bufio·err;
    }

    if(buf->pos == buf->buf) {
        errorf("attempted to unget past end of buffer");
        return bufio·err;
    }

    buf->pos--;
    return 0;
}