drop commented lines from table scripts
[musl-tables] / tab_posix.sh
1 #!/bin/sh
2
3 export LC_ALL=C
4
5 ( cd $MUSL; git log -n1 ) | awk '
6 BEGIN {
7         getline
8         hash = $2
9         getline
10
11         commit = "<h4>commit</h4><p>commit <a href=\"http://git.etalabs.net/cgi-bin/gitweb.cgi?p=musl;a=commit;h=" hash "\">" hash "</a>"
12         while (getline == 1)
13                 commit = commit "<br>" $0
14
15         FS = "\t"
16
17         posix = "data/posix2008"
18         syms = "data/musl.syms"
19         tags = "data/musl.tags"
20
21         while (getline < syms == 1)
22                 sym[$2] = $1
23         while (getline < tags == 1) {
24                 if ($2 ~ /bits\//)
25                         s = $3 " "
26                 else
27                         s = "<a href=\"http://git.etalabs.net/cgi-bin/gitweb.cgi?p=musl;a=blob;f=include/" $2 ";hb=" hash "#l" $4 "\">" $3 "</a> "
28                 kind[$1] = kind[$1] $3
29                 kindstr[$1] = kindstr[$1] s
30         }
31
32         legend = "<h4>legend</h4><ul><li>status: musl implementation status summary<ul>"
33         legend = legend "<li>(empty) - implemented"
34         legend = legend "<li>nosym - prototype found in include files (see decl) but not in libc.a (see sym)"
35         legend = legend "<li>nodecl - symbol is in libc.a but not declared in a public header"
36         legend = legend "<li>missing - neither in include files (see decl) nor in libc.a (see sym)"
37         legend = legend "</ul><li>sym: external symbol kind as found by `nm libc.a` (symbol kind only reported once)<ul>"
38         legend = legend "<li>C - symbol is common (uninitialized data)"
39         legend = legend "<li>D - symbol is in the initialized data section"
40         legend = legend "<li>R - symbol is in the read only data section"
41         legend = legend "<li>T - symbol is in the text section"
42         legend = legend "<li>V - weak object"
43         legend = legend "<li>W - weak symbol"
44         legend = legend "</ul><li>decl: kind of declaration as found by `ctags -R include` (every occurance is reported)<ul>"
45         legend = legend "<li>d - macro definition"
46         legend = legend "<li>p - function prototype"
47         legend = legend "<li>x - external and forward variable declaration"
48         legend = legend "</ul></ul>"
49         legend = legend "<p>(any option mark found in the synopsis of a manual is listed in the option column, this is often wrong)"
50
51         print "<h3>musl vs posix api</h3>"
52         print commit
53         print legend
54         print "<h4>table</h4><table border=1><tr><th colspan=3>musl<th colspan=4>posix<tr><th>status<th>sym<th>decl<th>name<th>header<th>option<th>desc"
55         nodecl = nosym = missing = 0
56         while (getline < posix == 1) {
57                 s = "<tr><td>"
58                 if (sym[$1] && kind[$1]) {
59                         s = s "&#160;"
60                 } else if (sym[$1]) {
61                         s = s "nodecl"
62                         nodecl++
63                 } else if (kind[$1] ~ /d/) {
64                         s = s "&#160;"
65                 } else if (kind[$1]) {
66                         s = s "nosym"
67                         nosym++
68                 } else {
69                         s = s "missing"
70                         missing++
71                 }
72                 s = s "<td>" sym[$1]
73                 if (!sym[$1])
74                         s = s "&#160;"
75                 s = s "<td>" kindstr[$1]
76                 if (!kind[$1])
77                         s = s "&#160;"
78
79                 s = s "<td><a href=\"http://pubs.opengroup.org/onlinepubs/9699919799/functions/" $1 ".html\">" $1 "</a>"
80                 n = split($2, x, " ")
81                 s = s "<td>"
82                 for (i = 1; i <= n; i++)
83                         s = s " <a href=\"http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/" x[i] ".html\">" x[i] "</a>"
84                 n = split($3, x, " ")
85                 s = s "<td>"
86                 for (i = 1; i <= n; i++)
87                         s = s " <a href=\"http://pubs.opengroup.org/onlinepubs/9699919799/help/codes.html#" x[i] "\">" x[i] "</a>"
88                 if (n==0)
89                         s = s "&#160;"
90                 s = s "<td>" $4
91                 print s
92         }
93         print "</table>"
94         print "<h4>stats</h4><ul><li>missing: " missing "<li>nosym: " nosym "<li>nodecl: " nodecl "</ul>"
95 }' >tab_posix.html