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.
33 if ((fp->_flags & (__SLBF | __SWR)) == (__SLBF | __SWR))
39 * Refill a stdio buffer.
40 * Return EOF on eof or error, 0 otherwise.
44 __srefill (register FILE * fp)
46 /* make sure stdio is set up */
50 fp->_r = 0; /* largely a convenience for callers */
52 /* SysV does not make this test; take it out for compatibility */
53 if (fp->_flags & __SEOF)
56 /* if not already reading, have to be reading and writing */
57 if ((fp->_flags & __SRD) == 0)
59 if ((fp->_flags & __SRW) == 0)
61 /* switch to reading */
62 if (fp->_flags & __SWR)
75 * We were reading. If there is an ungetc buffer,
76 * we must have been reading from that. Drop it,
77 * restoring the previous buffer (if any). If there
78 * is anything in that buffer, return.
83 if ((fp->_r = fp->_ur) != 0)
91 if (fp->_bf._base == NULL)
95 * Before reading from a line buffered or unbuffered file,
96 * flush all line buffered output files, per the ANSI C
100 if (fp->_flags & (__SLBF | __SNBF))
101 (void) _fwalk (fp->_data, lflush);
102 fp->_p = fp->_bf._base;
103 fp->_r = (*fp->_read) (fp->_cookie, (char *) fp->_p, fp->_bf._size);
104 fp->_flags &= ~__SMOD; /* buffer contents are again pristine */
108 fp->_flags |= __SEOF;
112 fp->_flags |= __SERR;