|
|
Message-ID: <20170710205955.GN1627@brightrain.aerifal.cx>
Date: Mon, 10 Jul 2017 16:59:55 -0400
From: Rich Felker <dalias@...c.org>
To: musl@...ts.openwall.com
Subject: Re: [PATCH] handle whitespace before %% in scanf
On Mon, Jul 10, 2017 at 04:44:45PM +0200, Jens Gustedt wrote:
> Hello Bartosz,
>
> On Mon, 10 Jul 2017 10:22:37 +0200 Bartosz Brachaczek
> <b.brachaczek@...il.com> wrote:
>
> > > EXAMPLE 5 The call:
> > >
> > > #include <stdio.h>
> > > /* ... */
> > > int n, i;
> > > n = sscanf("foo % bar 42", "foo%%bar%d", &i);
> > >
> > > will assign to 'n' the value 1 and to 'i' the value 42 because input
> > > white-space characters are skipped for both the '%' and 'd'
> > > conversion specifiers.
> >
> > Now, the code in the example is clearly broken, as either the format
> > string should be "foo%% bar%d" or the input string should be
> > "foo %bar 42", but the explanation does imply that '%%' consumes
> > whitespace.
>
> Yes, I have noted this as an editorial fix for C17
So you can confirm that it's intentional that %% consume space? That
seems utterly awful but I guess you can use %*1[%] in place of %% to
do what %% should...
Rich
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.