I am filing this case for Robbin Kawabata.

The case notes a change in behavior when using the *scanf() functions
to match a percent character.  I am filing this case only to note the
behavior change.  Since the change makes *scanf() conform to C, POSIX,
SUS, SVID3, and XPG standards as well as to all Solaris 1.x and 2.x man
pages (verified back to SunOS Release 4.1 man pages) and is unlikely to
adversely affect any programs; I am marking this case closed approved
automatic.

Template Version: @(#)sac_nextcase 1.66 04/17/08 SMI
This information is Copyright 2008 Sun Microsystems
1. Introduction
    1.1. Project/Component Working Name:
         Fix *scanf() '%%' processing
    1.2. Name of Document Author/Supplier:
         Author:  Robbin Kawabata
    1.3  Date of This Document:
        26 June, 2008
4. Technical Description
Since this corrects a standards violation, this fix will probably need
to be backported.  Therefore, a patch release binding is requested.

This case notes a behavior change for the *scanf() and *wscanf() family
of functions for handling the format specification "%%", which scans a
single '%' character in input.  The current Solaris Nevada scanf()
behavior produces a VSX test suite failure as described in CR 6690298.

The current Solaris scanf() format specifier "%%", accepts a single '%' 
character in input, without skipping over leading whitespace.  The VSX
test expects the "%%" specifier to accept a '%' character whether or
not it is preceded by whitespace.

The existing standards require that a "%%" conversion specification
should allow whitespace to precede '%' input.  The XPG6 scanf() man
page says:

    "... A conversion specification shall be executed in the following
     steps.

     Input white-space characters (as specified by the isspace function) 
     shall be skipped, unless the conversion specification includes a 
     [, c, C, or n conversion specifier.
        ...
     The following conversion specifers are valid:
        ...
     %  Matches a single '%' character; no conversion or assignment
        occurs.  
        The complete conversion specification shall be %%."

Our current man page describes the same behavior (using the English
"are" and "must be" instead of the Standardese "shall be").

Note the historical System V and BSD scanf() behavior with specifier
"%%", did not accept whitespace before an input '%'.  This is a case
where the SVID3 specification did not match the UNIX System V
behavior.  However, Linux scanf() does accept whitespace before '%'.
Because Linux systems behave according to the standards, we feel we
will not be able to change the standards to match Solaris behavior.

We propose to change the Solaris scanf() and wscanf() behavior so that
"%%" format specifier accepts '%' input character after skipping over
any whitespace characters that may precede it.  We also propose adding
a new note to the Solaris scanf.3c and fswscanf.3c man pages to mention
the behavior change, as below:

  NOTES:
  The behavior of all of the functions described on this man page, with
  conversion specifier "%%", has been changed to match the description
  on the man pages and in various standards.  Previously the "%%"
  specifier accepted a '%' character from input only if there were no
  preceding whitespace characters.  The new behavior accepts '%' even
  if there are preceding whitespace characters.  If the old behavior is
  desired, the conversion specification "%*[%]" can be used.

6. Resources and Schedule
    6.4. Steering Committee requested information
        6.4.1. Consolidation C-team Name:
                ON
    6.5. ARC review type: Automatic
    6.6. ARC Exposure: open


Reply via email to