From: Marko Kreen Date: Sun, 23 Dec 2012 10:05:34 +0000 (+0200) Subject: find_module: avoid big regex X-Git-Url: http://git.postgresql.org/gitweb/?a=commitdiff_plain;h=d985cfcb15fc316d546009c7c5e10ea5fe9f46fa;p=libusual.git find_module: avoid big regex --- 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 }