postgresql: upgrade to release 13.8
[LibreOffice.git] / bin / find-unused-typedefs.py
blob0fd96749c300c960124e6432c574e0b82465c63e
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: continue
19 typedefSet.add(typedefName)
21 for typedefName in sorted(typedefSet):
22 print(b"checking: " + typedefName)
23 a = subprocess.Popen(["git", "grep", "-wn", typedefName], stdout=subprocess.PIPE)
24 foundLine2 = b""
25 cnt = 0
26 with a.stdout as txt2:
27 for line2 in txt2:
28 cnt = cnt + 1
29 foundLine2 += line2
30 if cnt > 2: break
31 a.kill()
32 if cnt == 1:
33 print(b"remove: " + foundLine2)
34 elif cnt == 2:
35 print(b"inline: " + foundLine2)