summaryrefslogtreecommitdiff
path: root/src/backend/nodes
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2018-03-13 10:21:09 -0400
committerPeter Eisentraut <peter_e@gmx.net>2018-03-13 10:21:09 -0400
commit17bb62501787c56e0518e61db13a523d47afd724 (patch)
treefa577a267aac27c99f34b4fef859df43b3362e8e /src/backend/nodes
parent6cf86f435472b27bbc5e22c713bca08aa2d94af7 (diff)
downloadpostgresql-17bb62501787c56e0518e61db13a523d47afd724.tar.gz
Move strtoint() to common
Several places used similar code to convert a string to an int, so take the function that we already had and make it globally available. Reviewed-by: Michael Paquier <michael@paquier.xyz>
Diffstat (limited to 'src/backend/nodes')
-rw-r--r--src/backend/nodes/read.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/backend/nodes/read.c b/src/backend/nodes/read.c
index 6e9fa45e37..d3c742693b 100644
--- a/src/backend/nodes/read.c
+++ b/src/backend/nodes/read.c
@@ -21,6 +21,7 @@
#include <ctype.h>
+#include "common/string.h"
#include "nodes/pg_list.h"
#include "nodes/readfuncs.h"
#include "nodes/value.h"
@@ -215,18 +216,15 @@ nodeTokenType(char *token, int length)
{
/*
* Yes. Figure out whether it is integral or float; this requires
- * both a syntax check and a range check. strtol() can do both for us.
- * We know the token will end at a character that strtol will stop at,
+ * both a syntax check and a range check. strtoint() can do both for us.
+ * We know the token will end at a character that strtoint will stop at,
* so we do not need to modify the string.
*/
- long val;
char *endptr;
errno = 0;
- val = strtol(token, &endptr, 10);
- if (endptr != token + length || errno == ERANGE ||
- /* check for overflow of int */
- val != (int) val)
+ (void) strtoint(token, &endptr, 10);
+ if (endptr != token + length || errno == ERANGE)
return T_Float;
return T_Integer;
}