* Copyright (c) 1980 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
static char sccsid
[] = "@(#)wbuf.c 5.1 (Berkeley) %G%";
if (iop
->_flag
& _IORW
) {
iop
->_flag
&= ~(_IOEOF
|_IOREAD
);
if ((iop
->_flag
&_IOWRT
)==0)
if (iop
->_ptr
>= base
+iop
->_bufsiz
|| c
== '\n') {
n
= write(fileno(iop
), base
, rn
= iop
->_ptr
- base
);
} else if (iop
->_flag
&_IONBF
) {
n
= write(fileno(iop
), &c1
, rn
);
if ((base
=iop
->_base
)==NULL
) {
if (fstat(fileno(iop
), &stbuf
) < 0 ||
stbuf
.st_blksize
<= NULL
)
if ((iop
->_base
=base
=malloc(size
)) == NULL
) {
if (iop
==stdout
&& isatty(fileno(stdout
))) {
} else if ((rn
= n
= iop
->_ptr
- base
) > 0) {
n
= write(fileno(iop
), base
, n
);
iop
->_cnt
= iop
->_bufsiz
-1;
if ((iop
->_flag
&(_IONBF
|_IOWRT
))==_IOWRT
&& (base
=iop
->_base
)!=NULL
&& (n
=iop
->_ptr
-base
)>0) {
iop
->_cnt
= (iop
->_flag
&(_IOLBF
|_IONBF
)) ? 0 : iop
->_bufsiz
;
if (write(fileno(iop
), base
, n
)!=n
) {
if (iop
->_flag
&(_IOREAD
|_IOWRT
|_IORW
) && (iop
->_flag
&_IOSTRG
)==0) {
if (close(fileno(iop
)) < 0)
iop
->_base
= (char *)NULL
;
iop
->_ptr
= (char *)NULL
;