Loading...
--- Libc/Libc-763.11/stdio/printf.3
+++ Libc/Libc-498.1.7/stdio/printf.3
@@ -13,6 +13,10 @@
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\" must display the following acknowledgement:
+.\" This product includes software developed by the University of
+.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
@@ -30,49 +34,89 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)printf.3 8.1 (Berkeley) 6/4/93
-.\" $FreeBSD: src/lib/libc/stdio/printf.3,v 1.64 2009/12/02 07:51:25 brueffer Exp $
+.\" $FreeBSD: src/lib/libc/stdio/printf.3,v 1.58 2004/10/16 16:00:01 stefanf Exp $
.\"
-.Dd December 2, 2009
+.Dd October 16, 2004
.Dt PRINTF 3
.Os
.Sh NAME
-.Nm printf , fprintf , sprintf , snprintf , asprintf , dprintf ,
-.Nm vprintf , vfprintf, vsprintf , vsnprintf , vasprintf, vdprintf
+.Nm asprintf ,
+.Nm fprintf ,
+.Nm printf ,
+.Nm snprintf ,
+.Nm sprintf ,
+.Nm vasprintf ,
+.Nm vfprintf,
+.Nm vprintf ,
+.Nm vsnprintf ,
+.Nm vsprintf
.Nd formatted output conversion
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
.In stdio.h
.Ft int
-.Fn printf "const char * restrict format" ...
+.Fo asprintf
+.Fa "char **ret"
+.Fa "const char *format" ...
+.Fc
.Ft int
-.Fn fprintf "FILE * restrict stream" "const char * restrict format" ...
+.Fo fprintf
+.Fa "FILE *restrict stream"
+.Fa "const char *restrict format" ...
+.Fc
.Ft int
-.Fn sprintf "char * restrict str" "const char * restrict format" ...
+.Fo printf
+.Fa "const char *restrict format" ...
+.Fc
.Ft int
-.Fn snprintf "char * restrict str" "size_t size" "const char * restrict format" ...
+.Fo snprintf
+.Fa "char *restrict s"
+.Fa "size_t n"
+.Fa "const char *restrict format" ...
+.Fc
.Ft int
-.Fn asprintf "char **ret" "const char *format" ...
+.Fo sprintf
+.Fa "char *restrict s"
+.Fa "const char *restrict format" ...
+.Fc
+.In stdarg.h
+.In stdio.h
.Ft int
-.Fn dprintf "int fd" "const char * restrict format" ...
-.In stdarg.h
+.Fo vasprintf
+.Fa "char **ret"
+.Fa "const char *format"
+.Fa "va_list ap"
+.Fc
.Ft int
-.Fn vprintf "const char * restrict format" "va_list ap"
+.Fo vfprintf
+.Fa "FILE *restrict stream"
+.Fa "const char *restrict format"
+.Fa "va_list ap"
+.Fc
.Ft int
-.Fn vfprintf "FILE * restrict stream" "const char * restrict format" "va_list ap"
+.Fo vprintf
+.Fa "const char *restrict format"
+.Fa "va_list ap"
+.Fc
.Ft int
-.Fn vsprintf "char * restrict str" "const char * restrict format" "va_list ap"
+.Fo vsnprintf
+.Fa "char *restrict s"
+.Fa "size_t n"
+.Fa "const char *restrict format"
+.Fa "va_list ap"
+.Fc
.Ft int
-.Fn vsnprintf "char * restrict str" "size_t size" "const char * restrict format" "va_list ap"
-.Ft int
-.Fn vasprintf "char **ret" "const char *format" "va_list ap"
-.Ft int
-.Fn vdprintf "int fd" "const char * restrict format" "va_list ap"
+.Fo vsprintf
+.Fa "char *restrict s"
+.Fa "const char *restrict format"
+.Fa "va_list ap"
+.Fc
.Sh DESCRIPTION
The
.Fn printf
family of functions produces output according to a
-.Fa format
+.Fa format ,
as described below.
The
.Fn printf
@@ -87,10 +131,6 @@
.Fn vfprintf
write output to the given output
.Fa stream ;
-.Fn dprintf
-and
-.Fn vdprintf
-write output to the given file descriptor;
.Fn sprintf ,
.Fn snprintf ,
.Fn vsprintf ,
@@ -178,10 +218,6 @@
functions
effectively assume an infinite
.Fa n .
-.Pp
-For those routines that write to a user-provided character string,
-that string and the format strings should not overlap, as the
-behavior is undefined.
.Pp
The format string is composed of zero or more directives:
ordinary
@@ -225,7 +261,8 @@
For
.Cm o
conversions, the precision of the number is increased to force the first
-character of the output string to a zero.
+character of the output string to a zero (except if a zero value is printed
+with an explicit precision of zero).
For
.Cm x
and
@@ -608,7 +645,7 @@
Note that there may be multiple valid ways to represent floating-point
numbers in this hexadecimal format.
For example,
-.Li 0x1.92p+1 , 0x3.24p+0 , 0x6.48p-1 ,
+.Li 0x3.24p+0 , 0x6.48p-1
and
.Li 0xc.9p-2
are all equivalent.
@@ -830,29 +867,6 @@
Always use the proper secure idiom:
.Pp
.Dl "snprintf(buffer, sizeof(buffer), \*q%s\*q, string);"
-.Sh COMPATIBILITY
-The conversion formats
-.Cm \&%D , \&%O ,
-and
-.Cm %U
-are not standard and
-are provided only for backward compatibility.
-The effect of padding the
-.Cm %p
-format with zeros (either by the
-.Cm 0
-flag or by specifying a precision), and the benign effect (i.e., none)
-of the
-.Cm #
-flag on
-.Cm %n
-and
-.Cm %p
-conversions, as well as other
-nonsensical combinations such as
-.Cm %Ld ,
-are not standard; such combinations
-should be avoided.
.Sh ERRORS
In addition to the errors documented for the
.Xr write 2
@@ -867,8 +881,8 @@
.El
.Sh SEE ALSO
.Xr printf 1 ,
+.Xr fmtcheck 3 ,
.Xr printf_l 3 ,
-.Xr fmtcheck 3 ,
.Xr scanf 3 ,
.Xr setlocale 3 ,
.Xr stdarg 3 ,
@@ -894,13 +908,7 @@
and
.Fn vsnprintf
functions conform to
-.St -isoC-99 ,
-while
-.Fn dprintf
-and
-.Fn vdprintf
-conform to
-.St -p1003.1-2008 .
+.St -isoC-99 .
.Sh HISTORY
The functions
.Fn asprintf
@@ -918,13 +926,30 @@
.An Todd C. Miller Aq Todd.Miller@courtesan.com
for
.Ox 2.3 .
-The
-.Fn dprintf
-and
-.Fn vdprintf
-functions were added in
-.Fx 8.0 .
.Sh BUGS
+The conversion formats
+.Cm \&%D , \&%O ,
+and
+.Cm %U
+are not standard and
+are provided only for backward compatibility.
+The effect of padding the
+.Cm %p
+format with zeros (either by the
+.Cm 0
+flag or by specifying a precision), and the benign effect (i.e., none)
+of the
+.Cm #
+flag on
+.Cm %n
+and
+.Cm %p
+conversions, as well as other
+nonsensical combinations such as
+.Cm %Ld ,
+are not standard; such combinations
+should be avoided.
+.Pp
The
.Nm
family of functions do not correctly handle multibyte characters in the