Replace strtok_r uses with strsep.

This commit is contained in:
Jonas 'Sortie' Termansen 2015-06-01 17:06:31 +02:00
parent b180a14412
commit ae1ed0c13c
3 changed files with 5 additions and 9 deletions

View File

@ -579,9 +579,9 @@ bool RunCommand()
int argc = 0;
char* input = buffer;
char* saved = NULL;
while ( (argv[argc] = strtok_r(input, " \t\n", &saved)) )
argc++, input = NULL;
while ( (argv[argc] = strsep(&input, " \t\n")) )
if ( argv[argc][0] )
argc++;
if ( !argc )
return true;

View File

@ -1802,9 +1802,8 @@ size_t do_complete(char*** completions_ptr,
break;
}
char* path_input = path;
char* saved_ptr;
char* component;
while ( (component = strtok_r(path_input, ":", &saved_ptr)) )
while ( (component = strsep(&path_input, ":")) )
{
if ( DIR* dir = opendir(component) )
{
@ -1819,7 +1818,6 @@ size_t do_complete(char*** completions_ptr,
}
closedir(dir);
}
path_input = NULL;
}
free(path);
} while ( false );

View File

@ -93,10 +93,8 @@ bool has_path_executable(const char* name)
if ( !path_copy )
return false;
char* input = path_copy;
char* saved_ptr;
while ( char* component = strtok_r(input, ":", &saved_ptr) )
while ( char* component = strsep(&input, ":") )
{
input = NULL;
char* fullpath = print_string("%s/%s", component, name);
if ( !fullpath )
return free(fullpath), free(path_copy), false;