fix findproblems
[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         posix = "data/posix2008.ok.proto"
14
15         while (getline < syms == 1)
16                 sym[$2] = $1
17
18         while (getline < tags == 1) {
19                 if ($5 ~ /^#undef/)
20                         continue
21                 if ($1 in tag)
22                         tag[$1] = tag[$1] "@" $2 "\t" $3 "\t" $5 "\t" $6
23                 else
24                         tag[$1] = $2 "\t" $3 "\t" $5 "\t" $6
25         }
26
27         while (getline < posix == 1)
28                 pos[$1] = $2 "\t" $5 "\t" $6
29 }
30 {
31         s = ""
32         if (sym[$1])
33                 s = s " obj"
34         if (tag[$1])
35                 s = s " inc"
36         if (pos[$1])
37                 s = s " posix"
38
39         n = split(tag[$1],a,"@")
40         if (n==0) {
41                 n=1
42                 a[1]=""
43         }
44         for (i = 1; i <= n; i++)
45                 print $1 "\t" substr(s,2) "\t" sym[$1] "\t" a[i] "\t" pos[$1]
46 }' >data/musl.all
47
48 awk -F'\t' '
49 $2 == "obj" || $2 == "obj posix" {
50         # not declared
51         if ($1 !~ /^_/)
52                 print "nodecl\t" $1 "\t" $3
53 }
54 $2 ~ /inc/ && $5 == "p" {
55         # check for different declarations of the same symbol
56         if ($1 in proto) {
57                 if (proto[$1] != $6)
58                         print "proto\t" $1 "\t" $4 "\t" head[$1] "\t" $6 "\t" proto[$1]
59         } else {
60                 proto[$1] = $6
61                 head[$1] = $4
62         }
63 }
64 $2 ~ /inc posix/ && $4 != $8 {
65         # different header
66         n = split($8, a, " ")
67         for (i = 1; i <= n; i++)
68                 if ($4 == a[i])
69                         break
70         if (i > n)
71                 print "header\t" $1 "\t" $4 "\t" $8
72 }
73 $2 ~ /inc posix/ && $7 != $10 && $5 == "p" {
74         # different prototype
75         print "proto\t" $1 "\t" $4 "\t" $7 "\t" $10 "\t" $6 "\t" $9
76 }
77 ' data/musl.all >data/musl.problems
78