⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xsh_chap02_05.html

📁 posix标准英文,html格式
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<p>was the most recent operation on that stream), no action need be taken.</p></li><li><p>If it is a stream which is open for writing or appending (but not also open for reading), the application shall either performan <a href="../functions/fflush.html"><i>fflush</i>()</a>, or the stream shall be closed.</p></li><li><p>If the stream is open for reading and it is at the end of the file ( <a href="../functions/feof.html"><i>feof</i>()</a> istrue), no action need be taken.</p></li><li><p>If the stream is open with a mode that allows reading and the underlying open file description refers to a device that iscapable of seeking, the application shall either perform an <a href="../functions/fflush.html"><i>fflush</i>()</a>, or the streamshall be closed.</p></li></ul><p>Otherwise, the result is undefined.</p><p>For the second handle:</p><ul><li><p>If any previous active handle has been used by a function that explicitly changed the file offset, except as required above forthe first handle, the application shall perform an <a href="../functions/lseek.html"><i>lseek</i>()</a> or <a href="../functions/fseek.html"><i>fseek</i>()</a> (as appropriate to the type of handle) to an appropriate location.</p></li></ul><p>If the active handle ceases to be accessible before the requirements on the first handle, above, have been met, the state of theopen file description becomes undefined. This might occur during functions such as a <a href="../functions/fork.html"><i>fork</i>()</a> or <a href="../functions/_exit.html"><i>_exit</i>()</a>.</p><p>The <i><a href="../functions/exec.html">exec</a></i> functions make inaccessible all streams that are open at the time they arecalled, independent of which streams or file descriptors may be available to the new process image.</p><p>When these rules are followed, regardless of the sequence of handles used, implementations shall ensure that an application,even one consisting of several processes, shall yield correct results: no data shall be lost or duplicated when writing, and alldata shall be written in order, except as requested by seeks. It is implementation-defined whether, and under what conditions, allinput is seen exactly once.</p><p>If the rules above are not followed, the result is unspecified.</p><p>Each function that operates on a stream is said to have zero or more ``underlying functions''. This means that the streamfunction shares certain traits with the underlying functions, but does not require that there be any relation between theimplementations of the stream function and its underlying functions.</p><h4><a name="tag_02_05_02">  2.5.2 </a>Stream Orientation and Encoding Rules</h4><p>For conformance to the ISO/IEC&nbsp;9899:1999 standard, the definition of a stream includes an ``orientation''. After a streamis associated with an external file, but before any operations are performed on it, the stream is without orientation. Once awide-character input/output function has been applied to a stream without orientation, the stream shall become ``wide-oriented''.Similarly, once a byte input/output function has been applied to a stream without orientation, the stream shall become``byte-oriented''. Only a call to the <a href="../functions/freopen.html"><i>freopen</i>()</a> function or the <a href="../functions/fwide.html"><i>fwide</i>()</a> function can otherwise alter the orientation of a stream.</p><p>A successful call to <a href="../functions/freopen.html"><i>freopen</i>()</a> shall remove any orientation. The three predefinedstreams <i>standard input</i>, <i>standard output</i>, and <i>standard error</i> shall be unoriented at program start-up.</p><p>Byte input/output functions cannot be applied to a wide-oriented stream, and wide-character input/output functions cannot beapplied to a byte-oriented stream. The remaining stream operations shall not affect and shall not be affected by a stream'sorientation, except for the following additional restriction:</p><ul><li><p>For wide-oriented streams, after a successful call to a file-positioning function that leaves the file position indicator priorto the end-of-file, a wide-character output function can overwrite a partial character; any file contents beyond the byte(s)written are henceforth undefined.</p></li></ul><p>Each wide-oriented stream has an associated <b>mbstate_t</b> object that stores the current parse state of the stream. Asuccessful call to <a href="../functions/fgetpos.html"><i>fgetpos</i>()</a> shall store a representation of the value of this<b>mbstate_t</b> object as part of the value of the <b>fpos_t</b> object. A later successful call to <a href="../functions/fsetpos.html"><i>fsetpos</i>()</a> using the same stored <b>fpos_t</b> value shall restore the value of theassociated <b>mbstate_t</b> object as well as the position within the controlled stream.</p><p>Implementations that support multiple encoding rules associate an encoding rule with the stream. The encoding rule shall bedetermined by the setting of the <i>LC_CTYPE</i> category in the current locale at the time when the stream becomes wide-oriented.As with the stream's orientation, the encoding rule associated with a stream cannot be changed once it has been set, except by asuccessful call to <a href="../functions/freopen.html"><i>freopen</i>()</a> which clears the encoding rule and resets theorientation to unoriented.</p><p>Although wide-oriented streams are conceptually sequences of wide characters, the external file associated with a wide-orientedstream is a sequence of (possibly multi-byte) characters generalized as follows:</p><ul><li><p>Multi-byte encodings within files may contain embedded null bytes (unlike multi-byte encodings valid for use internal to theprogram).</p></li><li><p>A file need not begin nor end in the initial shift state.</p></li></ul><p>Moreover, the encodings used for characters may differ among files. Both the nature and choice of such encodings areimplementation-defined.</p><p>The wide-character input functions read characters from the stream and convert them to wide characters as if they were read bysuccessive calls to the <a href="../functions/fgetwc.html"><i>fgetwc</i>()</a> function. Each conversion shall occur as if by acall to the <a href="../functions/mbrtowc.html"><i>mbrtowc</i>()</a> function, with the conversion state described by the stream'sown <b>mbstate_t</b> object, <sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> &nbsp;except the encoding rule associated with the stream is used instead of the encoding rule impliedby the <i>LC_CTYPE</i> category of the current locale. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p><p>The wide-character output functions convert wide characters to (possibly multi-byte) characters and write them to the stream asif they were written by successive calls to the <a href="../functions/fputwc.html"><i>fputwc</i>()</a> function. Each conversionshall occur as if by a call to the <a href="../functions/wcrtomb.html"><i>wcrtomb</i>()</a> function, with the conversion statedescribed by the stream's own <b>mbstate_t</b> object, <sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> &nbsp;except the encoding rule associated with the stream is usedinstead of the encoding rule implied by the <i>LC_CTYPE</i> category of the current locale. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p><p>An ``encoding error'' shall occur if the character sequence presented to the underlying <a href="../functions/mbrtowc.html"><i>mbrtowc</i>()</a> function does not form a valid (generalized) character, or if the code valuepassed to the underlying <a href="../functions/wcrtomb.html"><i>wcrtomb</i>()</a> function does not correspond to a valid(generalized) character. The wide-character input/output functions and the byte input/output functions store the value of the macro[EILSEQ] in <i>errno</i> if and only if an encoding error occurs.</p><hr size="2" noshade><center><font size="2"><!--footer start-->UNIX &reg; is a registered Trademark of The Open Group.<br>POSIX &reg; is a registered Trademark of The IEEE.<br>[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href="../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>]</font></center><!--footer end--><hr size="2" noshade></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -