find_modules.sh/awk: replace split() with index()+substr()
authorMarko Kreen <markokr@gmail.com>
Wed, 20 Apr 2011 17:06:31 +0000 (20:06 +0300)
committerMarko Kreen <markokr@gmail.com>
Wed, 20 Apr 2011 17:12:09 +0000 (20:12 +0300)
heirloom/oawk does not support split-by-regex, seems
thats too modern construct (post-1978).  Internet says
thats where Solaris is.

Also simplify quoting a little.

find_modules.sh

index 94b6c1e07bb97a98a0bcdfe5d8dab379ddca80dc..3fa83f84f28298f60a1fefa856199c86b2ba428e 100755 (executable)
@@ -23,11 +23,11 @@ grep_usual() {
   for m in $m_done; do
     excl="$excl|$m"
   done
-  awk "
-/^#include[ \t]*[<\"]usual\\/($excl)[.]h/  { next; }
-/^#include[ \t]*[<\"]usual\\//             { split(\$0, tmp, \"[./]\"); print tmp[2]; }
-" "$@" \
-  | sort -u
+  prog='
+/^#include[ \t]*[<"]usual\/('"$excl"')[.]h/  { next; }
+/^#include[ \t]*[<"]usual\// { p1 = index($0, "/"); p2 = index($0,"."); print substr($0, p1+1, p2-p1-1); }
+'
+  awk "$prog" "$@" | sort -u
 }
 
 # return module filename globs