* Take the parsed expression value from the command line that was parsed * as a hexadecimal value and convert it as if the expression was parsed * as a decimal value. Returns -1 if the expression was not a valid * decimal value. */
| 901 | * decimal value. |
| 902 | */ |
| 903 | db_expr_t |
| 904 | db_hex2dec(db_expr_t expr) |
| 905 | { |
| 906 | uintptr_t x, y; |
| 907 | db_expr_t val; |
| 908 | |
| 909 | y = 1; |
| 910 | val = 0; |
| 911 | x = expr; |
| 912 | while (x != 0) { |
| 913 | if (x % 16 > 9) |
| 914 | return (-1); |
| 915 | val += (x % 16) * (y); |
| 916 | x >>= 4; |
| 917 | y *= 10; |
| 918 | } |
| 919 | return (val); |
| 920 | } |
no outgoing calls
no test coverage detected