Sorry Mark,
I disagree strongly.  The definition of white space (XBD section 3.442, P104
[using the 2016 edition page and line numbers], L2873-2877) and the definition
of the space character class in the description of Locales (XBD section 7.3.1,
P140, L4163-4170):

3.442 White Space
        A sequence of one or more characters that belong to the space character 
class as
        defined via the LC_CTYPE category in the current locale.

        In the POSIX locale, white space consists of one or more <blank> 
(<space> and
        <tab> characters), <newline>, <carriage-return>, <form-feed>, and 
<vertical-tab>
        characters.

space   Define characters to be classified as white-space characters.

        In the POSIX locale, exactly <space>, <form-feed>, <newline>, 
<carriage-return>,
        <tab>, and <vertical-tab> shall be included.

        In a locale definition file, no character specified for the keywords 
upper,
        lower, alpha, digit, graph, or xdigit shall be specified. The <space>, 
<formfeed>,
        <newline>, <carriage-return>, <tab>, and <vertical-tab> of the portable
        character set, and any characters included in the class blank are 
automatically
        included in this class.

make it abundantly clear that <carriage-return> is a white-space character in 
the POSIX
locale.  The description of white-space characters in fscanf()'s DESCRIPTION 
section on
P949, L32229 is wrong and needs to be fixed.  The current text:

        The format is a character string, beginning and ending in its initial 
shift
        state, if any, composed of zero or more directives. Each directive is 
composed
        of one of the following: one or more white-space characters (<space>, 
<tab>,
        <newline>, <vertical-tab>, or <form-feed>); an ordinary character 
(neither '%'
        nor a white-space character); or a conversion specification.

is wrong both because it omits <cariage-return> from the list and because it 
fails to
mention that the list is only true in the POSIX (or C) locale.  In other 
locales, the
list of white-space characters is the set of characters contained in that 
locale's
space character class.

The first parenthetical element in the last quote above should just be removed 
(which
does  not appear in the C Standard) or should be changed to match the 
parenthetical
element in the later reference on P950, L32253-32254:

        Input white-space characters (as specified by isspace()) shall be 
skipped,
        unless the conversion specification includes a [, c, C, or n conversion 
...

(which does appear in the C Standard).

Note that the C standard has two pseudo-definitions of white space.  In 
pre-processor
statements, white-space characters are just <space> and <tab> (but <space> may 
have
replaced comments and other white-space characters in translation phase 3).  In 
the
library section of the C Standard, isspace() returns true for "standard" 
white-space
characters (the same characters that appear in the POSIX space character class) 
and
any locale-specific characters chosen by the implementation (but no character 
can
yield a true response from both isspace() and isalnum()).  In the C Locale, 
only the
standard white-space characters yield a true response from isspace().

> On Sep 7, 2017, at 4:50 PM, Shware Systems <shwares...@aol.com> wrote:
> 
> I suspect <newline> in that list is meant to include both <CR> or <LF>, 
> possibly according to a 
> platform's or terminal's line ending convention, rather than list the codes 
> separately.
> I could
>  see an addition to Application Usage that applications may have to take 
> conventions into account when crafting control strings, but this is more a 
> bug in C not being specific enough, to me.
> 
> On Thursday, September 7, 2017 Schwarz, Konrad <konrad.schw...@siemens.com> 
> wrote:
> 
> Hi,
> 
> fscanf states that white space characters are skipped, and lists the white 
> space characters.  This list does not include carriage return.  The POSIX 
> definition of white space (link anker seems to be wrong) includes carriage 
> return.
> 
>  
> C0x.pdf speaks generically of white space characters.
> 
>  
> Is the omission of carriage return in fscanf deliberate?
> 
>  
> Regards
> 
>  
> Konrad Schwarz
> 


Reply via email to