X-Git-Url: http://nsz.repo.hu/git/?p=c-standard;a=blobdiff_plain;f=ann2html.sh;h=5a93b3542d311fb02ef012b47359eac40e8dbdac;hp=14c5766f4245fe4872491b241bcff6f185fcbe61;hb=5d87c6a24b31ceb8a6753667546b0cb311bd6843;hpb=84335d19c1aba5393801bc0939c2f625a2ded79d diff --git a/ann2html.sh b/ann2html.sh index 14c5766..5a93b35 100755 --- a/ann2html.sh +++ b/ann2html.sh @@ -8,12 +8,16 @@ BEGIN { ss[sid] = "
"
 }
 
-{
+function esc() {
 	gsub(/\&/, "\\&")
 	gsub(//, "\\>")
 }
 
+{
+	esc()
+}
+
 !title && /^[^@]/ {
 	title = $0
 	gsub(/  +/, "  ", title)
@@ -35,6 +39,7 @@ seencontents && !seenfore && /^[^@]/ {
 	s = $0
 	if (!sub(/ +\. .*/, "", s)) {
 		getline
+		esc()
 		sub(/^ */, " ")
 		s = s $0
 		sub(/ +\. .*/, "", s)
@@ -78,6 +83,7 @@ seencontents && !seenfore && /^[^@]/ {
 	}
 	sid++
 	getline
+	esc()
 	ss[sid] = ss[sid] "

" $0 "

\n" if (!seencontents) { ss[sid] = ss[sid] "
\n"
@@ -96,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")
@@ -133,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 @@ -161,8 +168,8 @@ seencontents && !seenfore && /^[^@]/ { next } -/^ *(Syntax|Semantics|Description|Constraints|Synopsis|Returns|Recommended practice|Implementation limits|Environmental limits)$/ { - ss[sid] = ss[sid] "
" $0 "
\n" +/^ ?(Syntax|Semantics|Description|Constraints|Synopsis|Returns|Recommended practice|Implementation limits|Environmental limits)$/ { + ss[sid] = ss[sid] "

" $0 "\n" next } @@ -211,7 +218,19 @@ seencontents && !seenfore && /^[^@]/ { } s = p s p = "" - while (match(s, noteid "\\)")) { + # 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) + p = p "" noteid-1 ")" + s = substr(s,RSTART+RLENGTH) + } + if (!match(s, noteid "\\)")) + break if (noteid==1 && s !~ /\.1\)/) break p = p substr(s,1,RSTART-1) @@ -243,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 ""