avr-libc-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-libc-dev] [bug #32322] snprintf() Hex conversion field width specif


From: Joerg Wunsch
Subject: [avr-libc-dev] [bug #32322] snprintf() Hex conversion field width specifiers malfunction
Date: Wed, 02 Feb 2011 10:15:32 +0000
User-agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.9.0.19) Gecko/2010071610 Firefox/3.0.19

Update of bug #32322 (project avr-libc):

                  Status:                    None => Invalid                
             Assigned to:                    None => joerg_wunsch           
             Open/Closed:                    Open => Closed                 

    _______________________________________________________

Follow-up Comment #1:

No bug involved (apart from the obvious bug that you supply the
arguments for sprintf() yet try to call snprintf()),

The field width includes everything that is eventually generated by
the format specifier, so the "0x" is always included in the field
width, and already occupies the entire output field except in the 0
case.  Any actual data to be formatted thus has to overflow the output
field.

The 0 case is different, as ISO/IEC 9899:1999 requires the
implementation to *not* generate the 0x prefix in that case:

# The result is converted to an ``alternative form''. [...] For x (or
  X) conversion, a nonzero result has 0x (or 0X) prefixed to it. [...]

Thus, the output field is sufficient, and as the '0' flag has been
given, it is zero-padded to the left, resulting in "00".


    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?32322>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]