| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: stdio.h,v 1.102 2021/09/11 18:38:25 rillig Exp $ */ | | 1 | /* $NetBSD: stdio.h,v 1.103 2021/09/11 19:05:06 rillig Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1990, 1993 | | 4 | * Copyright (c) 1990, 1993 |
5 | * The Regents of the University of California. All rights reserved. | | 5 | * The Regents of the University of California. All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to Berkeley by | | 7 | * This code is derived from software contributed to Berkeley by |
8 | * Chris Torek. | | 8 | * Chris Torek. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -93,33 +93,32 @@ struct __sbuf { | | | @@ -93,33 +93,32 @@ struct __sbuf { |
93 | * if (_flags&(__SLBF|__SWR)) == (__SLBF|__SWR), | | 93 | * if (_flags&(__SLBF|__SWR)) == (__SLBF|__SWR), |
94 | * _lbfsize is -_bf._size, else _lbfsize is 0 | | 94 | * _lbfsize is -_bf._size, else _lbfsize is 0 |
95 | * if _flags&__SRD, _w is 0 | | 95 | * if _flags&__SRD, _w is 0 |
96 | * if _flags&__SWR, _r is 0 | | 96 | * if _flags&__SWR, _r is 0 |
97 | * | | 97 | * |
98 | * This ensures that the getc and putc macros (or inline functions) never | | 98 | * This ensures that the getc and putc macros (or inline functions) never |
99 | * try to write or read from a file that is in `read' or `write' mode. | | 99 | * try to write or read from a file that is in `read' or `write' mode. |
100 | * (Moreover, they can, and do, automatically switch from read mode to | | 100 | * (Moreover, they can, and do, automatically switch from read mode to |
101 | * write mode, and back, on "r+" and "w+" files.) | | 101 | * write mode, and back, on "r+" and "w+" files.) |
102 | * | | 102 | * |
103 | * _lbfsize is used only to make the inline line-buffered output stream | | 103 | * _lbfsize is used only to make the inline line-buffered output stream |
104 | * code as compact as possible. | | 104 | * code as compact as possible. |
105 | * | | 105 | * |
106 | * _ub, _up, and _ur are used when ungetc() pushes back more characters | | 106 | * _ub (via _ext and struct __sfileext), _up, and _ur are used when ungetc() |
107 | * than fit in the current _bf, or when ungetc() pushes back a character | | 107 | * pushes back more characters than fit in the current _bf, or when ungetc() |
108 | * that does not match the previous one in _bf. When this happens, | | 108 | * pushes back a character that does not match the previous one in _bf. |
109 | * _ub._base becomes non-nil (i.e., a stream has ungetc() data iff | | 109 | * When this happens, _ext._base becomes non-nil (i.e., a stream has ungetc() |
110 | * _ub._base!=NULL) and _up and _ur save the current values of _p and _r. | | 110 | * data iff _ub._base != NULL) and _up and _ur save the current values of _p |
111 | * | | 111 | * and _r. |
112 | * NB: see WARNING above before changing the layout of this structure! | | | |
113 | */ | | 112 | */ |
114 | typedef struct __sFILE { | | 113 | typedef struct __sFILE { |
115 | unsigned char *_p; /* current position in (some) buffer */ | | 114 | unsigned char *_p; /* current position in (some) buffer */ |
116 | int _r; /* read space left for getc() */ | | 115 | int _r; /* read space left for getc() */ |
117 | int _w; /* write space left for putc() */ | | 116 | int _w; /* write space left for putc() */ |
118 | unsigned short _flags; /* flags, below; this FILE is free if 0 */ | | 117 | unsigned short _flags; /* flags, below; this FILE is free if 0 */ |
119 | short _file; /* fileno, if Unix descriptor, else -1 */ | | 118 | short _file; /* fileno, if Unix descriptor, else -1 */ |
120 | struct __sbuf _bf; /* the buffer (at least 1 byte, if !NULL) */ | | 119 | struct __sbuf _bf; /* the buffer (at least 1 byte, if !NULL) */ |
121 | int _lbfsize; /* 0 or -_bf._size, for inline putc */ | | 120 | int _lbfsize; /* 0 or -_bf._size, for inline putc */ |
122 | | | 121 | |
123 | /* operations */ | | 122 | /* operations */ |
124 | void *_cookie; /* cookie passed to io functions */ | | 123 | void *_cookie; /* cookie passed to io functions */ |
125 | int (*_close)(void *); | | 124 | int (*_close)(void *); |