summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2015-11-18 10:12:08 +0200
committerNoel Grandin <noelgrandin@gmail.com>2015-11-18 10:38:08 +0000
commit53f16c39f5c4c69ab603bf9098daec71f7a0acb8 (patch)
tree00b3166ecff36bb55dcf0b8c2122a08b72656ab5 /bin
parent4c1f958634ae88614a794bf232c67e9e785bf703 (diff)
remove unused typedefs and inline use-once typedefs
and improve the script a little Change-Id: I2792ea4dd5df3a50736fbe209225c3f16fb86b84 Reviewed-on: https://gerrit.libreoffice.org/20033 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.awk1
-rwxr-xr-xbin/find-unused-typedefs.py7
-rwxr-xr-xbin/find-unused-typedefs.sh5
3 files changed, 6 insertions, 7 deletions
diff --git a/bin/find-unused-defines.awk b/bin/find-unused-defines.awk
index 193986ea2466..fb3997ab4f54 100644
--- a/bin/find-unused-defines.awk
+++ b/bin/find-unused-defines.awk
@@ -14,7 +14,6 @@ END {
# | xargs -P 4 -Ixxx sh -c "git grep -w 'xxx' | awk '{ x++; y=\$0 } END { if (x==1) print y }' && echo \"xxx\" 1>&2"
-
# sed -i '' '/pattern/d'
# | awk 'arr[$0]++ END { for (i in arr) { if(arr[i]==1) print i } }' \
# | awk -f find-unused-defines.awk
diff --git a/bin/find-unused-typedefs.py b/bin/find-unused-typedefs.py
index e261d13e546b..e292f097526a 100755
--- a/bin/find-unused-typedefs.py
+++ b/bin/find-unused-typedefs.py
@@ -2,12 +2,13 @@
import subprocess
-a = subprocess.Popen("git grep -P '^typedef\s+.+\w+;' -- \"[!e][!x][!t]*\"", stdout=subprocess.PIPE, shell=True)
+a = subprocess.Popen("git grep -P '^typedef\s+.+\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]
+ idx2 = line.rfind(";")
+ idx1 = line.rfind(" ", 0, idx2)
+ typedefName = line[idx1+1 : idx2]
if typedefName.startswith("*"):
typedefName = typedefName[1:]
# ignore anything less than 5 characters, it's probably a parsing error
diff --git a/bin/find-unused-typedefs.sh b/bin/find-unused-typedefs.sh
index a8039f552178..7a6f54b2b1c8 100755
--- a/bin/find-unused-typedefs.sh
+++ b/bin/find-unused-typedefs.sh
@@ -18,9 +18,8 @@
# (8) if so, generate a sed command to remove the #define
#
bin/find-unused-typedefs.py \
- | sort \
- | uniq \
+ | sort -u \
| 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"
+ '( git grep -w xxx | awk -f bin/find-unused-defines.awk -v p1=xxx ) && echo xxx 1>&2'