| 996 | }; |
| 997 | |
| 998 | static enum string_value_kind expr_parse_string(const char *str, |
| 999 | enum symbol_type type, |
| 1000 | union string_value *val) |
| 1001 | { |
| 1002 | char *tail; |
| 1003 | enum string_value_kind kind; |
| 1004 | |
| 1005 | errno = 0; |
| 1006 | switch (type) { |
| 1007 | case S_BOOLEAN: |
| 1008 | case S_TRISTATE: |
| 1009 | val->s = !strcmp(str, "n") ? 0 : |
| 1010 | !strcmp(str, "m") ? 1 : |
| 1011 | !strcmp(str, "y") ? 2 : -1; |
| 1012 | return k_signed; |
| 1013 | case S_INT: |
| 1014 | val->s = strtoll(str, &tail, 10); |
| 1015 | kind = k_signed; |
| 1016 | break; |
| 1017 | case S_HEX: |
| 1018 | val->u = strtoull(str, &tail, 16); |
| 1019 | kind = k_unsigned; |
| 1020 | break; |
| 1021 | default: |
| 1022 | val->s = strtoll(str, &tail, 0); |
| 1023 | kind = k_signed; |
| 1024 | break; |
| 1025 | } |
| 1026 | return !errno && !*tail && tail > str && isxdigit(tail[-1]) |
| 1027 | ? kind : k_string; |
| 1028 | } |
| 1029 | |
| 1030 | tristate expr_calc_value(struct expr *e) |
| 1031 | { |