BEGIN { sp=0; skip=0; keeplf=0; lastwaslf=0; mode="text"; special_items["LONG"] = "LONG"; special_items["ULONG"] = "ULONG"; special_items["IPTR"] = "IPTR"; special_items["WORD"] = "WORD"; special_items["UWORD"] = "UWORD"; special_items["BYTE"] = "BYTE"; special_items["UBYTE"] = "UBYTE"; special_items["QUAD"] = "QUAD"; special_items["UQUAD"] = "UQUAD"; special_items["APTR"] = "APTR"; special_items["STACKLONG"] = "STACKLONG"; special_items["STACKULONG"] = "STACKULONG"; special_items["STACKIPTR"] = "STACKIPTR"; special_items["STACKWORD"] = "STACKWORD"; special_items["STACKUWORD"] = "STACKUWORD"; special_items["STACKBYTE"] = "STACKBYTE"; special_items["STACKUBYTE"] = "STACKUBYTE"; special_items["STACKQUAD"] = "STACKQUAD"; special_items["STACKUQUAD"] = "STACKUQUAD"; special_items["STACKFLOAT"] = "STACKFLOAT"; special_items["TagItem"] = "TagItem"; special_items["ti_Tag"] = "ti_Tag"; special_items["ti_Data"] = "ti_Data"; special_items["USER_TAG"] = "USER_TAG"; special_items["CreateRastPort()"] = "CreateRastPort()"; special_items["FreeRastPort()"] = "FreeRastPort()"; special_items["InitRastPort()"] = "InitRastPort()"; special_items["DeinitRastPort()"] = "DeinitRastPort()"; special_items["CloneRastPort()"] = "CloneRastPort()"; special_items["DoMethod()"] = "DoMethod()"; special_items["DoMethodA()"] = "DoMethodA()"; special_items["ReadArgs()"] = "ReadArgs()"; special_items["VPrintf()"] = "VPrintf()"; special_items["VFPrintf()"] = "VFPrintf()"; special_items["SMult64()"] = "SMult64()"; cmd="date \"+%d %b %Y\"" cmd | getline today; close (cmd); fninfo="gen/"ARGV[1]; gsub(/.src$/,".info",fninfo); toc=0; thischapter=""; if (fninfo!="") { while ((getline < fninfo) > 0) { if ($1=="prev") prev_doc=$2; else if ($1=="next") next_doc=$2; else if ($1=="toc") { a_toc[toc]=substr($0,5); n=split(a_toc[toc],a,":"); if (thischapter=="" && match(a[2],/\.$/)) thischapter=a[4]; toc ++; } } close (fninfo); } if (prev_doc!="") prev_doc="previous"; if (next_doc!="") next_doc="next"; if (fninfo!="") { file="page_header.html"; while ((getline < file) > 0) { gsub(/\\thischapter/,thischapter); print } close (file); } if (toc > 0) { print "
Table of Contents
" print "
    " level=0; for (t=0; t" level ++; } while (level > a[1]) { print "
" level --; } prefix=a[2]; no=a[3]; title=a[4]; print ""prefix" "title"" } while (level > 0) { print "" level --; } print "" print "


" } toc=0; while ((token=yylex()) != "") { if (token=="cmd") { if (yytext=="chapter") { getarg(); split(a_toc[toc],a,":"); yytext="\n\n

"a[2]" "yytext"

" skippar=1; toc++; } else if (yytext=="section") { getarg(); split(a_toc[toc],a,":"); yytext="\n\n

"a[2]" "yytext"

" skippar=1; toc++; } else if (yytext=="subsection") { getarg(); split(a_toc[toc],a,":"); yytext="\n\n

"a[2]" "yytext"

" skippar=1; toc++; } else if (yytext=="par") { if (skippar) { skippar = 0; yytext=""; } else { if (!keeplf) { yytext=""; showpar=1; } else { yytext="\n"; lastwaslf=1; skippar=0; } } } else if (yytext=="label") { getarg(); label=yytext; yytext=""; } else if (yytext=="lref") { getarg(); text=yytext; getarg(); label=yytext; found=0; while ((getline < "html.lab") > 0) { if ($1==label) { file=$2; found=1; break; } } close ("html.lab"); if (!found) yytext="!!!! Unknown label " label " !!!!"; else yytext=""text""; } else if (yytext=="begin") { stack[sp] = mode; sp ++; getarg(); mode=yytext; if (mode=="description") { yytext="\n\n
" } else if (mode=="itemize") { yytext="\n\n
" } else if (mode=="itemize") { yytext="\n" } else if (mode=="enumeration") { yytext="\n\n" } else if (mode=="emph") { yytext="\n\n"; } else if (mode=="example") { yytext=""; keeplf=0; } else yytext=""; sp --; mode=stack[sp]; } else if (yytext=="item") { if (mode=="description") { getarg(); gsub(/&/,"\\&",yytext); gsub(//,"\\>",yytext); gsub(/"/,"\\"",yytext); yytext="\n
"yytext"
" } else if (mode=="itemize") { yytext="\n
  • " } else if (mode=="enumeration") { yytext="\n
  • " } else yytext=""; } else if (yytext=="exec") { getarg(); gsub(/\$[(]TOP[)]/,TOP,yytext); cmd=yytext " | gawk -f src2html.gawk --assign TOP=\""TOP"\""; while ((cmd | getline) > 0) print; close (cmd); yytext=""; } else if (yytext=="execverb") { getarg(); gsub(/\$[(]TOP[)]/,TOP,yytext); cmd=yytext; while ((cmd | getline) > 0) print; close (cmd); yytext=""; } else if (yytext=="largepic") { getarg(); title=yytext; getarg(); file=yytext; if (showpar) printf ("\n

    "); yytext=""title""; } else if (yytext=="bold") { getarg(); yytext=""yytext""; } else if (yytext=="italics") { getarg(); yytext=""yytext""; } else if (yytext=="shell") { getarg(); yytext=""yytext""; } else if (yytext=="email") { getarg(); yytext=""yytext""; } else if (yytext=="filename") { getarg(); file=yytext; if (!match(file,/\$/)) { if (match(file,/^[a-zA-Z]+/)) { prefix=substr(file,RSTART,RLENGTH); if (prefix=="AROS") { file=""file"" } } } yytext="" file ""; } else if (yytext=="link") { getarg(); title=yytext; getarg(); link=yytext; yytext=""title""; } else { yytext="\n\n!!!!!!!!\n Unknown cmd: \"" yytext "\"\n!!!!!!!\n\n" } } else if (token=="code") { if (yytext in special_items) yytext=special_items[yytext]; yytext="" yytext ""; } else if (token=="text") { if (showpar && !skippar) { if (mode=="text") { gsub(/[ \t\n]+/," ",yytext); if (yytext != " ") { showpar=0; printf ("\n

    "); } } } if (mode=="example") { if (lastwaslf) { lastwaslf=0; #gsub(/^[ \t]+/,"",yytext); } } } printf ("%s", yytext); } # while print "" if (fninfo!="") { file="page_footer.html"; while ((getline < file) > 0) { gsub(/\\prev/,prev_doc); gsub(/\\next/,next_doc); gsub(/\\today/,today); print } } } function yylex() { if (yyrest=="") { if (getline yyrest <= 0) return ""; #EOF if (yyrest!="") yyrest=yyrest " "; if (keeplf) { yytext="par"; return "cmd"; } } if (match(yyrest,/^\\[a-z]+/)) { yytext=substr(yyrest,RSTART+1,RLENGTH-1); yyrest=substr(yyrest,RSTART+RLENGTH); return "cmd"; } else if (match(yyrest,/^\\\\/)) { yytext="\\"; yyrest=substr(yyrest,3); return "text"; } else if (match(yyrest,/^\|[^\|]+\|/)) { yytext=substr(yyrest,RSTART+1,RLENGTH-2); yyrest=substr(yyrest,RSTART+RLENGTH); return "code"; } else if (match(yyrest,/^{[^}]*}/)) { yytext=substr(yyrest,RSTART+1,RLENGTH-2); yyrest=substr(yyrest,RSTART+RLENGTH); return "arg"; } else if (match(yyrest,/^[^\\\|{]+/)) { yytext=substr(yyrest,RSTART,RLENGTH); yyrest=substr(yyrest,RSTART+RLENGTH); gsub(/&/,"\\&",yytext); gsub(//,"\\>",yytext); gsub(/"/,"\\"",yytext); return "text"; } else { if (yyrest=="") { if (!keeplf) { do { ret=getline yyrest; } while (yyrest=="" && ret>0); if (ret<=0) return ""; yyrest=yyrest " "; } yytext="par"; return "cmd"; } yytext=substr(yyrest,1,1); yyrest=substr(yyrest,2); # multiline if (yytext=="|") { } else if (yytext=="{") { } else { gsub(/&/,"\\&",yytext); gsub(//,"\\>",yytext); gsub(/"/,"\\"",yytext); } return "text"; } } function getarg(token) { while ((token=yylex()) != "") { if (token=="arg") return; } print "Missing argument in "FILENAME":"FN"\n" >>"/dev/stderr"; exit 10; }