
3 Mar
2020
3 Mar
'20
10:37 a.m.
On Mon, Mar 2, 2020 at 10:36 AM Michal Simek michal.simek@xilinx.com wrote:
Base autodetection is failing for this case: if test 257 -gt 3ae; then echo first; else echo second; fi
It is because base for 3ae is recognized by _parse_integer_fixup_radix() as 10. The patch is checking all chars to make sure that they are not 'a' or up. If they are base needs to be in hex.
...
for (i = 0; ; i++) {
char var = s[i];
if (var == '\0')
break;
if ((var >= 'a' && var <= 'f') ||
(var >= 'A' && var <= 'F')) {
*base = 16;
break;
}
}
int i = 0; char var;
do { var = tolower(s[i++]); if (...) { *base = 16; break; } } while (var);
or alike?
...
}
Is this relevant?
if (*base == 16 && s[0] == '0' && tolower(s[1]) == 'x') s += 2; return s;
--
With Best Regards,
Andy Shevchenko