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["AllocMem()"] = "AllocMem()"; special_items["AllocVec()"] = "AllocVec()"; special_items["FreeMem()"] = "FreeMem()"; special_items["FreeVec()"] = "FreeVec()"; special_items["CreatePort()"] = "CreatePort()"; special_items["CreateMsgPort()"] = "CreateMsgPort()"; special_items["DeletePort()"] = "DeletePort()"; special_items["DeleteMsgPort()"] = "DeleteMsgPort()"; special_items["PutMsg()"] = "PutMsg()"; special_items["GetMsg()"] = "GetMsg()"; special_items["DoMethod()"] = "DoMethod()"; special_items["DoMethodA()"] = "DoMethodA()"; special_items["OpenWindow()"] = "OpenWindow()"; special_items["OpenWindowTags()"] = "OpenWindowTags()"; special_items["OpenWindowTagList()"] = "OpenWindowTagList()"; special_items["CloseWindow()"] = "CloseWindow()"; special_items["WindowToFront()"] = "WindowToFront()"; special_items["WindowToBack()"] = "WindowToBack()"; special_items["OpenScreen()"] = "OpenScreen()"; special_items["OpenScreenTags()"] = "OpenScreenTags()"; special_items["OpenScreenTagList()"] = "OpenScreenTagList()"; special_items["CloseScreen()"] = "CloseScreen()"; special_items["ScreenToFront()"] = "ScreenToFront()"; special_items["ScreenToBack()"] = "ScreenToBack()"; special_items["ReadArgs()"] = "ReadArgs()"; special_items["VPrintf()"] = "VPrintf()"; special_items["VFPrintf()"] = "VFPrintf()"; special_items["Open()"] = "Open()"; special_items["Close()"] = "Close()"; special_items["Read()"] = "Read()"; special_items["Write()"] = "Write()"; special_items["SMult64()"] = "SMult64()"; special_files["exec/lists.h"] = "exec/lists.h"; special_files["intuition/intuition.h"] = "intuition/intuition.h"; cmd="date \"+%d %b %Y\"" cmd | getline today; close (cmd); if (ARGC==2) { fninfo="gen/"ARGV[1]; gsub(/.src$/,".info",fninfo); } else 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 "
\n
");
while ((getline line) > 0)
{
if (match(line,/\\end{example}/))
break;
else if (match(line,/\\link{.*}{.*}/))
{
printf ("%s", substr(line,1,RSTART-1));
yyrest=substr(line,RSTART+5,RLENGTH-5);
rest=substr(line,RSTART+RLENGTH);
match(yyrest,/^{[^}]*}/);
title=substr(yyrest,RSTART+1,RLENGTH-2);
link=substr(yyrest,RSTART+RLENGTH+1);
link=substr(link,1,length(link)-1);
printf (""title"%s\n", rest);
}
else
{
gsub(/&/,"\\&",line);
gsub(/,"\\<",line);
gsub(/>/,"\\>",line);
gsub(/"/,"\\"",line);
print line;
}
}
print "\n
"); yytext=""title""; } else if (yytext=="smallpic") { getarg(); file=yytext; if (showpar) printf ("\n
");
yytext="";
}
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""
}
else if (file in special_files)
file = special_files[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=="") { while (1) { if (getline yyrest <= 0) return ""; #EOF if (substr (yyrest,1,1) != "%") break; } 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); gsub(/"/,"\\"",yytext); return "text"; } else { if (yyrest=="") { if (!keeplf) { do { ret=getline yyrest; if (substr (yyrest,1,1) == "%") 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); gsub(/"/,"\\"",yytext); } return "text"; } } function getarg(token) { while ((token=yylex()) != "") { if (token=="arg") { #print "token=arg yytext=\""yytext"\"" >> "/dev/stderr"; return; } } print "Missing argument in "FILENAME":"FN"\n" >>"/dev/stderr"; exit 10; }