X-Git-Url: http://nsz.repo.hu/git/?p=c-standard;a=blobdiff_plain;f=ann2html.sh;h=9acba6243b6c2a378eb6033963fdcb51f65826ba;hp=ecb0411ebda6c2d67e54b4f8dfd4f4a5ce686d2d;hb=fb5050e94537cf9c61d58584264f1b3b0476e472;hpb=64ee437a499e51415f53367a1c0be1c371b298d1 diff --git a/ann2html.sh b/ann2html.sh index ecb0411..9acba62 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)$/ { - 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,7 +262,7 @@ 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" }