4 # Script to extract functions and external variables off SUS html docs
6 # Copyright (C) 2010 Bernhard Reutner-Fischer
10 # wget http://www.opengroup.org/onlinepubs/9699919799/download/susv4.tgz
12 # SUS=susv4 html2input.sh -vFULL_DECLARATIONS=1
14 # SUS=susv4 html2input.sh -vFULL_DECLARATIONS=0 -vSTDNAME=SUSv4
16 # Bug in time.h.html of SUSv4:
17 # It inconsistently reads "as variables" instead of "external variables" that
18 # is used everywhere except in time.h.html
20 test "x$SUS" = "x" && SUS="susv4"
21 test "x$AWK" = "x" && AWK="AWK"
22 test "x$GREP" = "x" && GREP="GREP"
24 $($GREP -l "shall be declared as functions" $SUS/basedefs/*.h.html) \
25 $($GREP -l "shall declare the following as variables" $SUS/basedefs/*.h.html) \
26 $($GREP -l "shall declare the following external variables" $SUS/basedefs/*.h.html)
29 function get_filename () {
36 fname=fname "." STDNAME
46 sub("<a [^>]*>", "", l)
48 if (l ~ /<img[^>]*Option[[:space:]][[:space:]]*Start[^>]*>/) {
49 sub("<img[^>]*>", "[Option Start]", l)
50 } else if (l ~ /<img[^>]*Option[[:space:]][[:space:]]*End[^>]*>/) {
51 sub("<img[^>]*>", "[Option End]", l)
56 function get_funcname (l) {
57 if (FULL_DECLARATIONS)
61 cnt = split(l, foo, " ")
62 if (cnt >= 2 && foo[2] ~ /^\(\*/) {
63 cnt = split(l, foo, "(")
64 # good enough for signal() and sigset()
70 gsub("[[\\]\\*]", "", l)
76 function get_varname (l) {
77 if (FULL_DECLARATIONS)
81 gsub(",[[:space:]][[:space:]]*", ",", l)
86 gsub("[[\\]\\*]", "", l)
92 /shall be declared as functions/{data=1;isvar=0;next;}
93 /shall declare the following as variables/{data=1;isvar=1;next;}
94 /shall declare the following external variables/{data=1;isvar=1;next;}
96 /<\/pre>/{data=0;next;}
98 if (data == 2 && fname) {
100 sub("^[[:space:]][[:space:]]*", " ", tmp)
106 if (tmp !~ /;$/ && tmp !~ />$/ &&
107 tmp !~ /Option Start\]$/ && tmp !~ /Option End\]$/)