From: Rich Felker <dalias@aerifal.cx>
To: musl@lists.openwall.com
Subject: Re: sscanf(3) return value doesn't count %100c assignments
Date: Fri, 15 Nov 2013 15:47:02 -0500 [thread overview]
Message-ID: <20131115204702.GE24286@brightrain.aerifal.cx> (raw)
In-Reply-To: <loom.20131115T212022-997@post.gmane.org>
On Fri, Nov 15, 2013 at 08:23:42PM +0000, David Wuertele wrote:
> Comparing musl-0.9.14 with glibc-2.13, I find sscanf(3) behaves
> differently. In Glibc, sscanf() returns the same assignment counts when
> using %Nc compared with using %s, but in Mulsl, sscanf returns different
> assignment counts.
>
> For example, take the following two instructions:
>
> sscanf (string, "%d %s", &number, remainder);
> sscanf (string, "%d %100c", &number, remainder);
>
> If each of these makes two assignments, they should both return 2.
> Glibc works this way. But even though with Musl they both make two
> assignments, Musl sscanf() returns 2 for the %s and it returns 1 for
> the %100c version.
musl's sscanf returns 1 because only the %d was matched. %100c
requires _exactly_ 100 characters; anything shorter is a matching
failure. See C99 7.19.6.2 The fscanf function, paragraph 12:
12 The conversion specifiers and their meanings are:
....
c
Matches a sequence of characters of exactly the number specified
by the field width (1 if no field width is present in the
directive).
What you're seeing is a known bug in glibc:
https://sourceware.org/bugzilla/show_bug.cgi?id=12701
It's an old WONTFIX from the days when Ulrich Drepper was maintainer.
Rich
next prev parent reply other threads:[~2013-11-15 20:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-15 20:23 David Wuertele
2013-11-15 20:47 ` Rich Felker [this message]
2013-11-15 21:17 ` David Wuertele
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20131115204702.GE24286@brightrain.aerifal.cx \
--to=dalias@aerifal.cx \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).