| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | .\" $NetBSD: printf.1,v 1.26 2018/03/12 00:42:05 dholland Exp $ | | 1 | .\" $NetBSD: printf.1,v 1.27 2018/03/12 09:29:43 wiz Exp $ |
2 | .\" | | 2 | .\" |
3 | .\" Copyright (c) 1989, 1990, 1993 | | 3 | .\" Copyright (c) 1989, 1990, 1993 |
4 | .\" The Regents of the University of California. All rights reserved. | | 4 | .\" The Regents of the University of California. All rights reserved. |
5 | .\" | | 5 | .\" |
6 | .\" This code is derived from software contributed to Berkeley by | | 6 | .\" This code is derived from software contributed to Berkeley by |
7 | .\" the Institute of Electrical and Electronics Engineers, Inc. | | 7 | .\" the Institute of Electrical and Electronics Engineers, Inc. |
8 | .\" | | 8 | .\" |
9 | .\" Redistribution and use in source and binary forms, with or without | | 9 | .\" Redistribution and use in source and binary forms, with or without |
10 | .\" modification, are permitted provided that the following conditions | | 10 | .\" modification, are permitted provided that the following conditions |
11 | .\" are met: | | 11 | .\" are met: |
12 | .\" 1. Redistributions of source code must retain the above copyright | | 12 | .\" 1. Redistributions of source code must retain the above copyright |
13 | .\" notice, this list of conditions and the following disclaimer. | | 13 | .\" notice, this list of conditions and the following disclaimer. |
14 | .\" 2. Redistributions in binary form must reproduce the above copyright | | 14 | .\" 2. Redistributions in binary form must reproduce the above copyright |
| @@ -60,28 +60,27 @@ The | | | @@ -60,28 +60,27 @@ The |
60 | after the first are treated as strings if the corresponding format is | | 60 | after the first are treated as strings if the corresponding format is |
61 | either | | 61 | either |
62 | .Cm b , | | 62 | .Cm b , |
63 | .Cm B , | | 63 | .Cm B , |
64 | .Cm c , | | 64 | .Cm c , |
65 | or | | 65 | or |
66 | .Cm s ; | | 66 | .Cm s ; |
67 | otherwise it is evaluated as a C constant, with the following extensions: | | 67 | otherwise it is evaluated as a C constant, with the following extensions: |
68 | .Pp | | 68 | .Pp |
69 | .Bl -bullet -offset indent -compact | | 69 | .Bl -bullet -offset indent -compact |
70 | .It | | 70 | .It |
71 | A leading plus or minus sign is allowed. | | 71 | A leading plus or minus sign is allowed. |
72 | .It | | 72 | .It |
73 | If the leading character is a single or double quote, the value is the | | 73 | If the leading character is a single or double quote, the value is the ASCII |
74 | .Tn ASCII | | | |
75 | code of the next character. | | 74 | code of the next character. |
76 | .El | | 75 | .El |
77 | .Pp | | 76 | .Pp |
78 | The format string is reused as often as necessary to satisfy the | | 77 | The format string is reused as often as necessary to satisfy the |
79 | .Ar arguments . | | 78 | .Ar arguments . |
80 | Any extra format specifications are evaluated with zero or the null | | 79 | Any extra format specifications are evaluated with zero or the null |
81 | string. | | 80 | string. |
82 | .Pp | | 81 | .Pp |
83 | Character escape sequences are in backslash notation as defined in | | 82 | Character escape sequences are in backslash notation as defined in |
84 | .St -ansiC . | | 83 | .St -ansiC . |
85 | The characters and their meanings are as follows: | | 84 | The characters and their meanings are as follows: |
86 | .Bl -tag -width Ds -offset indent | | 85 | .Bl -tag -width Ds -offset indent |
87 | .It Cm \ee | | 86 | .It Cm \ee |
| @@ -117,33 +116,31 @@ Write a | | | @@ -117,33 +116,31 @@ Write a |
117 | .Aq vertical tab | | 116 | .Aq vertical tab |
118 | character. | | 117 | character. |
119 | .It Cm \e\' | | 118 | .It Cm \e\' |
120 | Write a | | 119 | Write a |
121 | .Aq single quote | | 120 | .Aq single quote |
122 | character. | | 121 | character. |
123 | .It Cm \e" | | 122 | .It Cm \e" |
124 | Write a | | 123 | Write a |
125 | .Aq double quote | | 124 | .Aq double quote |
126 | character. | | 125 | character. |
127 | .It Cm \e\e | | 126 | .It Cm \e\e |
128 | Write a backslash character. | | 127 | Write a backslash character. |
129 | .It Cm \e Ns Ar num | | 128 | .It Cm \e Ns Ar num |
130 | Write an 8\-bit character whose | | 129 | Write an 8\-bit character whose ASCII |
131 | .Tn ASCII | | | |
132 | value is the 1\-, 2\-, or 3\-digit octal number | | 130 | value is the 1\-, 2\-, or 3\-digit octal number |
133 | .Ar num . | | 131 | .Ar num . |
134 | .It Cm \ex Ns Ar xx | | 132 | .It Cm \ex Ns Ar xx |
135 | Write an 8\-bit character whose | | 133 | Write an 8\-bit character whose ASCII |
136 | .Tn ASCII | | | |
137 | value is the 1\- or 2\-digit hexadecimal number | | 134 | value is the 1\- or 2\-digit hexadecimal number |
138 | .Ar xx . | | 135 | .Ar xx . |
139 | .El | | 136 | .El |
140 | .Pp | | 137 | .Pp |
141 | Each format specification is introduced by the percent character | | 138 | Each format specification is introduced by the percent character |
142 | .Pq Dq \&% . | | 139 | .Pq Dq \&% . |
143 | The remainder of the format specification includes, | | 140 | The remainder of the format specification includes, |
144 | in the following order: | | 141 | in the following order: |
145 | .Bl -tag -width Ds | | 142 | .Bl -tag -width Ds |
146 | .It Zero or more of the following flags : | | 143 | .It Zero or more of the following flags : |
147 | .Bl -tag -width Ds | | 144 | .Bl -tag -width Ds |
148 | .It Cm # | | 145 | .It Cm # |
149 | A | | 146 | A |
| @@ -299,30 +296,28 @@ whichever gives full precision in minimu | | | @@ -299,30 +296,28 @@ whichever gives full precision in minimu |
299 | Characters from the string | | 296 | Characters from the string |
300 | .Ar argument | | 297 | .Ar argument |
301 | are printed with backslash-escape sequences expanded. | | 298 | are printed with backslash-escape sequences expanded. |
302 | .Pp | | 299 | .Pp |
303 | The following additional backslash-escape sequences are supported: | | 300 | The following additional backslash-escape sequences are supported: |
304 | .Bl -tag -width Ds | | 301 | .Bl -tag -width Ds |
305 | .It Cm \ec | | 302 | .It Cm \ec |
306 | Causes | | 303 | Causes |
307 | .Nm | | 304 | .Nm |
308 | to ignore any remaining characters in the string operand containing it, | | 305 | to ignore any remaining characters in the string operand containing it, |
309 | any remaining string operands, and any additional characters in | | 306 | any remaining string operands, and any additional characters in |
310 | the format operand. | | 307 | the format operand. |
311 | .It Cm \e0 Ns Ar num | | 308 | .It Cm \e0 Ns Ar num |
312 | Write an 8\-bit character whose | | 309 | Write an 8\-bit character whose ASCII value is the 1\-, 2\-, or |
313 | .Tn ASCII | | 310 | 3\-digit octal number |
314 | value is the 1\-, 2\-, or 3\-digit | | | |
315 | octal number | | | |
316 | .Ar num . | | 311 | .Ar num . |
317 | .It Cm \e^ Ns Ar c | | 312 | .It Cm \e^ Ns Ar c |
318 | Write the control character | | 313 | Write the control character |
319 | .Ar c . | | 314 | .Ar c . |
320 | Generates characters `\e000' through `\e037`, and `\e177' (from `\e^?'). | | 315 | Generates characters `\e000' through `\e037`, and `\e177' (from `\e^?'). |
321 | .It Cm \eM\- Ns Ar c | | 316 | .It Cm \eM\- Ns Ar c |
322 | Write the character | | 317 | Write the character |
323 | .Ar c | | 318 | .Ar c |
324 | with the 8th bit set. | | 319 | with the 8th bit set. |
325 | Generates characters `\e241' through `\e376`. | | 320 | Generates characters `\e241' through `\e376`. |
326 | .It Cm \eM^ Ns Ar c | | 321 | .It Cm \eM^ Ns Ar c |
327 | Write the control character | | 322 | Write the control character |
328 | .Ar c | | 323 | .Ar c |
| @@ -374,30 +369,28 @@ from being interpreted as an option stri | | | @@ -374,30 +369,28 @@ from being interpreted as an option stri |
374 | .Xr printf 9 | | 369 | .Xr printf 9 |
375 | .Sh STANDARDS | | 370 | .Sh STANDARDS |
376 | The | | 371 | The |
377 | .Nm | | 372 | .Nm |
378 | utility conforms to | | 373 | utility conforms to |
379 | .St -p1003.1-2001 . | | 374 | .St -p1003.1-2001 . |
380 | .Pp | | 375 | .Pp |
381 | Support for the floating point formats and `*' as a field width and precision | | 376 | Support for the floating point formats and `*' as a field width and precision |
382 | are optional in POSIX. | | 377 | are optional in POSIX. |
383 | .Pp | | 378 | .Pp |
384 | The behaviour of the %B format and the \e', \e", \exxx, \ee and | | 379 | The behaviour of the %B format and the \e', \e", \exxx, \ee and |
385 | \e[M][\-|^]c escape sequences are undefined in POSIX. | | 380 | \e[M][\-|^]c escape sequences are undefined in POSIX. |
386 | .Sh BUGS | | 381 | .Sh BUGS |
387 | Since the floating point numbers are translated from | | 382 | Since the floating point numbers are translated from ASCII to |
388 | .Tn ASCII | | 383 | floating-point and then back again, floating-point precision may be lost. |
389 | to floating-point and | | | |
390 | then back again, floating-point precision may be lost. | | | |
391 | .Pp | | 384 | .Pp |
392 | Hexadecimal character constants are restricted to, and should be specified | | 385 | Hexadecimal character constants are restricted to, and should be specified |
393 | as, two character constants. | | 386 | as, two character constants. |
394 | This is contrary to the ISO C standard but | | 387 | This is contrary to the ISO C standard but |
395 | does guarantee detection of the end of the constant. | | 388 | does guarantee detection of the end of the constant. |
396 | .Sh NOTES | | 389 | .Sh NOTES |
397 | All formats which treat the | | 390 | All formats which treat the |
398 | .Ar argument | | 391 | .Ar argument |
399 | as a number first convert the | | 392 | as a number first convert the |
400 | .Ar argument | | 393 | .Ar argument |
401 | from its external representation as a character string | | 394 | from its external representation as a character string |
402 | to an internal numeric representation, and then apply the | | 395 | to an internal numeric representation, and then apply the |
403 | format to the internal numeric representation, producing | | 396 | format to the internal numeric representation, producing |