X-Git-Url: http://nsz.repo.hu/git/?p=c-standard;a=blobdiff_plain;f=ann2html.sh;h=5a93b3542d311fb02ef012b47359eac40e8dbdac;hp=509e3a293e8799f42558b85601dd4cac8e523613;hb=64f77827d2ab6711efabb423a08933f289dbce5e;hpb=3290b27f9f394936c32da8afa53d9b25fd968aa9 diff --git a/ann2html.sh b/ann2html.sh index 509e3a2..5a93b35 100755 --- a/ann2html.sh +++ b/ann2html.sh @@ -1,7 +1,5 @@ #!/bin/sh -# todo: opt - export LC_ALL=C awk ' BEGIN { @@ -10,12 +8,16 @@ BEGIN { ss[sid] = "
"
 }
 
-{
+function esc() {
 	gsub(/\&/, "\\&")
 	gsub(//, "\\>")
 }
 
+{
+	esc()
+}
+
 !title && /^[^@]/ {
 	title = $0
 	gsub(/  +/, "  ", title)
@@ -37,6 +39,7 @@ seencontents && !seenfore && /^[^@]/ {
 	s = $0
 	if (!sub(/ +\. .*/, "", s)) {
 		getline
+		esc()
 		sub(/^ */, " ")
 		s = s $0
 		sub(/ +\. .*/, "", s)
@@ -80,6 +83,7 @@ seencontents && !seenfore && /^[^@]/ {
 	}
 	sid++
 	getline
+	esc()
 	ss[sid] = ss[sid] "

" $0 "

\n" if (!seencontents) { ss[sid] = ss[sid] "
\n"
@@ -98,6 +102,7 @@ seencontents && !seenfore && /^[^@]/ {
 		slevel = 5
 	sect = $2
 	getline
+	esc()
 	# todo hX, back to top
 	ss[sid] = sprintf("%s\n", slevel, sect, sect, $0, slevel)
 	if ($0 == "Index")
@@ -135,7 +140,7 @@ seencontents && !seenfore && /^[^@]/ {
 /^@end pre/ {
 	if (!pre)
 		next
-	pre = pre "
\n" + pre = pre "\n
\n" if (nn) note[nn] = note[nn] "\n" pre else @@ -164,7 +169,7 @@ seencontents && !seenfore && /^[^@]/ { } /^ ?(Syntax|Semantics|Description|Constraints|Synopsis|Returns|Recommended practice|Implementation limits|Environmental limits)$/ { - ss[sid] = ss[sid] "
" $0 "
\n" + ss[sid] = ss[sid] "

" $0 "\n" next } @@ -213,6 +218,11 @@ seencontents && !seenfore && /^[^@]/ { } s = p s p = "" + # TODO: false positives.. + while (match(s, /[a-z]opt[ )"]/)) + s = substr(s,1,RSTART) "opt" substr(s,RSTART+RLENGTH-1) + if (match(s, /[a-z]opt$/)) + s = substr(s,1,RSTART) "opt" for (;;) { while (match(s, noteid-1 "\\)")) { p = p substr(s,1,RSTART-1) @@ -252,12 +262,13 @@ END { print ss[i] n = split(snote[i],a) if (n > 0) { - s = "

footnotes
\n" + s = "

Footnotes\n" for (j = 1; j <= n; j++) { s = s "

" a[j] ")" note[a[j]+0] "\n" } print s } + print "

Contents" } print ""