Bringing ChocolateCaste-0.7 into the main branch.
[AROS-Contrib.git] / bgui / RexxBGUI / makedoc.e
blobc1f8e0ed06331ead865b477a71e5815a7902c164
2 CONST ZERO=0
4 ENUM ERR_NONE,ERR_ARGS,ERR_OPEN
6 RAISE ERR_ARGS IF ReadArgs()=NIL,
7 ERR_OPEN IF Open()=ZERO
9 PROC main() HANDLE
10 DEF rda=NIL,in=ZERO,out=ZERO,str[257]:STRING,c,q,tprefix[10]:STRING,n
11 DEF a[2]:ARRAY OF LONG
12 rda:=ReadArgs('FROM/A,TO/A',a,NIL)
13 in:=Open(a[0],OLDFILE)
14 out:=Open(a[1],NEWFILE)
15 WHILE Fgets(in,str,256)
16 IF StrCmp(str,'\t\t/* ',STRLEN)
17 Fputs(out,'\n\e[1m')
18 Fputs(out,str+STRLEN)
19 Fputs(out,'\e[22m\n')
20 ELSEIF StrCmp(str,'\t\t-> ',STRLEN)
21 Fputs(out,str+STRLEN)
22 ELSEIF StrCmp(str,'\t\t->\n')
23 FputC(out,"\n")
24 ELSEIF StrCmp(str,'-> ',STRLEN)
25 Fputs(out,str+STRLEN)
26 ELSEIF StrCmp(str,'->\n')
27 FputC(out,"\n")
28 ELSEIF StrCmp(str,'\tELSEIF stricmp(first,\a',STRLEN)
29 q:=str+STRLEN
30 StrCopy(tprefix,'')
31 WHILE (c:=q[]++)<>"'" AND c DO StrAdd(tprefix,{c}+3,1)
32 VfPrintf(out,'\n\e[1m\s_#? TAGS\e[22m\n\n',[tprefix])
33 ELSEIF StrCmp(str,'\t\t\t\a',STRLEN)
34 q:=str+STRLEN
35 Fputs(out,tprefix)
36 FputC(out,"_")
37 n:=EstrLen(tprefix)+1
38 WHILE (c:=q[]++)<>"'" AND c DO FputC(out,c) BUT n++
39 WHILE n<30 DO FputC(out," ") BUT n++
40 n:=0
41 q:=str+InStr(str,'TAG_')+STRLEN
42 WHILE (c:=q[]++)<>"," AND c DO FputC(out,c) BUT n++
43 IF (q:=str+InStr(str,'->'))>str
44 WHILE n<6 DO FputC(out," ") BUT n++
45 q:=q+STRLEN
46 WHILE (c:=q[]++)<>"\n" AND c DO FputC(out,c)
47 ENDIF
48 FputC(out,"\n")
49 ENDIF
50 ENDWHILE
51 EXCEPT DO
52 Close(out)
53 Close(in)
54 IF rda THEN FreeArgs(rda)
55 SELECT exception
56 CASE ERR_ARGS; PrintFault(IoErr(),'MakeDoc cannot read args')
57 CASE ERR_OPEN; PrintFault(IoErr(),'MakeDoc cannot open file')
58 ENDSELECT
59 ENDPROC