about summary refs log tree commit diff stats
path: root/enumerate
diff options
context:
space:
mode:
Diffstat (limited to 'enumerate')
-rw-r--r--enumerate/enumerate.cc17
-rw-r--r--enumerate/makefile2
2 files changed, 5 insertions, 14 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: