mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Replace strtok_r uses with strsep.
This commit is contained in:
parent
b180a14412
commit
ae1ed0c13c
3 changed files with 5 additions and 9 deletions
|
@ -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;
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue