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;
}
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)) {
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;
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",
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;
}