Ignore:
File:
1 edited

Legend:

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

    r6ab8697 r2afb650  
    4141#include <stdarg.h>
    4242#include <macros.h>
    43 #include <string.h>
     43#include <str.h>
    4444#include <arch.h>
    4545
    4646/** show prefixes 0x or 0 */
    4747#define __PRINTF_FLAG_PREFIX       0x00000001
     48
    4849/** signed / unsigned number */
    4950#define __PRINTF_FLAG_SIGNED       0x00000002
     51
    5052/** print leading zeroes */
    5153#define __PRINTF_FLAG_ZEROPADDED   0x00000004
     54
    5255/** align to left */
    5356#define __PRINTF_FLAG_LEFTALIGNED  0x00000010
     57
    5458/** always show + sign */
    5559#define __PRINTF_FLAG_SHOWPLUS     0x00000020
     60
    5661/** print space instead of plus */
    5762#define __PRINTF_FLAG_SPACESIGN    0x00000040
     63
    5864/** show big characters */
    5965#define __PRINTF_FLAG_BIGCHARS     0x00000080
     66
    6067/** number has - sign */
    6168#define __PRINTF_FLAG_NEGATIVE     0x00000100
     
    7986} qualifier_t;
    8087
    81 static char nullstr[] = "(NULL)";
    82 static char digits_small[] = "0123456789abcdef";
    83 static char digits_big[] = "0123456789ABCDEF";
    84 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;
    8592
    8693/** Print one or more characters without adding newline.
     
    254261        if (str == NULL)
    255262                return printf_putstr(nullstr, ps);
    256 
     263       
    257264        /* Print leading spaces. */
    258265        size_t strw = str_length(str);
    259266        if (precision == 0)
    260267                precision = strw;
    261 
     268       
    262269        /* Left padding */
    263270        size_t counter = 0;
     
    269276                }
    270277        }
    271 
     278       
    272279        /* Part of @a str fitting into the alloted space. */
    273280        int retval;
     
    351358    uint32_t flags, printf_spec_t *ps)
    352359{
    353         char *digits;
     360        const char *digits;
    354361        if (flags & __PRINTF_FLAG_BIGCHARS)
    355362                digits = digits_big;
     
    384391         */
    385392        if (flags & __PRINTF_FLAG_PREFIX) {
    386                 switch(base) {
     393                switch (base) {
    387394                case 2:
    388395                        /* Binary formating is not standard, but usefull */
     
    448455        /* Print prefix */
    449456        if (flags & __PRINTF_FLAG_PREFIX) {
    450                 switch(base) {
     457                switch (base) {
    451458                case 2:
    452459                        /* Binary formating is not standard, but usefull */
     
    563570 *
    564571 *  - P, p Print value of a pointer. Void * value is expected and it is
    565  *         printed in hexadecimal notation with prefix (as with \%#X / \%#x
    566  *         for 32-bit or \%#X / \%#x for 64-bit long pointers).
     572 *         printed in hexadecimal notation with prefix (as with
     573 *         \%#0.8X / \%#0.8x for 32-bit or \%#0.16lX / \%#0.16lx for 64-bit
     574 *         long pointers).
    567575 *
    568576 *  - b Print value as unsigned binary number. Prefix is not printed by
     
    777785                        case 'p':
    778786                                flags |= __PRINTF_FLAG_PREFIX;
     787                                flags |= __PRINTF_FLAG_ZEROPADDED;
    779788                                base = 16;
    780789                                qualifier = PrintfQualifierPointer;
     
    839848                        case PrintfQualifierPointer:
    840849                                size = sizeof(void *);
    841                                 number = (uint64_t) (unsigned long) va_arg(ap, void *);
     850                                precision = size << 1;
     851                                number = (uint64_t) (uintptr_t) va_arg(ap, void *);
    842852                                break;
    843853                        default:
Note: See TracChangeset for help on using the changeset viewer.