Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitba82629

Browse files
committed
Allow trailing whitespace in parse_real(), for consistency with
parse_int() and with itself (strtod allows leading whitespace, so itseems odd not to allow trailing whitespace). parse_bool remainsnot-whitespace-friendly, but this is generically true for non-numericGUC variables, so I'll desist from changing it.
1 parentaa55d05 commitba82629

File tree

1 file changed

+18
-12
lines changed
  • src/backend/utils/misc

1 file changed

+18
-12
lines changed

‎src/backend/utils/misc/guc.c

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Written by Peter Eisentraut <peter_e@gmx.net>.
1111
*
1212
* 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 $
1414
*
1515
*--------------------------------------------------------------------
1616
*/
@@ -3721,9 +3721,9 @@ ReportGUCOption(struct config_generic * record)
37213721

37223722
/*
37233723
* 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.
37273727
*/
37283728
staticbool
37293729
parse_bool(constchar*value,bool*result)
@@ -3999,24 +3999,30 @@ parse_int(const char *value, int *result, int flags, const char **hintmsg)
39993999

40004000

40014001
/*
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.
40054005
*/
40064006
staticbool
40074007
parse_real(constchar*value,double*result)
40084008
{
40094009
doubleval;
40104010
char*endptr;
40114011

4012+
if (result)
4013+
*result=0;/* suppress compiler warning */
4014+
40124015
errno=0;
40134016
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)
40184018
return false;
4019-
}
4019+
4020+
/* allow whitespace after number */
4021+
while (isspace((unsignedchar)*endptr))
4022+
endptr++;
4023+
if (*endptr!='\0')
4024+
return false;
4025+
40204026
if (result)
40214027
*result=val;
40224028
return true;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp