Ignore:
Timestamp:
2009-04-01T19:01:39Z (15 years ago)
Author:
Jiri Svoboda <jirik.svoboda@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
06b785f
Parents:
f25b2819
Message:

Partial refactor of printf modules to reflect new string API.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/printf/printf_core.c

    rf25b2819 r1b0b48e0  
    253253        if (str == NULL)
    254254                return printf_putstr(nullstr, ps);
    255        
    256         /* Print leading spaces */
    257         size_t size = str_length(str);
     255
     256        /* Print leading spaces. */
     257        count_t strw = str_length(str);
    258258        if (precision == 0)
    259                 precision = size;
     259                precision = strw;
    260260
    261261        count_t counter = 0;
     
    269269
    270270        int retval;
    271         size_t bytes = str_lsize(str, min(size, precision));
    272         if ((retval = printf_putnchars_utf8(str, bytes, ps)) < 0)
     271        size_t size = str_lsize(str, precision);
     272        if ((retval = printf_putnchars_utf8(str, size, ps)) < 0)
    273273                return -counter;
    274        
     274
    275275        counter += retval;
    276        
     276
    277277        while (width-- > 0) {
    278278                if (printf_putchar(' ', ps) == 1)
     
    281281
    282282        return ((int) counter);
     283
    283284}
    284285
     
    292293 * @return Number of UTF-32 characters printed, negative value on failure.
    293294 */
    294 static int print_utf32(wchar_t *str, int width, unsigned int precision,
     295static int print_utf32(wchar_t *wstr, int width, unsigned int precision,
    295296        uint32_t flags, printf_spec_t *ps)
    296297{
    297         if (str == NULL)
     298        if (wstr == NULL)
    298299                return printf_putstr(nullstr, ps);
    299        
    300         /* Print leading spaces */
    301         size_t size = wstr_length(str);
     300
     301        /* Print leading spaces. */
     302        size_t strw = wstr_length(wstr);
    302303        if (precision == 0)
    303                 precision = size;
    304        
     304                precision = strw;
     305
    305306        count_t counter = 0;
    306307        width -= precision;
     
    311312                }
    312313        }
    313        
     314
    314315        int retval;
    315         size_t bytes = min(size, precision) * sizeof(wchar_t);
    316         if ((retval = printf_putnchars_utf32(str, bytes, ps)) < 0)
     316        size_t size = min(strw, precision) * sizeof(wchar_t);
     317        if ((retval = printf_putnchars_utf32(wstr, size, ps)) < 0)
    317318                return -counter;
    318        
     319
    319320        counter += retval;
    320        
     321
    321322        while (width-- > 0) {
    322323                if (printf_putchar(' ', ps) == 1)
    323324                        counter++;
    324325        }
    325        
     326
    326327        return ((int) counter);
    327328}
     
    585586int printf_core(const char *fmt, printf_spec_t *ps, va_list ap)
    586587{
    587         index_t i = 0;  /* Index of the currently processed character from fmt */
    588         index_t nxt = 0;
    589         index_t j = 0;  /* Index to the first not printed nonformating character */
     588        size_t i = 0;  /* Index of the currently processed character from fmt */
     589        size_t nxt = 0;
     590        size_t j = 0;  /* Index to the first not printed nonformating character */
    590591       
    591592        wchar_t uc;           /* Current UTF-32 character decoded from fmt */
Note: See TracChangeset for help on using the changeset viewer.