regenerate typedef table
[musl-tables] / tab_types.sh
1 #!/bin/sh
2
3 export LC_ALL=C
4
5 awk -F'\t' '
6 ($3=="t"||$3=="s") && ($2~/^include/ || $2~/^arch.*bits/) && $1!~/^__/ && $1!~/ __/ {
7         print $1
8 }' data/musl.inc.tags |sort -u |awk '
9 function gfmt(s) {
10         if (s ~ /^ *$/)
11                 return ""
12         s0 = s
13         sub(/:/, "#l", s)
14         return "<a href=\"http://sourceware.org/git/?p=glibc.git;a=blob;f=" s "\">" s0 "</a><br>"
15 }
16 function mfmt(s) {
17         if (s ~ /^ *$/)
18                 return ""
19         s0 = s
20         sub(/:/, "#n", s)
21         return "<a href=\"http://git.musl-libc.org/cgit/musl/tree/" s "\">" s0 "</a><br>"
22 }
23 function ga(s) {
24         n = split(s, a, / /)
25         r = ""
26         for (i = 1; i <= n; i++)
27                 r = r " " gfmt(a[i])
28         return r
29 }
30 function ma(s) {
31         n = split(s, a, / /)
32         r = ""
33         for (i = 1; i <= n; i++)
34                 r = r " " mfmt(a[i])
35         return r
36 }
37 function pinc(s) {
38         n = split(s, a, / /)
39         for (i = 1; i <= n; i++) {
40                 sub(/:.*/,"",a[i])
41                 sub(/include\//,"",a[i])
42                 sub(/arch.*bits\//,"",a[i])
43                 h0 = a[i]
44                 if (a[i] in pmap) {
45                         gsub(/\//,"_",a[i])
46                         return "<a href=\"http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/" a[i] ".html\">" h0 "</a>"
47                 }
48         }
49         return ""
50 }
51 BEGIN {
52         FS = "\t"
53
54         posix = "data/posix2008.inc"
55         g = "data/glibc.inc.tags"
56         m = "data/musl.inc.tags"
57
58         while (getline < posix == 1)
59                 pmap[$1] = 1
60         while (getline < g == 1)
61 #               if ($3=="t" || $3=="s")
62                         gmap[$1] = gmap[$1] " " $2 ":" $4
63         while (getline < m == 1)
64                 if (($3=="t" || $3=="s") && $2 !~ /^src\//)
65                         mmap[$1] = mmap[$1] " " $2 ":" $4
66
67         print "<h3>types</h3>"
68         print "<h4>table</h4><table border=1><tr><th>name<th>posix<th>musl<th>glibc"
69         
70
71         while (getline == 1) {
72                 print "<tr><td>" $1 "<td>" pinc(mmap[$1]) "<td>" ma(mmap[$1]) "<td>" ga(gmap[$1])
73 #               s = s "<td><a href=\"http://pubs.opengroup.org/onlinepubs/9699919799/functions/" $1 ".html\">" $1 "</a>"
74 #                       s = s " <a href=\"http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/" h ".html\">" x[i] "</a>"
75         }
76         print "</table>"
77 }' >tab_types.html