shithub: mc

Download patch

ref: 66a103f6afd50eb45e9ba62f167688edeb10063a
parent: a882c392dcde4b86d96b6b9e920c9d8e37f0aaad
author: Ori Bernstein <ori@eigenstate.org>
date: Sun Apr 12 18:05:49 EDT 2015

Remove subdir support from 'subdirs'.

--- a/build.myr
+++ b/build.myr
@@ -39,7 +39,7 @@
 	targs = std.htgetv(b.targs, "", [][:])
 	for t in targs
 		match t
-		| `Gen gt: run(gt.cmd, "")
+		| `Gen gt: run(gt.cmd)
 		| _:	/* skip */
 		;;
 	;;
@@ -71,7 +71,7 @@
 		| `Gen gt:
 			for n in gt.out
 				if std.sleq(n, targ)
-					run(gt.cmd, "")
+					run(gt.cmd)
 				;;
 			;;
 		| `Sub subs:
@@ -159,7 +159,7 @@
 const genfiles = {b, gt
 	for f in gt.out
 		if !std.fexists(f)
-			run(gt.cmd, "")
+			run(gt.cmd)
 			->
 		;;
 	;;
@@ -182,7 +182,7 @@
 			;;
 			if !std.fexists(d)
 				match std.htget(b.gensrc, d)
-				| `std.Some gt:	run(gt.cmd, "")
+				| `std.Some gt:	run(gt.cmd)
 				| `std.None:	std.fatal(1, "no input file %s\n", d)
 				;;
 			;;
@@ -219,7 +219,7 @@
 			cmd = std.slpush(cmd, "-S")
 		;;
 		cmd = std.slpush(cmd, src)
-		run(cmd, "")
+		run(cmd)
 		std.slfree(cmd)
 	elif std.hassuffix(src, ".s")
 		o = srcswapsuffix(src, config.Objsuffix)
@@ -229,7 +229,7 @@
 		cmd = std.slpush(cmd,"-o")
 		cmd = std.slpush(cmd, o)
 		cmd = std.slpush(cmd, src)
-		run(cmd, "")
+		run(cmd)
 		std.slfree(o)
 	else
 		std.fatal(1, "Unknown file type for %s\n", src)
@@ -277,7 +277,7 @@
 		cmd = std.slpush(cmd, std.sldup("10.6"))
 	;;
 
-	run(cmd, "")
+	run(cmd)
 	strlistfree(cmd)
 }
 
@@ -294,7 +294,7 @@
 		obj = srcswapsuffix(f, config.Objsuffix)
 		cmd = std.slpush(cmd, obj)
 	;;
-	run(cmd, "")
+	run(cmd)
 	strlistfree(cmd)
 }
 
@@ -312,7 +312,7 @@
 			std.fatal(1, "unknown file type for %s\n", f)
 		;;
 	;;
-	run(cmd, "")
+	run(cmd)
 	strlistfree(cmd)
 }
 
--- a/deps.myr
+++ b/deps.myr
@@ -12,8 +12,8 @@
 
 	/* a bit ugly: initialized from main() */
 	var usepat	: regex.regex#
-
 ;;
+
 var usepat	: regex.regex#
 
 type dep = union
@@ -177,7 +177,7 @@
 	deps = [][:]
 	if !std.fexists(path)
 		match std.htget(b.gensrc, path)
-		| `std.Some gt:	run(gt.cmd, "")
+		| `std.Some gt:	run(gt.cmd)
 		| `std.None:	std.fatal(1, "no input file %s\n", path)
 		;;
 	;;
--- a/subdir.myr
+++ b/subdir.myr
@@ -9,17 +9,15 @@
 
 const subdirs = {p, subs, targ
 	for s in subs
-		match targ
-		| `std.None:	/* nothing */
-		| `std.Some t:
-			if !std.sleq(t, s)
-				continue
-			;;
-		;;
-
 		std.put("Entering directory '%s'\n", s)
-		run(p.cmd, s)
+		if !std.chdir(s)
+			std.fatal(1, "unable to enter directory %s\n", s)
+		;;
+		run(p.cmd)
 		std.put("Leaving directory '%s'\n", s)
+		if !std.chdir("..")
+			std.fatal(1, "unable to leave directory %s\n", s)
+		;;
 	;;
 }
 
--- a/util.myr
+++ b/util.myr
@@ -3,7 +3,7 @@
 use "opts.use"
 
 pkg bld =
-	const run	: (cmd : byte[:][:], dir : byte[:] -> void)
+	const run	: (cmd : byte[:][:] -> void)
 	const printcmd
 	const srcsplit	: (src : byte[:] -> (byte[:], byte[:], byte[:]))
 	const swapsuffix	: (f : byte[:], suff : byte[:], newsuff : byte[:] -> byte[:])
@@ -11,7 +11,7 @@
 	const strlistfree	: (sl : byte[:][:] -> void)
 ;;
 
-const run = {cmd, dir
+const run = {cmd
 	var pid
 
 	printcmd(cmd)
@@ -19,11 +19,6 @@
 	if pid == -1
 		std.fatal(1, "could not fork command\n")
 	elif pid == 0
-		if dir.len > 0
-			if !std.chdir(dir)
-				std.fatal(1, "unable to enter directory %s\n", dir)
-			;;
-		;;
 		if std.execvp(cmd[0], cmd) < 0
 			std.fatal(1, "failed to exec %s\n", cmd[0])
 		;;