Files
oldlinux-files/Ref-docs/POSIX/susv3/xrat/xbd_chap05.html
2024-02-19 00:21:47 -05:00

83 lines
3.6 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 -->
<!-- Copyright (c) 2001 The Open Group, All Rights Reserved -->
<title>Rationale</title>
</head>
<body>
<basefont size="3">
<center><font size="2">The Open Group Base Specifications Issue 6<br>
IEEE Std 1003.1-2001<br>
Copyright &copy; 2001 The IEEE and The Open Group</font></center>
<hr size="2" noshade>
<h3><a name="tag_01_05"></a>File Format Notation</h3>
<p>The notation for spaces allows some flexibility for application output. Note that an empty character position in <i>format</i>
represents one or more &lt;blank&gt;s on the output (not <i>white space</i>, which can include &lt;newline&gt;s). Therefore,
another utility that reads that output as its input must be prepared to parse the data using <a href=
"../functions/scanf.html"><i>scanf</i>()</a>, <a href="../utilities/awk.html"><i>awk</i></a>, and so on. The <tt>'<img src=
"../images/delta.gif" border="0">'</tt> character is used when exactly one &lt;space&gt; is output.</p>
<p>The treatment of integers and spaces is different from the <a href="../functions/printf.html"><i>printf</i>()</a> function in
that they can be surrounded with &lt;blank&gt;s. This was done so that, given a format such as:</p>
<blockquote>
<pre>
<tt>"%d\n",&lt;</tt><i>foo</i><tt>&gt;
</tt>
</pre>
</blockquote>
<p>the implementation could use a <a href="../functions/printf.html"><i>printf</i>()</a> call such as:</p>
<blockquote>
<pre>
<tt>printf("%6d\n", foo);
</tt>
</pre>
</blockquote>
<p>and still conform. This notation is thus somewhat like <a href="../functions/scanf.html"><i>scanf</i>()</a> in addition to <a
href="../functions/printf.html"><i>printf</i>()</a>.</p>
<p>The <a href="../functions/printf.html"><i>printf</i>()</a> function was chosen as a model because most of the standard
developers were familiar with it. One difference from the C function <a href="../functions/printf.html"><i>printf</i>()</a> is that
the <tt>l</tt> and <tt>h</tt> conversion specifier characters are not used. As expressed by the Shell and Utilities volume of
IEEE&nbsp;Std&nbsp;1003.1-2001, there is no differentiation between decimal values for type <b>int</b>, type <b>long</b>, or type
<b>short</b>. The conversion specifications <tt>%d</tt> or <tt>%i</tt> should be interpreted as an arbitrary length sequence of
digits. Also, no distinction is made between single precision and double precision numbers ( <b>float</b> or <b>double</b> in C).
These are simply referred to as floating-point numbers.</p>
<p>Many of the output descriptions in the Shell and Utilities volume of IEEE&nbsp;Std&nbsp;1003.1-2001 use the term ``line'', such
as:</p>
<blockquote>
<pre>
<tt>"%s", &lt;input line&gt;
</tt>
</pre>
</blockquote>
<p>Since the definition of <i>line</i> includes the trailing &lt;newline&gt; already, there is no need to include a <tt>'\n'</tt>
in the format; a double &lt;newline&gt; would otherwise result.</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>