replace non-thread-safe functions

replace all uses of strtok, localtime, gmtime and readdir

on platforms without safe versions, use homebrew or unsafe...
This commit is contained in:
ac-stef
2016-02-28 23:14:47 +01:00
parent 98d01d1f34
commit 32ffd3a4cd
11 changed files with 60 additions and 38 deletions
+2 -2
View File
@@ -87,7 +87,7 @@ const char *highlight(const char *text)
if(!marker || !strstr(text, player1->name)) return text;
defformatstring(subst)("\fs%s%s\fr", marker, player1->name);
char *temp = newstring(text);
char *s = strtok(temp, sep), *l = temp, *c, *r = result;
char *b, *s = strtok_r(temp, sep, &b), *l = temp, *c, *r = result;
result[0] = '\0';
while(s)
{
@@ -101,7 +101,7 @@ const char *highlight(const char *text)
}
l = s + strlen(s);
}
s = strtok(NULL, sep);
s = strtok_r(NULL, sep, &b);
}
if(MAXTRANS - strlen(result) > strlen(text) - (l - temp)) strcat(result, text + (l - temp));
delete[] temp;