BEGIN{chap=0;s="";underscore=0;nodetitle="";TMP1="faq2texi.tmp1";app=0; print "@setfilename gcc-faq.info\n"; } function removebadchars(s,parts,N,tmp1,tmp2,k,L,firststring,start) { tmp1=""; N=split(s,parts," "); for (k=1;k<=N;k++) { if (parts[k]!~/[,:'`]/) if (k>1) tmp1 = (tmp1 " " parts[k]) else tmp1 = parts[k]; else {if (k>1) firststring=1 else firststring=0; L=match(parts[k],/[.:'`]/); start=1; do { if (firststring==1) tmp1 = (tmp1 " " substr(parts[k],1,L-1)) else {tmp1= (tmp1 substr(parts[k],start,L-1+start)); firststring=0; } start = L+1 tmp2 = substr(parts[k],start,length(parts[k])-start); } while (L=match(tmp2,/[.:'`]/)); } } return tmp1; } #end of removebadchars function writetop(i,j,k) { print "@menu\n\n"; print "List of Chapters\n"; for (i=1;i<=maxch;i++) { print "*" chaptername[i] "::\n"; } print "\n"; print "Appendices\n"; for (i=1;i<=maxapp;i++) print "*" appname[i] "::\n"; print "\n\n"; print "@end menu\n"; } #end write top {if (chap==1&&$0~/[^\ ]/) {$0=(s $0); if ($2~/[a-z0-9][\.,\)]$/) $2=""; chap=0; } } /---+/{underscore=1} /^\[Appendix [A-Z]\]/ { app++; tmp="@appendix"; if (NF<=2) getline; for (i=3;i<=NF;i++) appname[app]=(appname[app] " " $i); appname[app]=removebadchars(appname[app]); $0="@node " appname[app] " ,,, top\n" $0=($0 tmp " " appname [app]); } /\[[0-9+\.]+\]/ {nodetitle=""; if ($1~/\[[0-9\.]+\]/) {l=split($1,sec,"."); if (l<=3&&NF>1) {if ($2~/[a-z1-9][\.,\)]$/) $2=""; if (l==3) $1="@subsection " else if (l==2) $1="@section " else $1="@chapter "; } else if (l<=3) {if (l==3) s="@subsection " else if (l==2) s="@section " else s="@chapter "; chap=1; } } } {if (chap!=1&&underscore!=1) print $0 > TMP1; if (underscore==1) underscore=0; } END{ maxapp=app; close(TMP1); ch=0; #chapter counter se=0; #section counter ss=0; #subsection counter while (getline < TMP1) {if ($1=="@chapter") {maxse[ch]=se; maxss[ch,se]=ss; ch++; for (i=2;i<=NF;i++) chaptername[ch] = (chaptername[ch] " " $i); chaptername[ch]=removebadchars(chaptername[ch]); se=0; ss=0; } else if ($1=="@section") {maxss[ch,se]=ss; se++; for (i=2;i<=NF;i++) sectionname[ch,se] = (sectionname[ch,se] " " $i); sectionname[ch,se] = removebadchars(sectionname[ch,se]); ss=0 } else if ($1=="@subsection") {ss++; for (i=2;i<=NF;i++) subsectionname[ch,se,ss] = (subsectionname[ch,se,ss] " " $i); subsectionname[ch,se,ss] = removebadchars(subsectionname[ch,se,ss]); } } # End of while loop (obtains chapter,section,subsection names to implement nodes) close(TMP1); maxch=ch; ch=0; se=0; ss=0; print "@node top, " chaptername[1] ", (dir), (dir) \n\n"; while (getline