From d985cfcb15fc316d546009c7c5e10ea5fe9f46fa Mon Sep 17 00:00:00 2001 From: Marko Kreen Date: Sun, 23 Dec 2012 12:05:34 +0200 Subject: [PATCH] find_module: avoid big regex --- find_modules.sh | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/find_modules.sh b/find_modules.sh index 91ef409..882dfc6 100755 --- a/find_modules.sh +++ b/find_modules.sh @@ -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 } -- 2.39.5