MCPcopy Create free account
hub / github.com/Entware/Entware / expr_parse_string

Function expr_parse_string

scripts/config/expr.c:998–1028  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

996};
997
998static 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
1030tristate expr_calc_value(struct expr *e)
1031{

Callers 1

expr_calc_valueFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected