diff options
author | Peter Eisentraut <peter@eisentraut.org> | 2024-07-23 09:13:48 +0200 |
---|---|---|
committer | Peter Eisentraut <peter@eisentraut.org> | 2024-07-23 09:20:22 +0200 |
commit | 65504b747f3c217dfa91297db6ea219924a3fa8a (patch) | |
tree | bef6c1c1681c9a2b9813e6f20ec50bc2f826ef0f /src/backend/utils/misc/tzparser.c | |
parent | 4d130b28727ce5db4114bcc2a3e2c790643032de (diff) | |
download | postgresql-65504b747f3c217dfa91297db6ea219924a3fa8a.tar.gz postgresql-65504b747f3c217dfa91297db6ea219924a3fa8a.zip |
Replace remaining strtok() with strtok_r()
for thread-safety in the server in the future
Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Reviewed-by: David Steele <david@pgmasters.net>
Discussion: https://www.postgresql.org/message-id/flat/79692bf9-17d3-41e6-b9c9-fc8c3944222a@eisentraut.org
Diffstat (limited to 'src/backend/utils/misc/tzparser.c')
-rw-r--r-- | src/backend/utils/misc/tzparser.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/backend/utils/misc/tzparser.c b/src/backend/utils/misc/tzparser.c index 21fd866d6d6..96cc3912e56 100644 --- a/src/backend/utils/misc/tzparser.c +++ b/src/backend/utils/misc/tzparser.c @@ -97,6 +97,7 @@ validateTzEntry(tzEntry *tzentry) static bool splitTzLine(const char *filename, int lineno, char *line, tzEntry *tzentry) { + char *brkl; char *abbrev; char *offset; char *offset_endptr; @@ -106,7 +107,7 @@ splitTzLine(const char *filename, int lineno, char *line, tzEntry *tzentry) tzentry->lineno = lineno; tzentry->filename = filename; - abbrev = strtok(line, WHITESPACE); + abbrev = strtok_r(line, WHITESPACE, &brkl); if (!abbrev) { GUC_check_errmsg("missing time zone abbreviation in time zone file \"%s\", line %d", @@ -115,7 +116,7 @@ splitTzLine(const char *filename, int lineno, char *line, tzEntry *tzentry) } tzentry->abbrev = pstrdup(abbrev); - offset = strtok(NULL, WHITESPACE); + offset = strtok_r(NULL, WHITESPACE, &brkl); if (!offset) { GUC_check_errmsg("missing time zone offset in time zone file \"%s\", line %d", @@ -135,11 +136,11 @@ splitTzLine(const char *filename, int lineno, char *line, tzEntry *tzentry) return false; } - is_dst = strtok(NULL, WHITESPACE); + is_dst = strtok_r(NULL, WHITESPACE, &brkl); if (is_dst && pg_strcasecmp(is_dst, "D") == 0) { tzentry->is_dst = true; - remain = strtok(NULL, WHITESPACE); + remain = strtok_r(NULL, WHITESPACE, &brkl); } else { @@ -158,7 +159,7 @@ splitTzLine(const char *filename, int lineno, char *line, tzEntry *tzentry) tzentry->zone = pstrdup(offset); tzentry->offset = 0 * SECS_PER_HOUR; tzentry->is_dst = false; - remain = strtok(NULL, WHITESPACE); + remain = strtok_r(NULL, WHITESPACE, &brkl); } if (!remain) /* no more non-whitespace chars */ @@ -394,8 +395,9 @@ ParseTzFile(const char *filename, int depth, { /* pstrdup so we can use filename in result data structure */ char *includeFile = pstrdup(line + strlen("@INCLUDE")); + char *brki; - includeFile = strtok(includeFile, WHITESPACE); + includeFile = strtok_r(includeFile, WHITESPACE, &brki); if (!includeFile || !*includeFile) { GUC_check_errmsg("@INCLUDE without file name in time zone file \"%s\", line %d", |