aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2013-03-14 13:51:47 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2013-03-14 13:51:47 -0400
commitc2754991ba6e513a07c15b4058df13d58f8c55ba (patch)
treeb29bf1abc39c7b242ff960ac2d05436cd1308f9c
parent4387cf956b9eb13aad569634e0c4df081d76e2e3 (diff)
downloadpostgresql-c2754991ba6e513a07c15b4058df13d58f8c55ba.tar.gz
postgresql-c2754991ba6e513a07c15b4058df13d58f8c55ba.zip
Minor fixes for hstore_to_json_loose().
Fix unportable use of isdigit(), get rid of useless calculations.
-rw-r--r--contrib/hstore/hstore_io.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/contrib/hstore/hstore_io.c b/contrib/hstore/hstore_io.c
index 07b60e621b2..a9a55d89b8b 100644
--- a/contrib/hstore/hstore_io.c
+++ b/contrib/hstore/hstore_io.c
@@ -1299,7 +1299,8 @@ hstore_to_json_loose(PG_FUNCTION_ARGS)
* don't treat something with a leading zero followed by another
* digit as numeric - could be a zip code or similar
*/
- if (src->len > 0 && (src->data[0] != '0' || !isdigit(src->data[1])) &&
+ if (src->len > 0 &&
+ !(src->data[0] == '0' && isdigit((unsigned char) src->data[1])) &&
strspn(src->data, "+-0123456789Ee.") == src->len)
{
/*
@@ -1308,7 +1309,7 @@ hstore_to_json_loose(PG_FUNCTION_ARGS)
*/
char *endptr = "junk";
- (void) (strtol(src->data, &endptr, 10) + 1);
+ (void) strtol(src->data, &endptr, 10);
if (*endptr == '\0')
{
/*
@@ -1320,7 +1321,7 @@ hstore_to_json_loose(PG_FUNCTION_ARGS)
else
{
/* not an int - try a double */
- (void) (strtod(src->data, &endptr) + 1.0);
+ (void) strtod(src->data, &endptr);
if (*endptr == '\0')
is_number = true;
}