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

error
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;
}