Commit Diff


commit - 9e4e21f929949583450edcb7ecb1072a7cfb975f
commit + ade78a5f9f5e649c90b9bb8e5918160917006f44
blob - f58fe287f5a03c63cca850d61f608f9272a7b4ca
blob + 3ffee0beee1663f6c8a6433dfe4a5f0bb8c68d68
--- make/TODO.md
+++ make/TODO.md
@@ -165,14 +165,10 @@ This must be defined at the top of the file.
 Allow specifying additional `PATH` directories.
 
 
-# Replace usage of `strtok()` and `strtok_r()` with `strsep()`
-
-
 # Provide implementations of non-standard functions (libcompat)
 - `err(3)` and `errx(3)`
 - `reallocarray(3)`
-- `asprintf(3)`
-- `strsep(3)` or `strtok_r(3)`
+- `strsep(3)`
 
 
 # Future TODOs
blob - d1396fc54787ab618c23cbad4d91c972a9532ed1
blob + cc694d669c9d7bfe6c8b778df8d0e882ec1264be
--- make/make.c
+++ make/make.c
@@ -635,7 +635,7 @@ char *s;
 	sub->makefile = NULL;
 	sc->dir->subdirs = sub;
 
-	p = strtok (s, ",");
+	p = strsep (&s, ",");
 	if (p == NULL)
 		return -1;
 
@@ -645,7 +645,7 @@ char *s;
 	if (access (path, F_OK) != 0)
 		errx (1, "%s: directory not found: %s", path_to_str (dir), sub->name);
 	
-	p = strtok (NULL, ",");
+	p = strsep (&s, ",");
 	if (p == NULL) {
 		sub->type = SC_DIR;
 		sub->dir = NULL;
@@ -653,13 +653,14 @@ char *s;
 		return 0;
 	}
 
+	// TODO: handle empty fields
 	p = trim (p);
 	if (strcmp (p, "DIR") == 0) {
 		sub->type = SC_DIR;
 		sub->dir = NULL;
 		sub->makefile = MAKEFILE;
 
-		p = strtok (NULL, ",");
+		p = strsep (&s, ",");
 		if (p == NULL)
 			return 0;
 
@@ -670,12 +671,12 @@ char *s;
 		sub->gnu = new (struct gnu);
 		sub->gnu->prog = NULL;
 
-		p = strtok (NULL, ",");
+		p = strsep (&s, ",");
 		if (p == NULL)
 			return 0;
 		sub->gnu->prog = strdup (trim (p));
 
-		p = strtok (NULL, ",");
+		p = strsep (&s, ",");
 		if (p == NULL)
 			return 0;
 		sub->makefile = strdup (trim (p));
@@ -684,7 +685,6 @@ char *s;
 	} else {
 		return -1;
 	}
-
 }
 
 struct rule *