summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2015-07-24 13:39:49 +0200
committerNoel Grandin <noelgrandin@gmail.com>2015-07-27 06:12:01 +0000
commitefac5fa06e2d00bd67c582d8a6b1f1fc69c9b9f5 (patch)
tree4fdf4539e1b876d4d3d671379be040661c6e847a /bin
parentafbf466103fd8bb2f3c120a36c181852ad4c967f (diff)
remove some unused defines
Change-Id: Ib2d50e8c29ccbc5ffcb52cdff4ae3eaae9a62188 Reviewed-on: https://gerrit.libreoffice.org/17332 Reviewed-by: Noel Grandin <noelgrandin@gmail.com> Tested-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'bin')
-rw-r--r--bin/find-unused-defines.awk2
-rwxr-xr-xbin/find-unused-defines.sh17
2 files changed, 10 insertions, 9 deletions
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"