tdf#137335 calculate paragraph height in RTF/DOCX
[LibreOffice.git] / bin / find-unused-typedefs.py
blob14135874e8873767e03d7513fc3cc38f9b99533a
1 #!/usr/bin/python3
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(b";")
13 idx1 = line.rfind(b" ", 0, idx2)
14 typedefName = line[idx1+1 : idx2]
15 if typedefName.startswith(b"*"):
16 typedefName = typedefName[1:]
17 # ignore anything less than 5 characters, it's probably a parsing error
18 if len(typedefName) < 5:
19 continue
20 typedefSet.add(typedefName)
22 for typedefName in sorted(typedefSet):
23 print(b"checking: " + typedefName)
24 a = subprocess.Popen(["git", "grep", "-wn", typedefName], stdout=subprocess.PIPE)
25 foundLine2 = b""
26 cnt = 0
27 with a.stdout as txt2:
28 for line2 in txt2:
29 cnt = cnt + 1
30 foundLine2 += line2
31 if cnt > 2:
32 break
33 a.kill()
34 if cnt == 1:
35 print(b"remove: " + foundLine2)
36 elif cnt == 2:
37 print(b"inline: " + foundLine2)