|
10 | 10 | * |
11 | 11 | * |
12 | 12 | * 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 $ |
14 | 14 | * |
15 | 15 | *------------------------------------------------------------------------- |
16 | 16 | */ |
17 | 17 | #include"postgres.h" |
18 | 18 |
|
19 | | -#include<errno.h> |
20 | 19 | #include<math.h> |
21 | 20 | #include<limits.h> |
22 | 21 | #include<ctype.h> |
@@ -84,19 +83,6 @@ pg_atoi(char *s, int size, int c) |
84 | 83 | errmsg("invalid input syntax for integer: \"%s\"", |
85 | 84 | s))); |
86 | 85 |
|
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 | | - |
100 | 86 | switch (size) |
101 | 87 | { |
102 | 88 | casesizeof(int32): |
@@ -125,6 +111,20 @@ pg_atoi(char *s, int size, int c) |
125 | 111 | default: |
126 | 112 | elog(ERROR,"unsupported result size: %d",size); |
127 | 113 | } |
| 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 | + |
128 | 128 | return (int32)l; |
129 | 129 | } |
130 | 130 |
|
|