diff options
author | Noel Grandin <noel@peralex.com> | 2015-08-03 08:44:51 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2015-08-03 08:53:21 +0000 |
commit | f5deb463492d5e61e573ba9d533df97c555280d7 (patch) | |
tree | b55da0b35bd9cbd154592741ceae70589cbeb4a5 /bin | |
parent | dbfed66eebde65f5844a0f1a2cfe548ad4eda962 (diff) |
remove some unused typedefs
Change-Id: I98c1e7eaa66b7afb05255a017a3de54714637501
Reviewed-on: https://gerrit.libreoffice.org/17491
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/find-unused-typedefs.py | 16 | ||||
-rwxr-xr-x | bin/find-unused-typedefs.sh | 26 |
2 files changed, 42 insertions, 0 deletions
diff --git a/bin/find-unused-typedefs.py b/bin/find-unused-typedefs.py new file mode 100755 index 000000000000..e261d13e546b --- /dev/null +++ b/bin/find-unused-typedefs.py @@ -0,0 +1,16 @@ +#!/usr/bin/python + +import subprocess + +a = subprocess.Popen("git grep -P '^typedef\s+.+\w+;' -- \"[!e][!x][!t]*\"", stdout=subprocess.PIPE, shell=True) + +with a.stdout as txt: + for line in txt: + idx1 = line.rfind(" ") + typedefName = line[idx1+1 : len(line)-2] + if typedefName.startswith("*"): + typedefName = typedefName[1:] + # ignore anything less than 5 characters, it's probably a parsing error + if len(typedefName) > 4: + print typedefName + diff --git a/bin/find-unused-typedefs.sh b/bin/find-unused-typedefs.sh new file mode 100755 index 000000000000..a8039f552178 --- /dev/null +++ b/bin/find-unused-typedefs.sh @@ -0,0 +1,26 @@ +# +# This is a pretty brute-force approach. It takes several hours to run on a top-spec MacbookAir. +# It also produces some false positives, so it requires careful examination and testing of the results. +# +# Algorithm Summary: +# First we find all #defines, +# then we search for each of them in turn, +# and if we find only one instance of a #define, we print it out. +# +# 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 +# +bin/find-unused-typedefs.py \ + | sort \ + | uniq \ + | xargs -Ixxx -n 1 -P 8 sh -c \ + "( git grep -w 'xxx' | awk -f bin/find-unused-defines.awk -v p1=xxx ) && echo \"xxx\" 1>&2" + + |