convert string to double, detecting overflows/underflows */
| 881 | |
| 882 | /* convert string to double, detecting overflows/underflows */ |
| 883 | bool |
| 884 | strtodouble(const char *str, bool errorOK, double *dv) |
| 885 | { |
| 886 | char *end; |
| 887 | |
| 888 | errno = 0; |
| 889 | *dv = strtod(str, &end); |
| 890 | |
| 891 | if (unlikely(errno != 0)) |
| 892 | { |
| 893 | if (!errorOK) |
| 894 | pg_log_error("value \"%s\" is out of range for type double", str); |
| 895 | return false; |
| 896 | } |
| 897 | |
| 898 | if (unlikely(end == str || *end != '\0')) |
| 899 | { |
| 900 | if (!errorOK) |
| 901 | pg_log_error("invalid input syntax for type double: \"%s\"", str); |
| 902 | return false; |
| 903 | } |
| 904 | return true; |
| 905 | } |
| 906 | |
| 907 | /* |
| 908 | * Initialize a random state struct. |