diff options
| -rw-r--r-- | man3/scanf.3 | 49 |
1 files changed, 36 insertions, 13 deletions
diff --git a/man3/scanf.3 b/man3/scanf.3 index 9fb8b67440..b72ada2586 100644 --- a/man3/scanf.3 +++ b/man3/scanf.3 @@ -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 |
