about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2018-02-15 20:36:16 -0800
committerKartik K. Agaram <vc@akkartik.com>2018-02-15 20:36:16 -0800
commit745a6dee7875154e3512bed5d2c73869dddef13e (patch)
treef3a9e5ff020205f0b592df51cc11807058370b29
parent6086465de72dc1b194a8b3b465fe72788a1d6a7c (diff)
downloadmu-745a6dee7875154e3512bed5d2c73869dddef13e.tar.gz
4204
-rw-r--r--020run.cc11
-rwxr-xr-xbuild4
2 files changed, 12 insertions, 3 deletions
diff --git a/020run.cc b/020run.cc
index e82c07e7..d171f112 100644
--- a/020run.cc
+++ b/020run.cc
@@ -273,13 +273,22 @@ void load_all(string dir) {
   int num_files = scandir(dir.c_str(), &files, NULL, alphasort);
   for (int i = 0;  i < num_files;  ++i) {
     string curr_file = files[i]->d_name;
-    if (isdigit(curr_file.at(0)))
+    if (isdigit(curr_file.at(0)) && ends_with(curr_file, ".mu"))
       load_file_or_directory(dir+'/'+curr_file);
     free(files[i]);
     files[i] = NULL;
   }
   free(files);
 }
+
+bool ends_with(const string& s, const string& pat) {
+  for (string::const_reverse_iterator p = s.rbegin(), q = pat.rbegin();  q != pat.rend();  ++p, ++q) {
+    if (p == s.rend()) return false;  // pat too long
+    if (*p != *q) return false;
+  }
+  return true;
+}
+
 :(before "End Includes")
 #include <dirent.h>
 #include <sys/stat.h>
diff --git a/build b/build
index 5a3cae9e..dda1c974 100755
--- a/build
+++ b/build
@@ -90,7 +90,7 @@ older_than tangle/tangle tangle/*.cc && {
   noisy_cd ..  # no effect; just to show us returning to the parent directory
 }
 
-LAYERS=$(./enumerate/enumerate --until $UNTIL_LAYER  |grep '.cc$')
+LAYERS=$(./enumerate/enumerate --until $UNTIL_LAYER  |grep '\.cc$')
 older_than mu.cc $LAYERS enumerate/enumerate tangle/tangle && {
   # no update here; rely on 'update' calls downstream
   ./tangle/tangle $LAYERS  > mu.cc
@@ -134,7 +134,7 @@ older_than mu_bin mu.cc *_list cleave/cleave termbox/* && {
 
 ## [0-9]*.mu -> core.mu
 
-MU_LAYERS=$(./enumerate/enumerate --until $UNTIL_LAYER  |grep '.mu$') || exit 0  # ok if no .mu files
+MU_LAYERS=$(./enumerate/enumerate --until $UNTIL_LAYER  |grep '\.mu$') || exit 0  # ok if no .mu files
 cat $MU_LAYERS  |update core.mu
 
 exit 0