home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fonts 1 / freshfonts1.bin / bbs / programs / amiga / pastex13.lha / DVIPS / dvips5519.lha / dvips / vmcms / dvips.exec < prev    next >
Text File  |  1992-11-15  |  8KB  |  228 lines

  1. /* DVIPS exec:                                            */
  2. /* This is version 2.0 as of 9 Nov. 1992.                 */
  3. /* Written by Jim Hafner (hafner@almaden.ibm.com).        */
  4. /*                                                        */
  5. /* Command is:                                            */
  6. /*    DVIPS dvifilename -options                          */
  7. /*                                                        */
  8. /* For a list of options type:                            */
  9. /*    DVIPS                                               */
  10.  
  11. /* END OF HEADER (this line must be preceded by a blank line) */
  12.  
  13. /* This is part of the VM/CMS distribution of Rokicki's DVIPS program.
  14.  * Installers may need to customize this exec extensively, though we
  15.  * have tried to make it as generic as possible.
  16.  *
  17.  * You are welcome to modify this exec in any way you choose.
  18.  *
  19.  * See the file README VMCMS for more comments about the VMCMS
  20.  * version of DVIPS and for some suggestions on modifying this EXEC.
  21.  *
  22.  * One suggestion for modifying this exec is to scan the arguments
  23.  * looking for the -P PRINTER option.  You can use this to access
  24.  * specific font disks for different printers, either by matching
  25.  * the printer with a disk or reading the config.PRINTER file
  26.  * for the 'M' (metafont mode) option and using that.
  27.  *
  28.  * This exec calls the DVIPS module with the appropriate libraries
  29.  * linked.  It assumes   (SITE DEPENDENCIES)
  30.  *   -- your font disks are linked
  31.  *   -- your syntax is Unix-like
  32.  *
  33.  * 11/9/92:  Modified significantly by J. Hafner to add
  34.  *   -- VM/CMS or Unix-like file name descriptors (the on-line
  35.  *      help in the code also shows this).
  36.  *   -- Note, dvifilename MUST be the first (not the last) command
  37.  *      line argument for this exec to work.
  38.  *   -- enhanced the TXTLIB and LOADLIB save and restore mechanism
  39.  *      to handle large libraries.
  40.  *   -- Now we do automatic font generation outside of the main
  41.  *      module.  After the DVIPS MODULE has finished, this exec
  42.  *      checks for a newly created MISSFONT LOG file.  If it exists,
  43.  *      it prompts to see if the user wants to try to generate the
  44.  *      missing fonts.  To do that, it queues the lines in MISSFONT LOG
  45.  *      and 'EXEC's them, one by one.
  46.  *   -- We have returned system call inside the code for font generation
  47.  *      but we prevent this within this EXEC by adding the '-M' option
  48.  *      when DVIPS MODULE is called.   Installers can remove this
  49.  *      option if their versions of MF and GFtoPK can run with DVIPS
  50.  *      still in memory.  Using the '-M0' option from the command line
  51.  *      will also work.
  52.  *
  53.  * THANKS:
  54.  *   Many thanks to Ronald Kappert (R.Kappert@uci.kun.nl) for sending
  55.  *   me many suggestions to enhance the support for this program.
  56.  *   Also, Michel Goossens (goossens@cernvm.cern.ch) for other ideas
  57.  *   and helping with the testing.
  58.  */
  59. Address 'COMMAND';
  60. parse source . . execfn execft execfm .
  61. Trace 'ON'
  62.  
  63. /* Note: in the on-line help in the code, we have set the
  64.          command line syntax to always put the filename information
  65.          first.  It is NOT forced by the MODULE itself, but this
  66.          EXEC will get confused otherwise. */
  67. Parse Arg fn ft fm " -"Args
  68. If ( fn = '' | fn = '?' | fn = '-?' | Args = '?') then signal Help;
  69.  
  70. If ft = '' then ft='DVI'
  71. If fm = '' then fm='*'
  72.  
  73. /* If filename has a '.' in it, we assume that the name is given using
  74.    Unix-style naming conventions so we use that.  Otherwise we build
  75.    it in this form from the fn, ft, fm. */
  76. If Index(fn,'.') ^= 0 then
  77.       Infn = fn
  78.    else
  79.       Infn = fn'.'ft'.'fm
  80.  
  81. Upper Infn
  82.  
  83. If Args ^= '' then Args = '-'Args
  84.  
  85. /* remove any existing MISSFONT LOG A files */
  86. 'ESTATE MISSFONT LOG A'
  87. If rc = 0 then 'ERASE MISSFONT LOG A'
  88.  
  89. call resetLibs       /* reset libraries for DVIPS */
  90.  
  91. /* Now call the real thing; note the prepending of -M option
  92.    to prevent system calls for automatic font generation.
  93.    This can be removed if it is safe to do so
  94.    or it can be overriden at the command line with -M0 option */
  95.  
  96. 'DVIPS' Infn '-M' Args
  97.  
  98. call restoreLibs     /* Restore old libraries */
  99.  
  100. /* Now we see if any missing fonts were found and we ask the user
  101.    if they want us to try to generate them at this point */
  102.  
  103. failedfont = 0  /* this will be changed to 1 if MakeTeXPK fails */
  104. 'ESTATE MISSFONT LOG A'
  105. if rc = 0 then do   /* I'd like to Clear-Screen for this but ... */
  106.    call MissFontPrompt ;  /* we only come back if Yes */
  107.    'MAKEBUF'
  108.    'EXECIO * DISKR MISSFONT LOG A (FINIS'
  109.    cnt=queued()
  110. /* we erase MISSFONT LOG now and rebuild it if there are failures */
  111.    'ERASE MISSFONT LOG A'
  112.    do i=1 to cnt
  113.       parse pull line
  114.       parse var line EXEC mktxpk fontdata
  115.       upper mktxpk
  116. /* now we exec the MakeTeXPK command given by this line */
  117.       EXEC mktxpk fontdata
  118.          if rc ^= 0 then do
  119.            call failfontmsg fontdata
  120.            failedfont = 1 ;
  121.            'EXECIO 1 DISKW MISSFONT LOG A (STR' line
  122.            end
  123.       end
  124.      'DROPBUF'
  125.      'FINIS MISSFONT LOG A'
  126.    if failedfont = 1 then call fontfail
  127.       else call redoDvipsPrompt Infn Args
  128.    end /* rc = 0 from 'ESTATE MISSFONT LOG' */
  129.  
  130. Exit ;
  131.  
  132.  
  133. Savelibs: procedure
  134.    arg library
  135.    'MAKEBUF';
  136.    tmplibs = ''
  137.    'QUERY' library '(STACK'
  138.    do i = 1 to queued()
  139.      pull Mode Eq_sign Tmptmplibs
  140.      if Tmptmplibs = 'NONE' then tmplibs = ''
  141.         else tmplibs = tmplibs Tmptmplibs
  142.    end;
  143.    'DROPBUF';
  144.    return tmplibs  ;
  145.  
  146. resetLibs:
  147.    /* get current status of library settings */
  148.    Txtlibs=Savelibs(TXTLIB)
  149.    Loadlibs=Savelibs(LOADLIB)
  150.    /* Establish environment for dvips */
  151.    'GLOBAL TXTLIB IBMLIB EDCBASE'
  152.    'GLOBAL LOADLIB EDCLINK'
  153.    return ;
  154.  
  155. restoreLibs:
  156.    'GLOBAL TXTLIB' Txtlibs
  157.    'GLOBAL LOADLIB' Loadlibs
  158.    return ;
  159.  
  160. MissFontPrompt:
  161.    say ''
  162.    say 'One or more fonts were missing when DVIPS processed your'
  163.    say 'file 'Infn'.'
  164.    say 'Do you want to generate them now? (Please respond with'
  165.    say '"y", "yes", "n" or "no" -- these are case insensitive.)'
  166.    pull answer
  167.    answer = 'SUBSTR'(answer,1,1) ;
  168.    if ( answer ^= "Y" & answer ^= "N" ) then answer=BadReply() ;
  169.    if answer = "N" then call MissFontReplyN ;
  170.    return ;   /* answer was a 'Y' so we can return */
  171.  
  172. BadReply:
  173.    say "What did you say? It wasn't one of the choices!"
  174.    say 'Please try again and respond with "y", "yes", "n" or "no"'
  175.    pull answer
  176.    answer = 'SUBSTR'(answer,1,1) ;
  177. /* we keeping asking until we get a 'yes' or 'no'.  Maybe we should
  178.    put a counter on this? */
  179.    if ( answer ^= "Y" & answer ^= "N" ) then answer=BadReply() ;
  180.    return answer ;
  181.  
  182. MissFontReplyN:
  183.    say "I'll save the MISSFONT LOG file so you can run"
  184.    say "MAKETEXP EXEC yourself.  If you don't want to do that,"
  185.    say "you may want to erase this file."
  186.    exit 0
  187.  
  188. failfontmsg:
  189.    arg MissFontData
  190.    say " "
  191.    say "I failed to complete a call to MAKETEXP EXEC for fontdata"
  192.    say "     "MissFontData"."
  193.    say " "
  194.    return ;
  195.  
  196. fontfail:
  197.    say "I failed to generate all the necessary fonts and so"
  198.    say "will exit now.  You can use the MISSFONT LOG file to"
  199.    say "try to correct the problem."
  200.    exit 10
  201.  
  202. redoDvipsPrompt:
  203.    arg Infn Args
  204.    say "I've tried to generate all the fonts that were missing as"
  205.    say "you requested.  Another call to DVIPS might be in order."
  206.    say "Do you want me to do that NOW?"
  207.    pull redoDvipsReply
  208.    if 'ABBREV'(redoDvipsReply,"Y",1) then do
  209. /* we call the module here instead of the exec since we don't want to
  210.  * get into some silly loop trying to create fonts that we are failing
  211.  * to generate; be sure '-M' flag is set here. We also have to get the
  212.  * libraries restored. */
  213.          call resetLibs ;
  214.          'DVIPS' Infn Args '-M' ;
  215.          dvipsrc = rc ;
  216.          call restoreLibs ;
  217.          exit dvipsrc ;
  218.          end
  219.       else exit 0
  220.  
  221. Help:
  222. /* dvips now has on-line help if called with no filename */
  223.   call resetLibs ;
  224.   'DVIPS' ;
  225.   call restoreLibs ;
  226.   Exit 100;
  227.  
  228.