Mercurial > hg > forks > yadex
diff src/cfgfile.cc @ 93:5652866f31eb
Cleanups.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 06 Oct 2014 00:33:26 +0300 |
parents | 002bc70a3982 |
children |
line wrap: on
line diff
--- a/src/cfgfile.cc Mon Oct 06 00:27:07 2014 +0300 +++ b/src/cfgfile.cc Mon Oct 06 00:33:26 2014 +0300 @@ -198,6 +198,12 @@ static const char *confirm_i2e(confirm_t internal); +static bool v_is_hex(const char *str) +{ + return str[0] == '0' && tolower(str[1]) == 'x'; +} + + /* * parse_config_file_default - parse the default config file(s) * @@ -489,8 +495,7 @@ addition, we don't want any non-zero negative numbers. In terms of regexp, /^(0x)?0*$/i. */ if (errno != 0 || neg && ! - (strspn(value + 1, "0") == strlen(value + 1) || value[1] == '0' && tolower(value[2]) == 'x' - && strspn(value + 3, "0") == strlen(value + 3))) + (strspn(value + 1, "0") == strlen(value + 1) || v_is_hex(value+1) && strspn(value + 3, "0") == strlen(value + 3))) { err("%s(%u,%d): unsigned integer out of range", filename, lnum, 1 + (int) (value - line)); @@ -686,9 +691,7 @@ || neg && ! (strspn(value + 1, "0") == strlen(value + 1) - || value[1] == '0' - && tolower(value[2]) == 'x' - && strspn(value + 3, "0") == strlen(value + 3))) + || v_is_hex(value+1) && strspn(value + 3, "0") == strlen(value + 3))) { err("unsigned integer out of range \"%s\"", value); return 1;