summaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/int8.c
diff options
context:
space:
mode:
authorNeil Conway <neilc@samurai.com>2004-03-11 02:11:14 +0000
committerNeil Conway <neilc@samurai.com>2004-03-11 02:11:14 +0000
commite2ded829f6b672529d072620e43de65466286b59 (patch)
tree9ffc21ade136f5e667fb41dbd2e8b1c56436b3e5 /src/backend/utils/adt/int8.c
parent0b86ade1c2f3dcd2407e535baad1654e65252316 (diff)
Revise int2/int4/int8/float4/float8 input routines to allow for
any amount of leading or trailing whitespace (where "whitespace" is defined by isspace()). This is for SQL conformance, as well as consistency with other numeric types (e.g. oid, numeric). Also refactor pg_atoi() to avoid looking at errno where not necessary, and add a bunch of regression tests for the input to these types.
Diffstat (limited to 'src/backend/utils/adt/int8.c')
-rw-r--r--src/backend/utils/adt/int8.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/backend/utils/adt/int8.c b/src/backend/utils/adt/int8.c
index 200876e7989..8667e53680a 100644
--- a/src/backend/utils/adt/int8.c
+++ b/src/backend/utils/adt/int8.c
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/int8.c,v 1.51 2004/02/03 08:29:56 joe Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/int8.c,v 1.52 2004/03/11 02:11:13 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@@ -113,8 +113,11 @@ scanint8(const char *str, bool errorOK, int64 *result)
tmp = newtmp;
}
- /* trailing junk? */
- if (*ptr)
+ /* allow trailing whitespace, but not other trailing chars */
+ while (*ptr != '\0' && isspace(*ptr))
+ ptr++;
+
+ if (*ptr != '\0')
{
if (errorOK)
return false;