Changeset 04803bf in mainline for kernel/generic/src/printf/printf_core.c
- Timestamp:
- 2011-03-21T22:00:17Z (15 years ago)
- 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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/printf/printf_core.c
rb50b5af2 r04803bf 39 39 #include <printf/printf_core.h> 40 40 #include <print.h> 41 #include < arch/arg.h>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 … … 76 83 PrintfQualifierLong, 77 84 PrintfQualifierLongLong, 78 PrintfQualifierPointer 85 PrintfQualifierPointer, 86 PrintfQualifierSize 79 87 } qualifier_t; 80 88 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;89 static const char *nullstr = "(NULL)"; 90 static const char *digits_small = "0123456789abcdef"; 91 static const char *digits_big = "0123456789ABCDEF"; 92 static const char invalch = U_SPECIAL; 85 93 86 94 /** Print one or more characters without adding newline. … … 254 262 if (str == NULL) 255 263 return printf_putstr(nullstr, ps); 256 264 257 265 /* Print leading spaces. */ 258 266 size_t strw = str_length(str); 259 267 if (precision == 0) 260 268 precision = strw; 261 269 262 270 /* Left padding */ 263 271 size_t counter = 0; … … 269 277 } 270 278 } 271 279 272 280 /* Part of @a str fitting into the alloted space. */ 273 281 int retval; … … 351 359 uint32_t flags, printf_spec_t *ps) 352 360 { 353 c har *digits;361 const char *digits; 354 362 if (flags & __PRINTF_FLAG_BIGCHARS) 355 363 digits = digits_big; … … 384 392 */ 385 393 if (flags & __PRINTF_FLAG_PREFIX) { 386 switch (base) {394 switch (base) { 387 395 case 2: 388 396 /* Binary formating is not standard, but usefull */ … … 448 456 /* Print prefix */ 449 457 if (flags & __PRINTF_FLAG_PREFIX) { 450 switch (base) {458 switch (base) { 451 459 case 2: 452 460 /* Binary formating is not standard, but usefull */ … … 546 554 * - "" Signed or unsigned int (default value).@n 547 555 * - "l" Signed or unsigned long int.@n 548 * If conversion is "c", the character is w char_t (wide character).@n556 * If conversion is "c", the character is wint_t (wide character).@n 549 557 * If conversion is "s", the string is wchar_t * (wide string).@n 550 558 * - "ll" Signed or unsigned long long int.@n 559 * - "z" Signed or unsigned ssize_t or site_t.@n 551 560 * 552 561 * CONVERSION:@n … … 563 572 * 564 573 * - 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). 574 * printed in hexadecimal notation with prefix (as with 575 * \%#0.8X / \%#0.8x for 32-bit or \%#0.16lX / \%#0.16lx for 64-bit 576 * long pointers). 567 577 * 568 578 * - b Print value as unsigned binary number. Prefix is not printed by … … 729 739 } 730 740 break; 741 case 'z': 742 qualifier = PrintfQualifierSize; 743 i = nxt; 744 uc = str_decode(fmt, &nxt, STR_NO_LIMIT); 745 break; 731 746 default: 732 747 /* Default type */ … … 756 771 case 'c': 757 772 if (qualifier == PrintfQualifierLong) 758 retval = print_wchar(va_arg(ap, w char_t), width, flags, ps);773 retval = print_wchar(va_arg(ap, wint_t), width, flags, ps); 759 774 else 760 775 retval = print_char(va_arg(ap, unsigned int), width, flags, ps); … … 777 792 case 'p': 778 793 flags |= __PRINTF_FLAG_PREFIX; 794 flags |= __PRINTF_FLAG_ZEROPADDED; 779 795 base = 16; 780 796 qualifier = PrintfQualifierPointer; … … 839 855 case PrintfQualifierPointer: 840 856 size = sizeof(void *); 841 number = (uint64_t) (unsigned long) va_arg(ap, void *); 857 precision = size << 1; 858 number = (uint64_t) (uintptr_t) va_arg(ap, void *); 859 break; 860 case PrintfQualifierSize: 861 size = sizeof(size_t); 862 number = (uint64_t) va_arg(ap, size_t); 842 863 break; 843 864 default:
Note:
See TracChangeset
for help on using the changeset viewer.