update makefile
[musl-tables] / findproblems.sh
1 #!/bin/sh
2
3 export LC_ALL=C
4
5 ./makeproto.sh
6 {
7         awk -F'\t' '{print $1}' data/musl.tags data/posix2008.ok # data/c99
8         awk -F'\t' '{print $2}' data/musl.syms
9 } |sort |uniq |awk -F'\t' '
10 BEGIN {
11         syms = "data/musl.syms"
12         tags = "data/musl.tags.proto"
13         srctags = "data/musl.src.tags.proto"
14         posix = "data/posix2008.ok.proto"
15
16         while (getline < syms == 1)
17                 sym[$2] = $1
18
19         while (getline < tags == 1) {
20                 if ($5 ~ /^#undef/)
21                         continue
22                 if ($1 in tag)
23                         tag[$1] = tag[$1] "@" $2 "\t" $3 "\t" $5 "\t" $6
24                 else
25                         tag[$1] = $2 "\t" $3 "\t" $5 "\t" $6
26         }
27
28         while (getline < srctags == 1) {
29                 if ($3 != "f")
30                         continue
31                 if ($1 in stag)
32                         stag[$1] = stag[$1] "@" $2 "\t" $3 "\t" $5 "\t" $6
33                 else
34                         stag[$1] = $2 "\t" $3 "\t" $5 "\t" $6
35         }
36
37         while (getline < posix == 1)
38                 pos[$1] = $2 "\t" $5 "\t" $6
39 }
40 {
41         s = ""
42         if (sym[$1])
43                 s = s " obj"
44         if (tag[$1])
45                 s = s " inc"
46         else
47                 tag[$1] = "\t\t\t"
48         if (pos[$1])
49                 s = s " posix"
50         else
51                 pos[$1] = "\t\t"
52
53         n = split(tag[$1],a,"@")
54         for (i = 1; i <= n; i++)
55                 print $1 "\t" substr(s,2) "\t" sym[$1] "\t" a[i] "\t" pos[$1]
56         n = split(stag[$1],a,"@")
57         for (i = 1; i <= n; i++)
58                 print $1 "\t" substr(s,2) "\t" sym[$1] "\t" a[i] "\t" pos[$1]
59 }' >data/musl.all
60
61 awk -F'\t' '
62 BEGIN {
63 }
64
65 herr && lastid != $1 {
66         print herr
67         herr = ""
68 }
69 $2 == "obj" || $2 == "obj posix" {
70         # not declared
71         if ($1 !~ /^_/)
72                 print "nodecl\t" $1 "\t" $3
73 }
74 $5 == "p" {
75         # check for different declarations of the same symbol
76         if ($1 in proto) {
77                 if (proto[$1] != $6)
78                         print "proto\t" $1 "\t" $4 "\t" head[$1] "\t" $6 "\t" proto[$1]
79         } else {
80                 proto[$1] = $6
81                 protoshort[$1] = $7
82                 head[$1] = $4
83         }
84 }
85 $5 == "f" && $1 in protoshort {
86         # func definition with different proto
87         dec = protoshort[$1]
88         def = $7
89         gsub(/extern */, "", dec)
90         gsub(/void/, "", dec)
91         gsub(/void/, "", def)
92         if (protoshort[$1] != $7 && dec != def)
93                 print "proto\t" $1 "\t" $4 "\t" head[$1] "\t" $7 "\t" protoshort[$1]
94 }
95 $2 ~ /inc posix/ && $4 == $8 {
96         head[$1] = $4
97         herr = ""
98 }
99 $2 ~ /inc posix/ && head[$1] != $8 && $4 !~ /^bits\// && $5 != "f" {
100         # different header
101         n = split($8, a, " ")
102         for (i = 1; i <= n; i++)
103                 if ($4 == a[i])
104                         break
105         if (i > n)
106                 # delay error msg
107                 herr = "header\t" $1 "\t" $4 "\t" $8
108 }
109 $2 ~ /inc posix/ && $7 != $10 && $5 == "p" {
110         # different prototype
111         print "proto\t" $1 "\t" $4 "\t" $7 "\t" $10 "\t" $6 "\t" $9
112 }
113 {
114         lastid = $1
115 }
116 END{
117         if(herr)
118                 print herr
119 }
120 ' data/musl.all |uniq >data/musl.problems
121