Update contrib.
3 * Portions Copyright (c) 1990-1999 Nokia Corporation and/or its subsidiary(-ies).
7 /* No user fns here. Pesch 15apr92. */
10 * Copyright (c) 1990 The Regents of the University of California.
11 * All rights reserved.
13 * Redistribution and use in source and binary forms are permitted
14 * provided that the above copyright notice and this paragraph are
15 * duplicated in all such forms and that any documentation,
16 * advertising materials, and other materials related to such
17 * distribution and use acknowledge that the software was developed
18 * by the University of California, Berkeley. The name of the
19 * University may not be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
23 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
31 * Various output routines call wsetup to be sure it is safe to write,
32 * because either _flags does not include __SWR, or _buf is NULL.
33 * _wsetup returns 0 if OK to write, nonzero otherwise.
37 __swsetup (register FILE * fp)
39 /* Make sure stdio is set up. */
44 * If we are not writing, we had better be reading and writing.
47 if ((fp->_flags & __SWR) == 0)
49 if ((fp->_flags & __SRW) == 0)
51 if (fp->_flags & __SRD)
53 /* clobber any ungetc data */
56 fp->_flags &= ~(__SRD | __SEOF);
58 fp->_p = fp->_bf._base;
64 * Make a buffer if necessary, then set _w.
66 /* NOT NEEDED FOR CYGNUS SPRINTF ONLY jpg */
67 if (fp->_bf._base == NULL)
70 if (fp->_flags & __SLBF)
73 * It is line buffered, so make _lbfsize be -_bufsize
74 * for the putc() macro. We will change _lbfsize back
75 * to 0 whenever we turn off __SWR.
78 fp->_lbfsize = -fp->_bf._size;
81 fp->_w = fp->_flags & __SNBF ? 0 : fp->_bf._size;