Skip to content

Commit c275499

Browse files
committed
Minor fixes for hstore_to_json_loose().
Fix unportable use of isdigit(), get rid of useless calculations.
1 parent 4387cf9 commit c275499

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

contrib/hstore/hstore_io.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,7 +1299,8 @@ hstore_to_json_loose(PG_FUNCTION_ARGS)
12991299
* don't treat something with a leading zero followed by another
13001300
* digit as numeric - could be a zip code or similar
13011301
*/
1302-
if (src->len > 0 && (src->data[0] != '0' || !isdigit(src->data[1])) &&
1302+
if (src->len > 0 &&
1303+
!(src->data[0] == '0' && isdigit((unsigned char) src->data[1])) &&
13031304
strspn(src->data, "+-0123456789Ee.") == src->len)
13041305
{
13051306
/*
@@ -1308,7 +1309,7 @@ hstore_to_json_loose(PG_FUNCTION_ARGS)
13081309
*/
13091310
char *endptr = "junk";
13101311

1311-
(void) (strtol(src->data, &endptr, 10) + 1);
1312+
(void) strtol(src->data, &endptr, 10);
13121313
if (*endptr == '\0')
13131314
{
13141315
/*
@@ -1320,7 +1321,7 @@ hstore_to_json_loose(PG_FUNCTION_ARGS)
13201321
else
13211322
{
13221323
/* not an int - try a double */
1323-
(void) (strtod(src->data, &endptr) + 1.0);
1324+
(void) strtod(src->data, &endptr);
13241325
if (*endptr == '\0')
13251326
is_number = true;
13261327
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy