Changeset b54d2f1 in mainline for kernel/generic/src/printf/printf_core.c
- Timestamp:
- 2009-03-31T22:11:11Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e1813cf
- Parents:
- 32704cb
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/printf/printf_core.c
r32704cb rb54d2f1 258 258 if (precision == 0) 259 259 precision = size; 260 260 261 261 count_t counter = 0; 262 262 width -= precision; … … 267 267 } 268 268 } 269 269 270 270 int retval; 271 271 size_t bytes = utf8_count_bytes(str, min(size, precision)); … … 279 279 counter++; 280 280 } 281 281 282 282 return ((int) counter); 283 283 } … … 586 586 { 587 587 index_t i = 0; /* Index of the currently processed character from fmt */ 588 index_t nxt = 0; 588 589 index_t j = 0; /* Index to the first not printed nonformating character */ 589 590 … … 592 593 int retval; /* Return values from nested functions */ 593 594 594 while ((uc = utf8_decode(fmt, &i, UTF8_NO_LIMIT)) != 0) { 595 while (true) { 596 i = nxt; 597 uc = utf8_decode(fmt, &nxt, UTF8_NO_LIMIT); 598 599 if (uc == '\0') break; 600 595 601 /* Control character */ 596 602 if (uc == '%') { … … 612 618 613 619 do { 614 i ++;615 uc = utf8_decode(fmt, & i, UTF8_NO_LIMIT);620 i = nxt; 621 uc = utf8_decode(fmt, &nxt, UTF8_NO_LIMIT); 616 622 switch (uc) { 617 623 case '#': … … 638 644 int width = 0; 639 645 if (isdigit(uc)) { 640 while ((uc = utf8_decode(fmt, &i, UTF8_NO_LIMIT)) != 0) { 646 while (true) { 647 width *= 10; 648 width += uc - '0'; 649 650 i = nxt; 651 uc = utf8_decode(fmt, &nxt, UTF8_NO_LIMIT); 652 if (uc == '\0') 653 break; 641 654 if (!isdigit(uc)) 642 655 break; 643 644 width *= 10;645 width += uc - '0';646 i++;647 656 } 648 657 } else if (uc == '*') { 649 658 /* Get width value from argument list */ 650 i ++;651 uc = utf8_decode(fmt, & i, UTF8_NO_LIMIT);659 i = nxt; 660 uc = utf8_decode(fmt, &nxt, UTF8_NO_LIMIT); 652 661 width = (int) va_arg(ap, int); 653 662 if (width < 0) { … … 661 670 int precision = 0; 662 671 if (uc == '.') { 663 i ++;664 uc = utf8_decode(fmt, & i, UTF8_NO_LIMIT);672 i = nxt; 673 uc = utf8_decode(fmt, &nxt, UTF8_NO_LIMIT); 665 674 if (isdigit(uc)) { 666 while ((uc = utf8_decode(fmt, &i, UTF8_NO_LIMIT)) != 0) { 675 while (true) { 676 precision *= 10; 677 precision += uc - '0'; 678 679 i = nxt; 680 uc = utf8_decode(fmt, &nxt, UTF8_NO_LIMIT); 681 if (uc == '\0') 682 break; 667 683 if (!isdigit(uc)) 668 684 break; 669 670 precision *= 10;671 precision += uc - '0';672 i++;673 685 } 674 } else if ( fmt[i]== '*') {686 } else if (uc == '*') { 675 687 /* Get precision value from the argument list */ 676 i ++;677 uc = utf8_decode(fmt, & i, UTF8_NO_LIMIT);688 i = nxt; 689 uc = utf8_decode(fmt, &nxt, UTF8_NO_LIMIT); 678 690 precision = (int) va_arg(ap, int); 679 691 if (precision < 0) { … … 693 705 /* Char or short */ 694 706 qualifier = PrintfQualifierShort; 695 i ++;696 uc = utf8_decode(fmt, & i, UTF8_NO_LIMIT);707 i = nxt; 708 uc = utf8_decode(fmt, &nxt, UTF8_NO_LIMIT); 697 709 if (uc == 'h') { 698 i ++;699 uc = utf8_decode(fmt, & i, UTF8_NO_LIMIT);710 i = nxt; 711 uc = utf8_decode(fmt, &nxt, UTF8_NO_LIMIT); 700 712 qualifier = PrintfQualifierByte; 701 713 } … … 704 716 /* Long or long long */ 705 717 qualifier = PrintfQualifierLong; 706 i ++;707 uc = utf8_decode(fmt, & i, UTF8_NO_LIMIT);718 i = nxt; 719 uc = utf8_decode(fmt, &nxt, UTF8_NO_LIMIT); 708 720 if (uc == 'l') { 709 i ++;710 uc = utf8_decode(fmt, & i, UTF8_NO_LIMIT);721 i = nxt; 722 uc = utf8_decode(fmt, &nxt, UTF8_NO_LIMIT); 711 723 qualifier = PrintfQualifierLongLong; 712 724 } … … 735 747 736 748 counter += retval; 737 j = i + 1;749 j = nxt; 738 750 goto next_char; 739 751 case 'c': … … 749 761 750 762 counter += retval; 751 j = i + 1;763 j = nxt; 752 764 goto next_char; 753 765 … … 853 865 854 866 counter += retval; 855 j = i + 1;867 j = nxt; 856 868 } 857 869 next_char: 858 859 i++; 870 ; 860 871 } 861 872
Note:
See TracChangeset
for help on using the changeset viewer.