OSDN Git Service

LDP: Update original to LDP v3.79
[linuxjm/LDP_man-pages.git] / original / man3 / scanf.3
index 9fb8b67..e58301e 100644 (file)
@@ -49,7 +49,7 @@
 .\"     Add ERRORS section.
 .\"     Document the 'a' and 'm' modifiers for dynamic string allocation.
 .\"
-.TH SCANF 3  2013-01-30 "GNU" "Linux Programmer's Manual"
+.TH SCANF 3  2014-01-11 "GNU" "Linux Programmer's Manual"
 .SH NAME
 scanf, fscanf, sscanf, vscanf, vsscanf, vfscanf \- input format conversion
 .SH SYNOPSIS
@@ -264,7 +264,7 @@ and
 If
 .I format
 contains \(aq%\(aq
-specifications then these correspond in order with successive
+specifications, then these correspond in order with successive
 .I pointer
 arguments.
 In the
@@ -331,7 +331,7 @@ characters is equivalent to
 If used with
 .B %c
 or
-.B %s
+.BR %s ,
 the corresponding parameter is considered
 as a pointer to a wide character or wide-character string respectively.
 .\" This use of l was introduced in Amendment 1 to ISO C90.
@@ -606,13 +606,35 @@ documentation of
 .I libc (glibc-1.08)
 for a more concise description.
 .SH NOTES
-The GNU C library supported the dynamic allocation conversion specifier
+.SS The 'a' assignment-allocation modifier
+Originally, the GNU C library supported dynamic allocation for string inputs
 (as a nonstandard extension) via the
 .B a
-character.  This feature
-seems to be present at least as far back as glibc 2.0.
+character.
+(This feature is present at least as far back as glibc 2.0.)
+Thus, one could write the following to have
+.BR scanf ()
+allocate a buffer for an input string,
+with a pointer to that buffer being returned in
+.IR *buf :
+
+    char *buf;
+    scanf("%as", &buf);
+.PP
+The use of the letter
+.B a
+for this purpose was problematic, since
+.B a
+is also specified by the ISO C standard as a synonym for
+.B f
+(floating-point input).
+POSIX.1-2008 instead specifies the
+.B m
+modifier for assignment allocation (as documented in DESCRIPTION, above).
 .PP
-It is not available if the program is compiled with
+Note that the
+.B a
+modifier is not available if the program is compiled with
 .I "gcc -std=c99"
 or
 .IR "gcc -D_ISOC99_SOURCE"
@@ -622,14 +644,17 @@ is also specified), in which case the
 .B a
 is interpreted as a specifier for floating-point numbers (see above).
 
-Since version 2.7, glibc also provides the
+Support for the
 .B m
-modifier for the same purpose as the
-.BR a
-modifier.
-The
+modifier was added to glibc starting with version 2.7,
+and new programs should use that modifier instead of
+.BR a .
+
+As well as being standardized by POSIX, the
 .B m
-modifier has the following advantages:
+modifier has the following further advantages over
+the use of
+.BR a:
 .IP * 2
 It may also be applied to
 .B %c
@@ -640,9 +665,7 @@ It avoids ambiguity with respect to the
 .B %a
 floating-point conversion specifier (and is unaffected by
 .IR "gcc -std=c99"
-etc.)
-.IP *
-It is specified in the POSIX.1-2008 standard.
+etc.).
 .SH BUGS
 All functions are fully C89 conformant, but provide the
 additional specifiers
@@ -719,3 +742,12 @@ call successfully read a string.
 .BR strtod (3),
 .BR strtol (3),
 .BR strtoul (3)
+.SH COLOPHON
+This page is part of release 3.79 of the Linux
+.I man-pages
+project.
+A description of the project,
+information about reporting bugs,
+and the latest version of this page,
+can be found at
+\%http://www.kernel.org/doc/man\-pages/.