tdf#131510 fix German autocorrect list for 'daß'
[LibreOffice.git] / bin / find-unused-typedefs.py
blob9a6c0eef911874d7b18e0cfc227505e3e872be6b
1 #!/usr/bin/python2
3 import subprocess
5 # find typedefs, excluding the externals folder
6 a = subprocess.Popen("git grep -P 'typedef\\s+.+\\s+\\w+;' -- \"[!e][!x][!t]*\"", stdout=subprocess.PIPE, shell=True)
8 # parse out the typedef names
9 typedefSet = set()
10 with a.stdout as txt:
11 for line in txt:
12 idx2 = line.rfind(";")
13 idx1 = line.rfind(" ", 0, idx2)
14 typedefName = line[idx1+1 : idx2]
15 if typedefName.startswith("*"):
16 typedefName = typedefName[1:]
17 # ignore anything less than 5 characters, it's probably a parsing error
18 if len(typedefName) < 5: continue
19 typedefSet.add(typedefName)
21 for typedefName in sorted(typedefSet):
22 print("checking: " + typedefName)
23 a = subprocess.Popen(["git", "grep", "-wn", typedefName], stdout=subprocess.PIPE)
24 foundLine2 = ""
25 cnt = 0
26 with a.stdout as txt2:
27 for line2 in txt2:
28 cnt = cnt + 1
29 foundLine2 += line2
30 if cnt == 1:
31 print("remove: " + foundLine2)
32 elif cnt == 2:
33 print("inline: " + foundLine2)