Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c2e164f

Browse files
Merge pull request #6 from postgrespro/PGPRO-6866
PGPRO-6866: do not use the function pg_atoi if possible
2 parents 9a911f7 + ef4120f commit c2e164f

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

tsparser.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,10 @@ typedef struct TParser
269269
int type;
270270
} TParser;
271271

272+
#if PG_VERSION_NUM < 120000
273+
#define pg_strtoint32(value) pg_atoi((value), sizeof(int32), 0)
274+
#endif
275+
272276

273277
/* forward decls here */
274278
static bool TParserGet(TParser *prs);
@@ -2533,13 +2537,13 @@ tsparser_headline(PG_FUNCTION_ARGS)
25332537
char *val = defGetString(defel);
25342538

25352539
if (pg_strcasecmp(defel->defname, "MaxWords") == 0)
2536-
max_words = pg_atoi(val, sizeof(int32), 0);
2540+
max_words = pg_strtoint32(val);
25372541
else if (pg_strcasecmp(defel->defname, "MinWords") == 0)
2538-
min_words = pg_atoi(val, sizeof(int32), 0);
2542+
min_words = pg_strtoint32(val);
25392543
else if (pg_strcasecmp(defel->defname, "ShortWord") == 0)
2540-
shortword = pg_atoi(val, sizeof(int32), 0);
2544+
shortword = pg_strtoint32(val);
25412545
else if (pg_strcasecmp(defel->defname, "MaxFragments") == 0)
2542-
max_fragments = pg_atoi(val, sizeof(int32), 0);
2546+
max_fragments = pg_strtoint32(val);
25432547
else if (pg_strcasecmp(defel->defname, "StartSel") == 0)
25442548
prs->startsel = pstrdup(val);
25452549
else if (pg_strcasecmp(defel->defname, "StopSel") == 0)

0 commit comments

Comments
 (0)