office-gobmx/bin/find-unused-typedefs.py
Mike Kaganski 9b6ea15266 Fix escaped sequences in regular expressions
Regression after commit bd96a6f7b7,
which changed meaning of these.

Thanks Stephan!

Change-Id: I43cb871de32bd01d98e9adbb6c20b4e3c88ce715
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99348
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2020-07-24 11:07:09 +02:00

34 lines
1 KiB
Python
Executable file

#!/usr/bin/python2
import subprocess
# find typedefs, excluding the externals folder
a = subprocess.Popen("git grep -P 'typedef\\s+.+\\s+\\w+;' -- \"[!e][!x][!t]*\"", stdout=subprocess.PIPE, shell=True)
# parse out the typedef names
typedefSet = set()
with a.stdout as txt:
for line in txt:
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
if len(typedefName) < 5: continue
typedefSet.add(typedefName)
for typedefName in sorted(typedefSet):
print("checking: " + typedefName)
a = subprocess.Popen(["git", "grep", "-wn", typedefName], stdout=subprocess.PIPE)
foundLine2 = ""
cnt = 0
with a.stdout as txt2:
for line2 in txt2:
cnt = cnt + 1
foundLine2 += line2
if cnt == 1:
print("remove: " + foundLine2)
elif cnt == 2:
print("inline: " + foundLine2)