if (type == _IONBF) {
f->buf_size = 0;
- } else {
+ } else if (type == _IOLBF || type == _IOFBF) {
if (buf && size >= UNGET) {
- f->buf = (void *)buf;
+ f->buf = (void *)(buf + UNGET);
f->buf_size = size - UNGET;
}
if (type == _IOLBF && f->buf_size)
f->lbf = '\n';
+ } else {
+ return -1;
}
f->flags |= F_SVB;