Ignore:
Timestamp:
2011-03-21T22:00:17Z (15 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
143932e3
Parents:
b50b5af2 (diff), 7308e84 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes (needs fixes).

File:
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/io/printf_core.c

    rb50b5af2 r04803bf  
    4141#include <io/printf_core.h>
    4242#include <ctype.h>
    43 #include <string.h>
     43#include <str.h>
    4444
    4545/** show prefixes 0x or 0 */
    4646#define __PRINTF_FLAG_PREFIX       0x00000001
     47
    4748/** signed / unsigned number */
    4849#define __PRINTF_FLAG_SIGNED       0x00000002
     50
    4951/** print leading zeroes */
    5052#define __PRINTF_FLAG_ZEROPADDED   0x00000004
     53
    5154/** align to left */
    5255#define __PRINTF_FLAG_LEFTALIGNED  0x00000010
     56
    5357/** always show + sign */
    5458#define __PRINTF_FLAG_SHOWPLUS     0x00000020
     59
    5560/** print space instead of plus */
    5661#define __PRINTF_FLAG_SPACESIGN    0x00000040
     62
    5763/** show big characters */
    5864#define __PRINTF_FLAG_BIGCHARS     0x00000080
     65
    5966/** number has - sign */
    6067#define __PRINTF_FLAG_NEGATIVE     0x00000100
     
    7582        PrintfQualifierLong,
    7683        PrintfQualifierLongLong,
    77         PrintfQualifierPointer
     84        PrintfQualifierPointer,
     85        PrintfQualifierSize
    7886} qualifier_t;
    7987
    80 static char nullstr[] = "(NULL)";
    81 static char digits_small[] = "0123456789abcdef";
    82 static char digits_big[] = "0123456789ABCDEF";
    83 static char invalch = U_SPECIAL;
     88static const char *nullstr = "(NULL)";
     89static const char *digits_small = "0123456789abcdef";
     90static const char *digits_big = "0123456789ABCDEF";
     91static const char invalch = U_SPECIAL;
    8492
    8593/** Print one or more characters without adding newline.
     
    253261        if (str == NULL)
    254262                return printf_putstr(nullstr, ps);
    255 
     263       
    256264        /* Print leading spaces. */
    257265        size_t strw = str_length(str);
    258266        if (precision == 0)
    259267                precision = strw;
    260 
     268       
    261269        /* Left padding */
    262270        size_t counter = 0;
     
    268276                }
    269277        }
    270 
     278       
    271279        /* Part of @a str fitting into the alloted space. */
    272280        int retval;
     
    350358    uint32_t flags, printf_spec_t *ps)
    351359{
    352         char *digits;
     360        const char *digits;
    353361        if (flags & __PRINTF_FLAG_BIGCHARS)
    354362                digits = digits_big;
     
    383391         */
    384392        if (flags & __PRINTF_FLAG_PREFIX) {
    385                 switch(base) {
     393                switch (base) {
    386394                case 2:
    387395                        /* Binary formating is not standard, but usefull */
     
    447455        /* Print prefix */
    448456        if (flags & __PRINTF_FLAG_PREFIX) {
    449                 switch(base) {
     457                switch (base) {
    450458                case 2:
    451459                        /* Binary formating is not standard, but usefull */
     
    545553 *  - ""   Signed or unsigned int (default value).@n
    546554 *  - "l"  Signed or unsigned long int.@n
    547  *         If conversion is "c", the character is wchar_t (wide character).@n
     555 *         If conversion is "c", the character is wint_t (wide character).@n
    548556 *         If conversion is "s", the string is wchar_t * (wide string).@n
    549557 *  - "ll" Signed or unsigned long long int.@n
     558 *  - "z"  Signed or unsigned ssize_t or site_t.@n
    550559 *
    551560 * CONVERSION:@n
     
    562571 *
    563572 *  - P, p Print value of a pointer. Void * value is expected and it is
    564  *         printed in hexadecimal notation with prefix (as with \%#X / \%#x
    565  *         for 32-bit or \%#X / \%#x for 64-bit long pointers).
     573 *         printed in hexadecimal notation with prefix (as with
     574 *         \%#0.8X / \%#0.8x for 32-bit or \%#0.16lX / \%#0.16lx for 64-bit
     575 *         long pointers).
    566576 *
    567577 *  - b Print value as unsigned binary number. Prefix is not printed by
     
    728738                                }
    729739                                break;
     740                        case 'z':
     741                                qualifier = PrintfQualifierSize;
     742                                i = nxt;
     743                                uc = str_decode(fmt, &nxt, STR_NO_LIMIT);
     744                                break;
    730745                        default:
    731746                                /* Default type */
     
    755770                        case 'c':
    756771                                if (qualifier == PrintfQualifierLong)
    757                                         retval = print_wchar(va_arg(ap, wchar_t), width, flags, ps);
     772                                        retval = print_wchar(va_arg(ap, wint_t), width, flags, ps);
    758773                                else
    759774                                        retval = print_char(va_arg(ap, unsigned int), width, flags, ps);
     
    776791                        case 'p':
    777792                                flags |= __PRINTF_FLAG_PREFIX;
     793                                flags |= __PRINTF_FLAG_ZEROPADDED;
    778794                                base = 16;
    779795                                qualifier = PrintfQualifierPointer;
     
    838854                        case PrintfQualifierPointer:
    839855                                size = sizeof(void *);
    840                                 number = (uint64_t) (unsigned long) va_arg(ap, void *);
     856                                precision = size << 1;
     857                                number = (uint64_t) (uintptr_t) va_arg(ap, void *);
     858                                break;
     859                        case PrintfQualifierSize:
     860                                size = sizeof(size_t);
     861                                number = (uint64_t) va_arg(ap, size_t);
    841862                                break;
    842863                        default:
Note: See TracChangeset for help on using the changeset viewer.