about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-02-17 00:39:52 -0800
committerKartik K. Agaram <vc@akkartik.com>2016-02-17 00:39:52 -0800
commit852936bfaaa385790613b889e01fe1edd6f0312c (patch)
treea9101950406430355b87c478af4bbf8f48fa2d15
parent37421f8a8bbccc871a3d452d81f03ad9a58f23bf (diff)
downloadmu-852936bfaaa385790613b889e01fe1edd6f0312c.tar.gz
2665
-rw-r--r--enumerate/enumerate.cc17
-rw-r--r--enumerate/makefile2
-rw-r--r--makefile2
3 files changed, 6 insertions, 15 deletions
diff --git a/enumerate/enumerate.cc b/enumerate/enumerate.cc
index 58497909..2777c407 100644
--- a/enumerate/enumerate.cc
+++ b/enumerate/enumerate.cc
@@ -1,3 +1,4 @@
+#include<assert.h>
 #include<cstdlib>
 #include<dirent.h>
 #include<vector>
@@ -7,14 +8,11 @@ using std::string;
 #include<iostream>
 using std::cout;
 
-int enumerate_files_in_cwd_until(string last_file);
-string flag_value(const string& flag, int argc, const char* argv[]);
-
 int main(int argc, const char* argv[]) {
-  return enumerate_files_in_cwd_until(flag_value("--until", argc, argv));
-}
+  assert(argc == 3);
+  assert(string(argv[1]) == "--until");
+  string last_file(argv[2]);
 
-int enumerate_files_in_cwd_until(string last_file) {
   dirent** files;
   int num_files = scandir(".", &files, NULL, alphasort);
   for (int i = 0; i < num_files; ++i) {
@@ -26,10 +24,3 @@ int enumerate_files_in_cwd_until(string last_file) {
   // don't bother freeing files
   return 0;
 }
-
-string flag_value(const string& flag, int argc, const char* argv[]) {
-  for (int i = 1; i < argc-1; ++i)
-    if (string(argv[i]) == flag)
-      return argv[i+1];
-  return "";
-}
diff --git a/enumerate/makefile b/enumerate/makefile
index b8760460..e1a06f63 100644
--- a/enumerate/makefile
+++ b/enumerate/makefile
@@ -1,4 +1,4 @@
-tangle: makefile
+enumerate: makefile enumerate.cc
 	c++ -O3 -Wall -Wextra -fno-strict-aliasing enumerate.cc -o enumerate
 
 clean:
diff --git a/makefile b/makefile
index cc8af389..5dd114c2 100644
--- a/makefile
+++ b/makefile
@@ -16,7 +16,7 @@ core.mu: [0-9]*.mu mu.cc
 	cat $$(./enumerate/enumerate --until zzz |grep '.mu$$') > core.mu
 
 enumerate/enumerate:
-	cd enumerate && make && ./enumerate test
+	cd enumerate && make
 
 tangle/tangle:
 	cd tangle && make && ./tangle test