792 return false; |
792 return false; |
793 } |
793 } |
794 } |
794 } |
795 |
795 |
796 static bool set_fp_numeric_flag(const char* name, char* value, Flag::Flags origin) { |
796 static bool set_fp_numeric_flag(const char* name, char* value, Flag::Flags origin) { |
797 double v; |
797 char* end; |
798 if (sscanf(value, "%lf", &v) != 1) { |
798 errno = 0; |
|
799 double v = strtod(value, &end); |
|
800 if ((errno != 0) || (*end != 0)) { |
799 return false; |
801 return false; |
800 } |
802 } |
801 |
803 |
802 if (CommandLineFlags::doubleAtPut(name, &v, origin) == Flag::SUCCESS) { |
804 if (CommandLineFlags::doubleAtPut(name, &v, origin) == Flag::SUCCESS) { |
803 return true; |
805 return true; |
977 return false; |
979 return false; |
978 } |
980 } |
979 return set_string_flag(real_name, value, origin); |
981 return set_string_flag(real_name, value, origin); |
980 } |
982 } |
981 |
983 |
982 #define SIGNED_FP_NUMBER_RANGE "[-0123456789.]" |
984 #define SIGNED_FP_NUMBER_RANGE "[-0123456789.eE+]" |
983 #define SIGNED_NUMBER_RANGE "[-0123456789]" |
985 #define SIGNED_NUMBER_RANGE "[-0123456789]" |
984 #define NUMBER_RANGE "[0123456789]" |
986 #define NUMBER_RANGE "[0123456789eE+-]" |
985 char value[BUFLEN + 1]; |
987 char value[BUFLEN + 1]; |
986 char value2[BUFLEN + 1]; |
988 char value2[BUFLEN + 1]; |
987 if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "=" "%" XSTR(BUFLEN) SIGNED_NUMBER_RANGE "." "%" XSTR(BUFLEN) NUMBER_RANGE "%c", name, value, value2, &dummy) == 3) { |
989 if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "=" "%" XSTR(BUFLEN) SIGNED_NUMBER_RANGE "." "%" XSTR(BUFLEN) NUMBER_RANGE "%c", name, value, value2, &dummy) == 3) { |
988 // Looks like a floating-point number -- try again with more lenient format string |
990 // Looks like a floating-point number -- try again with more lenient format string |
989 if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "=" "%" XSTR(BUFLEN) SIGNED_FP_NUMBER_RANGE "%c", name, value, &dummy) == 2) { |
991 if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "=" "%" XSTR(BUFLEN) SIGNED_FP_NUMBER_RANGE "%c", name, value, &dummy) == 2) { |