Use strtok_r() instead of strtok()

This commit is contained in:
Todd C. Miller
2015-06-19 12:35:51 -06:00
parent 048e251ae0
commit e2328479dd
14 changed files with 47 additions and 32 deletions

View File

@@ -243,7 +243,7 @@ build_command_info(const char *command)
static char *
find_editor(int nfiles, char * const files[], char **argv_out[])
{
char *cp, **ep, **nargv, *editor, *editor_path;
char *cp, *last, **ep, **nargv, *editor, *editor_path;
int ac, i, nargc, wasblank;
/* Lookup EDITOR in user's environment. */
@@ -275,7 +275,7 @@ find_editor(int nfiles, char * const files[], char **argv_out[])
}
}
/* If we can't find the editor in the user's PATH, give up. */
cp = strtok(editor, " \t");
cp = strtok_r(editor, " \t", &last);
if (cp == NULL ||
(editor_path = find_in_path(editor, plugin_state.envp)) == NULL) {
free(editor);
@@ -291,7 +291,7 @@ find_editor(int nfiles, char * const files[], char **argv_out[])
}
for (ac = 0; cp != NULL && ac < nargc; ac++) {
nargv[ac] = cp;
cp = strtok(NULL, " \t");
cp = strtok_r(NULL, " \t", &last);
}
nargv[ac++] = "--";
for (i = 0; i < nfiles; )