Synchronize sr_parse_sizestring() with sr_si_string_u64() capabilities.
Add support for the T/P/E suffixes. Since this conversion helper deals
with integer values exclusively, there is no issue with case insensitive
matches. The value cannot be pico. Neither is there an ambiguity with
the 10e6 notation.
This addresses bug #763.
Fix a style nit while we are here. Put braces around both arms of a
complex conditional.
*/
SR_API int sr_parse_sizestring(const char *sizestring, uint64_t *size)
{
- int multiplier, done;
+ uint64_t multiplier;
+ int done;
double frac_part;
char *s;
case 'G':
multiplier = SR_GHZ(1);
break;
+ case 't':
+ case 'T':
+ multiplier = SR_GHZ(1000);
+ break;
+ case 'p':
+ case 'P':
+ multiplier = SR_GHZ(1000 * 1000);
+ break;
+ case 'e':
+ case 'E':
+ multiplier = SR_GHZ(1000 * 1000 * 1000);
+ break;
default:
done = TRUE;
s--;
if (multiplier > 0) {
*size *= multiplier;
*size += frac_part * multiplier;
- } else
+ } else {
*size += frac_part;
+ }
if (s && *s && g_ascii_strcasecmp(s, "Hz"))
return SR_ERR;