The updated spec follows. The requested binding is patch.

I have reset the timer to expire on 10/24.

----
Standard C Library Functions                                 strfnum(3C)

NAME
         strfnum, strfunum - format a number as a scaled string

SYNOPSIS
         #include <string.h>

         int strfnum(char *restrict buffer, size_t buf_len,
         const char *restrict fmt, intmax_t value);

         int strfunum(char *restrict buffer, size_t buf_len,
         const char *restrict fmt, uintmax_t value);

DESCRIPTION
         The strfnum(), strfunum() functions will convert the integer
         <value> to a string, which will write at most <buf_len> bytes
         to the output <buffer>. The format of the output string is
         described by the <fmt> string.

     Conversion Specification
         The <fmt> string determines how <value> will be formatted to
         the output in a fashion similar to sprintf(). Each conversion
         specifier within the string consists of the % character, after
         which the following appear in sequence:

           o Zero or more of the following modifiers:
                 '0' : the resulting string is zero padded.
                 '-' : the resulting string is left aligned.
                 '+' : the resulting string's first char is a
                       '+' if result is greater than zero.
                 ' ' : the resulting string's first char is a
                       space is the result is greater than zero;
                       used only if the '+' modifier is not
                       defined.
                 '#' : suppress trailing zeroes.
                 't' : include thousands separator(s).
                 'u' : suppress unit suffix.
           o An optional decimal length. If the result is smaller,
             the output will be padded according to the modifiers
             if present, otherwise the result will be space-padded.
           o An optional decimal precision, expressed as .# where
             # is an unsigned decimal integer. When not specified,
             three digits is the default precision.
           o An optional 'b' character, which will express the result
             as radix-2 rather than radix-10 (radix 2 uses 1024^N
             whereas the default of radix 10 uses 1000^N to convert
             the number).
           o One character from the following set:
                 'A' : the unit is choosen automatically for the best
                       human-readable result. The integer part of the
                       result will be between 0 and 999 when radix-10
                       is used for the conversion, or 0 to 1023 when
                       radix-2 is used for the conversion.
                 'N' : use no units for conversion (will divide by 1).
                 'K' : use the SI unit of kilo.
                 'M' : use the SI unit of mega.
                 'G' : use the SI unit of giga.
                 'P' : use the SI unit of peta.
                 'T' : use the SI unit of tera.
                 'E' : use the SI unit of exa.
                 '%' : output a literal % character.

RETURN VALUE
         The strfnum() function returns the number of bytes
         written into <buffer> if less than or equal to <buf_len>,
         otherwise returns the number of bytes that would have been
         written to <buffer> if <buf_len> had been sufficiently large.
         The value of <buf_len> may be passed as zero, and/or <buffer>
         may be a null pointer; this will result in a return value of
         the minimal-length buffer required to contain a complete
         result (minus a terminating NUL character).

EXAMPLES
         strfnum(buffer, len, "%5M", 123456789)
         will output "123.457M" into the buffer

         strfnum(buffer, len, "%5.M", 123456789)
         will output " 123M" into the buffer

         strfnum(buffer, len, "%5.0M", 123456789)
         will output " 123M" into the buffer

         strfnum(buffer, len, "%5.1M", 123456789)
         will output "123.5M" into the buffer

         strfnum(buffer, len, "%5.2M", 123456789)
         will output "123.46M" into the buffer

         strfnum(buffer, len, "%5.3M", 123456789)
         will output "123.457M" into the buffer

         strfnum(buffer, len, "%5.4M", 123456789)
         will output "123.4568M" into the buffer

         strfnum(buffer, len, "%+5.2K", 123456789)
         will output "+123456.79K" into the buffer

         strfnum(buffer, len, "%N", 123456789)
         will output "123456789" into the buffer.

         strfnum(buffer, len, "%A", 0)
         will output "0.000" into the buffer.

         strfnum(buffer, len, "%b", 0)
         will output "0.000" into the buffer.

         strfnum(buffer, len, "%bK", 0)
         will output "0.000K" into the buffer.

         strfnum(buffer, len, "%ubK", 1024)
         will output "1.000" into the buffer.

         strfnum(buffer, len, "FOO %0#5.4bA BAR", 1047552);
         will output "FOO 01023K BAR" into the buffer.

NOTES
         The radix and thousands characters follow the
         current locale setting.

ATTRIBUTES
         Interface Stability             Committed
         MT-Level                        Thread and async-signal safe

Reply via email to