mirror of
https://github.com/reactos/ccache.git
synced 2024-11-27 13:40:32 +00:00
Use reentrant strtok_r() instead of strtok()
This commit is contained in:
parent
074e8ade4e
commit
ff2089c914
4
args.c
4
args.c
@ -43,10 +43,10 @@ args_init_from_string(const char *command)
|
||||
struct args *args;
|
||||
char *p = x_strdup(command);
|
||||
char *q = p;
|
||||
char *word;
|
||||
char *word, *saveptr = NULL;
|
||||
|
||||
args = args_init(0, NULL);
|
||||
while ((word = strtok(q, " \t\r\n"))) {
|
||||
while ((word = strtok_r(q, " \t\r\n", &saveptr))) {
|
||||
args_add(args, word);
|
||||
q = NULL;
|
||||
}
|
||||
|
8
ccache.c
8
ccache.c
@ -944,10 +944,10 @@ calculate_common_hash(struct args *args, struct mdfour *hash)
|
||||
|
||||
p = getenv("CCACHE_EXTRAFILES");
|
||||
if (p) {
|
||||
char *path, *q;
|
||||
char *path, *q, *saveptr = NULL;
|
||||
p = x_strdup(p);
|
||||
q = p;
|
||||
while ((path = strtok(q, PATH_DELIM))) {
|
||||
while ((path = strtok_r(q, PATH_DELIM, &saveptr))) {
|
||||
cc_log("Hashing extra file %s", path);
|
||||
hash_delimiter(hash, "extrafile");
|
||||
if (!hash_file(hash, path)) {
|
||||
@ -1847,14 +1847,14 @@ static unsigned
|
||||
parse_sloppiness(char *p)
|
||||
{
|
||||
unsigned result = 0;
|
||||
char *word, *q;
|
||||
char *word, *q, *saveptr = NULL;
|
||||
|
||||
if (!p) {
|
||||
return result;
|
||||
}
|
||||
p = x_strdup(p);
|
||||
q = p;
|
||||
while ((word = strtok(q, ", "))) {
|
||||
while ((word = strtok_r(q, ", ", &saveptr))) {
|
||||
if (str_eq(word, "file_macro")) {
|
||||
cc_log("Being sloppy about __FILE__");
|
||||
result |= SLOPPY_FILE_MACRO;
|
||||
|
@ -247,13 +247,15 @@ find_executable(const char *name, const char *exclude_name)
|
||||
static char *
|
||||
find_executable_in_path(const char *name, const char *exclude_name, char *path)
|
||||
{
|
||||
char *tok;
|
||||
char *tok, *saveptr = NULL;
|
||||
|
||||
path = x_strdup(path);
|
||||
|
||||
/* search the path looking for the first compiler of the right name
|
||||
that isn't us */
|
||||
for (tok = strtok(path, PATH_DELIM); tok; tok = strtok(NULL, PATH_DELIM)) {
|
||||
for (tok = strtok_r(path, PATH_DELIM, &saveptr);
|
||||
tok;
|
||||
tok = strtok_r(NULL, PATH_DELIM, &saveptr)) {
|
||||
#ifdef _WIN32
|
||||
char namebuf[MAX_PATH];
|
||||
int ret = SearchPath(tok, name, ".exe",
|
||||
|
@ -287,12 +287,12 @@ int
|
||||
hash_multicommand_output(struct mdfour *hash, const char *commands,
|
||||
const char *compiler)
|
||||
{
|
||||
char *command_string, *command, *p;
|
||||
char *command_string, *command, *p, *saveptr = NULL;
|
||||
int ok = 1;
|
||||
|
||||
command_string = x_strdup(commands);
|
||||
p = command_string;
|
||||
while ((command = strtok(p, ";"))) {
|
||||
while ((command = strtok_r(p, ";", &saveptr))) {
|
||||
if (!hash_command_output(hash, command, compiler)) {
|
||||
ok = 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user