Replace strtok_r uses with strsep.
This commit is contained in:
parent
b180a14412
commit
ae1ed0c13c
|
@ -579,9 +579,9 @@ bool RunCommand()
|
||||||
|
|
||||||
int argc = 0;
|
int argc = 0;
|
||||||
char* input = buffer;
|
char* input = buffer;
|
||||||
char* saved = NULL;
|
while ( (argv[argc] = strsep(&input, " \t\n")) )
|
||||||
while ( (argv[argc] = strtok_r(input, " \t\n", &saved)) )
|
if ( argv[argc][0] )
|
||||||
argc++, input = NULL;
|
argc++;
|
||||||
|
|
||||||
if ( !argc )
|
if ( !argc )
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -1802,9 +1802,8 @@ size_t do_complete(char*** completions_ptr,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
char* path_input = path;
|
char* path_input = path;
|
||||||
char* saved_ptr;
|
|
||||||
char* component;
|
char* component;
|
||||||
while ( (component = strtok_r(path_input, ":", &saved_ptr)) )
|
while ( (component = strsep(&path_input, ":")) )
|
||||||
{
|
{
|
||||||
if ( DIR* dir = opendir(component) )
|
if ( DIR* dir = opendir(component) )
|
||||||
{
|
{
|
||||||
|
@ -1819,7 +1818,6 @@ size_t do_complete(char*** completions_ptr,
|
||||||
}
|
}
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
}
|
}
|
||||||
path_input = NULL;
|
|
||||||
}
|
}
|
||||||
free(path);
|
free(path);
|
||||||
} while ( false );
|
} while ( false );
|
||||||
|
|
|
@ -93,10 +93,8 @@ bool has_path_executable(const char* name)
|
||||||
if ( !path_copy )
|
if ( !path_copy )
|
||||||
return false;
|
return false;
|
||||||
char* input = path_copy;
|
char* input = path_copy;
|
||||||
char* saved_ptr;
|
while ( char* component = strsep(&input, ":") )
|
||||||
while ( char* component = strtok_r(input, ":", &saved_ptr) )
|
|
||||||
{
|
{
|
||||||
input = NULL;
|
|
||||||
char* fullpath = print_string("%s/%s", component, name);
|
char* fullpath = print_string("%s/%s", component, name);
|
||||||
if ( !fullpath )
|
if ( !fullpath )
|
||||||
return free(fullpath), free(path_copy), false;
|
return free(fullpath), free(path_copy), false;
|
||||||
|
|
Loading…
Reference in New Issue