make strtok_r private

Fixes #189

Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
This commit is contained in:
Steffen Jaeckel
2022-02-01 13:30:34 +01:00
parent 93e04b8d03
commit 728e050a05
4 changed files with 8 additions and 8 deletions

View File

@@ -883,13 +883,13 @@ xmpp_stanza_t *xmpp_stanza_get_child_by_path(xmpp_stanza_t *stanza, ...)
break; break;
} }
saveattr = ns = NULL; saveattr = ns = NULL;
attr = xmpp_strtok_r(tok, "[", &saveattr); attr = strophe_strtok_r(tok, "[", &saveattr);
if (attr) { if (attr) {
attr = xmpp_strtok_r(NULL, "]", &saveattr); attr = strophe_strtok_r(NULL, "]", &saveattr);
if (attr) { if (attr) {
if (!strncmp(attr, "@ns='", 5)) { if (!strncmp(attr, "@ns='", 5)) {
ns = attr + 5; ns = attr + 5;
xmpp_strtok_r(ns, "'", &saveattr); strophe_strtok_r(ns, "'", &saveattr);
} }
} }
} }

View File

@@ -80,7 +80,7 @@ char *strophe_strndup(const xmpp_ctx_t *ctx, const char *s, size_t len)
* For example, visual studio older than 2005 doesn't provide strtok_r() * For example, visual studio older than 2005 doesn't provide strtok_r()
* nor strtok_s(). * nor strtok_s().
*/ */
char *xmpp_strtok_r(char *s, const char *delim, char **saveptr) char *strophe_strtok_r(char *s, const char *delim, char **saveptr)
{ {
size_t len; size_t len;

View File

@@ -26,7 +26,7 @@
#define xmpp_min(x, y) ((x) < (y) ? (x) : (y)) #define xmpp_min(x, y) ((x) < (y) ? (x) : (y))
/* string functions */ /* string functions */
char *xmpp_strtok_r(char *s, const char *delim, char **saveptr); char *strophe_strtok_r(char *s, const char *delim, char **saveptr);
/* timing functions */ /* timing functions */
uint64_t time_stamp(void); uint64_t time_stamp(void);

View File

@@ -41,19 +41,19 @@ static int test_strtok_r(void)
assert(strcmp(s1, s2) == 0); assert(strcmp(s1, s2) == 0);
sub1 = strtok_r(s1, "-", &sp1); sub1 = strtok_r(s1, "-", &sp1);
sub2 = xmpp_strtok_r(s2, "-", &sp2); sub2 = strophe_strtok_r(s2, "-", &sp2);
if (strcmp(sub1, sub2) != 0) { if (strcmp(sub1, sub2) != 0) {
printf("1st token is '%s', must be '%s'\n", sub2, sub1); printf("1st token is '%s', must be '%s'\n", sub2, sub1);
return -1; return -1;
} }
sub1 = strtok_r(NULL, "-=", &sp1); sub1 = strtok_r(NULL, "-=", &sp1);
sub2 = xmpp_strtok_r(NULL, "-=", &sp2); sub2 = strophe_strtok_r(NULL, "-=", &sp2);
if (strcmp(sub1, sub2) != 0) { if (strcmp(sub1, sub2) != 0) {
printf("2nd token is '%s', must be '%s'\n", sub2, sub1); printf("2nd token is '%s', must be '%s'\n", sub2, sub1);
return -1; return -1;
} }
sub1 = strtok_r(NULL, "-", &sp1); sub1 = strtok_r(NULL, "-", &sp1);
sub2 = xmpp_strtok_r(NULL, "-", &sp2); sub2 = strophe_strtok_r(NULL, "-", &sp2);
if (sub1 != sub2) { if (sub1 != sub2) {
printf("3rd call returns %p instead of NULL\n", sub2); printf("3rd call returns %p instead of NULL\n", sub2);
return -1; return -1;