< prev index next >
src/share/vm/runtime/arguments.cpp
Print this page
rev 8851 : [mq]: webrev.00
rev 8852 : [mq]: webrev.01
rev 8853 : [mq]: webrev.02
@@ -579,12 +579,14 @@
return false;
}
}
static bool set_fp_numeric_flag(char* name, char* value, Flag::Flags origin) {
- double v;
- if (sscanf(value, "%lf", &v) != 1) {
+ char* end;
+ errno = 0;
+ double v = strtod(value, &end);
+ if ((errno != 0) || (*end != 0)) {
return false;
}
if (CommandLineFlags::doubleAtPut(name, &v, origin) == Flag::SUCCESS) {
return true;
@@ -714,13 +716,13 @@
value = NULL;
}
return set_string_flag(name, value, origin);
}
-#define SIGNED_FP_NUMBER_RANGE "[-0123456789.]"
+#define SIGNED_FP_NUMBER_RANGE "[-0123456789.eE+]"
#define SIGNED_NUMBER_RANGE "[-0123456789]"
-#define NUMBER_RANGE "[0123456789]"
+#define NUMBER_RANGE "[0123456789eE+-]"
char value[BUFLEN + 1];
char value2[BUFLEN + 1];
if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "=" "%" XSTR(BUFLEN) SIGNED_NUMBER_RANGE "." "%" XSTR(BUFLEN) NUMBER_RANGE "%c", name, value, value2, &dummy) == 3) {
// Looks like a floating-point number -- try again with more lenient format string
if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "=" "%" XSTR(BUFLEN) SIGNED_FP_NUMBER_RANGE "%c", name, value, &dummy) == 2) {
< prev index next >