commit - ee835173a241055761945fd3f30c886bffb88f1c
commit + 93176f76ce805c8d733e8173c401fa2ac2bdf9c6
blob - ee99ac0e60d9e8e5f30827586ee5d40dd6b065c3
blob + 9d10d6571043fe1e077c4525e8e120ac65ed674e
--- make/make.c
+++ make/make.c
{
size_t len = 0, cap = 4;
struct path *p;
- char *last;
char *t;
p = calloc (cap + 1, sizeof (struct path));
- for (t = strtok_r (s, "/", &last); t != NULL; t = strtok_r (NULL, "/", &last)) {
- if (strcmp (t, ".") == 0)
+ while ((t = strsep (&s, "/")) != NULL) {
+ if (*t == '\0' || strcmp (t, ".") == 0)
continue;
if (len == cap) {
struct rule *r;
struct file *f;
struct dep *dep, *deps, *dt;
- char *u, *p;
+ char *u, *v, *p;
int flag;
r = new (struct rule);
*t = '\0';
/* parse deps */
- u = strdup (trim (expand (sc, t + 1, NULL)));
- for (p = strtok (u, " \t"); p != NULL; p = strtok (NULL, " \t")) {
+ v = u = strdup (trim (expand (sc, t + 1, NULL)));
+ while ((p = strsep (&v, " \t")) != NULL) {
+ if (*p == '\0')
+ continue;
+
dep = new (struct dep);
dep->next = NULL;
dep->path = parse_path (p);
sc->dir->infs = inf;
} else {
- for (p = strtok (u, " \t"); p != NULL; p = strtok (NULL, " \t")) {
+ v = u;
+ while ((p = strsep (&v, " \t")) != NULL) {
+ if (*p == '\0')
+ continue;
/* TODO: check name */
f = find_file (sc->dir, p);