Changeset c47e1a8 in mainline for uspace/lib/c/generic/io/printf_core.c
- Timestamp:
- 2010-05-21T07:50:04Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d51ee2b
- Parents:
- cf8cc36 (diff), 15b592b (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 moved
-
uspace/lib/c/generic/io/printf_core.c (moved) (moved from uspace/lib/libc/generic/io/printf_core.c ) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/io/printf_core.c
rcf8cc36 rc47e1a8 41 41 #include <io/printf_core.h> 42 42 #include <ctype.h> 43 #include <str ing.h>43 #include <str.h> 44 44 45 45 /** show prefixes 0x or 0 */ 46 46 #define __PRINTF_FLAG_PREFIX 0x00000001 47 47 48 /** signed / unsigned number */ 48 49 #define __PRINTF_FLAG_SIGNED 0x00000002 50 49 51 /** print leading zeroes */ 50 52 #define __PRINTF_FLAG_ZEROPADDED 0x00000004 53 51 54 /** align to left */ 52 55 #define __PRINTF_FLAG_LEFTALIGNED 0x00000010 56 53 57 /** always show + sign */ 54 58 #define __PRINTF_FLAG_SHOWPLUS 0x00000020 59 55 60 /** print space instead of plus */ 56 61 #define __PRINTF_FLAG_SPACESIGN 0x00000040 62 57 63 /** show big characters */ 58 64 #define __PRINTF_FLAG_BIGCHARS 0x00000080 65 59 66 /** number has - sign */ 60 67 #define __PRINTF_FLAG_NEGATIVE 0x00000100 … … 78 85 } qualifier_t; 79 86 80 static c har nullstr[]= "(NULL)";81 static c har digits_small[]= "0123456789abcdef";82 static c har digits_big[]= "0123456789ABCDEF";83 static c har invalch = U_SPECIAL;87 static const char *nullstr = "(NULL)"; 88 static const char *digits_small = "0123456789abcdef"; 89 static const char *digits_big = "0123456789ABCDEF"; 90 static const char invalch = U_SPECIAL; 84 91 85 92 /** Print one or more characters without adding newline. … … 253 260 if (str == NULL) 254 261 return printf_putstr(nullstr, ps); 255 262 256 263 /* Print leading spaces. */ 257 264 size_t strw = str_length(str); 258 265 if (precision == 0) 259 266 precision = strw; 260 267 261 268 /* Left padding */ 262 269 size_t counter = 0; … … 268 275 } 269 276 } 270 277 271 278 /* Part of @a str fitting into the alloted space. */ 272 279 int retval; … … 350 357 uint32_t flags, printf_spec_t *ps) 351 358 { 352 c har *digits;359 const char *digits; 353 360 if (flags & __PRINTF_FLAG_BIGCHARS) 354 361 digits = digits_big; … … 383 390 */ 384 391 if (flags & __PRINTF_FLAG_PREFIX) { 385 switch (base) {392 switch (base) { 386 393 case 2: 387 394 /* Binary formating is not standard, but usefull */ … … 447 454 /* Print prefix */ 448 455 if (flags & __PRINTF_FLAG_PREFIX) { 449 switch (base) {456 switch (base) { 450 457 case 2: 451 458 /* Binary formating is not standard, but usefull */ … … 562 569 * 563 570 * - 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). 571 * printed in hexadecimal notation with prefix (as with 572 * \%#0.8X / \%#0.8x for 32-bit or \%#0.16lX / \%#0.16lx for 64-bit 573 * long pointers). 566 574 * 567 575 * - b Print value as unsigned binary number. Prefix is not printed by … … 776 784 case 'p': 777 785 flags |= __PRINTF_FLAG_PREFIX; 786 flags |= __PRINTF_FLAG_ZEROPADDED; 778 787 base = 16; 779 788 qualifier = PrintfQualifierPointer; … … 838 847 case PrintfQualifierPointer: 839 848 size = sizeof(void *); 840 number = (uint64_t) (unsigned long) va_arg(ap, void *); 849 precision = size << 1; 850 number = (uint64_t) (uintptr_t) va_arg(ap, void *); 841 851 break; 842 852 default:
Note:
See TracChangeset
for help on using the changeset viewer.
