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 >
OS/2 REXX Batch file  |  1995-03-23  |  2KB  |  64 lines

  1. /*
  2.  * Convert Bibtex to C.
  3.  */
  4.  
  5. Parse Arg PASCALFILE CFILE .
  6.  
  7. If "" = PASCALFILE Then
  8.   Exit 1
  9. If "" = CFILE Then
  10.   Exit 1
  11.  
  12. NL = '0A'X
  13.  
  14. SEDSCRIPTNAME1 = 'amiga_script1.sed'
  15. SEDSCRIPTNAME2 = 'amiga_script2.sed'
  16.  
  17. /*
  18.  * Prepare the SED scripts.
  19.  */
  20. SED1 =         '1a\'                                                 || NL
  21. SED1 = SED1 || '\#include \<setjmp.h\> \'                            || NL
  22. SED1 = SED1 || 'jmp_buf jmp9998, jmp32; int lab31=0;'                || NL
  23. SED1 = SED1 || 's/goto lab31 ; /{lab31=1; return;}/'                 || NL
  24. SED1 = SED1 || 's/goto lab32/longjmp(jmp32,1)/'                      || NL
  25. SED1 = SED1 || 's/goto lab9998/longjmp(jmp9998,1)/g'                 || NL
  26. SED1 = SED1 || 's/lab31://'                                          || NL
  27. SED1 = SED1 || 's/lab32://'                                          || NL
  28. SED1 = SED1 || 's/hack1 () ;/if(setjmp(jmp9998)==1) goto lab9998;'
  29. SED1 = SED1 || 'if(setjmp(jmp32)==0)while(true)/'                    || NL
  30. SED1 = SED1 || 's/hack2 ()/break/'                                   || NL
  31. SED1 = SED1 || '/^void main_body/,$s/while ( true/while ( lab31==0/'
  32. If ~Open('output',SEDSCRIPTNAME1,'Write') Then Do
  33.   Say "Can't open file `" || SEDSCRIPTNAME1 || "'"
  34.   Exit 10
  35. End
  36. Call WriteLn('output',SED1)
  37. Call Close('output')
  38.  
  39. SED2 =         's/(buftype)//g' || NL
  40. SED2 = SED2 || 's/(pdstype)//g'
  41. If ~Open('output',SEDSCRIPTNAME2,'Write') Then Do
  42.   Say "Can't open file `" || SEDSCRIPTNAME2 || "'"
  43.   Exit 10
  44. End
  45. Call WriteLn('output',SED2)
  46. Call Close('output')
  47.  
  48. /*
  49.  * OK, off we go!
  50.  */
  51. Address Command
  52.  
  53. "type ../lib/common.defines" PASCALFILE "> temp_1"
  54. "../web2c/web2c -handycpascal.h < temp_1 > temp_2"
  55. "sed -f" SEDSCRIPTNAME1 "< temp_2 > temp_3"
  56. "../web2c/fixwrites < temp_3 >" CFILE
  57.  
  58. "sed -f" SEDSCRIPTNAME2 "< coerce.h > xcoerce.h"
  59. "copy xcoerce.h coerce.h"
  60.  
  61. "delete quiet xcoerce.h temp_?" SEDSCRIPTNAME1 SEDSCRIPTNAME2
  62.  
  63. Exit 0
  64.