home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dream 45
/
Amiga_Dream_45.iso
/
Amiga
/
Magazine
/
Dossier-LaTeX
/
AmiWeb2C.lha
/
source
/
web2c-6.1
/
web2c
/
bibtex
/
convert.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1995-03-23
|
2KB
|
64 lines
/*
* Convert Bibtex to C.
*/
Parse Arg PASCALFILE CFILE .
If "" = PASCALFILE Then
Exit 1
If "" = CFILE Then
Exit 1
NL = '0A'X
SEDSCRIPTNAME1 = 'amiga_script1.sed'
SEDSCRIPTNAME2 = 'amiga_script2.sed'
/*
* Prepare the SED scripts.
*/
SED1 = '1a\' || NL
SED1 = SED1 || '\#include \<setjmp.h\> \' || NL
SED1 = SED1 || 'jmp_buf jmp9998, jmp32; int lab31=0;' || NL
SED1 = SED1 || 's/goto lab31 ; /{lab31=1; return;}/' || NL
SED1 = SED1 || 's/goto lab32/longjmp(jmp32,1)/' || NL
SED1 = SED1 || 's/goto lab9998/longjmp(jmp9998,1)/g' || NL
SED1 = SED1 || 's/lab31://' || NL
SED1 = SED1 || 's/lab32://' || NL
SED1 = SED1 || 's/hack1 () ;/if(setjmp(jmp9998)==1) goto lab9998;'
SED1 = SED1 || 'if(setjmp(jmp32)==0)while(true)/' || NL
SED1 = SED1 || 's/hack2 ()/break/' || NL
SED1 = SED1 || '/^void main_body/,$s/while ( true/while ( lab31==0/'
If ~Open('output',SEDSCRIPTNAME1,'Write') Then Do
Say "Can't open file `" || SEDSCRIPTNAME1 || "'"
Exit 10
End
Call WriteLn('output',SED1)
Call Close('output')
SED2 = 's/(buftype)//g' || NL
SED2 = SED2 || 's/(pdstype)//g'
If ~Open('output',SEDSCRIPTNAME2,'Write') Then Do
Say "Can't open file `" || SEDSCRIPTNAME2 || "'"
Exit 10
End
Call WriteLn('output',SED2)
Call Close('output')
/*
* OK, off we go!
*/
Address Command
"type ../lib/common.defines" PASCALFILE "> temp_1"
"../web2c/web2c -handycpascal.h < temp_1 > temp_2"
"sed -f" SEDSCRIPTNAME1 "< temp_2 > temp_3"
"../web2c/fixwrites < temp_3 >" CFILE
"sed -f" SEDSCRIPTNAME2 "< coerce.h > xcoerce.h"
"copy xcoerce.h coerce.h"
"delete quiet xcoerce.h temp_?" SEDSCRIPTNAME1 SEDSCRIPTNAME2
Exit 0