Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 94f6df7 in mainline


Ignore:
Timestamp:
2012-04-15T06:18:53Z (10 years ago)
Author:
Sean Bartell <wingedtachikoma@…>
Branches:
lfn, master
Children:
f682f5a
Parents:
6484602
Message:

fix printf %s when precision > string length

Location:
uspace
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/tester/print/print1.c

    r6484602 r94f6df7  
    4242       
    4343        TPRINTF("Testing printf(\"%%8.10s\", \"text\"):\n");
    44         TPRINTF("Expected output: \"text\"\n");
     44        TPRINTF("Expected output: \"    text\"\n");
    4545        TPRINTF("Real output:     \"%8.10s\"\n\n", "text");
    4646       
     
    4949        TPRINTF("Real output:     \"%8.10s\"\n\n", "very long text");
    5050       
     51        TPRINTF("Testing printf(\"%%-*.*s\", 7, 7, \"text\"):\n");
     52        TPRINTF("Expected output: \"text   \"\n");
     53        TPRINTF("Real output:     \"%-*.*s\"\n\n", 7, 7, "text");
     54       
    5155        return NULL;
    5256}
  • uspace/lib/c/generic/io/printf_core.c

    r6484602 r94f6df7  
    283283        /* Print leading spaces. */
    284284        size_t strw = str_length(str);
    285         if (precision == 0)
     285        if (precision == 0 || precision > strw)
    286286                precision = strw;
    287287       
     
    331331        /* Print leading spaces. */
    332332        size_t strw = wstr_length(str);
    333         if (precision == 0)
     333        if (precision == 0 || precision > strw)
    334334                precision = strw;
    335335       
Note: See TracChangeset for help on using the changeset viewer.