From efac5fa06e2d00bd67c582d8a6b1f1fc69c9b9f5 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Fri, 24 Jul 2015 13:39:49 +0200 Subject: remove some unused defines Change-Id: Ib2d50e8c29ccbc5ffcb52cdff4ae3eaae9a62188 Reviewed-on: https://gerrit.libreoffice.org/17332 Reviewed-by: Noel Grandin Tested-by: Noel Grandin --- bin/find-unused-defines.awk | 2 ++ bin/find-unused-defines.sh | 17 ++++++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) (limited to 'bin') diff --git a/bin/find-unused-defines.awk b/bin/find-unused-defines.awk index c5c52963975b..193986ea2466 100644 --- a/bin/find-unused-defines.awk +++ b/bin/find-unused-defines.awk @@ -6,6 +6,8 @@ END { tmp = substr(y, 0, index(y, ":")-1) if (x==1) print "sed -i '/[[:space:]]" p1 "[[:space:]]/d' " tmp + # mark these as potential places to inline a constant + if (x==2) print "#inline " p1 " " tmp } diff --git a/bin/find-unused-defines.sh b/bin/find-unused-defines.sh index 6c07de4aeea5..bd03cdcfa075 100755 --- a/bin/find-unused-defines.sh +++ b/bin/find-unused-defines.sh @@ -10,17 +10,16 @@ # Algorithm Detail: # (1) find #defines, excluding the externals folder # (2) extract just the constant name from the search results -# (3) trim blank lines -# (4) sort the results, mostly so I have an idea how far along the process is -# (5) for each result: -# (6) grep for the constant -# (7) use awk to to check if only one match for a given constant was found -# (8) if so, generate a sed command to remove the #define +# (3) sort and uniq the results, mostly so I have an idea how far along the process is +# (4) for each result: +# (5) grep for the constant +# (6) use awk to to check if only one match for a given constant was found +# (7) if so, generate a sed command to remove the #define # -git grep -P '^#define\s+\w+\s+\w' -- "[!e][!x][!t]*" \ - | cut -s -d ' ' -f 2 \ - | sed '/^$/d' \ +git grep -hP '^#define\s+\w+.*\\' -- "[!e][!x][!t]*" \ + | sed -r 's/#define[ ]+([a-zA-Z0-9_]+).*/\1/' \ | sort \ + | uniq \ | xargs -Ixxx sh -c \ "git grep -w 'xxx' | awk -f bin/find-unused-defines.awk -v p1=xxx && echo \"xxx\" 1>&2" -- cgit