Issue #1454 - Remove usage of non re-entrant strtok()

Thanks to Jaroslav Kysela <perex@perex.cz> for providing the initial fix.
This commit is contained in:
Adam Sutton 2012-12-13 20:57:09 +00:00
parent 3a54bc7f16
commit 86fac417c2
4 changed files with 13 additions and 12 deletions

View file

@ -634,7 +634,7 @@ static void _xmltv_load_grabbers ( void )
size_t i, p, n;
char *outbuf;
char name[1000];
char *tmp, *path;
char *tmp, *tmp2, *path;
/* Load data */
outlen = spawn_and_store_stdout(XMLTV_FIND, NULL, &outbuf);
@ -668,7 +668,7 @@ static void _xmltv_load_grabbers ( void )
NULL
};
path = strdup(tmp);
tmp = strtok(path, ":");
tmp = strtok_r(path, ":", &tmp2);
while (tmp) {
DIR *dir;
struct dirent *de;
@ -691,7 +691,7 @@ static void _xmltv_load_grabbers ( void )
}
closedir(dir);
}
tmp = strtok(NULL, ":");
tmp = strtok_r(NULL, ":", &tmp2);
}
free(path);
}

View file

@ -214,12 +214,13 @@ fb_dir *fb_opendir ( const char *path )
/* Bundle */
#if ENABLE_BUNDLE
char *tmp1 = strdup(path);
char *tmp2 = strtok(tmp1, "/");
char *tmp1, *tmp2, *tmp3;
*tmp1 = strdup(path);
*tmp2 = strtok_r(tmp1, "/", &tmp3);
filebundle_entry_t *fb = filebundle_root;
while (fb && tmp2) {
if (fb->type == FB_DIR && !strcmp(fb->name, tmp2)) {
tmp2 = strtok(NULL, "/");
tmp2 = strtok_r(NULL, "/", &tmp3);
if (tmp2) fb = fb->d.child;
} else {
fb = fb->next;

View file

@ -53,13 +53,13 @@ find_exec ( const char *name, char *out, size_t len )
{
int ret = 0;
char bin[512];
char *path, *tmp;
char *path, *tmp, *tmp2;
DIR *dir;
struct dirent *de;
struct stat st;
if (!(path = getenv("PATH"))) return 0;
path = strdup(path);
tmp = strtok(path, ":");
tmp = strtok_r(path, ":", &tmp2);
while (tmp && !ret) {
if ((dir = opendir(tmp))) {
while ((de = readdir(dir))) {
@ -73,7 +73,7 @@ find_exec ( const char *name, char *out, size_t len )
}
closedir(dir);
}
tmp = strtok(NULL, ":");
tmp = strtok_r(NULL, ":", &tmp2);
}
free(path);
return ret;

View file

@ -352,7 +352,7 @@ extjs_channels_update(htsmsg_t *in)
if((s = htsmsg_get_str(c, "epggrabsrc")) != NULL) {
char *tmp = strdup(s);
char *sptr = NULL;
char *sptr, *sptr2;
char *modecid = strtok_r(tmp, ",", &sptr);
char *modid, *ecid;
epggrab_module_t *mod;
@ -377,8 +377,8 @@ extjs_channels_update(htsmsg_t *in)
/* Add new */
while (modecid) {
modid = strtok(modecid, "|");
ecid = strtok(NULL, "|");
modid = strtok_r(modecid, "|", &sptr2);
ecid = strtok_r(NULL, "|", &sptr2);
modecid = strtok_r(NULL, ",", &sptr);
if (!(mod = epggrab_module_find_by_id(modid)))