Bug 249025 - description of scanf %u incorrectly says "optionally signed" (patch included)
Summary: description of scanf %u incorrectly says "optionally signed" (patch included)
Status: Closed Not A Bug
Alias: None
Product: Documentation
Classification: Unclassified
Component: Manual Pages (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-08-31 01:26 UTC by wbe
Modified: 2020-09-11 16:10 UTC (History)
2 users (show)

See Also:
wbe: maintainer-feedback?


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description wbe 2020-08-31 01:26:03 UTC
I believe the description of %u in man3/scanf.3, which says that %u matches an OPTIONALLY SIGNED decimal integer, is incorrect.  If you agree, the following "diff -u" 1-line patch to the man3/scanf.3 file from 12.1-RELEASE-p8 should fix the problem.  If this error is in 12.1, it's probably in other versions of FreeBSD as well.

<pre>

--- scanf.3~    2020-08-30 20:59:00.080775000 -0400
+++ scanf.3     2020-08-30 21:00:37.400650000 -0400
@@ -296,7 +296,7 @@
 the next pointer must be a pointer to
 .Vt "unsigned int" .
 .It Cm u
-Matches an optionally signed decimal integer;
+Matches an unsigned decimal integer;
 the next pointer must be a pointer to
 .Vt "unsigned int" .
 .It Cm x , X

</pre>

 -WBE
Comment 1 Hiroki Sato freebsd_committer 2020-08-31 01:42:41 UTC
(In reply to wbe from comment #0)

%u actually matches an optionally signed integer.  This means digits with "+" or "-".  The value is casted to an unsigned type after the matching.  This wording (and behavior) is the same as one in the specification.  I do not think the current version is incorrect.
Comment 2 wbe 2020-09-11 16:06:24 UTC
Looks like you're correct and I was wrong.  From what I now see in C90, C99, C++, man strtoul(), etc. the specs call for no meaningful difference between %u and %d these days in what of the input string is read and how it's interpreted.

I thought they used to be different.  Sorry for the bother.
 -WBE