src/lib/ppc405lib/printf.c
// Format a string
//
// If the string is the NULL pointer then normally "(null)" is printed
// unless the precision is < 6, in which case the empty string is printed.
// The specification leaves it as undefined what happens if a string requests
// 0 padding; Here we always pad with blanks (although GCC/PowerPC catches
// this as an error).
Format a string
If the string is the NULL pointer then normally "(null)" is printed
unless the precision is < 6, in which case the empty string is printed.
The specification leaves it as undefined what happens if a string requests
0 padding; Here we always pad with blanks (although GCC/PowerPC catches
this as an error).
Format a string If the string is the NULL pointer then normally " ( null ) " is printed unless the precision is < 6 in which case the empty string is printed . The specification leaves it as undefined what happens if a string requests 0 padding ; Here we always pad with blanks ( although GCC / PowerPC catches this as an error ) .
static ssize_t
format_string(FILE *stream, const char *s, int options, 
              size_t width, size_t precision)
{
    size_t len;
    ssize_t padchars, nchars;
    int rc;
    if (s == 0) {
        if ((options & OPTION_PRECISION) && (precision < 6)) {
            s = "";
        } else {
            s = "(null)";
        }
    }
    len = strlen(s);
    if (options & OPTION_PRECISION) {
        len = MIN(len, precision);
    }
    options &= ~OPTION_PAD_ZERO;
    padchars = pad(stream, len, options, width);
    if (padchars < 0) return padchars;
    nchars = padchars + len;
    rc = swrite(stream, (void *)s, len, 0);
    if (rc < 0) return rc;
    return nchars;
}
static ssize_t format_string ( FILE * stream , const char * s , int options , size_t width , size_t precision ) { size_t len ; ssize_t padchars , nchars ; int rc ; if ( s == 0 ) { if ( ( options & OPTION_PRECISION ) && ( precision < 6 ) ) { s = " " ; } else { s = " " ; } } len = strlen ( s ) ; if ( options & OPTION_PRECISION ) { len = MIN ( len , precision ) ; } options &= ~ OPTION_PAD_ZERO ; padchars = pad ( stream , len , options , width ) ; if ( padchars < 0 ) return padchars ; nchars = padchars + len ; rc = swrite ( stream , ( void * ) s , len , 0 ) ; if ( rc < 0 ) return rc ; return nchars ; }
Format a string
If the string is the NULL pointer then normally "(null)" is printed
unless the precision is < 6, in which case the empty string is printed.
Format a string If the string is the NULL pointer then normally " ( null ) " is printed unless the precision is < 6 in which case the empty string is printed .