Changeset 58d5a7e7 in mainline for kernel/generic/src/printf/printf_core.c
- Timestamp:
- 2009-04-02T21:33:08Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7ce3cb2
- Parents:
- 82bb9c1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/printf/printf_core.c
r82bb9c1 r58d5a7e7 115 115 } 116 116 117 /** Print UTF-8 string without adding anewline.118 * 119 * @param str UTF-8 string to print.120 * @param ps 121 * 122 * @return Number of UTF-8characters printed.117 /** Print string without adding newline. 118 * 119 * @param str String to print. 120 * @param ps Write function specification and support data. 121 * 122 * @return Number of characters printed. 123 123 * 124 124 */ … … 239 239 } 240 240 241 /** Print UTF-8string.242 * 243 * @param str UTF-8 string to be printed.241 /** Format and print a string. 242 * 243 * @param str String to be printed. 244 244 * @param width Width modifier. 245 245 * @param precision Precision modifier. 246 246 * @param flags Flags that modify the way the string is printed. 247 247 * 248 * @return Number of UTF-8characters printed, negative value on failure.249 */ 250 static int print_ utf8(char *str, int width, unsigned int precision,248 * @return Number of characters printed, negative value on failure. 249 */ 250 static int print_str(char *str, int width, unsigned int precision, 251 251 uint32_t flags, printf_spec_t *ps) 252 252 { … … 259 259 precision = strw; 260 260 261 /* Left padding */ 261 262 count_t counter = 0; 262 263 width -= precision; … … 268 269 } 269 270 271 /* Part of @a str fitting into the alloted space. */ 270 272 int retval; 271 273 size_t size = str_wsize(str, precision); … … 275 277 counter += retval; 276 278 279 /* Right padding */ 277 280 while (width-- > 0) { 278 281 if (printf_putchar(' ', ps) == 1) … … 284 287 } 285 288 286 /** Print UTF-32 string. 287 * 288 * @param str UTF-32 string to be printed. 289 * @param width Width modifier. 290 * @param precision Precision modifier. 291 * @param flags Flags that modify the way the string is printed. 292 * 293 * @return Number of UTF-32 characters printed, negative value on failure. 294 */ 295 static int print_utf32(wchar_t *wstr, int width, unsigned int precision, 289 /** Format and print a wide string. 290 * 291 * @param wstr Wide string to be printed. 292 * @param width Width modifier. 293 * @param precision Precision modifier. 294 * @param flags Flags that modify the way the string is printed. 295 * 296 * @return Number of characters printed, negative value 297 * on failure. 298 */ 299 static int print_wstr(wchar_t *wstr, int width, unsigned int precision, 296 300 uint32_t flags, printf_spec_t *ps) 297 301 { … … 304 308 precision = strw; 305 309 310 /* Left padding */ 306 311 count_t counter = 0; 307 312 width -= precision; … … 313 318 } 314 319 320 /* Part of @a wstr fitting into the alloted space. */ 315 321 int retval; 316 322 size_t size = wstr_wlength(wstr, precision) * sizeof(wchar_t); … … 320 326 counter += retval; 321 327 328 /* Right padding */ 322 329 while (width-- > 0) { 323 330 if (printf_putchar(' ', ps) == 1) … … 417 424 } 418 425 419 /* Print leading spaces */426 /* Print leading spaces. */ 420 427 if (number_size > precision) { 421 /* Print the whole number, not only a part */428 /* Print the whole number, not only a part. */ 422 429 precision = number_size; 423 430 } … … 433 440 } 434 441 435 /* Print sign */442 /* Print sign. */ 436 443 if (sgn) { 437 444 if (printf_putchar(sgn, ps) == 1) … … 439 446 } 440 447 441 /* Print prefix */448 /* Print prefix. */ 442 449 if (flags & __PRINTF_FLAG_PREFIX) { 443 450 switch(base) { … … 472 479 } 473 480 474 /* Print leading zeroes */481 /* Print leading zeroes. */ 475 482 precision -= number_size; 476 483 while (precision-- > 0) { … … 479 486 } 480 487 481 /* Print the number itself */488 /* Print the number itself. */ 482 489 int retval; 483 490 if ((retval = printf_putstr(++ptr, ps)) > 0) 484 491 counter += retval; 485 492 486 /* Print tailing spaces */493 /* Print tailing spaces. */ 487 494 488 495 while (width-- > 0) { … … 576 583 * not printed by default. 577 584 * 578 * All other characters from fmt except the formatting directives are printed in585 * All other characters from fmt except the formatting directives are printed 579 586 * verbatim. 580 587 * 581 * @param fmt Formatting NULL terminated string (UTF-8 or plain ASCII). 582 * 583 * @return Number of UTF-8 characters printed, negative value on failure. 588 * @param fmt Format string. 589 * @return Number of characters printed, negative value on failure. 584 590 * 585 591 */ … … 590 596 size_t j = 0; /* Index to the first not printed nonformating character */ 591 597 592 wchar_t uc; /* Current UTF-32character decoded from fmt */593 count_t counter = 0; /* Number of UTF-8characters printed */598 wchar_t uc; /* Current character decoded from fmt */ 599 count_t counter = 0; /* Number of characters printed */ 594 600 int retval; /* Return values from nested functions */ 595 601 … … 738 744 case 's': 739 745 if (qualifier == PrintfQualifierLong) 740 retval = print_ utf32(va_arg(ap, wchar_t *), width, precision, flags, ps);746 retval = print_wstr(va_arg(ap, wchar_t *), width, precision, flags, ps); 741 747 else 742 retval = print_ utf8(va_arg(ap, char *), width, precision, flags, ps);748 retval = print_str(va_arg(ap, char *), width, precision, flags, ps); 743 749 744 750 if (retval < 0) {
Note:
See TracChangeset
for help on using the changeset viewer.