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

Changeset 58d5a7e7 in mainline


Ignore:
Timestamp:
2009-04-02T21:33:08Z (13 years ago)
Author:
Jiri Svoboda <jirik.svoboda@…>
Branches:
lfn, master
Children:
7ce3cb2
Parents:
82bb9c1
Message:

Partial conversion of prinf_core.c

File:
1 edited

Legend:

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

    r82bb9c1 r58d5a7e7  
    115115}
    116116
    117 /** Print UTF-8 string without adding a newline.
    118  *
    119  * @param str UTF-8 string to print.
    120  * @param ps  Write function specification and support data.
    121  *
    122  * @return Number of UTF-8 characters printed.
     117/** Print string without adding newline.
     118 *
     119 * @param str   String to print.
     120 * @param ps    Write function specification and support data.
     121 *
     122 * @return Number of characters printed.
    123123 *
    124124 */
     
    239239}
    240240
    241 /** Print UTF-8 string.
    242  *
    243  * @param str       UTF-8 string to be printed.
     241/** Format and print a string.
     242 *
     243 * @param str       String to be printed.
    244244 * @param width     Width modifier.
    245245 * @param precision Precision modifier.
    246246 * @param flags     Flags that modify the way the string is printed.
    247247 *
    248  * @return Number of UTF-8 characters printed, negative value on failure.
    249  */
    250 static int print_utf8(char *str, int width, unsigned int precision,
     248 * @return Number of characters printed, negative value on failure.
     249 */
     250static int print_str(char *str, int width, unsigned int precision,
    251251        uint32_t flags, printf_spec_t *ps)
    252252{
     
    259259                precision = strw;
    260260
     261        /* Left padding */
    261262        count_t counter = 0;
    262263        width -= precision;
     
    268269        }
    269270
     271        /* Part of @a str fitting into the alloted space. */
    270272        int retval;
    271273        size_t size = str_wsize(str, precision);
     
    275277        counter += retval;
    276278
     279        /* Right padding */
    277280        while (width-- > 0) {
    278281                if (printf_putchar(' ', ps) == 1)
     
    284287}
    285288
    286 /** Print UTF-32 string.
    287  *
    288  * @param str       UTF-32 string to be printed.
    289  * @param width     Width modifier.
    290  * @param precision Precision modifier.
    291  * @param flags     Flags that modify the way the string is printed.
    292  *
    293  * @return Number of UTF-32 characters printed, negative value on failure.
    294  */
    295 static int print_utf32(wchar_t *wstr, int width, unsigned int precision,
     289/** Format and print a wide string.
     290 *
     291 * @param wstr          Wide string to be printed.
     292 * @param width         Width modifier.
     293 * @param precision     Precision modifier.
     294 * @param flags         Flags that modify the way the string is printed.
     295 *
     296 * @return              Number of characters printed, negative value
     297 *                      on failure.
     298 */
     299static int print_wstr(wchar_t *wstr, int width, unsigned int precision,
    296300        uint32_t flags, printf_spec_t *ps)
    297301{
     
    304308                precision = strw;
    305309
     310        /* Left padding */
    306311        count_t counter = 0;
    307312        width -= precision;
     
    313318        }
    314319
     320        /* Part of @a wstr fitting into the alloted space. */
    315321        int retval;
    316322        size_t size = wstr_wlength(wstr, precision) * sizeof(wchar_t);
     
    320326        counter += retval;
    321327
     328        /* Right padding */
    322329        while (width-- > 0) {
    323330                if (printf_putchar(' ', ps) == 1)
     
    417424        }
    418425       
    419         /* Print leading spaces */
     426        /* Print leading spaces. */
    420427        if (number_size > precision) {
    421                 /* Print the whole number, not only a part */
     428                /* Print the whole number, not only a part. */
    422429                precision = number_size;
    423430        }
     
    433440        }
    434441       
    435         /* Print sign */
     442        /* Print sign. */
    436443        if (sgn) {
    437444                if (printf_putchar(sgn, ps) == 1)
     
    439446        }
    440447       
    441         /* Print prefix */
     448        /* Print prefix. */
    442449        if (flags & __PRINTF_FLAG_PREFIX) {
    443450                switch(base) {
     
    472479        }
    473480       
    474         /* Print leading zeroes */
     481        /* Print leading zeroes. */
    475482        precision -= number_size;
    476483        while (precision-- > 0) {
     
    479486        }
    480487       
    481         /* Print the number itself */
     488        /* Print the number itself. */
    482489        int retval;
    483490        if ((retval = printf_putstr(++ptr, ps)) > 0)
    484491                counter += retval;
    485492       
    486         /* Print tailing spaces */
     493        /* Print tailing spaces. */
    487494       
    488495        while (width-- > 0) {
     
    576583 *         not printed by default.
    577584 *
    578  * All other characters from fmt except the formatting directives are printed in
     585 * All other characters from fmt except the formatting directives are printed
    579586 * verbatim.
    580587 *
    581  * @param fmt Formatting NULL terminated string (UTF-8 or plain ASCII).
    582  *
    583  * @return Number of UTF-8 characters printed, negative value on failure.
     588 * @param fmt Format string.
     589 * @return Number of characters printed, negative value on failure.
    584590 *
    585591 */
     
    590596        size_t j = 0;  /* Index to the first not printed nonformating character */
    591597       
    592         wchar_t uc;           /* Current UTF-32 character decoded from fmt */
    593         count_t counter = 0;  /* Number of UTF-8 characters printed */
     598        wchar_t uc;           /* Current character decoded from fmt */
     599        count_t counter = 0;  /* Number of characters printed */
    594600        int retval;           /* Return values from nested functions */
    595601       
     
    738744                        case 's':
    739745                                if (qualifier == PrintfQualifierLong)
    740                                         retval = print_utf32(va_arg(ap, wchar_t *), width, precision, flags, ps);
     746                                        retval = print_wstr(va_arg(ap, wchar_t *), width, precision, flags, ps);
    741747                                else
    742                                         retval = print_utf8(va_arg(ap, char *), width, precision, flags, ps);
     748                                        retval = print_str(va_arg(ap, char *), width, precision, flags, ps);
    743749                               
    744750                                if (retval < 0) {
Note: See TracChangeset for help on using the changeset viewer.