diff --git a/urjtag/ChangeLog b/urjtag/ChangeLog index 0b7ab970..3346ae38 100644 --- a/urjtag/ChangeLog +++ b/urjtag/ChangeLog @@ -1,3 +1,7 @@ +2010-08-07 Mike Frysinger + + * src/global/params.c (parse_param_lu): Accept unsigned values in hex format. + 2010-07-31 Mike Frysinger * src/bus/buses.c, src/flash/jedec.c, src/tap/cable.c: Convert to ARRAY_SIZE. diff --git a/urjtag/src/global/params.c b/urjtag/src/global/params.c index 733baa75..6f9d9de9 100644 --- a/urjtag/src/global/params.c +++ b/urjtag/src/global/params.c @@ -180,10 +180,25 @@ urj_param_push_bool (const urj_param_t ***bp, int key, int val) static int parse_param_lu(const char *eq, long unsigned *lu) { - if (sscanf(eq + 1, "%lu", lu) == 1) - return URJ_STATUS_OK; + eq += 1; + + /* Handle hex values as well as decimal. While the C library will take + * care of this for us if we used the 'i' conversion modifier, that takes + * us into the signed/unsigned world. Unfortunately, the 'u' conversion + * modifier doesn't handle hex values transparently. So do it ourselves. + */ + if (strncmp(eq, "0x", 2)) + { + if (sscanf(eq, "%lu", lu) == 1) + return URJ_STATUS_OK; + } + else + { + if (sscanf(eq, "%lx", lu) == 1) + return URJ_STATUS_OK; + } - urj_error_set (URJ_ERROR_SYNTAX, "need unsigned int, not '%s'", eq + 1); + urj_error_set (URJ_ERROR_SYNTAX, "need unsigned int, not '%s'", eq); return URJ_STATUS_FAIL; }