From 9a6ff5bc53dedbaa601a1a76cbaf8a76afd60c9f Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 15 Apr 2024 21:41:06 +0200 Subject: Adding upstream version 6.7. Signed-off-by: Daniel Baumann --- man3/scanf.3 | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) (limited to 'man3/scanf.3') diff --git a/man3/scanf.3 b/man3/scanf.3 index 7934509..3ac97c0 100644 --- a/man3/scanf.3 +++ b/man3/scanf.3 @@ -2,7 +2,7 @@ .\" Copyright 2022 Alejandro Colomar .\" SPDX-License-Identifier: Linux-man-pages-copyleft .\" -.TH scanf 3 2023-07-20 "Linux man-pages 6.05.01" +.TH scanf 3 2023-12-09 "Linux man-pages 6.7" .SH NAME scanf, fscanf, vscanf, vfscanf \- input FILE format conversion .SH LIBRARY @@ -11,23 +11,23 @@ Standard C library .SH SYNOPSIS .nf .B #include -.PP +.P .BI "int scanf(const char *restrict " format ", ...);" .BI "int fscanf(FILE *restrict " stream , .BI " const char *restrict " format ", ...);" -.PP +.P .B #include -.PP +.P .BI "int vscanf(const char *restrict " format ", va_list " ap ); .BI "int vfscanf(FILE *restrict " stream , .BI " const char *restrict " format ", va_list " ap ); .fi -.PP +.P .RS -4 Feature Test Macro Requirements for glibc (see .BR feature_test_macros (7)): .RE -.PP +.P .BR vscanf (), .BR vfscanf (): .nf @@ -36,7 +36,7 @@ Feature Test Macro Requirements for glibc (see .SH DESCRIPTION The .BR scanf () -family of functions scans input like +family of functions scans formatted input like .BR sscanf (3), but read from a .IR FILE . @@ -49,7 +49,7 @@ and parse them later with .BR sscanf (3) or more specialized functions such as .BR strtol (3). -.PP +.P The .BR scanf () function reads input from the standard input stream @@ -58,7 +58,7 @@ and .BR fscanf () reads input from the stream pointer .IR stream . -.PP +.P The .BR vfscanf () function is analogous to @@ -77,7 +77,7 @@ On success, these functions return the number of input items successfully matched and assigned; this can be fewer than provided for, or even zero, in the event of an early matching failure. -.PP +.P The value .B EOF is returned if the end of input is reached before either the first @@ -132,11 +132,27 @@ T{ .BR vfscanf () T} Thread safety MT-Safe locale .TE -.sp 1 .SH STANDARDS C11, POSIX.1-2008. .SH HISTORY C99, POSIX.1-2001. +.SH CAVEATS +These functions make it difficult to +distinguish newlines from other white space, +This is especially problematic with line-buffered input, +like the standard input stream. +.P +These functions can't report errors after the last +non-suppressed conversion specification. +.SH BUGS +It is impossible to accurately know +how many characters these functions have consumed from the input stream, +since they only report the number of successful conversions. +For example, +if the input is "123\en\ a", +.I scanf(\[dq]%d\ %d\[dq], &a, &b) +will consume the digits, the newline, and the space, but not the letter a. +This makes it difficult to recover from invalid input. .SH SEE ALSO .BR fgets (3), .BR getline (3), -- cgit v1.2.3