find_module: avoid big regex
authorMarko Kreen <[email protected]>
Sun, 23 Dec 2012 10:05:34 +0000 (12:05 +0200)
committerMarko Kreen <[email protected]>
Thu, 3 Jan 2013 21:56:28 +0000 (23:56 +0200)
find_modules.sh

index 91ef409ac59c69e31eb690b565c446d2af1afa69..882dfc68055eb47efddcd31338f2958ddf989c12 100755 (executable)
@@ -19,15 +19,18 @@ test -n "$1" || exit 0
 
 # return uniq module names, exclude already found ones
 grep_usual() {
-  excl="config"
+  excl='excl["config"]=1'
   for m in $m_done; do
-    excl="$excl|$m"
+    excl="$excl;excl[\"$m\"]=1"
   done
-  excl=`echo $excl | sed 's,/,\\\\/,g'`
   prog='
-/^#include[ \t]*[<"]usual\/('"$excl"')[.]h/  { next; }
-/^#include[ \t]*[<"]usual\// { p1 = index($0, "/"); p2 = index($0,"."); print substr($0, p1+1, p2-p1-1); }
-'
+BEGIN { '"$excl"' }
+/^#include[ \t]*[<"]usual\// {
+  p1 = index($0, "/");
+  p2 = index($0, ".");
+  m = substr($0, p1+1, p2-p1-1);
+  if (!(m in excl)) print m;
+}'
   awk "$prog" "$@" | sort -u
 }