File: include_wash.py

package info (click to toggle)
varnish 7.7.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,256 kB
  • sloc: ansic: 104,222; python: 2,679; makefile: 1,303; sh: 1,077; awk: 114; perl: 105; ruby: 41
file content (41 lines) | stat: -rw-r--r-- 1,247 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python3

import os

def check(fn):
    l = []
    for i in open(fn):
        i = i.strip()
        if not i:
            continue
        if i[0] != "#":
            continue
        if i.find("include") == -1:
            continue
        if i.find('"') == -1:
            l.append(i.split('<')[1].split('>')[0])
        else:
            l.append(i.split('"')[1])
    if "vrt.h" in l:
        vrt = l.index("vrt.h")
        if "vdef.h" not in l:
            print(fn, "vdef.h not included with vrt.h")
        vdef = l.index("vdef.h")
        if vdef > vrt:
            print(fn, "vdef.h included after vrt.h")
        for i in ("stddef.h", "stdint.h", "cache/cache.h", "cache.h"):
            if i in l:
                print(fn, i + " included with vrt.h")

    for i in ("cache/cache.h", "cache.h"):
        if i in l:
            for j in ("stddef.h", "stdint.h", "vrt.h",
                      "math.h", "pthread.h", "stdarg.h", "sys/types.h",
                      "vdef.h", "miniobj.h", "vas.h", "vqueue.h", "vtree.h"):
                if j in l:
                    print(fn, j + " included with cache.h")

for (dir, dns, fns) in os.walk("."):
    for f in fns:
        if f[-2:] == ".c":
            check(dir + "/" + f)