|
10 | 10 | * Written by Peter Eisentraut <peter_e@gmx.net>.
|
11 | 11 | *
|
12 | 12 | * IDENTIFICATION
|
13 |
| - * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.401 2007/06/2118:14:21 tgl Exp $ |
| 13 | + * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.402 2007/06/2122:59:12 tgl Exp $ |
14 | 14 | *
|
15 | 15 | *--------------------------------------------------------------------
|
16 | 16 | */
|
@@ -3721,9 +3721,9 @@ ReportGUCOption(struct config_generic * record)
|
3721 | 3721 |
|
3722 | 3722 | /*
|
3723 | 3723 | * Try to interpret value as boolean value. Valid values are: true,
|
3724 |
| - * false, yes, no, on, off, 1, 0. If the string parses okay, return |
3725 |
| - *true, else false.Ifresult is not NULL, returnthe parsing result |
3726 |
| - *there. |
| 3724 | + * false, yes, no, on, off, 1, 0; as well as unique prefixes thereof. |
| 3725 | + * Ifthe string parses okay, returntrue, else false. |
| 3726 | + *If okay and result is not NULL, return the value in *result. |
3727 | 3727 | */
|
3728 | 3728 | staticbool
|
3729 | 3729 | parse_bool(constchar*value,bool*result)
|
@@ -3999,24 +3999,30 @@ parse_int(const char *value, int *result, int flags, const char **hintmsg)
|
3999 | 3999 |
|
4000 | 4000 |
|
4001 | 4001 | /*
|
4002 |
| - * Try to parse value as a floating pointconstant in the usual |
4003 |
| - *format.If thevalue parsed okay return true, else false. If |
4004 |
| - * result is not NULL, return thesemanticvaluethere. |
| 4002 | + * Try to parse value as a floating pointnumber in the usual format. |
| 4003 | + * If thestring parses okay, return true, else false. |
| 4004 | + *If okay andresult is not NULL, return the valuein *result. |
4005 | 4005 | */
|
4006 | 4006 | staticbool
|
4007 | 4007 | parse_real(constchar*value,double*result)
|
4008 | 4008 | {
|
4009 | 4009 | doubleval;
|
4010 | 4010 | char*endptr;
|
4011 | 4011 |
|
| 4012 | +if (result) |
| 4013 | +*result=0;/* suppress compiler warning */ |
| 4014 | + |
4012 | 4015 | errno=0;
|
4013 | 4016 | val=strtod(value,&endptr);
|
4014 |
| -if (endptr==value||*endptr!='\0'||errno==ERANGE) |
4015 |
| -{ |
4016 |
| -if (result) |
4017 |
| -*result=0;/* suppress compiler warning */ |
| 4017 | +if (endptr==value||errno==ERANGE) |
4018 | 4018 | return false;
|
4019 |
| -} |
| 4019 | + |
| 4020 | +/* allow whitespace after number */ |
| 4021 | +while (isspace((unsignedchar)*endptr)) |
| 4022 | +endptr++; |
| 4023 | +if (*endptr!='\0') |
| 4024 | +return false; |
| 4025 | + |
4020 | 4026 | if (result)
|
4021 | 4027 | *result=val;
|
4022 | 4028 | return true;
|
|