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

Commit164442f

Browse files
committed
Rearrange code in pg_atoi() to avoid assuming that isspace() cannot
change errno. No reported bugs here, but why take a chance?
1 parentbae3fef commit164442f

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

‎src/backend/utils/adt/numutils.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/utils/adt/numutils.c,v 1.69 2005/10/15 02:49:29 momjian Exp $
13+
* $PostgreSQL: pgsql/src/backend/utils/adt/numutils.c,v 1.70 2005/11/30 23:10:08 tgl Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
1717
#include"postgres.h"
1818

19-
#include<errno.h>
2019
#include<math.h>
2120
#include<limits.h>
2221
#include<ctype.h>
@@ -84,19 +83,6 @@ pg_atoi(char *s, int size, int c)
8483
errmsg("invalid input syntax for integer: \"%s\"",
8584
s)));
8685

87-
/*
88-
* Skip any trailing whitespace; if anything but whitespace remains before
89-
* the terminating character, bail out
90-
*/
91-
while (*badp&&*badp!=c&&isspace((unsignedchar)*badp))
92-
badp++;
93-
94-
if (*badp&&*badp!=c)
95-
ereport(ERROR,
96-
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
97-
errmsg("invalid input syntax for integer: \"%s\"",
98-
s)));
99-
10086
switch (size)
10187
{
10288
casesizeof(int32):
@@ -125,6 +111,20 @@ pg_atoi(char *s, int size, int c)
125111
default:
126112
elog(ERROR,"unsupported result size: %d",size);
127113
}
114+
115+
/*
116+
* Skip any trailing whitespace; if anything but whitespace remains before
117+
* the terminating character, bail out
118+
*/
119+
while (*badp&&*badp!=c&&isspace((unsignedchar)*badp))
120+
badp++;
121+
122+
if (*badp&&*badp!=c)
123+
ereport(ERROR,
124+
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
125+
errmsg("invalid input syntax for integer: \"%s\"",
126+
s)));
127+
128128
return (int32)l;
129129
}
130130

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp