From e2ded829f6b672529d072620e43de65466286b59 Mon Sep 17 00:00:00 2001 From: Neil Conway Date: Thu, 11 Mar 2004 02:11:14 +0000 Subject: 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. --- src/backend/utils/adt/int8.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/backend/utils/adt/int8.c') diff --git a/src/backend/utils/adt/int8.c b/src/backend/utils/adt/int8.c index 200876e798..8667e53680 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; -- cgit v1.2.1