Changes in kernel/generic/src/printf/printf_core.c [6ab8697:2afb650] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/printf/printf_core.c
r6ab8697 r2afb650 41 41 #include <stdarg.h> 42 42 #include <macros.h> 43 #include <str ing.h>43 #include <str.h> 44 44 #include <arch.h> 45 45 46 46 /** show prefixes 0x or 0 */ 47 47 #define __PRINTF_FLAG_PREFIX 0x00000001 48 48 49 /** signed / unsigned number */ 49 50 #define __PRINTF_FLAG_SIGNED 0x00000002 51 50 52 /** print leading zeroes */ 51 53 #define __PRINTF_FLAG_ZEROPADDED 0x00000004 54 52 55 /** align to left */ 53 56 #define __PRINTF_FLAG_LEFTALIGNED 0x00000010 57 54 58 /** always show + sign */ 55 59 #define __PRINTF_FLAG_SHOWPLUS 0x00000020 60 56 61 /** print space instead of plus */ 57 62 #define __PRINTF_FLAG_SPACESIGN 0x00000040 63 58 64 /** show big characters */ 59 65 #define __PRINTF_FLAG_BIGCHARS 0x00000080 66 60 67 /** number has - sign */ 61 68 #define __PRINTF_FLAG_NEGATIVE 0x00000100 … … 79 86 } qualifier_t; 80 87 81 static c har nullstr[]= "(NULL)";82 static c har digits_small[]= "0123456789abcdef";83 static c har digits_big[]= "0123456789ABCDEF";84 static c har invalch = U_SPECIAL;88 static const char *nullstr = "(NULL)"; 89 static const char *digits_small = "0123456789abcdef"; 90 static const char *digits_big = "0123456789ABCDEF"; 91 static const char invalch = U_SPECIAL; 85 92 86 93 /** Print one or more characters without adding newline. … … 254 261 if (str == NULL) 255 262 return printf_putstr(nullstr, ps); 256 263 257 264 /* Print leading spaces. */ 258 265 size_t strw = str_length(str); 259 266 if (precision == 0) 260 267 precision = strw; 261 268 262 269 /* Left padding */ 263 270 size_t counter = 0; … … 269 276 } 270 277 } 271 278 272 279 /* Part of @a str fitting into the alloted space. */ 273 280 int retval; … … 351 358 uint32_t flags, printf_spec_t *ps) 352 359 { 353 c har *digits;360 const char *digits; 354 361 if (flags & __PRINTF_FLAG_BIGCHARS) 355 362 digits = digits_big; … … 384 391 */ 385 392 if (flags & __PRINTF_FLAG_PREFIX) { 386 switch (base) {393 switch (base) { 387 394 case 2: 388 395 /* Binary formating is not standard, but usefull */ … … 448 455 /* Print prefix */ 449 456 if (flags & __PRINTF_FLAG_PREFIX) { 450 switch (base) {457 switch (base) { 451 458 case 2: 452 459 /* Binary formating is not standard, but usefull */ … … 563 570 * 564 571 * - 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). 567 575 * 568 576 * - b Print value as unsigned binary number. Prefix is not printed by … … 777 785 case 'p': 778 786 flags |= __PRINTF_FLAG_PREFIX; 787 flags |= __PRINTF_FLAG_ZEROPADDED; 779 788 base = 16; 780 789 qualifier = PrintfQualifierPointer; … … 839 848 case PrintfQualifierPointer: 840 849 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 *); 842 852 break; 843 853 default:
Note:
See TracChangeset
for help on using the changeset viewer.