parse 4 digit hexadecimal number */
| 664 | |
| 665 | /* parse 4 digit hexadecimal number */ |
| 666 | static unsigned parse_hex4(const unsigned char * const input) |
| 667 | { |
| 668 | unsigned int h = 0; |
| 669 | size_t i = 0; |
| 670 | |
| 671 | for (i = 0; i < 4; i++) |
| 672 | { |
| 673 | /* parse digit */ |
| 674 | if ((input[i] >= '0') && (input[i] <= '9')) |
| 675 | { |
| 676 | h += (unsigned int) input[i] - '0'; |
| 677 | } |
| 678 | else if ((input[i] >= 'A') && (input[i] <= 'F')) |
| 679 | { |
| 680 | h += (unsigned int) 10 + input[i] - 'A'; |
| 681 | } |
| 682 | else if ((input[i] >= 'a') && (input[i] <= 'f')) |
| 683 | { |
| 684 | h += (unsigned int) 10 + input[i] - 'a'; |
| 685 | } |
| 686 | else /* invalid */ |
| 687 | { |
| 688 | return 0; |
| 689 | } |
| 690 | |
| 691 | if (i < 3) |
| 692 | { |
| 693 | /* shift left to make place for the next nibble */ |
| 694 | h = h << 4; |
| 695 | } |
| 696 | } |
| 697 | |
| 698 | return h; |
| 699 | } |
| 700 | |
| 701 | /* converts a UTF-16 literal to UTF-8 |
| 702 | * A literal can be one or two sequences of the form \uXXXX */ |
no outgoing calls
no test coverage detected