=================== Com_HexStrToInt =================== */
| 590 | =================== |
| 591 | */ |
| 592 | int Com_HexStrToInt( const char *str ) |
| 593 | { |
| 594 | if ( !str || !str[ 0 ] ) |
| 595 | return -1; |
| 596 | |
| 597 | // check for hex code |
| 598 | if( str[ 0 ] == '0' && str[ 1 ] == 'x' ) |
| 599 | { |
| 600 | size_t i, n = 0; |
| 601 | |
| 602 | for( i = 2; i < strlen( str ); i++ ) |
| 603 | { |
| 604 | char digit; |
| 605 | |
| 606 | n *= 16; |
| 607 | |
| 608 | digit = tolower( str[ i ] ); |
| 609 | |
| 610 | if( digit >= '0' && digit <= '9' ) |
| 611 | digit -= '0'; |
| 612 | else if( digit >= 'a' && digit <= 'f' ) |
| 613 | digit = digit - 'a' + 10; |
| 614 | else |
| 615 | return -1; |
| 616 | |
| 617 | n += digit; |
| 618 | } |
| 619 | |
| 620 | return n; |
| 621 | } |
| 622 | |
| 623 | return -1; |
| 624 | } |
| 625 | |
| 626 | |
| 627 | /* |
no outgoing calls
no test coverage detected