Email List: Xaustin-group-lX
[All Lists]

Re: scanf "%%" and whitespace

To: Geoff Clare <gwc@xxxxxxxxxxxxx>
Subject: Re: scanf "%%" and whitespace
From: "Clive D.W. Feather" <clive@xxxxxxxxx>
Date: Thu, 2 Aug 2007 08:35:30 +0100
Cc: austin-group-l@xxxxxxxxxxxxx
References: <20070801160059.GA23415@xxxxxx>
Geoff Clare said:
> As far as I can see, the descriptions of scanf() in SUSv3 and C99
> require a %% in the format to consume any whitespace characters that
> precede a % in the input.

I agree it's what the C99 Standard requires.

> Is this intentional, or is it a defect in C99?

I can see arguments either way. On the one hand, %% was intended to be an
escape code for a single %. On the other hand, it's always been specified
as a conversion and not like a non-white-space character in the format.

My own inclination would be to rewrite C99 to make %% be an escape sequence
rather than a strangely-behaved conversion and have it not consume any
whitespace. But you'll have to go to WG14 for a formal decision.

-- 
Clive D.W. Feather  | Work:  <clive@xxxxxx>   | Tel:    +44 20 8495 6138
Internet Expert     | Home:  <clive@xxxxxx>  | Fax:    +44 870 051 9937
Demon Internet      | WWW: http://www.davros.org | Mobile: +44 7973 377646
THUS plc            |                            |

<Prev in Thread] Current Thread [Next in Thread>