*** ./web2c/doc/install.t~0	Thu Feb  6 18:48:32 1997
--- ./web2c/doc/install.texi	Thu May 29 13:26:54 1997
***************
*** 87,94 ****
  
  For a description of the generic options (which mainly allow you to
  specify installation directories) and basic @code{configure} usage,
! @pxref{Invoking configure,, Running @code{configure} scripts, autoconf,
! Autoconf} (a copy is in the file @file{kpathsea/CONFIGURE}).
  
  @table @samp
  @item --disable-dump-share
--- 87,94 ----
  
  For a description of the generic options (which mainly allow you to
  specify installation directories) and basic @code{configure} usage,
! @ref{Invoking configure,, Running @code{configure} scripts, autoconf,
! Autoconf}.  (A copy is in the file @file{kpathsea/CONFIGURE}.)
  
  @table @samp
  @item --disable-dump-share
*** ./web2c/lib/texmfmp.c~0	Tue Feb  4 01:01:56 1997
--- ./web2c/lib/texmfmp.c	Tue Jun  3 18:56:16 1997
***************
*** 13,18 ****
--- 13,19 ----
     Makefile rule.  */
  #include "TEX-OR-MF-OR-MPd.h"
  
+ #include <kpathsea/config.h>
  #include <kpathsea/c-ctype.h>
  #include <kpathsea/line.h>
  #include <kpathsea/readable.h>
*************** static string dump_name;
*** 90,95 ****
--- 91,101 ----
  /* The main body of the WEB is transformed into this procedure.  */
  extern void mainbody ();
  
+ #ifdef TeX
+ /* Non-zero if the user mentions -extend-jobname explicitly.  */
+ static int extendjobname_used;
+ #endif
+ 
  static void maybe_set_dump_default_from_input P1H(string *);
  static void parse_options P2H(int, string *);
  
*************** main P2C(int, ac,  string *, av)
*** 124,129 ****
--- 130,160 ----
       below, and because we have to do this before any path searching.  */
    kpse_set_progname (user_progname ? user_progname : argv[0]);
  
+ #ifdef TeX
+ #if (defined (__MSDOS__) || defined (WIN32)) && defined (_PC_NAME_MAX)
+   /* FAT (not VFAT!) volumes don't allow more than a single dot in
+      the basename of a file.  For these we disallow "always" and
+      "maybe", and make the program always behave as with "never".
+ 
+      For this to work, their `pathconf' be better good, or they will
+      be surprised!  (DJGPP's `pathconf' works as advertised.)  */
+   if (pathconf (optind < argc
+ 		&& argv[optind][0] != '\\' && argv[optind][0] != '&'
+ 		? argv[optind]
+ 		: ".",
+ 		_PC_NAME_MAX) <= 12)
+     {
+       if (extendjobname == 1 || extendjobname == 2) {
+ 	if (extendjobname_used || extendjobname == 2)
+ 	  WARNING ("-extend-jobname=always/maybe are not supported for this filesystem");
+ #if 0
+ 	extendjobname = 0;
+ #endif
+       }
+     }
+ #endif
+ #endif
+ 
    /* If no dump default yet, and we're not doing anything special on
       this run, look at the first line of the main input file for a
       %&<dumpname> specifier.  */
*************** main P2C(int, ac,  string *, av)
*** 136,148 ****
    if (readyalready != 314159) {
      /* The `ini_version' variable is declared/used in the change files.  */
      boolean virversion = false;
!     if (STREQ (program_invocation_short_name, INI_PROGRAM)) {
        iniversion = true;
!     } else if (STREQ (program_invocation_short_name, VIR_PROGRAM)) {
        virversion = true;
      } 
  #ifdef TeX
!       else if (STREQ (program_invocation_short_name, "mltex")) {
        mltexp = true;
      }
  #endif /* TeX */
--- 167,179 ----
    if (readyalready != 314159) {
      /* The `ini_version' variable is declared/used in the change files.  */
      boolean virversion = false;
!     if (FILESTRCASEEQ (program_invocation_short_name, INI_PROGRAM)) {
        iniversion = true;
!     } else if (FILESTRCASEEQ (program_invocation_short_name, VIR_PROGRAM)) {
        virversion = true;
      } 
  #ifdef TeX
!       else if (FILESTRCASEEQ (program_invocation_short_name, "mltex")) {
        mltexp = true;
      }
  #endif /* TeX */
*************** parse_options P2C(int, argc,  string *, 
*** 628,633 ****
--- 659,665 ----
  #ifdef TeX
      } else if (ARGUMENT_IS ("extend-jobname")) {
        /* These numbers match @d's in tex.ch.  */
+       extendjobname_used = 1;
        if (STREQ (optarg, "never")) {
          extendjobname = 0;
        } else if (STREQ (optarg, "maybe")) {
*************** openoutnameok P1C(const_string, fname)
*** 744,750 ****
    string openout_any = kpse_var_value ("openout_any");
    if (!(openout_any && *openout_any && *openout_any != 'n'
           && *openout_any != '0')) {
! #ifdef unix
      const_string base = basename (fname);
      /* Disallow .rhosts, .login, etc.  Allow .tex (for LaTeX).  */
      if (*base == 0 || (*base == '.' && !STREQ (base, ".tex"))) {
--- 776,783 ----
    string openout_any = kpse_var_value ("openout_any");
    if (!(openout_any && *openout_any && *openout_any != 'n'
           && *openout_any != '0')) {
!     /* Using unix alone is bad idea.  DJGPP defines it.  */
! #if defined (unix) && !defined (MSDOS)
      const_string base = basename (fname);
      /* Disallow .rhosts, .login, etc.  Allow .tex (for LaTeX).  */
      if (*base == 0 || (*base == '.' && !STREQ (base, ".tex"))) {
*************** initscreen P1H(void)
*** 1477,1483 ****
  #ifdef AMIGA
        tty_type = "amiterm";
  #else /* not AMIGA */
! #if defined (OS2) || defined (WIN32)
        tty_type = "mftalk";
  #else /* not (OS2 or WIN32) */
        /* If DISPLAY is set, we are X11; otherwise, who knows.  */
--- 1510,1516 ----
  #ifdef AMIGA
        tty_type = "amiterm";
  #else /* not AMIGA */
! #if defined (OS2) || defined (WIN32) || defined (__DJGPP__)
        tty_type = "mftalk";
  #else /* not (OS2 or WIN32) */
        /* If DISPLAY is set, we are X11; otherwise, who knows.  */
*************** initscreen P1H(void)
*** 1489,1495 ****
        if (tty_type == NULL
            || (!STREQ (tty_type, "trap") && !isatty (fileno (stdout))))
          return 0;
! #endif /* not (OS2 or WIN32) */
  #endif /* not AMIGA */
    }
  
--- 1522,1528 ----
        if (tty_type == NULL
            || (!STREQ (tty_type, "trap") && !isatty (fileno (stdout))))
          return 0;
! #endif /* not (OS2 or WIN32 or __DJGPP__) */
  #endif /* not AMIGA */
    }
  
*** ./web2c/mpware/dmp.c~0	Tue Dec 10 23:58:54 1996
--- ./web2c/mpware/dmp.c	Thu May  8 15:16:40 1997
*************** FILE *fsearch(nam, ext, format)
*** 197,204 ****
      FILE *f = NULL;
      
      string fname = kpse_find_file (nam, format, true);
      if (fname) {
!       f = xfopen (fname, FOPEN_R_MODE);
      }
      if (f==NULL) quit("Cannot find ",nam,ext);
      return f;
--- 197,220 ----
      FILE *f = NULL;
      
      string fname = kpse_find_file (nam, format, true);
+     /* Need to know which formats require binary input.
+        This was shamelessly stolen from `kpse_open_file'.  */
+     const_string mode = format == kpse_gf_format 
+                         || format == kpse_ocp_format
+        	                || format == kpse_ofm_format
+                         || format == kpse_ovf_format
+                         || format == kpse_tfm_format
+                         || format == kpse_vf_format
+                         || format == kpse_tex_ps_header_format
+ 			|| format == kpse_pk_format
+ 			|| format == kpse_base_format
+ 			|| format == kpse_fmt_format
+ 			|| format == kpse_mem_format
+ 			|| format == kpse_pict_format
+                         ? FOPEN_RBIN_MODE : FOPEN_R_MODE;
+ 
      if (fname) {
!       f = xfopen (fname, mode);
      }
      if (f==NULL) quit("Cannot find ",nam,ext);
      return f;
*** ./web2c/mpware/makempx.i~0	Fri Feb  7 20:40:28 1997
--- ./web2c/mpware/makempx.in	Sun Jun 15 18:34:38 1997
***************
*** 138,144 ****
      else
        # failure
        mv -f mpx$$.i $TROFF_INERR
!       echo "$0: Command failed: cat $TROFFERR | $TROFF" >&2
        rm -f mpx$$.t
        exit 2
      fi
--- 138,144 ----
      else
        # failure
        mv -f mpx$$.i $TROFF_INERR
!       echo "$0: Command failed: cat $TROFF_INERR | $TROFF" >&2
        rm -f mpx$$.t
        exit 2
      fi
*** ./web2c/web2c/Makefile.i~0	Fri Feb  7 20:40:16 1997
--- ./web2c/web2c/Makefile.in	Tue Apr 29 17:19:30 1997
***************
*** 13,28 ****
  proglib = ../lib/lib.a
  programs = web2c fixwrites splitup
  
! web2c_objects = main.o y.tab.o $(LEX_OUTPUT_ROOT).o
  all: $(programs)
  web2c: $(web2c_objects)
  	$(kpathsea_link) $(web2c_objects) $(LEXLIB) $(LOADLIBES) 
  
! main.o: main.c y.tab.h
! y.tab.c y.tab.h: web2c.y
  	@echo Expect one shift/reduce conflict.
  	$(YACC) -d -v $(srcdir)/web2c.y
! $(LEX_OUTPUT_ROOT).o: y.tab.h
  $(LEX_OUTPUT_ROOT).c: web2c.l
  	$(LEX) $(srcdir)/web2c.l
  
--- 13,31 ----
  proglib = ../lib/lib.a
  programs = web2c fixwrites splitup
  
! web2c_objects = main.o y_tab.o $(LEX_OUTPUT_ROOT).o
  all: $(programs)
  web2c: $(web2c_objects)
  	$(kpathsea_link) $(web2c_objects) $(LEXLIB) $(LOADLIBES) 
  
! # Use y_tab.* for the sake of MS-DOS which doesn't allow multiple dots.
! main.o: main.c y_tab.h
! y_tab.c y_tab.h: web2c.y
  	@echo Expect one shift/reduce conflict.
  	$(YACC) -d -v $(srcdir)/web2c.y
! 	test -f	y_tab.c || mv -f y.tab.c y_tab.c
! 	test -f	y_tab.h || mv -f y.tab.h y_tab.h
! $(LEX_OUTPUT_ROOT).o: y_tab.h
  $(LEX_OUTPUT_ROOT).c: web2c.l
  	$(LEX) $(srcdir)/web2c.l
  
***************
*** 52,58 ****
  ac_include ../make/clean.make
  
  clean::
! 	rm -f y.tab.c y.tab.h y.output yacc.* $(LEX_OUTPUT_ROOT).c
  
  ac_include ../make/rdepend.make
  fixwrites.o: fixwrites.c ../config.h ../../kpathsea/config.h \
--- 55,61 ----
  ac_include ../make/clean.make
  
  clean::
! 	rm -f y_tab.c y_tab.h y.output yacc.* $(LEX_OUTPUT_ROOT).c
  
  ac_include ../make/rdepend.make
  fixwrites.o: fixwrites.c ../config.h ../../kpathsea/config.h \
***************
*** 65,71 ****
   ../../kpathsea/c-proto.h ../../kpathsea/debug.h \
   ../../kpathsea/types.h ../../kpathsea/lib.h ../../kpathsea/progname.h \
   ../../kpathsea/c-fopen.h ../../kpathsea/c-pathmx.h
! lex.yy.o: lex.yy.c \
   web2c.h ../config.h ../../kpathsea/config.h ../c-auto.h \
   ../../kpathsea/c-std.h \
   ../../kpathsea/c-unistd.h ../../kpathsea/systypes.h \
--- 68,74 ----
   ../../kpathsea/c-proto.h ../../kpathsea/debug.h \
   ../../kpathsea/types.h ../../kpathsea/lib.h ../../kpathsea/progname.h \
   ../../kpathsea/c-fopen.h ../../kpathsea/c-pathmx.h
! $(LEX_OUTPUT_ROOT).o: $(LEX_OUTPUT_ROOT).c \
   web2c.h ../config.h ../../kpathsea/config.h ../c-auto.h \
   ../../kpathsea/c-std.h \
   ../../kpathsea/c-unistd.h ../../kpathsea/systypes.h \
***************
*** 75,81 ****
   ../../kpathsea/c-limits.h \
   ../../kpathsea/c-proto.h ../../kpathsea/debug.h \
   ../../kpathsea/types.h ../../kpathsea/lib.h ../../kpathsea/progname.h \
!  ../../kpathsea/c-fopen.h y.tab.h
  main.o: main.c web2c.h ../config.h ../../kpathsea/config.h ../c-auto.h \
   ../../kpathsea/c-std.h \
   ../../kpathsea/c-unistd.h ../../kpathsea/systypes.h \
--- 78,84 ----
   ../../kpathsea/c-limits.h \
   ../../kpathsea/c-proto.h ../../kpathsea/debug.h \
   ../../kpathsea/types.h ../../kpathsea/lib.h ../../kpathsea/progname.h \
!  ../../kpathsea/c-fopen.h y_tab.h
  main.o: main.c web2c.h ../config.h ../../kpathsea/config.h ../c-auto.h \
   ../../kpathsea/c-std.h \
   ../../kpathsea/c-unistd.h ../../kpathsea/systypes.h \
***************
*** 85,91 ****
   ../../kpathsea/c-limits.h \
   ../../kpathsea/c-proto.h ../../kpathsea/debug.h \
   ../../kpathsea/types.h ../../kpathsea/lib.h ../../kpathsea/progname.h \
!  ../../kpathsea/c-fopen.h y.tab.h
  regfix.o: regfix.c ../config.h ../../kpathsea/config.h ../c-auto.h \
   ../../kpathsea/c-std.h \
   ../../kpathsea/c-unistd.h ../../kpathsea/systypes.h \
--- 88,94 ----
   ../../kpathsea/c-limits.h \
   ../../kpathsea/c-proto.h ../../kpathsea/debug.h \
   ../../kpathsea/types.h ../../kpathsea/lib.h ../../kpathsea/progname.h \
!  ../../kpathsea/c-fopen.h y_tab.h
  regfix.o: regfix.c ../config.h ../../kpathsea/config.h ../c-auto.h \
   ../../kpathsea/c-std.h \
   ../../kpathsea/c-unistd.h ../../kpathsea/systypes.h \
***************
*** 106,112 ****
   ../../kpathsea/c-proto.h ../../kpathsea/debug.h \
   ../../kpathsea/types.h ../../kpathsea/lib.h ../../kpathsea/progname.h \
   ../../kpathsea/c-fopen.h
! y.tab.o: y.tab.c web2c.h ../config.h ../../kpathsea/config.h \
   ../c-auto.h ../../kpathsea/c-std.h \
   ../../kpathsea/c-unistd.h ../../kpathsea/systypes.h \
   ../../kpathsea/c-memstr.h \
--- 109,115 ----
   ../../kpathsea/c-proto.h ../../kpathsea/debug.h \
   ../../kpathsea/types.h ../../kpathsea/lib.h ../../kpathsea/progname.h \
   ../../kpathsea/c-fopen.h
! y_tab.o: y_tab.c web2c.h ../config.h ../../kpathsea/config.h \
   ../c-auto.h ../../kpathsea/c-std.h \
   ../../kpathsea/c-unistd.h ../../kpathsea/systypes.h \
   ../../kpathsea/c-memstr.h \
*** ./web2c/web2c/main.c~0	Sat Nov 25 00:56:36 1995
--- ./web2c/web2c/main.c	Tue Apr 29 17:31:46 1997
***************
*** 15,21 ****
     was written by Tomas Rokicki, with modifications by Tim Morgan, et al. */
  
  #include "web2c.h"
! #include "y.tab.h"
  
  
  /* Changing this value will probably stimulate bugs in some
--- 15,21 ----
     was written by Tomas Rokicki, with modifications by Tim Morgan, et al. */
  
  #include "web2c.h"
! #include "y_tab.h"
  
  
  /* Changing this value will probably stimulate bugs in some
*** ./web2c/web2c/web2c.l~0	Mon Dec  9 00:07:30 1996
--- ./web2c/web2c/web2c.l	Tue Apr 29 17:32:52 1997
***************
*** 2,8 ****
  /* web2c.l -- lexical analysis for Tangle output.  Public domain.  */
  
  #include "web2c.h"
! #include "y.tab.h"
  
  /* For some reason flex wants to do a system call, so we must lose our
     definition of the Pascal read.  */
--- 2,8 ----
  /* web2c.l -- lexical analysis for Tangle output.  Public domain.  */
  
  #include "web2c.h"
! #include "y_tab.h"
  
  /* For some reason flex wants to do a system call, so we must lose our
     definition of the Pascal read.  */
*** ./web2c/cpascal.h~0	Sun Dec  8 23:51:00 1996
--- ./web2c/cpascal.h	Tue May  6 12:23:02 1997
***************
*** 93,101 ****
--- 93,108 ----
  
  /* So dvicopy can use stdin/stdout.  */
  #ifdef WIN32
+ #include <io.h>
  #define makebinaryfile(arg) (_setmode(fileno(arg), _O_BINARY), arg)
  #else
+ #ifdef __DJGPP__
+ #include <io.h>
+ /* Don't set console device to binary.  */
+ #define makebinaryfile(arg) ((!isatty(fileno(arg)) && setmode(fileno(arg), O_BINARY)), arg)
+ #else
  #define makebinaryfile(arg) (arg)
+ #endif
  #endif
  
  /* It's not worth fixing fixwrites to handle Pascal-style n:m write
*** ./web2c/doc/web2c.t~0	Thu Feb  6 18:56:40 1997
--- ./web2c/doc/web2c.texi	Tue Jun  3 18:39:26 1997
***************
*** 963,979 ****
  .drv .dtx .ins .ltx .tex .texi .texinfo .txi
  @end example
  @noindent
! then @TeX{} strips the extension; thus, @file{foo.tex}
  produces @file{foo.dvi}, but @file{foo.bar.tex} produces
  @file{foo.bar.dvi}.  
  
  @item never
! Never strip the extension: @file{foo.tex} produces @file{foo.tex.dvi}.
  
  @item always
! Always strip the extension: @file{foo.bar} produces @file{foo.dvi}.
! (This is the behavior of the original @TeX{} program.)
  @end table
  
  @item -ipc
  @itemx -ipc-start
--- 963,983 ----
  .drv .dtx .ins .ltx .tex .texi .texinfo .txi
  @end example
  @noindent
! then @TeX{} strips the extension, otherwise it keeps the original
! extension and appends @file{.dvi} to it; thus, @file{foo.tex}
  produces @file{foo.dvi}, but @file{foo.bar.tex} produces
  @file{foo.bar.dvi}.  
  
  @item never
! Never append the extension: @file{foo.bar} produces @file{foo.dvi}.
! (This is the behavior of the original @TeX{} program.)
  
  @item always
! Always append the extension: @file{foo.tex} produces @file{foo.tex.dvi}.
  @end table
+ 
+ On filesystems where only a single dot in the basename is allowed,
+ @TeX{} will complain if you request @samp{always} or @samp{maybe}.
  
  @item -ipc
  @itemx -ipc-start
*** ./web2c/doc/Makefile.i~0	Fri Feb  7 20:40:12 1997
--- ./web2c/doc/Makefile.in	Thu May 29 13:07:26 1997
***************
*** 49,55 ****
  install-exec:
  install-data: web2c.info
  	$(SHELL) $(top_srcdir)/../mkdirchain $(infodir)
! 	cd $(srcdir) && for i in web2c.info*; do \
  	  $(INSTALL_DATA) $$i $(infodir)/$$i; done
  	$(POSTINSTALL)
  	if $(SHELL) -c 'install-info --version' >/dev/null 2>&1; then \
--- 49,55 ----
  install-exec:
  install-data: web2c.info
  	$(SHELL) $(top_srcdir)/../mkdirchain $(infodir)
! 	cd $(srcdir) && for i in web2c.i*; do \
  	  $(INSTALL_DATA) $$i $(infodir)/$$i; done
  	$(POSTINSTALL)
  	if $(SHELL) -c 'install-info --version' >/dev/null 2>&1; then \
*** ./kpathsea/kpathsea.t~0	Fri Feb  7 00:46:10 1997
--- ./kpathsea/kpathsea.texi	Wed Apr 16 16:21:12 1997
***************
*** 356,362 ****
  Kpathsea supports additional features in search paths: layered default
  values, environment variable names, config file values, users' home
  directories, and recursive subdirectory searching.  Thus, we say that
! Kpathsea @dfn{expands} a path element, meaning transforming all thel
  magic specifications into the basic directory name or names.  This
  process is described in the sections below.  It happens in the same
  order as the sections.
--- 356,362 ----
  Kpathsea supports additional features in search paths: layered default
  values, environment variable names, config file values, users' home
  directories, and recursive subdirectory searching.  Thus, we say that
! Kpathsea @dfn{expands} a path element, meaning transforming all the
  magic specifications into the basic directory name or names.  This
  process is described in the sections below.  It happens in the same
  order as the sections.
***************
*** 768,774 ****
  @vindex st_nlink
  The trick is that in every real Unix implementation (as opposed to the
  POSIX specification), a directory which contains no subdirectories will
! have exactly two links (namely, one for @file{.} and one for @file{..}).
  That is to say, the @code{st_nlink} field in the @samp{stat} structure
  will be two.  Thus, we don't have to stat everything in the bottom-level
  (leaf) directories---we can just check @code{st_nlink}, notice it's two,
--- 768,775 ----
  @vindex st_nlink
  The trick is that in every real Unix implementation (as opposed to the
  POSIX specification), a directory which contains no subdirectories will
! have exactly two links (namely, one for the directory itself and one for
! @file{.}). 
  That is to say, the @code{st_nlink} field in the @samp{stat} structure
  will be two.  Thus, we don't have to stat everything in the bottom-level
  (leaf) directories---we can just check @code{st_nlink}, notice it's two,
*** ./kpathsea/c-fopen.h~0	Mon Oct 14 19:36:34 1996
--- ./kpathsea/c-fopen.h	Tue May  6 12:20:36 1997
***************
*** 37,43 ****
  #ifdef DOS
  #define FOPEN_RBIN_MODE "r+b"
  #else
! #if defined (VMS) || defined (VMCMS) || defined (OS2) || defined (WIN32)
  #define	FOPEN_RBIN_MODE	"rb"
  #else
  #define	FOPEN_RBIN_MODE	"r"
--- 37,43 ----
  #ifdef DOS
  #define FOPEN_RBIN_MODE "r+b"
  #else
! #if defined (VMS) || defined (VMCMS) || defined (OS2) || defined (WIN32) || defined (__DJGPP__)
  #define	FOPEN_RBIN_MODE	"rb"
  #else
  #define	FOPEN_RBIN_MODE	"r"
***************
*** 50,56 ****
  #ifdef DOS
  #define FOPEN_WBIN_MODE "w+b"
  #else
! #if defined (OS2) || defined (WIN32)
  #define FOPEN_WBIN_MODE "wb"
  #else
  #ifdef VMCMS
--- 50,56 ----
  #ifdef DOS
  #define FOPEN_WBIN_MODE "w+b"
  #else
! #if defined (OS2) || defined (WIN32) || defined (__DJGPP__)
  #define FOPEN_WBIN_MODE "wb"
  #else
  #ifdef VMCMS
***************
*** 61,65 ****
--- 61,97 ----
  #endif /* not (OS2 or WIN32) */
  #endif /* not DOS */
  #endif /* not FOPEN_WBIN_MODE */
+ 
+ /* How to open a binary file for appending:  */
+ #ifndef FOPEN_ABIN_MODE
+ # if defined (DOS) || defined (OS2) || defined (WIN32) || defined (__DJGPP__)
+ #  define FOPEN_ABIN_MODE "ab"
+ # else
+ #  define FOPEN_ABIN_MODE "a"
+ # endif /* not (DOS or OS2 or WIN32 or DJGPP) */
+ #endif /* not FOPEN_ABIN_MODE */
+ 
+ /* How to switch an already open file handle to binary mode.
+    Used on DOSISH systems when we need to switch a standard
+    stream, such as stdin or stdout, to binary mode.  */
+ #include <fcntl.h>
+ #ifdef DOSISH
+ # include <io.h>
+ # ifndef O_BINARY
+ #  ifdef _O_BINARY
+ #   define O_BINARY _O_BINARY
+ #  endif
+ # endif
+ # ifdef __DJGPP__
+ #  define SET_BINARY(f) setmode((f), O_BINARY)
+ # else
+ #  ifdef (WIN32)
+ #   define SET_BINARY(f) _setmode((f), O_BINARY)
+ #  endif
+ # endif
+ #else  /* not DOSISH */
+ # define O_BINARY 0
+ # define SET_BINARY(f) 0
+ #endif /* not DOSISH */
  
  #endif /* not C_FOPEN_H */
*** ./kpathsea/kpathsea.h~0	Fri Feb  7 20:39:26 1997
--- ./kpathsea/kpathsea.h	Sun Jun 22 16:18:18 1997
***************
*** 1,3 ****
--- 1,5 ----
+ #include <kpathsea/config.h>
+ 
  #include <kpathsea/absolute.h>
  #include <kpathsea/c-auto.h>
  #include <kpathsea/c-ctype.h>
***************
*** 17,23 ****
  #include <kpathsea/c-vararg.h>
  #include <kpathsea/cnf.h>
  #include <kpathsea/concatn.h>
- #include <kpathsea/config.h>
  #include <kpathsea/db.h>
  #include <kpathsea/debug.h>
  #include <kpathsea/default.h>
--- 19,24 ----
*** ./kpathsea/config.h~0	Mon Dec  9 00:15:10 1996
--- ./kpathsea/config.h	Sun May  4 16:57:18 1997
***************
*** 19,30 ****
--- 19,45 ----
  
  #ifndef KPATHSEA_CONFIG_H
  #define KPATHSEA_CONFIG_H
+    
+ /* If we have either DOS or OS2, we are DOSISH.  */
+ #if defined (DOS) || defined (OS2) || defined (WIN32) || defined(__MSDOS__)
+ #define DOSISH
+ #endif
+ 
+ #if defined (DOSISH)
+ #define MONOCASE_FILENAMES	/* case-insensitive filename comparisons */
+ #endif
  
  #ifdef WIN32
  #define __STDC__ 1
  #include "../win32/win32-compat.h"
  #endif /* not WIN32 */
  
+ #ifdef __DJGPP__
+ #include <fcntl.h>	/* for long filenames' stuff */
+ #include <dir.h>	/* for `getdisk' */
+ #include <io.h>		/* for `setmode' */
+ #endif
+ 
  /* System dependencies that are figured out by `configure'.  If we are
     compiling standalone, we get our c-auto.h.  Otherwise, the package
     containing us must provide this (unless it can somehow generate ours
***************
*** 45,61 ****
     variations should be done in configure.)  Presently the defines used
     are: AMIGA DOS OS2 VMCMS VMS WIN32.  I do not use any of these systems
     myself; if you do, I'd be grateful for any changes. --kb@mail.tug.org */
-    
- /* If we have either DOS or OS2, we are DOSISH.  */
- #if defined (DOS) || defined (OS2) || defined (WIN32)
- #define DOSISH
- #endif
  
  /* If you want to find subdirectories in a directory with non-Unix
     semantics (specifically, if a directory with no subdirectories does
     not have exactly two links), define this.  */
! #if !defined (DOSISH) && !defined (VMS) && !defined (VMCMS)
  #define ST_NLINK_TRICK
  #endif /* not DOS and not VMS and not VMCMS */
  
  #ifdef AMIGA
--- 60,74 ----
     variations should be done in configure.)  Presently the defines used
     are: AMIGA DOS OS2 VMCMS VMS WIN32.  I do not use any of these systems
     myself; if you do, I'd be grateful for any changes. --kb@mail.tug.org */
  
  /* If you want to find subdirectories in a directory with non-Unix
     semantics (specifically, if a directory with no subdirectories does
     not have exactly two links), define this.  */
! #if !defined (VMS) && !defined (VMCMS)
! #if !defined (DOSISH) || defined(__DJGPP__)
! /* Surprise!  DJGPP returns st_nlink exactly like on Unix.  */
  #define ST_NLINK_TRICK
+ #endif /* either not DOSISH or __DJGPP__ */
  #endif /* not DOS and not VMS and not VMCMS */
  
  #ifdef AMIGA
*** ./kpathsea/progname.c~0	Thu Feb  6 20:40:44 1997
--- ./kpathsea/progname.c	Mon Jun  2 18:02:28 1997
*************** kpse_set_progname P1C(const_string, prog
*** 449,457 ****
--- 449,522 ----
  #endif /* WIN32 */
  
  #ifndef HAVE_PROGRAM_INVOCATION_NAME
+ 
+ #ifdef __DJGPP__
+   /* DJGPP programs support long filenames on Windows 95, but ARGV0 there
+      is always made with the short 8+3 aliases of all the pathname elements.
+      If long names are supported, we need to convert that to a long name.
+ 
+      All we really need is to call `_truename', but most of the code
+      below is required to deal with the special case of networked drives.  */
+   if (pathconf (progname, _PC_NAME_MAX) > 12) {
+     char long_progname[PATH_MAX];
+ 
+     if (_truename (progname, long_progname)) {
+       char *fp;
+ 
+       if (long_progname[1] != ':') {
+ 	/* A complication: `_truename' returns network-specific string at
+ 	   the beginning of `long_progname' when the program resides on a
+ 	   networked drive, and DOS calls cannot grok such pathnames.  We
+ 	   need to convert the filesystem name back to a drive letter.  */
+ 	char rootname[PATH_MAX], rootdir[4];
+ 
+ 	if (progname[0] && progname[1] == ':')
+ 	  rootdir[0] = progname[0]; /* explicit drive in `progname' */
+ 	else
+ 	  rootdir[0] = getdisk () + 'A';
+ 	rootdir[1] = ':';
+ 	rootdir[2] = '\\';
+ 	rootdir[3] = '\0';
+ 	if (_truename (rootdir, rootname)) {
+ 	  /* Find out where `rootname' ends in `long_progname' and replace
+ 	     it with the drive letter.  */
+ 	  int root_len = strlen (rootname);
+ 
+ 	  if (IS_DIR_SEP (rootname[root_len - 1]))
+ 	    root_len--;	/* keep the trailing slash */
+ 	  long_progname[0] = rootdir[0];
+ 	  long_progname[1] = ':';
+ 	  memmove (long_progname + 2, long_progname + root_len,
+ 		   strlen (long_progname + root_len) + 1);
+ 	}
+       }
+ 
+       /* Convert everything to canonical form.  */
+       if (long_progname[0] >= 'A' && long_progname[0] <= 'Z')
+ 	long_progname[0] += 'a' - 'A'; /* make drive lower case, for beauty */
+       for (fp = long_progname; *fp; fp++)
+ 	if (IS_DIR_SEP (*fp))
+ 	  *fp = DIR_SEP;
+ 
+       program_invocation_name = xstrdup (long_progname);
+     }
+     else
+       /* If `_truename' failed, God help them, because we won't...  */
+       program_invocation_name = xstrdup (progname);
+   }
+   else
+ #endif /* __DJGPP__ */
    program_invocation_name = xstrdup (progname);
  #endif
  
+   /* We need to find SELFAUTOLOC *before* removing the ".exe" suffix from
+      the program_name, otherwise the PATH search inside selfdir will fail,
+      since `prog' doesn't exists as a file, there's `prog.exe' instead.  */
+ #ifndef WIN32
+   sdir = selfdir (program_invocation_name);
+ #endif
+   xputenv ("SELFAUTOLOC", sdir);
+ 
    /* If configured --enable-shared and running from the build directory
       with the wrapper scripts (e.g., for make check), the binaries will
       be named foo.exe instead of foo.  Or possibly if we're running on a
*************** kpse_set_progname P1C(const_string, prog
*** 468,480 ****
  #ifndef HAVE_PROGRAM_INVOCATION_NAME
    program_invocation_short_name = (string) basename (program_invocation_name);
  #endif
! 
    /* SELFAUTODIR is actually the parent of the invocation directory,
       and SELFAUTOPARENT the grandparent.  This is how teTeX did it.  */
! #ifndef WIN32
!   sdir = selfdir (program_invocation_name);
! #endif
!   xputenv ("SELFAUTOLOC", sdir);
    sdir_parent = my_dirname (sdir);
    xputenv ("SELFAUTODIR", sdir_parent);
    sdir_grandparent = my_dirname (sdir_parent);
--- 533,542 ----
  #ifndef HAVE_PROGRAM_INVOCATION_NAME
    program_invocation_short_name = (string) basename (program_invocation_name);
  #endif
!   
    /* SELFAUTODIR is actually the parent of the invocation directory,
       and SELFAUTOPARENT the grandparent.  This is how teTeX did it.  */
! 
    sdir_parent = my_dirname (sdir);
    xputenv ("SELFAUTODIR", sdir_parent);
    sdir_grandparent = my_dirname (sdir_parent);
*** ./kpathsea/xgetcwd.c~0	Sun Dec 15 22:39:10 1996
--- ./kpathsea/xgetcwd.c	Wed Apr 30 16:00:16 1997
*************** xgetcwd P1H(void)
*** 112,117 ****
--- 112,140 ----
      /* Go back to where we were.  */
      xchdir (cwd_path);
  
+ #ifdef DOSISH
+   /* Prepend the drive letter to CWD_PATH, since this technique
+      never tells us waht the drive is.
+ 
+      Note that on MS-DOS/MS-Windows, the branch that works around
+      missing `getwd' will probably only work for DJGPP (which does
+      have `getwd'), because only DJGPP reports meaningful
+      st_ino numbers.  But someday, somebody might need this...  */
+   {
+     char drive[3];
+     string temp = cwd_path;
+ 
+     /* Make the drive letter lower-case, unless it is beyond Z: (yes,
+        there ARE such drives, in case of Novell Netware on MS-DOS).  */
+     drive[0] = root_stat.st_dev + (root_stat.st_dev < 26 ? 'a' : 'A');
+     drive[1] = ':';
+     drive[2] = '\0';
+ 
+     cwd_path = concat (drive, cwd_path);
+     free (temp);
+   }
+ #endif
+ 
    return cwd_path;
  #endif /* not HAVE_GETWD */
  }
*** ./kpathsea/absolute.c~0	Sat Sep 30 17:57:08 1995
--- ./kpathsea/absolute.c	Thu Apr 24 19:29:12 1997
*************** Foundation, Inc., 59 Temple Place - Suit
*** 21,31 ****
  #include <kpathsea/absolute.h>
  #include <kpathsea/c-pathch.h>
  
- #ifdef DOSISH
- #include <kpathsea/c-ctype.h> /* for ISALPHA */
- #endif /* DOS */
- 
- 
  /* Sorry this is such a system-dependent mess, but I can't see any way
     to usefully generalize.  */
  
--- 21,26 ----
*************** kpse_absolute_p P2C(const_string, filena
*** 38,44 ****
  #else /* not VMS */
    boolean absolute = IS_DIR_SEP (*filename)
  #ifdef DOSISH
!                      || ISALPHA (*filename) && IS_DEVICE_SEP (filename[1])
  #endif /* DOSISH */
  #ifdef AMIGA
  		     /* Colon anywhere means a device.  */
--- 33,40 ----
  #else /* not VMS */
    boolean absolute = IS_DIR_SEP (*filename)
  #ifdef DOSISH
!     		     /* Novell allows non-alphanumeric drive letters.  */
!                      || *filename && IS_DEVICE_SEP (filename[1])
  #endif /* DOSISH */
  #ifdef AMIGA
  		     /* Colon anywhere means a device.  */
*** ./kpathsea/cnf.c~0	Thu Feb  6 22:04:04 1997
--- ./kpathsea/cnf.c	Thu Apr 24 19:47:58 1997
*************** do_line P1C(string, line)
*** 143,149 ****
  #endif
  #endif
  
! #if !defined (ALLOW_SEMICOLON_IN_FILENAMES) && defined (unix) 
    {
      string loc;
      for (loc = value; *loc; loc++) {
--- 143,151 ----
  #endif
  #endif
  
! /* DJGPP defines `unix' (for portability), but generates MSDOS programs.  */
! #ifndef __DJGPP__
! #if !defined (ALLOW_SEMICOLON_IN_FILENAMES) && defined (unix)
    {
      string loc;
      for (loc = value; *loc; loc++) {
*************** do_line P1C(string, line)
*** 151,156 ****
--- 153,159 ----
          *loc = ':';
      }
    }
+ #endif
  #endif
  
    /* We want TEXINPUTS.prog to override plain TEXINPUTS.  The simplest
*** ./kpathsea/kdefault.c~0	Mon Nov 11 23:22:08 1996
--- ./kpathsea/kdefault.c	Thu Apr 24 22:08:48 1997
*************** main ()
*** 102,111 ****
    test_expand_default (NULL, default_path);
    test_expand_default ("", default_path);
    test_expand_default ("none", default_path);
!   test_expand_default (":", default_path);
!   test_expand_default (":first", default_path);
!   test_expand_default ("last:", default_path);
!   test_expand_default ("middle::elddim", default_path);
    
    return 0;
  }
--- 102,111 ----
    test_expand_default (NULL, default_path);
    test_expand_default ("", default_path);
    test_expand_default ("none", default_path);
!   test_expand_default (ENV_SEP_STRING, default_path);
!   test_expand_default (ENV_SEP_STRING "first", default_path);
!   test_expand_default ("last" ENV_SEP_STRING, default_path);
!   test_expand_default ("middle" ENV_SEP_STRING ENV_SEP_STRING "elddim", default_path);
    
    return 0;
  }
*** ./kpathsea/kpsewhich.c~0	Tue Feb  4 01:01:56 1997
--- ./kpathsea/kpsewhich.c	Mon Jun 23 11:54:04 1997
*************** path_expand P1C(const_string, pathvar)
*** 199,206 ****
        for (dir = *dirs; dir; ) {
          string thedir = STR_LLIST (*dir);
          unsigned len = strlen (thedir);
!         if (len > 1) {
!           /* Discard trailing slash if that's not the entire element.  */
            thedir[len - 1] = 0;
          }
          fputs (thedir, stdout);
--- 199,208 ----
        for (dir = *dirs; dir; ) {
          string thedir = STR_LLIST (*dir);
          unsigned len = strlen (thedir);
!         if (!(len <= 1					/* "/" */
! 	      || (len == 3 && (IS_DIR_SEP (thedir[2])	/* "d:/" */
! 			       && NAME_BEGINS_WITH_DEVICE (thedir))))) {
!           /* Discard trailing slash if that's not the root directory.  */
            thedir[len - 1] = 0;
          }
          fputs (thedir, stdout);
*************** path_expand P1C(const_string, pathvar)
*** 232,238 ****
  -must-exist         search the disk as well as ls-R if necessary\n\
  -path=STRING        search in the path STRING.\n\
  -progname=STRING    set program name to STRING.\n\
! -separator=STRING   STRING separates components in -path output; default :.\n\
  -show-path=NAME     output search path for file type NAME (see list below).\n\
  -version            print version number and exit.\n\
  "
--- 234,240 ----
  -must-exist         search the disk as well as ls-R if necessary\n\
  -path=STRING        search in the path STRING.\n\
  -progname=STRING    set program name to STRING.\n\
! -separator=STRING   STRING separates components in -path output; default %s.\n\
  -show-path=NAME     output search path for file type NAME (see list below).\n\
  -version            print version number and exit.\n\
  "
*************** read_command_line P2C(int, argc,  string
*** 300,306 ****
        extern DllImport char *kpse_bug_address; /* from version.c */
        
        printf ("Usage: %s [OPTION]... [FILENAME]...\n", argv[0]);
!       fputs (USAGE, stdout);
        putchar ('\n');
        fputs (kpse_bug_address, stdout);
        
--- 302,308 ----
        extern DllImport char *kpse_bug_address; /* from version.c */
        
        printf ("Usage: %s [OPTION]... [FILENAME]...\n", argv[0]);
!       printf (USAGE, ENV_SEP_STRING);
        putchar ('\n');
        fputs (kpse_bug_address, stdout);
        
*** ./kpathsea/path-elt.c~0	Thu Jan  2 01:01:38 1997
--- ./kpathsea/path-elt.c	Thu Apr 24 22:49:38 1997
*************** main ()
*** 127,137 ****
    print_path_elements (NULL);	/* */
    print_path_elements ("");	/* "" */
    print_path_elements ("a");	/* a */
!   print_path_elements (":");	/* "", "" */
!   print_path_elements ("::");	/* "", "", "" */
!   print_path_elements ("a:");	/* a, "" */ 
!   print_path_elements (":b");	/* "", b */ 
!   print_path_elements ("a:b");	/* a, b */ 
    
    return 0;
  }
--- 127,137 ----
    print_path_elements (NULL);	/* */
    print_path_elements ("");	/* "" */
    print_path_elements ("a");	/* a */
!   print_path_elements (ENV_SEP_STRING);	/* "", "" */
!   print_path_elements (ENV_SEP_STRING ENV_SEP_STRING);	/* "", "", "" */
!   print_path_elements ("a" ENV_SEP_STRING);	/* a, "" */ 
!   print_path_elements (ENV_SEP_STRING "b");	/* "", b */ 
!   print_path_elements ("a" ENV_SEP_STRING "b");	/* a, b */ 
    
    return 0;
  }
*** ./kpathsea/pathsearch.c~0	Tue Jan 21 21:18:02 1997
--- ./kpathsea/pathsearch.c	Mon Jun  2 17:59:40 1997
*************** Foundation, Inc., 59 Temple Place - Suit
*** 30,35 ****
--- 30,39 ----
  
  #include <time.h> /* for `time' */
  
+ #ifdef __DJGPP__
+ #include <sys/stat.h>	/* for stat bits */
+ #endif
+ 
  /* The very first search is for texmf.cnf, called when someone tries to
     initialize the TFM path or whatever.  init_path calls kpse_cnf_get
     which calls kpse_all_path_search to find all the texmf.cnf's.  We
*************** search P4C(const_string, path,  const_st
*** 264,276 ****
             boolean, must_exist,  boolean, all)
  {
    str_list_type ret_list;
  
    /* Make a leading ~ count as an absolute filename, and expand $FOO's.  */
!   string name = kpse_expand (original_name);
    
    /* If the first name is absolute or explicitly relative, no need to
       consider PATH at all.  */
!   boolean absolute_p = kpse_absolute_p (name, true);
    
    if (KPSE_DEBUG_P (KPSE_DEBUG_SEARCH))
      DEBUGF4 ("start search(file=%s, must_exist=%d, find_all=%d, path=%s).\n",
--- 268,305 ----
             boolean, must_exist,  boolean, all)
  {
    str_list_type ret_list;
+   string name;
+   boolean absolute_p;
+ 
+ #ifdef __DJGPP__
+   /* We will use `stat' heavily, so let's request for
+      the fastest possible version of `stat', by telling
+      it what members of struct stat do we really need.
+ 
+      We need to set this on each call because this is a
+      library function; the caller might need other options
+      from `stat'.  Thus save the flags and restore them
+      before exit.
+ 
+      This call tells `stat' that we do NOT need to recognize
+      executable files (neither by an extension nor by a magic
+      signature); that we do NOT need time stamp of root directories;
+      and that we do NOT need the write access bit in st_mode.
+ 
+      Note that `kpse_set_progname' needs the EXEC bits,
+      but it was already called by the time we get here.  */
+   unsigned short save_djgpp_flags  = _djstat_flags;
+ 
+   _djstat_flags = _STAT_EXEC_MAGIC | _STAT_EXEC_EXT
+ 		  | _STAT_ROOT_TIME | _STAT_WRITEBIT;
+ #endif
  
    /* Make a leading ~ count as an absolute filename, and expand $FOO's.  */
!   name = kpse_expand (original_name);
    
    /* If the first name is absolute or explicitly relative, no need to
       consider PATH at all.  */
!   absolute_p = kpse_absolute_p (name, true);
    
    if (KPSE_DEBUG_P (KPSE_DEBUG_SEARCH))
      DEBUGF4 ("start search(file=%s, must_exist=%d, find_all=%d, path=%s).\n",
*************** search P4C(const_string, path,  const_st
*** 299,304 ****
--- 328,338 ----
      if (KPSE_DEBUG_P (KPSE_DEBUG_SEARCH))
        putc ('\n', stderr);
    }  
+ 
+ #ifdef __DJGPP__
+   /* Undo any side effects.  */
+   _djstat_flags = save_djgpp_flags;
+ #endif
    
    return STR_LIST (ret_list);
  }
*************** main ()
*** 355,366 ****
    /* All lists end with NULL.  */
    test_path_search (".", "nonexistent");
    test_path_search (".", "/nonexistent");
!   test_path_search ("/k:.", "kpathsea.texi");
!   test_path_search ("/k:.", "/etc/fstab");
!   test_path_search (".:" TEXFONTS "//", "cmr10.tfm");
!   test_path_search (".:" TEXFONTS "//", "logo10.tfm");
!   test_path_search (TEXFONTS "//times:.::", "ptmr.vf");
!   test_path_search (TEXFONTS "/adobe//:"
                      "/usr/local/src/TeX+MF/typefaces//", "plcr.pfa");
    
    test_path_search ("~karl", ".bashrc");
--- 389,401 ----
    /* All lists end with NULL.  */
    test_path_search (".", "nonexistent");
    test_path_search (".", "/nonexistent");
!   test_path_search ("/k" ENV_SEP_STRING ".", "kpathsea.texi");
!   test_path_search ("/k" ENV_SEP_STRING ".", "/etc/fstab");
!   test_path_search ("." ENV_SEP_STRING TEXFONTS "//", "cmr10.tfm");
!   test_path_search ("." ENV_SEP_STRING TEXFONTS "//", "logo10.tfm");
!   test_path_search (TEXFONTS "//times" ENV_SEP_STRING "."
! 		    ENV_SEP_STRING ENV_SEP_STRING, "ptmr.vf");
!   test_path_search (TEXFONTS "/adobe//" ENV_SEP_STRING
                      "/usr/local/src/TeX+MF/typefaces//", "plcr.pfa");
    
    test_path_search ("~karl", ".bashrc");
*************** main ()
*** 369,378 ****
    xputenv ("NONEXIST", "nonexistent");
    test_path_search (".", "$NONEXISTENT");
    xputenv ("KPATHSEA", "kpathsea");
!   test_path_search ("/k:.", "$KPATHSEA.texi");  
!   test_path_search ("/k:.", "${KPATHSEA}.texi");  
!   test_path_search ("$KPATHSEA:.", "README");  
!   test_path_search (".:$KPATHSEA", "README");  
    
    return 0;
  }
--- 404,413 ----
    xputenv ("NONEXIST", "nonexistent");
    test_path_search (".", "$NONEXISTENT");
    xputenv ("KPATHSEA", "kpathsea");
!   test_path_search ("/k" ENV_SEP_STRING ".", "$KPATHSEA.texi");  
!   test_path_search ("/k" ENV_SEP_STRING ".", "${KPATHSEA}.texi");  
!   test_path_search ("$KPATHSEA" ENV_SEP_STRING ".", "README");  
!   test_path_search ("." ENV_SEP_STRING "$KPATHSEA", "README");  
    
    return 0;
  }
*** ./kpathsea/readable.c~0	Tue Dec 10 01:03:54 1996
--- ./kpathsea/readable.c	Thu Apr 24 23:16:48 1997
*************** Foundation, Inc., 59 Temple Place - Suit
*** 28,35 ****
--- 28,41 ----
     regular file, as it is potentially useful to read fifo's or some
     kinds of devices.  */
  
+ #ifdef __DJGPP__
+ /* `stat' is way too expensive for such a simple job.  */
+ #define READABLE(fn, st) \
+   (access (fn, R_OK) == 0 && access (fn, D_OK) == -1)
+ #else
  #define READABLE(fn, st) \
    (access (fn, R_OK) == 0 && stat (fn, &(st)) == 0 && !S_ISDIR (st.st_mode))
+ #endif
  
  
  /* POSIX invented the brain-damage of not necessarily truncating
*** ./kpathsea/tex-file.c~0	Sun Feb  2 23:09:02 1997
--- ./kpathsea/tex-file.c	Tue May 27 12:22:12 1997
*************** Foundation, Inc., 59 Temple Place - Suit
*** 30,36 ****
  #include <kpathsea/tex-make.h>
  #include <kpathsea/variable.h>
  
- 
  /* See tex-file.h.  */
  const_string kpse_fallback_font = NULL;
  const_string kpse_fallback_resolutions_string = NULL;
--- 30,35 ----
*************** kpse_maketex_option P2C(const_string, fm
*** 157,167 ****
    if (FILESTRCASEEQ (fmtname, "pk")) {
      fmt = kpse_pk_format;
    } else if (FILESTRCASEEQ (fmtname, "mf")) {
!     fmt = kpse_tex_format;
    } else if (FILESTRCASEEQ (fmtname, "tex")) {
      fmt = kpse_tex_format;
    } else if (FILESTRCASEEQ (fmtname, "tfm")) {
!     fmt = kpse_tex_format;
    }
    kpse_set_program_enabled (fmt, value, kpse_src_cmdline);
  }
--- 156,166 ----
    if (FILESTRCASEEQ (fmtname, "pk")) {
      fmt = kpse_pk_format;
    } else if (FILESTRCASEEQ (fmtname, "mf")) {
!     fmt = kpse_mf_format;
    } else if (FILESTRCASEEQ (fmtname, "tex")) {
      fmt = kpse_tex_format;
    } else if (FILESTRCASEEQ (fmtname, "tfm")) {
!     fmt = kpse_tfm_format;
    }
    kpse_set_program_enabled (fmt, value, kpse_src_cmdline);
  }
*************** kpse_find_file P3C(const_string, name,  
*** 527,534 ****
    boolean name_has_suffix_already = false;
    string ret = NULL;
  
!   /* A null or empty NAME is surely a mistake.  */
!   assert (name && *name);
    
    if (FMT_INFO.path == NULL)
      kpse_init_format (format);
--- 526,534 ----
    boolean name_has_suffix_already = false;
    string ret = NULL;
  
!   /* NAME being NULL is a programming bug somewhere.  NAME can be empty,
!      though; this happens with constructs like `\input\relax'.  */
!   assert (name);
    
    if (FMT_INFO.path == NULL)
      kpse_init_format (format);
*************** kpse_open_file P2C(const_string, name,  
*** 627,632 ****
--- 627,638 ----
                        || type == kpse_ovf_format
                        || type == kpse_tfm_format
                        || type == kpse_vf_format
+                       || type == kpse_tex_ps_header_format
+ 		      || type == kpse_pk_format
+ 		      || type == kpse_base_format
+ 		      || type == kpse_fmt_format
+ 		      || type == kpse_mem_format
+ 		      || type == kpse_pict_format
                        ? FOPEN_RBIN_MODE : FOPEN_R_MODE;
    FILE *f = fullname ? fopen (fullname, mode) : NULL;
    if (!f) {
*** ./kpathsea/tex-make.c~0	Sun Feb  2 00:06:10 1997
--- ./kpathsea/tex-make.c	Mon Jun  2 14:35:50 1997
*************** set_maketex_mag P1H(void)
*** 54,60 ****
       up DPI, but may as well be safe, and also get the magstep number.  */
    (void) kpse_magstep_fix (dpi, bdpi, &m);
    
-   /* Have to do something different for DOS?  */
    if (m == 0)
      sprintf (q, "%d+%d/%d", dpi / bdpi, dpi % bdpi, bdpi);
    else
--- 54,59 ----
*************** maketex P2C(kpse_file_format_type, forma
*** 129,134 ****
--- 128,142 ----
    unsigned i;
    FILE *f;
    string cmd = xstrdup (passed_cmd);
+ 
+ #ifdef MSDOS
+   /* For discarding stderr.  This is so we don't require an MSDOS user
+      to istall a unixy shell (see kpse_make_tex below): they might
+      devise their own ingenious ways of running MakeTeX... even though
+      they don't have such a shell.  */
+   int temp_stderr = -1;
+   int save_stderr = -1;
+ #endif
    
    /* If the user snuck `backquotes` or $(command) substitutions into the
       name, foil them.  */
*************** maketex P2C(kpse_file_format_type, forma
*** 144,149 ****
--- 152,169 ----
    if (!kpse_make_tex_discard_errors) {
      fprintf (stderr, "kpathsea: Running %s\n", cmd);
    }
+ #ifdef MSDOS
+   else {
+     temp_stderr = open ("NUL", O_WRONLY);
+     if (temp_stderr >= 0) {
+       save_stderr = dup (2);
+       if (save_stderr >= 0)
+ 	dup2 (temp_stderr, 2);
+     }
+     /* Else they lose: the errors WILL be shown.  However, open/dup
+        aren't supposed to fail in this case, it's just my paranoia. */
+   }
+ #endif
    
    /* Run the script.  The Amiga has a different interface.  */
  #ifdef AMIGA
*************** maketex P2C(kpse_file_format_type, forma
*** 151,156 ****
--- 171,188 ----
  #else /* not AMIGA */
    f = popen (cmd, FOPEN_R_MODE);
  
+ #ifdef MSDOS
+   if (kpse_make_tex_discard_errors) {
+     /* Close /dev/null and revert stderr.  */
+     if (save_stderr >= 0) {
+       dup2 (save_stderr, 2);
+       close (save_stderr);
+     }
+     if (temp_stderr >= 0)
+       close (temp_stderr);
+   }
+ #endif
+ 
    if (f) {
      int c;
      string fn;             /* The final filename.  */
*************** kpse_make_tex P2C(kpse_file_format_type,
*** 261,266 ****
--- 293,302 ----
         shell; otherwise, if the MakeTeX... script doesn't exist, we
         will see the `sh: MakeTeX...: not found' error.  No point in
         doing this if we're not actually going to run anything.  */
+ #ifndef MSDOS
+     /* We don't want to require that a Unix-like shell be installed
+        on MS-DOS systems, so we will redirect stderr by hand (in
+        maketex).  */
      if (kpse_make_tex_discard_errors) {
        string old_cmd = cmd;
  #ifdef OS2
*************** kpse_make_tex P2C(kpse_file_format_type,
*** 270,282 ****
  #endif
        free (old_cmd);
      }
  
      ret = maketex (format, cmd);
  
      free (cmd);
      if (*args)
        free (args);
!   }  
  
    return ret;
  }
--- 306,319 ----
  #endif
        free (old_cmd);
      }
+ #endif
  
      ret = maketex (format, cmd);
  
      free (cmd);
      if (*args)
        free (args);
!   }
  
    return ret;
  }
*** ./kpathsea/MakeTeXcommon.~0	Sat Feb  8 17:53:00 1997
--- ./kpathsea/MakeTeXcommon	Thu May 29 14:32:42 1997
***************
*** 25,42 ****
  
  # TEMPDIR needs to be unique to each process because of the possibility of two
  # people running dvips (or whatever) simultaneously.
! TEMPDIR=${TMPDIR-/tmp}/mt.$$
  
  # We want to output only filenames to standard output, but it's too
  # error-prone to write the scripts that way, so we direct stdout here.
! STDOUT=$TEMPDIR/stdout.$$
  
  # We will change search paths to include $KPSE_DOT. This is necessary
  # since we cd to $TEMPDIR.
  KPSE_DOT=`pwd`; export KPSE_DOT
  
  # Clean up on normal or abnormal exit.
! trap 'cd $KPSE_DOT; test -f $STDOUT && cat $STDOUT; rm -rf $TEMPDIR; exit 0' \
    0 1 2 15
  
  
--- 25,48 ----
  
  # TEMPDIR needs to be unique to each process because of the possibility of two
  # people running dvips (or whatever) simultaneously.
! # MS-DOS limits extension to 3 characters, so put PID into the basename.
! TEMPDIR=${TMPDIR-/tmp}/mt$$.tmp
  
  # We want to output only filenames to standard output, but it's too
  # error-prone to write the scripts that way, so we direct stdout here.
! # MS-DOS limits extension to 3 characters, so put PID into the basename.
! STDOUT=$TEMPDIR/std$$.out
  
  # We will change search paths to include $KPSE_DOT. This is necessary
  # since we cd to $TEMPDIR.
  KPSE_DOT=`pwd`; export KPSE_DOT
  
  # Clean up on normal or abnormal exit.
! # The funky "cd /" is for MS-DOS and MS-Windows where there is a separate
! # current directory on each drive, and therefore "cd $KPSE_DOT" might
! # still leave $TMPDIR current directory on its drive, in which case it
! # cannot be removed.
! trap 'cd /; cd $KPSE_DOT; test -f $STDOUT && cat $STDOUT; rm -rf $TEMPDIR; exit 0' \
    0 1 2 15
  
  
*** ./kpathsea/MakeTeXls-R.~0	Sat Feb  8 17:52:00 1997
--- ./kpathsea/MakeTeXls-R	Fri Apr 25 13:19:32 1997
***************
*** 32,38 ****
  db_file=`\ls -l $TEXMFLS_R/ls-R 2>/dev/null | awk '{print $NF}'`
  test -z "$db_file" && db_file=$TEXMFLS_R/ls-R
  db_dir=`echo $db_file | sed 's%/[^/][^/]*$%%'` # can't rely on dirname
! db_file_tmp=$db_dir/ls-R-tmp$$
  
  test -w "$db_dir" || { echo "$0: Cannot write to $db_dir." >&2; exit 1; }
  
--- 32,38 ----
  db_file=`\ls -l $TEXMFLS_R/ls-R 2>/dev/null | awk '{print $NF}'`
  test -z "$db_file" && db_file=$TEXMFLS_R/ls-R
  db_dir=`echo $db_file | sed 's%/[^/][^/]*$%%'` # can't rely on dirname
! db_file_tmp=$db_dir/lsR$$.tmp # PID in the first 8 chars (MS-DOS)
  
  test -w "$db_dir" || { echo "$0: Cannot write to $db_dir." >&2; exit 1; }
  
*** ./kpathsea/MakeTeXMF.~0	Sat Feb  8 17:52:00 1997
--- ./kpathsea/MakeTeXMF	Fri Apr 25 13:28:24 1997
***************
*** 59,69 ****
    exit 0
  fi
  
  base=
  case "$name" in
    dc*) base=dxbase;;
    ec*|tc*) base=exbase;;
!     *) cat >"$mfname.tmp$$" <<END-OF-SAUTER
  design_size := $realsize;
  input b-$rootname;
  END-OF-SAUTER
--- 59,70 ----
    exit 0
  fi
  
+ # MS-DOS limits extension to 3 characters, so put PID into the basename.
  base=
  case "$name" in
    dc*) base=dxbase;;
    ec*|tc*) base=exbase;;
!     *) cat >"mf$$.tmp" <<END-OF-SAUTER
  design_size := $realsize;
  input b-$rootname;
  END-OF-SAUTER
***************
*** 71,86 ****
  esac
  
  test -n "$base" &&
!   echo "if unknown $base: input $base fi;" >"$mfname.tmp$$"
  
! cat >>"$mfname.tmp$$" <<END
  gensize := $realsize;
  generate $rootname;
  END
  
! chmod $MT_FILE_PERMS "$mfname.tmp$$"
  rm -f "$mfname"
! mv "$mfname.tmp$$" "$mfname"
  
  echo "$fontdir/$mfname" >$STDOUT
  $TEXMFCNF_DIR/MakeTeXupdate "$fontdir" "$mfname"
--- 72,87 ----
  esac
  
  test -n "$base" &&
!   echo "if unknown $base: input $base fi;" >"mf$$.tmp"
  
! cat >>"mf$$.tmp" <<END
  gensize := $realsize;
  generate $rootname;
  END
  
! chmod $MT_FILE_PERMS "mf$$.tmp"
  rm -f "$mfname"
! mv "mf$$.tmp" "$mfname"
  
  echo "$fontdir/$mfname" >$STDOUT
  $TEXMFCNF_DIR/MakeTeXupdate "$fontdir" "$mfname"
*** ./kpathsea/MakeTeXPK.~0	Sat May 17 16:12:02 1997
--- ./kpathsea/MakeTeXPK	Mon Jun  2 14:27:12 1997
***************
*** 99,105 ****
  
  $TEXMFCNF_DIR/MakeTeX-mkdir $PKDESTDIR
  if test ! -d $PKDESTDIR; then
!   echo "$0: MakeTeXmkdir $PKDESTDIR failed." >&2
    exit 1
  fi
  
--- 99,105 ----
  
  $TEXMFCNF_DIR/MakeTeX-mkdir $PKDESTDIR
  if test ! -d $PKDESTDIR; then
!   echo "$0: MakeTeX-mkdir $PKDESTDIR failed." >&2
    exit 1
  fi
  
***************
*** 114,122 ****
  fi
  
  # Install the PK file carefully, since others may be working simultaneously.
! mv $PKNAME $PKDESTDIR/pktmp.$$ || exit 1
  cd $PKDESTDIR || exit 1
! test -r $PKNAME || mv pktmp.$$ $PKNAME || exit 1
  chmod $MT_FILE_PERMS $PKNAME
  
  # Update ls-R if necessary.
--- 114,127 ----
  fi
  
  # Install the PK file carefully, since others may be working simultaneously.
! # Put the PID into basename (MS-DOS), so it won't be truncated.
! # Use cp when mv fails, since DOS will fail mv for deeply-nested
! # directories.
! mv $PKNAME $PKDESTDIR/pk$$.tmp 2> /dev/null \
!  || cp $PKNAME $PKDESTDIR/pk$$.tmp || exit 1
! rm -f $PKNAME
  cd $PKDESTDIR || exit 1
! test -r $PKNAME || mv pk$$.tmp $PKNAME || exit 1
  chmod $MT_FILE_PERMS $PKNAME
  
  # Update ls-R if necessary.
*** ./kpathsea/MakeTeXTFM.~0	Sat Feb  8 17:52:00 1997
--- ./kpathsea/MakeTeXTFM	Thu Jun 12 19:50:18 1997
***************
*** 7,13 ****
  # te@informatik.uni-hannover.de and kb@mail.tug.org. Public domain.
  
  version='$Id: MakeTeXTFM,v 1.5 1997/02/08 15:52:15 karl Exp karl $'
! usage="Usage: $0 FONT.
    Makes a TFM file for FONT, if possible."
  
  : ${TEXMFMAIN=`kpsewhich -expand-var='$TEXMFMAIN'`}
--- 7,13 ----
  # te@informatik.uni-hannover.de and kb@mail.tug.org. Public domain.
  
  version='$Id: MakeTeXTFM,v 1.5 1997/02/08 15:52:15 karl Exp karl $'
! usage="Usage: $0 FONT DEST.
    Makes a TFM file for FONT, if possible."
  
  : ${TEXMFMAIN=`kpsewhich -expand-var='$TEXMFMAIN'`}
***************
*** 44,52 ****
  fi
  
  # Try to create the destdir first. Do not create fonts, if this fails.
! $TEXMFCNF_DIR/MakeTeXmkdir "$TFMDESTDIR"
  if test ! -d "$TFMDESTDIR"; then
!   echo "$0: MakeTeXmkdir $TFMDESTDIR failed."
    exit 1
  fi
  
--- 44,52 ----
  fi
  
  # Try to create the destdir first. Do not create fonts, if this fails.
! $TEXMFCNF_DIR/MakeTeX-mkdir "$TFMDESTDIR"
  if test ! -d "$TFMDESTDIR"; then
!   echo "$0: MakeTeX-mkdir $TFMDESTDIR failed."
    exit 1
  fi
  
***************
*** 56,64 ****
  test -r $TFMNAME || { echo "$0: \`$cmd' failed to make $TFMNAME."; exit 1; }
  
  # Install the TFM file carefully, since others may be working simultaneously.
! mv $TFMNAME $TFMDESTDIR/tfmtmp.$$ || exit 1
  cd $TFMDESTDIR || exit 1
! test -r $TFMNAME || mv tfmtmp.$$ $TFMNAME || exit 1
  chmod $MT_FILE_PERMS $TFMNAME
  
  # OK, success with the TFM.
--- 56,65 ----
  test -r $TFMNAME || { echo "$0: \`$cmd' failed to make $TFMNAME."; exit 1; }
  
  # Install the TFM file carefully, since others may be working simultaneously.
! # Put the PID into basename (MS-DOS), so it won't be truncated.
! mv $TFMNAME $TFMDESTDIR/tfm$$.tmp || exit 1
  cd $TFMDESTDIR || exit 1
! test -r $TFMNAME || mv tfm$$.tmp $TFMNAME || exit 1
  chmod $MT_FILE_PERMS $TFMNAME
  
  # OK, success with the TFM.
***************
*** 70,82 ****
  cd $TEMPDIR
  if test -r $GFNAME && test ! -f $PKDESTDIR/$PKNAME; then
    gftopk ./$GFNAME $PKNAME || exit 1
!   $TEXMFCNF_DIR/MakeTeXmkdir "$PKDESTDIR"
!   mv $PKNAME $PKDESTDIR/pktmp.$$ || exit 1
    cd $PKDESTDIR || exit 1
    if test -f $PKNAME; then
!     rm -f pktmp.$$
    else
!     mv pktmp.$$ $PKNAME
      chmod $MT_FILE_PERMS $PKNAME
      $TEXMFCNF_DIR/MakeTeXupdate $PKDESTDIR $PKNAME
    fi
--- 71,83 ----
  cd $TEMPDIR
  if test -r $GFNAME && test ! -f $PKDESTDIR/$PKNAME; then
    gftopk ./$GFNAME $PKNAME || exit 1
!   $TEXMFCNF_DIR/MakeTeX-mkdir "$PKDESTDIR"
!   mv $PKNAME $PKDESTDIR/pkt$$.tmp || exit 1
    cd $PKDESTDIR || exit 1
    if test -f $PKNAME; then
!     rm -f pkt$$.tmp
    else
!     mv pkt$$.tmp $PKNAME
      chmod $MT_FILE_PERMS $PKNAME
      $TEXMFCNF_DIR/MakeTeXupdate $PKDESTDIR $PKNAME
    fi
*** ./kpathsea/Makefile.i~0	Fri Feb  7 20:39:38 1997
--- ./kpathsea/Makefile.in	Mon Jun  2 14:58:20 1997
***************
*** 53,60 ****
  $(objects): ../klibtool.config
  
  # Make variable substitutions from paths.h.
! texmf.cnf: texmf.cnf.in texmf.sed
! 	sed -f texmf.sed $(srcdir)/texmf.cnf.in >$@
  
  # The idea is to turn each var=value into s%@var@%value%g. Seems simpler
  # to put the substitutions in a file than to play shell quoting games.
--- 53,60 ----
  $(objects): ../klibtool.config
  
  # Make variable substitutions from paths.h.
! texmf.cnf: texmf-in.cnf texmf.sed
! 	sed -f texmf.sed $(srcdir)/texmf-in.cnf >$@
  
  # The idea is to turn each var=value into s%@var@%value%g. Seems simpler
  # to put the substitutions in a file than to play shell quoting games.
***************
*** 131,137 ****
  	else true; fi
  	$(INSTALL_SCRIPT) $(srcdir)/MakeTeXls-R $(scriptdir)/MakeTeXls-R
  	$(INSTALL_SCRIPT) $(srcdir)/MakeTeXcommon $(web2cdir)/MakeTeXcommon
! 	$(INSTALL_SCRIPT) $(srcdir)/MakeTeXmkdir $(web2cdir)/MakeTeXmkdir
  	$(INSTALL_SCRIPT) $(srcdir)/MakeTeXnames $(web2cdir)/MakeTeXnames
  	$(INSTALL_SCRIPT) $(srcdir)/MakeTeXnames.cnf $(web2cdir)/MakeTeXnames.cnf
  	$(INSTALL_SCRIPT) $(srcdir)/MakeTeXupdate $(web2cdir)/MakeTeXupdate
--- 131,137 ----
  	else true; fi
  	$(INSTALL_SCRIPT) $(srcdir)/MakeTeXls-R $(scriptdir)/MakeTeXls-R
  	$(INSTALL_SCRIPT) $(srcdir)/MakeTeXcommon $(web2cdir)/MakeTeXcommon
! 	$(INSTALL_SCRIPT) $(srcdir)/MakeTeX-mkdir $(web2cdir)/MakeTeX-mkdir
  	$(INSTALL_SCRIPT) $(srcdir)/MakeTeXnames $(web2cdir)/MakeTeXnames
  	$(INSTALL_SCRIPT) $(srcdir)/MakeTeXnames.cnf $(web2cdir)/MakeTeXnames.cnf
  	$(INSTALL_SCRIPT) $(srcdir)/MakeTeXupdate $(web2cdir)/MakeTeXupdate
***************
*** 146,152 ****
  	   || test ! -r $(web2cdir)/texmf.cnf; then \
  	  $(INSTALL_DATA) texmf.cnf $(web2cdir)/texmf.cnf; \
  	else true; fi
! 	$(INSTALL_DATA) $(srcdir)/kpathsea.info $(infodir)/kpathsea.info
  	$(SHELL) $(top_srcdir)/../mkdirchain $(includedir)/kpathsea
  	for f in $(install_headers); do \
  	  $(INSTALL_DATA) $$f $(includedir)/kpathsea/$$f; done
--- 146,153 ----
  	   || test ! -r $(web2cdir)/texmf.cnf; then \
  	  $(INSTALL_DATA) texmf.cnf $(web2cdir)/texmf.cnf; \
  	else true; fi
! 	for i in $(srcdir)/kpathsea.i*; do \
! 	  $(INSTALL_DATA) $$i $(infodir)/$$i; done
  	$(SHELL) $(top_srcdir)/../mkdirchain $(includedir)/kpathsea
  	for f in $(install_headers); do \
  	  $(INSTALL_DATA) $$f $(includedir)/kpathsea/$$f; done
***************
*** 158,164 ****
  	else true; fi
  
  uninstall-data:
! 	rm -f $(infodir)/kpathsea.info*
  	for f in $(install_headers); do rm -f $(includedir)/$$f; done
  
  # distdir is used by other distributions; they define $(distdir).
--- 159,165 ----
  	else true; fi
  
  uninstall-data:
! 	rm -f $(infodir)/kpathsea.i*
  	for f in $(install_headers); do rm -f $(includedir)/$$f; done
  
  # distdir is used by other distributions; they define $(distdir).
*** ./kpathsea/xputenv.c~0	Fri Dec 13 00:25:14 1996
--- ./kpathsea/xputenv.c	Wed May  7 11:57:42 1997
*************** xputenv P2C(const_string, var_name,  con
*** 45,50 ****
--- 45,51 ----
    static unsigned saved_len;
    string old_item = NULL;
    string new_item = concat3 (var_name, "=", value);
+   unsigned name_len = strlen (var_name);
    boolean found = false;
  
  #ifndef SMART_PUTENV
*************** xputenv P2C(const_string, var_name,  con
*** 59,65 ****
      {
        /* Check if we've assigned VAR_NAME before.  */
        unsigned i;
-       unsigned len = strlen (var_name);
        for (i = 0; i < saved_len && !found; i++)
          {
            if (STREQ (saved_env_items[i], var_name))
--- 60,65 ----
*************** xputenv P2C(const_string, var_name,  con
*** 72,83 ****
  		 is not made between the value being "" or the variable
  		 not set. */
  	      if (old_item)
! 		old_item -= (len + 1);
  #else
                assert (old_item);
                /* Back up to the `NAME=' in the environment before the
                   value that getenv returns.  */
!               old_item -= (len + 1);
  #endif
              }
          }
--- 72,83 ----
  		 is not made between the value being "" or the variable
  		 not set. */
  	      if (old_item)
! 		old_item -= (name_len + 1);
  #else
                assert (old_item);
                /* Back up to the `NAME=' in the environment before the
                   value that getenv returns.  */
!               old_item -= (name_len + 1);
  #endif
              }
          }
*************** xputenv P2C(const_string, var_name,  con
*** 93,109 ****
      }
  #endif /* not SMART_PUTENV */
  
!   /* As far as I can see there's no way to distinguish between the
!      various errors; putenv doesn't have errno values.  */
!   if (putenv (new_item) < 0)
!     FATAL1 ("putenv (%s) failed", new_item);
!   
  #ifndef SMART_PUTENV
!   /* Can't free `new_item' because its contained value is now in
!      `environ', but we can free `old_item', since it's been replaced.  */
!   if (old_item)
!     free (old_item);
  #endif /* not SMART_PUTENV */
  }
  
  
--- 93,121 ----
      }
  #endif /* not SMART_PUTENV */
  
!   /* If the old and the new values are identical, don't do anything.
!      This is both more memory-efficient and safer as far as our
!      assumptions (about how putenv is implemented in libc) go.  */
!   if (!old_item || !STREQ (old_item, new_item))
!     {
!       char *new_val;
!       /* As far as I can see there's no way to distinguish between the
! 	 various errors; putenv doesn't have errno values.  */
!       if (putenv (new_item) < 0)
! 	FATAL1 ("putenv (%s) failed", new_item);
! 
!       /* If their putenv copied `new_item', we can free it.  */
!       new_val = getenv (var_name);
!       if (new_val && new_val - name_len - 1 != new_item)
! 	free (new_item);
! 
  #ifndef SMART_PUTENV
!       /* Can't free `new_item' because its contained value is now in
! 	 `environ', but we can free `old_item', since it's been replaced.  */
!       if (old_item)
! 	free (old_item);
  #endif /* not SMART_PUTENV */
+     }
  }
  
  
*** ./kpathsea/MakeTeXnames.~0	Sat Feb  8 17:52:00 1997
--- ./kpathsea/MakeTeXnames	Fri May 16 16:15:30 1997
***************
*** 82,88 ****
  
  case "$DEST" in
    "") ;;
!   /*) MT_PKDESTDIR=$DEST;; # Absolute, explicit destdir => use it.
     *) MT_NAMEPART=$DEST;; # Relative destdir => append to the default.
  esac
  
--- 82,88 ----
  
  case "$DEST" in
    "") ;;
!   /* | [A-z]:/*) MT_PKDESTDIR=$DEST;; # Absolute, explicit destdir => use it.
     *) MT_NAMEPART=$DEST;; # Relative destdir => append to the default.
  esac
  
*** ./kpathsea/install.t~0	Thu Feb  6 20:40:44 1997
--- ./kpathsea/install.texi	Mon Jun  9 11:04:14 1997
***************
*** 106,113 ****
  @item
  The first time you run a DVI driver, a bunch of PK fonts will be built
  by Metafont via @code{MakeTeXPK} (and added to the filename database).
! This will take some time.  Don't be alarmed; they will created only this
! first time (unless something is wrong with your path definitions).
  
  By default, @code{MakeTeXPK} assumes @file{/usr/local/share/texmf/fonts}
  is globally writable.  If you need a different arrangement, 
--- 106,113 ----
  @item
  The first time you run a DVI driver, a bunch of PK fonts will be built
  by Metafont via @code{MakeTeXPK} (and added to the filename database).
! This will take some time.  Don't be alarmed; they will be created only
! this first time (unless something is wrong with your path definitions).
  
  By default, @code{MakeTeXPK} assumes @file{/usr/local/share/texmf/fonts}
  is globally writable.  If you need a different arrangement, 
***************
*** 120,126 ****
  @pindex MakeTeXPK @r{, initial runs}
  @cindex tests, simple
  For some simple tests, try @samp{tex story \\bye} and @samp{latex
! simple}.  Then run @file{xdvi story} or @file{dvips simple} on the
  resulting DVI files to preview/print the documents.  @xref{Installation
  testing}.
  @end enumerate
--- 120,126 ----
  @pindex MakeTeXPK @r{, initial runs}
  @cindex tests, simple
  For some simple tests, try @samp{tex story \\bye} and @samp{latex
! sample2e}.  Then run @file{xdvi story} or @file{dvips sample2e} on the
  resulting DVI files to preview/print the documents.  @xref{Installation
  testing}.
  @end enumerate
***************
*** 184,189 ****
--- 184,190 ----
  are approximate.
  
  @multitable {distribution} {.tar.gz} {unpacked} {compiled} {installed}
+ @item Distribution @tab .tar.gz @tab Unpacked @tab Compiled @tab Installed
  @item dviljk   @tab   .9 @tab  3.8 @tab
  @item dvipsk   @tab   .9 @tab  3.2 @tab
  @item xdvik    @tab   .7 @tab  2.5 @tab
***************
*** 936,959 ****
  @flindex MakeTeXmkdir
  Tell @code{MakeTeXmkdir} to create directories append-only, i.e., set
  their sticky bit (@pxref{Mode Structure,,, fileutils, GNU File
! Utilities}).
  
  @item dosnames
  @cindex 8.3 filenames, using
! @cindex DOS compatible names
  @flindex dpi@var{nnn} directories
  Use 8.3 names; e.g., @file{dpi600/cmr10.pk} instead of
! @file{cmr10.600pk}.
  
  @item nomode
  @cindex mode directory, omitting
! Omit the directory level for the mode name; this is fine as long as
! you generate fonts for only one mode.
  
  @item strip
  @cindex supplier directory, omitting
  @cindex typeface directory, omitting
! Omit the font supplier and typeface name directory levels.
  
  @item varfonts
  @flindex /var/tex/fonts
--- 937,977 ----
  @flindex MakeTeXmkdir
  Tell @code{MakeTeXmkdir} to create directories append-only, i.e., set
  their sticky bit (@pxref{Mode Structure,,, fileutils, GNU File
! Utilities}).  This feature is silently ignored on non-Unix platforms
! (e.g. Windows/NT and MS-DOS) which don't support similar functionality.
  
  @item dosnames
  @cindex 8.3 filenames, using
! @cindex DOS compatible filenames
  @flindex dpi@var{nnn} directories
  Use 8.3 names; e.g., @file{dpi600/cmr10.pk} instead of
! @file{cmr10.600pk}.  Note that this feature only affects filenames that
! would otherwise clash with other TeX-related filenames; @file{MakeTeX}
! scripts do nothing about filenames which exceed the 8+3 MS-DOS limits
! but remain unique when truncated (by the OS) to these limits, and nether
! do the scripts care about possible clashes with files which aren't
! related with TeX.  For example, @file{cmr10.600pk} would clash with
! @file{cmr10.600gf} and is therefore changed when @samp{dosnames} is in
! effect, but @file{mf.pool} and @file{mp.base} don't clash with any
! TeX-related files and are therefore unchanged.
! 
! This feature is turned on by default on MS-DOS if your
! @code{MT_FEATURES} variable is empty (i.e., @file{MakeTeX} scripts
! behave as if the original @file{MakeTeXnames.cnf} defines
! @samp{MT_FEATURES="dosnames"}).  However, if you set @code{MT_FEATURES}
! on @file{MakeTeX.site} or in the environment, or edit
! @file{MakeTeXnames.cnf}, you need to set @samp{dosnames} explicitly.
  
  @item nomode
  @cindex mode directory, omitting
! Omit the directory level for the mode name (e.g., @file{ljfour}); this
! is fine as long as you generate fonts for only one mode.
  
  @item strip
  @cindex supplier directory, omitting
  @cindex typeface directory, omitting
! Omit the font supplier and typeface name (e.g., @file{ams/euler})
! directory levels.
  
  @item varfonts
  @flindex /var/tex/fonts
***************
*** 1005,1012 ****
  @vindex DVIPSMAKEPK
  @vindex XDVIMAKEPK
  @vindex DVILJMAKEPK
! @noindent These names are overridden by an environment variable specific
! to the program---for example, @code{DVIPSMAKEPK} for Dvipsk.
  
  @comment next two paragraphs are repeated in dvips.texi
  @flindex missfont.log
--- 1023,1032 ----
  @vindex DVIPSMAKEPK
  @vindex XDVIMAKEPK
  @vindex DVILJMAKEPK
! @noindent Some of these names are overridden by an environment variable
! specific to the program---for example, @code{DVIPSMAKEPK} for Dvipsk.
! Currently, only the name of @file{MakeTeXPK} script can be customized in
! this way.
  
  @comment next two paragraphs are repeated in dvips.texi
  @flindex missfont.log
***************
*** 1078,1096 ****
  set the others. (@xref{Calling sequence}.)
  
  @vindex MAKETEXPK @r{environment variable}
! @cindex specification for @code{MakeTeXPK}
! You can change the specification for the arguments passed to the
! external script by setting the environment variable named as the script
! name, but all capitals---@code{MAKETEXPK}, for example.  If you've
! changed the script name by setting (say) @code{DVIPSMAKEPK} to
! @samp{foo}, then the spec is taken from the environment variable
! @code{FOO}.
  
! The spec can contain any variable references, to the above variables or
! any others.  As an example, the default spec for @code{MakeTeXPK} is:
  @example
  $KPATHSEA_DPI $MAKETEX_BASE_DPI $MAKETEX_MAG $MAKETEX_MODE
  @end example
  
  @noindent The convention of passing the name of the file to be created
  as the first argument cannot be changed.
--- 1098,1141 ----
  set the others. (@xref{Calling sequence}.)
  
  @vindex MAKETEXPK @r{environment variable}
! @vindex MAKETEXMF @r{environment variable}
! @vindex MAKETEXTFM @r{environment variable}
! @vindex MAKETEXTEX @r{environment variable}
! You can change the way the external scripts are called by setting the
! environment variable named as the script name, but all
! capitals---@code{MAKETEXMF}, for example.  If you've changed the script
! name by setting (say) @code{DVIPSMAKEPK} to @samp{foo}, then the spec is
! taken from the environment variable @code{FOO}.  The value of the
! variable that defines how to call the script (@code{MAKETEXMF} in our
! example) can contain any variable references, to the above variables or
! any others; when the script is invoked, the name of the file to be
! created is put @strong{after} whatever this variable expands to.  For
! example, if you have set @samp{MAKETXMF=my_private_maketexmf foo bar}
! then Kpathsea will issue the following command to build @file{cmr11.mf}:
  
! @example
!   my_private_maketexmf foo bar cmr11
! @end example
! 
! You can use names of other variables in the above definition of
! @code{MAKETEXMF} above, in which case these variables are expanded when
! Kpathsea processes the definition of @code{MAKETEXMF}.
! 
! @cindex specification for @code{MakeTeXPK}
! For @code{MakeTeXPK} only, you can further tailor the specification for
! the arguments passed to the script.  By default, the spec for
! @code{MakeTeXPK} as built into Kpathsea is this:
  @example
  $KPATHSEA_DPI $MAKETEX_BASE_DPI $MAKETEX_MAG $MAKETEX_MODE
  @end example
+ 
+ In contrast to what happens when you define @code{MAKETEXPK}, the name
+ of the file to be created is put on the command line @strong{before} the
+ expansion of these variables.  By defining your own values for some or
+ all of these variables, you can change how the script that produces
+ @file{.pk} files is invoked.  Since this feature is not needed for
+ scripts other than @code{MakeTeXPK} (and indeed is rarely used even in
+ that case), it is not currently supported for other scripts.
  
  @noindent The convention of passing the name of the file to be created
  as the first argument cannot be changed.
*** ./kpathsea/bugs.t~0	Tue Jan 21 21:02:52 1997
--- ./kpathsea/bugs.texi	Thu Jun  5 15:49:40 1997
***************
*** 211,219 ****
  @vindex KPATHSEA_DEBUG
  @vindex kpathsea_debug
  You can also set the environment variable @code{KPATHSEA_DEBUG}; in this
! case, you should use the numbers below.  Also, if you run the program
! under a debugger and set the variable @code{kpathsea_debug}, Also use
! the numbers below
  
  @kindex -1 @r{debugging value}
  In any case, by far the simplest value to use is @samp{-1}, which will
--- 211,219 ----
  @vindex KPATHSEA_DEBUG
  @vindex kpathsea_debug
  You can also set the environment variable @code{KPATHSEA_DEBUG}; in this
! case, you should use the numbers below.  If you run the program under a
! debugger and set the variable @code{kpathsea_debug}, also use the
! numbers below.
  
  @kindex -1 @r{debugging value}
  In any case, by far the simplest value to use is @samp{-1}, which will
***************
*** 283,288 ****
--- 283,304 ----
  @file{texmf.cnf} and @file{texfonts.map}), or just the first (as with
  most lookups).  This can help you correlate what Kpathsea is doing with
  what is in your input file.
+ 
+ @item GSFTOPK_DEBUG @r{(64)}
+ Activates debugging printout specific to @code{gsftopk} program.
+ 
+ @item MAKETEX_DEBUG @r{(128)}
+ If you use the optional @code{MakeTeX} programs instead of the
+ traditional shell scripts, this will report the name of the site file
+ (@file{MakeTeX.site} by default) which is read, directories created by
+ @code{MakeTeX-mkdir}, the full path of the @file{ls-R} database built by
+ @code{MakeTeXls-R}, font map searches, @code{MT_FEATURES} in effect,
+ parameters from @code{MakeTeXnames}, filenames added by
+ @code{MakeTeXupdate}, and some subsidiary commands run by the programs.
+ 
+ @item MAKETEX_FINE_DEBUG @r{(256)}
+ When the optional @code{MakeTeX} programs are used, this will print
+ additional debugging info from functions internal to these programs.
  @end vtable
  
  @cindex @samp{kdebug:}
*** ./kpathsea/MakeTeXnames.c~0	Sat Feb  8 17:53:00 1997
--- ./kpathsea/MakeTeXnames.cnf	Sat May 17 11:20:06 1997
***************
*** 9,14 ****
--- 9,20 ----
  # Possible features: appendonlydir dosnames nomode strip varfonts.
  : ${MT_FEATURES=}
  
+ # MS-DOS: set "dosnames" by default.  $COMSPEC is defined on DOS to
+ # point to the login shell.
+ if test -n "$COMSPEC"; then
+   MT_FEATURES="dosnames"
+ fi
+ 
  # Set append-only bit on created directories.
  case "$MT_FEATURES" in
    *appendonlydir*) MT_DIR_PERMS=1$MT_DIR_PERMS;;
*** ./make/tkpathsea.m~0	Fri Feb  7 20:39:48 1997
--- ./make/tkpathsea.mak	Tue Apr 29 18:07:08 1997
***************
*** 4,9 ****
  # This is wrong: the library doesn't depend on kpsewhich.c or
  # acconfig.h.  But what to do?
  $(kpathsea): $(kpathsea_srcdir)/*.c $(kpathsea_srcdir)/*.h \
! 	     $(kpathsea_srcdir)/texmf.cnf.in $(top_srcdir)/../make/paths.make
  	cd $(kpathsea_dir) && $(MAKE) $(makeargs)
  # End of tkpathsea.make.
--- 4,9 ----
  # This is wrong: the library doesn't depend on kpsewhich.c or
  # acconfig.h.  But what to do?
  $(kpathsea): $(kpathsea_srcdir)/*.c $(kpathsea_srcdir)/*.h \
! 	     $(kpathsea_srcdir)/texmf-in.cnf $(top_srcdir)/../make/paths.make
  	cd $(kpathsea_dir) && $(MAKE) $(makeargs)
  # End of tkpathsea.make.
*** ./dviljk/Makefile.i~0	Fri Feb  7 20:45:04 1997
--- ./dviljk/Makefile.in	Tue Jun  3 10:24:02 1997
***************
*** 72,79 ****
  
  # It seems simplest to keep this separate. Use find and cpio instead of
  # just cp -r in case the source hierarchy is cvs- or rcs-ified.
  install-fonts:
! 	find fonts -name \*.tfm -o -name \*.vf -print | cpio -pld $(texmf)
  
  uninstall-data:
  	rm -f $(mandir)/dvilj.$(manext)
--- 72,81 ----
  
  # It seems simplest to keep this separate. Use find and cpio instead of
  # just cp -r in case the source hierarchy is cvs- or rcs-ified.
+ # Use "" to quote wildcards because backslash is a directory separator
+ # on MS-DOS and MS-Windows.
  install-fonts:
! 	find fonts \( -name "*.tfm" -o -name "*.vf" \) -print | cpio -pld $(texmf)
  
  uninstall-data:
  	rm -f $(mandir)/dvilj.$(manext)
*** ./dviljk/config.h~0	Sun Dec  8 00:18:56 1996
--- ./dviljk/config.h	Tue May  6 12:22:04 1997
***************
*** 250,257 ****
  #endif
  #endif
  
! 
! #ifdef unix
  #define OS "Unix"
  #define READ_BINARY     "r"
  #define WRITE_BINARY    "w"
--- 250,256 ----
  #endif
  #endif
  
! #if defined (unix) && !defined (__DJGPP__)
  #define OS "Unix"
  #define READ_BINARY     "r"
  #define WRITE_BINARY    "w"
***************
*** 261,270 ****
  #endif
  
  #ifdef MSDOS
! #define OS "MS-DOS"
! #define READ_BINARY     "rb"
! #define WRITE_BINARY    "wb"
! #define MSC5
  #endif
  #ifdef OS2
  #define OS "OS/2"
--- 260,274 ----
  #endif
  
  #ifdef MSDOS
! # define OS "MS-DOS"
! # define READ_BINARY     "rb"
! # define WRITE_BINARY    "wb"
! # ifdef __DJGPP__
! #  include <io.h>		/* for prototype of `setmode' */
! #  define AssureBinary(f) setmode((f), O_BINARY)
! # else
! #  define MSC5			/* assume Microsoft C */
! # endif
  #endif
  #ifdef OS2
  #define OS "OS/2"
***************
*** 276,281 ****
--- 280,287 ----
  #define OS "Win32"
  #define READ_BINARY     "rb"
  #define WRITE_BINARY    "wb"
+ #  include <io.h>		/* for prototype of `_setmode' */
+ #  define AssureBinary(f) _setmode((f), _O_BINARY)
  #define MSC10
  #endif
  
***************
*** 411,413 ****
--- 417,430 ----
  # define SEEK_END 2
  #endif
  
+ #ifndef O_BINARY
+ # ifdef _O_BINARY
+ #  define O_BINARY _O_BINARY
+ # else
+ #  define O_BINARY 0
+ #endif
+ #endif
+ 
+ #if !defined (AssureBinary) && !defined (MSC5)
+ # define AssureBinary(f)  0
+ #endif
*** ./dviljk/dvi2xx.c~0	Fri Feb  7 20:45:20 1997
--- ./dviljk/dvi2xx.c	Mon Jun 23 18:20:56 1997
*************** char    *argv[];
*** 248,256 ****
    xosfile_set_type(EmitFileName,0xff4);
  #endif
  
! #ifdef MSDOS
!   AssureBinary(outfp);
! #endif
  
  #ifdef TIMING
  #ifdef BSD_TIME_CALLS
--- 248,258 ----
    xosfile_set_type(EmitFileName,0xff4);
  #endif
  
!   /* If EmitFileName is "-", we use stdout.  But it is by default open
!      in TEXT mode, and we need to switch it to binary, unless they are
!      writing to the screen (in which case they get what they deserve).  */
!   if (O_BINARY && !isatty(fileno(outfp)))
!     AssureBinary(fileno(outfp));
  
  #ifdef TIMING
  #ifdef BSD_TIME_CALLS
*************** char c;
*** 1275,1281 ****
  #endif /* IBM3812 */
  
  
! #ifdef MSDOS
  /*-->AssureBinary*/
  /**********************************************************************/
  /*************************** AssureBinary *****************************/
--- 1277,1283 ----
  #endif /* IBM3812 */
  
  
! #ifdef MSC5
  /*-->AssureBinary*/
  /**********************************************************************/
  /*************************** AssureBinary *****************************/
*************** FILEPTR f;
*** 1314,1320 ****
      intdos(&regs, &regs);               /* call DOS interrupt     */
    }
  }
! #endif /* MSDOS */
  
  /*------------------------ end dviIO.c ----------------------------------*/
  
--- 1316,1322 ----
      intdos(&regs, &regs);               /* call DOS interrupt     */
    }
  }
! #endif /* MSC5 */
  
  /*------------------------ end dviIO.c ----------------------------------*/
  
*************** check_checksum (c1, c2, name)
*** 2901,2907 ****
      unsigned c1, c2;
      const char *name;
  {
!   if (c1 && c2 && c1 != c2 && !kpse_tex_hush ("checksum")) {
       Warning ("Checksum mismatch in %s", name) ;
     }
  }
--- 2903,2913 ----
      unsigned c1, c2;
      const char *name;
  {
!   if (c1 && c2 && c1 != c2
! #ifdef KPATHSEA
!       && !kpse_tex_hush ("checksum")
! #endif
!       ) {
       Warning ("Checksum mismatch in %s", name) ;
     }
  }
*************** Primary author of Dvi2xx: Gustaf Neumann
*** 3313,3320 ****
--- 3319,3338 ----
          dvifp = BINOPEN("Kbd:");
  #else
          dvifp = stdin;
+ 	if (O_BINARY && !isatty(fileno(dvifp)))
+ 	  AssureBinary(fileno(dvifp));
  #endif
        } else {
+ #ifdef KPATHSEA
+         /* split into directory + file name */
+ 	tcp = (char *)basename(argv[argind]);/* this knows about any kind of slashes */
+ 	if (tcp == argv[argind])
+ 	  curarea[0] = '\0';
+ 	else {
+ 	  (void) strcpy(curarea, argv[argind]);
+ 	  curarea[tcp-argv[argind]] = '\0';
+ 	}
+ #else
          tcp = strrchr(argv[argind], '/');
          /* split into directory + file name */
          if (tcp == NULL) {
*************** Primary author of Dvi2xx: Gustaf Neumann
*** 3325,3330 ****
--- 3343,3349 ----
            curarea[tcp-argv[argind]+1] = '\0';
            tcp += 1;
          }
+ #endif
  
          (void) strcpy(curname, tcp);
          /* split into file name + extension */
*************** Primary author of Dvi2xx: Gustaf Neumann
*** 3352,3358 ****
                filename[l - 4] = '\0';
            }
            if (tcp1 != NULL || (dvifp = BINOPEN(filename)) == FPNULL) {
! #ifdef MSDOS
              Fatal("%s: can't find DVI file \"%s\"\n\n",
                    G_progname, filename);
  #else
--- 3371,3377 ----
                filename[l - 4] = '\0';
            }
            if (tcp1 != NULL || (dvifp = BINOPEN(filename)) == FPNULL) {
! #ifdef MSC5
              Fatal("%s: can't find DVI file \"%s\"\n\n",
                    G_progname, filename);
  #else
*************** Primary author of Dvi2xx: Gustaf Neumann
*** 3457,3467 ****
--- 3476,3488 ----
      fprintf(ERR_STREAM,"\t-z  ..... print test page with pagecounter after job\n");
  #endif
      fprintf(ERR_STREAM,"\t-   ..... dvifile is stdin (must be seekable); implies -e-\n");
+ #ifdef KPATHSEA
      {
        extern DllImport char *kpse_bug_address;
        putc ('\n', ERR_STREAM);
        fputs (kpse_bug_address, ERR_STREAM);
      }
+ #endif
      exit(1);
    }
    if (EQ(EmitFileName, "")) {
*************** printf("[%ld]=%lf * %lf * %lf + 0.5 = %l
*** 4997,5003 ****
            strcpy (tfontptr->name, name);
            free (name);
            
!           if (!STREQ (tfontptr->n, font_ret.name)) {
                fprintf (stderr,
                         "dvilj: Font %s not found, using %s at %d instead.\n",
                         tfontptr->n, font_ret.name, font_ret.dpi);
--- 5018,5024 ----
            strcpy (tfontptr->name, name);
            free (name);
            
!           if (!FILESTRCASEEQ (tfontptr->n, font_ret.name)) {
                fprintf (stderr,
                         "dvilj: Font %s not found, using %s at %d instead.\n",
                         tfontptr->n, font_ret.name, font_ret.dpi);
*** ./dviljk/dvi2xx.h~0	Sun Dec  8 00:13:56 1996
--- ./dviljk/dvi2xx.h	Mon Jun  9 14:22:08 1997
***************
*** 37,43 ****
  # include <fcntl.h>
  # endif
  #endif
! #ifdef MSDOS
  #include <dos.h>     /* only for binaryopen on device  */
  #endif
  #if defined (unix) && !defined (KPATHSEA)
--- 37,43 ----
  # include <fcntl.h>
  # endif
  #endif
! #ifdef MSC5
  #include <dos.h>     /* only for binaryopen on device  */
  #endif
  #if defined (unix) && !defined (KPATHSEA)
***************
*** 57,74 ****
  #ifdef __riscos
  # ifdef RISC_USE_OSL
  #  define MAXOPEN_OS    16
! #else
  #  define MAXOPEN_OS    8      /* don't know if this IS the maximum */
  # endif
  #else
  # ifdef   OPEN_MAX                    /* ... in a friendly unix system  */
  #  ifndef vms
! #   define  MAXOPEN_OS (OPEN_MAX - 8)
  #  else
  #   define  MAXOPEN_OS 12     /* OPEN_MAX seems to be 8 on VMS systems */
  #  endif
  # else
! #  define  MAXOPEN_OS  12     /* limit on number of open font files */
  # endif
  #endif
  
--- 57,82 ----
  #ifdef __riscos
  # ifdef RISC_USE_OSL
  #  define MAXOPEN_OS    16
! # else
  #  define MAXOPEN_OS    8      /* don't know if this IS the maximum */
  # endif
  #else
  # ifdef   OPEN_MAX                    /* ... in a friendly unix system  */
  #  ifndef vms
! #   define MAXOPEN_OS (OPEN_MAX - 8)
  #  else
  #   define  MAXOPEN_OS 12     /* OPEN_MAX seems to be 8 on VMS systems */
  #  endif
  # else
! #  ifdef __DJGPP__
!     /* DJGPP needs few handles free in the first 20, or else child programs
!        (called by MakeTeX... scripts) won't run, since the stub loader
!        cannot open the .exe program.  This is because DOS only copies the
!        first 20 handles to the child program.  */
! #   define MAXOPEN_OS   5
! #  else
! #   define  MAXOPEN_OS  12     /* limit on number of open font files */
! #  endif
  # endif
  #endif
  
***************
*** 299,305 ****
  void    setbuf();
  #  endif
  
! #  ifdef MSDOS
  int     intdos();
  #  endif
  # endif
--- 307,313 ----
  void    setbuf();
  #  endif
  
! #  ifdef MSC5
  int     intdos();
  #  endif
  # endif
***************
*** 441,447 ****
  
  double  ActualFactor DVIPROTO((long4));
  void    AllDone DVIPROTO((bool));
! #ifdef  MSDOS
  void    AssureBinary DVIPROTO((FILEPTR));  /* DOS and Microsoft C dependent !!! */
  #endif
  void    CloseFiles DVIPROTO((void));
--- 449,455 ----
  
  double  ActualFactor DVIPROTO((long4));
  void    AllDone DVIPROTO((bool));
! #ifdef  MSC5
  void    AssureBinary DVIPROTO((FILEPTR));  /* DOS and Microsoft C dependent !!! */
  #endif
  void    CloseFiles DVIPROTO((void));
*** ./dviljk/README.~0	Sun Jun  2 14:18:10 1996
--- ./dviljk/README	Thu Jun 19 11:30:50 1997
***************
*** 13,20 ****
  Aside from configuration, this differs from the original primarily in
  that it uses the same code for path searching as TeX and my other
  distributions.  I haven't tested the non-Unix support present in the
! original, or support for any device but the LJ4. I also moved the
! inessential files to a directory `contrib'.
  
  dviljk is free software; Gustaf's original files are (I believe) public
  domain.  The files I wrote are covered by the GNU General Public License
--- 13,22 ----
  Aside from configuration, this differs from the original primarily in
  that it uses the same code for path searching as TeX and my other
  distributions.  I haven't tested the non-Unix support present in the
! original, or support for any device but the LJ4.  However, I'm told that
! dviljk does work on MS-DOS/MS-Windows when compiled with either DJGPP
! port of GNU C or with Microsoft Visual C compilers.  At least in the
! DJGPP port, the LJ and LJ2P devices were reported to work.
  
  dviljk is free software; Gustaf's original files are (I believe) public
  domain.  The files I wrote are covered by the GNU General Public License
*** ./dviljk/dvihp.~0	Fri Feb  7 20:45:22 1997
--- ./dviljk/dvihp	Sat May 24 16:53:08 1997
***************
*** 63,69 ****
      -l*) opt="$opt `echo $1 | sed s/l/t/`";;
      -m)  opt="$opt -A";;                        # -m => -A (manual feed)
      -n)  shift; opt="$opt -p$1";;               # -n => -p (page count)
!     -n*) opt="$opt `echo $1 | sed s/d/-p/`";;
      -o)  if test $# -eq 1; then                 # -o (output file)
             # No remaining args, output to foo.lj.
             output=`basename $infile .dvi`.lj
--- 63,69 ----
      -l*) opt="$opt `echo $1 | sed s/l/t/`";;
      -m)  opt="$opt -A";;                        # -m => -A (manual feed)
      -n)  shift; opt="$opt -p$1";;               # -n => -p (page count)
!     -n*) opt="$opt `echo $1 | sed s/^-n/-p/`";;
      -o)  if test $# -eq 1; then                 # -o (output file)
             # No remaining args, output to foo.lj.
             output=`basename $infile .dvi`.lj
***************
*** 89,97 ****
    shift
  done
  
! vfless_dvi=$TMPDIR/$$.dvi-vf
! dvicopy_log=$TMPDIR/$$.dvicopy
! dvilj_log=$TMPDIR/$$.dvilj
  
  # Expand VF references.
  # If $infile is null, this will read standard input.
--- 89,98 ----
    shift
  done
  
! # Make sure the filenames are unique on MS-DOS
! vfless_dvi=$TMPDIR/dvi$$.-vf
! dvicopy_log=$TMPDIR/dvi$$.copy
! dvilj_log=$TMPDIR/dvi$$.lj
  
  # Expand VF references.
  # If $infile is null, this will read standard input.
***************
*** 120,123 ****
    exit 2
  fi
  
! rm -f $TMPDIR/$$.*
--- 121,124 ----
    exit 2
  fi
  
! rm -f $TMPDIR/dvi$$.*
*** ./dvipsk/dvips.c~0	Fri Feb  7 20:43:24 1997
--- ./dvipsk/dvips.c	Sun May  4 17:31:00 1997
*************** extern char *getcwd (char *, int);
*** 205,211 ****
  extern char *getcwd ();
  #endif /* not ANSI */
  #endif /* not HAVE_GETWD */
! #if defined(SYSV) || defined(VMS) || defined(MSDOS) || defined(OS2) || defined(ATARIST)
  #define MAXPATHLEN (256)
  #else
  #include <sys/param.h>          /* for MAXPATHLEN */
--- 205,211 ----
  extern char *getcwd ();
  #endif /* not ANSI */
  #endif /* not HAVE_GETWD */
! #if defined(SYSV) || defined(VMS) || (defined(MSDOS) && !defined(__DJGPP__)) || defined(OS2) || defined(ATARIST)
  #define MAXPATHLEN (256)
  #else
  #include <sys/param.h>          /* for MAXPATHLEN */
*************** default:
*** 912,922 ****
                 lastext = 0 ;
                 iname = nextstring ;
                 p = argv[i] ;
                 while (*p) {
                    *nextstring = *p++ ;
                    if (*nextstring == '.')
                       lastext = nextstring - iname ;
!                   else if (*nextstring == '/' || *nextstring == ':')
                       lastext = 0 ;
                    nextstring++ ;
                 }
--- 912,926 ----
                 lastext = 0 ;
                 iname = nextstring ;
                 p = argv[i] ;
+ 	       if (NAME_BEGINS_WITH_DEVICE(p)) { /* get past DOSISH drive */
+ 		  *nextstring++ = *p++ ;
+ 		  *nextstring++ = *p++ ;
+ 	       }
                 while (*p) {
                    *nextstring = *p++ ;
                    if (*nextstring == '.')
                       lastext = nextstring - iname ;
!                   else if (IS_DIR_SEP(*nextstring))
                       lastext = 0 ;
                    nextstring++ ;
                 }
*************** default:
*** 1057,1066 ****
   *   or slash.
   */
        {
!          char *p ;
  
!          for (p=oname; *p && p[1]; p++)
!             if (*p == ':' || *p == DIR_SEP)
                 oname = p + 1 ;
        }
     }
--- 1061,1070 ----
   *   or slash.
   */
        {
!          char *p = NAME_BEGINS_WITH_DEVICE(oname) ? oname + 2 : oname ;
  
!          for (oname=p; *p && p[1]; p++)
!             if (IS_DIR_SEP(*p))
                 oname = p + 1 ;
        }
     }
*************** default:
*** 1092,1098 ****
     if (*iname != 0) {
        fulliname = nextstring ;
  #ifndef IGNORE_CWD
!       if (*iname != '/') {
          getcwd(nextstring, MAXPATHLEN + 2);
          while (*nextstring++) ;
  #ifdef VMS              /* VMS doesn't need the '/' character appended */
--- 1096,1102 ----
     if (*iname != 0) {
        fulliname = nextstring ;
  #ifndef IGNORE_CWD
!       if (!IS_DIR_SEP(*iname) && !NAME_BEGINS_WITH_DEVICE(iname)) {
          getcwd(nextstring, MAXPATHLEN + 2);
          while (*nextstring++) ;
  #ifdef VMS              /* VMS doesn't need the '/' character appended */
*************** default:
*** 1103,1112 ****
        }
  #endif
        strcpy(nextstring,iname) ;
!       while (*nextstring++) ; /* advance nextstring past fulliname */
!    } else if (filter)
!       dvifile = stdin;
!    else {
        fprintf (stderr, "Missing DVI file argument (or -f).\n");
        fprintf (stderr, "Try --help for more information.\n");
        exit (1);
--- 1107,1118 ----
        }
  #endif
        strcpy(nextstring,iname) ;
!       while (*nextstring++) ; /* advance nextstring past iname */
!    } else if (filter) {
!       dvifile = stdin ;
!       if (O_BINARY && !isatty(fileno(stdin)))
! 	 SET_BINARY(fileno(stdin)) ;
!    } else {
        fprintf (stderr, "Missing DVI file argument (or -f).\n");
        fprintf (stderr, "Try --help for more information.\n");
        exit (1);
*** ./dvipsk/dvips.t~0	Mon Feb  3 00:19:12 1997
--- ./dvipsk/dvips.texi	Wed Jun 18 18:08:08 1997
***************
*** 23,29 ****
  @direntry
  * DVI-to-Postscript: (dvips).        Translating TeX DVI files to PostScript.
  * afm2tfm: (dvips)Invoking afm2tfm.  Making Type 1 fonts available to TeX.
! * dvips: (dvips)Invoking dvips.      DVI-to-PostScript translator.
  @end direntry
  
  @titlepage
--- 23,29 ----
  @direntry
  * DVI-to-Postscript: (dvips).        Translating TeX DVI files to PostScript.
  * afm2tfm: (dvips)Invoking afm2tfm.  Making Type 1 fonts available to TeX.
! * dvips: (dvips)Invoking Dvips.      DVI-to-PostScript translator.
  @end direntry
  
  @titlepage
***************
*** 914,923 ****
  @kindex - @r{as output filename}
  @kindex ! @r{starting output filename}
  @kindex | @r{starting output filename}
  If @var{name} is @samp{-}, output goes to standard output.  If the first
  character of @var{name} is @samp{!} or @samp{|}, then the remainder will
  be used as an argument to @code{popen}; thus, specifying @samp{|lpr} as
! the output file will automatically queue the file for printing as usual.
  
  @samp{-o} disables the automatic reading of the @code{PRINTER}
  environment variable, and turns off the automatic sending of control-D.
--- 914,928 ----
  @kindex - @r{as output filename}
  @kindex ! @r{starting output filename}
  @kindex | @r{starting output filename}
+ @cindex lpr spooler, MS-DOS emulation
+ @cindex spooling to lpr on MS-DOS
  If @var{name} is @samp{-}, output goes to standard output.  If the first
  character of @var{name} is @samp{!} or @samp{|}, then the remainder will
  be used as an argument to @code{popen}; thus, specifying @samp{|lpr} as
! the output file will automatically queue the file for printing as
! usual.  (The MS-DOS version will print to the local printer device
! @file{PRN} when @var{name} is @samp{|lpr} and a program by that name
! cannot be found.)
  
  @samp{-o} disables the automatic reading of the @code{PRINTER}
  environment variable, and turns off the automatic sending of control-D.
***************
*** 971,987 ****
  @item -P @var{printer}
  @opindex -P @var{printer}
  @flindex config.ps
! Read the configuration file @file{config.@var{printer}}, which can set
! the output name (most likely @samp{o |lpr -P@var{printer}}), resolution,
! Metafont mode, and perhaps font paths and other printer-specific
! defaults.  It works best to put sitewide defaults in the one master
! @samp{config.ps} file and only things that vary printer to printer in
! the @samp{config.@var{printer}} files; @samp{config.ps} is read before
  @samp{config.@var{printer}}.
  
  If no @samp{-P} or @samp{-o} is given, the environment variable
  @code{PRINTER} is checked.  If that variable exists, and a corresponding
! @file{config.@var{printer}} file exists, it is read.
  @xref{Configuration file searching}.
  
  @item -q*
--- 976,994 ----
  @item -P @var{printer}
  @opindex -P @var{printer}
  @flindex config.ps
! Read the configuration file @file{config.@var{printer}}
! (@file{@var{printer}.cfg} on MS-DOS), which can set the output name
! (most likely @samp{o |lpr -P@var{printer}}), resolution, Metafont mode,
! and perhaps font paths and other printer-specific defaults.  It works
! best to put sitewide defaults in the one master @samp{config.ps} file
! and only things that vary printer to printer in the
! @samp{config.@var{printer}} files; @samp{config.ps} is read before
  @samp{config.@var{printer}}.
  
  If no @samp{-P} or @samp{-o} is given, the environment variable
  @code{PRINTER} is checked.  If that variable exists, and a corresponding
! @file{config.@var{printer}} (@file{@var{printer}.cfg} on MS-DOS) file
! exists, it is read.
  @xref{Configuration file searching}.
  
  @item -q*
***************
*** 1151,1156 ****
--- 1158,1168 ----
  @code{MakeTeXPK} program with the @code{MAKETEXPK} environment
  variable; @pxref{MakeTeX script arguments,,, kpathsea, Kpathsea}.
  
+ @item DVIPSRC
+ Specifies the name of the startup file (@pxref{Configuration file
+ searching}) which is read after @file{config.ps} but before any
+ printer-specific configuration files.
+ 
  @item DVIPSSIZES
  @cindex last-resort font scaling, with @code{DVIPSSIZES}
  Last-resort sizes for scaling of unfound fonts.  Overrides the @samp{R}
***************
*** 1164,1170 ****
  @cindex configuration file path
  Path to search for Dvips' @file{config.@var{printer}} configuration
  files, including the base @file{config.ps}.  Using this single
! environment variable, you can override everything else.
  
  @item TEXPICTS
  Path to search for included graphics files.  Overrides the @samp{S}
--- 1176,1185 ----
  @cindex configuration file path
  Path to search for Dvips' @file{config.@var{printer}} configuration
  files, including the base @file{config.ps}.  Using this single
! environment variable, you can override everything else.  (The
! printer-specific configuration files are called @file{@var{printer}.cfg}
! on MS-DOS, but @file{config.ps} is called by that name on all
! platforms.)
  
  @item TEXPICTS
  Path to search for included graphics files.  Overrides the @samp{S}
***************
*** 1181,1187 ****
  @cindex configuration files
  
  This section describes in detail the Dvips-specific @file{config.*}
! device configuration files, which override the @file{texmf.cnf}
  configuration files generic to Kpathsea which Dvips also reads
  (@pxref{Config files,,, kpathsea, Kpathsea}).
  
--- 1196,1203 ----
  @cindex configuration files
  
  This section describes in detail the Dvips-specific @file{config.*}
! device configuration files (called @file{*.cfg} on MS-DOS), which
! override the @file{texmf.cnf}
  configuration files generic to Kpathsea which Dvips also reads
  (@pxref{Config files,,, kpathsea, Kpathsea}).
  
***************
*** 1213,1220 ****
  
  @item
  @flindex .dvipsrc@r{, searched for}
! @file{$HOME/.dvipsrc} is loaded, so individual users can override any
! options set in the global file.
  
  @item
  @opindex -P@var{printer}@r{, and config file searching}
--- 1229,1245 ----
  
  @item
  @flindex .dvipsrc@r{, searched for}
! A user-specific startup file is loaded, so individual users can override
! any options set in the global file.  The environment variable
! @code{DVIPSRC}, if defined, is used as the specification of the startup
! file.  If this variable is undefined, Dvips uses a platform-specific
! default name.  On Unix Dvips looks for the default startup file under
! the name @file{$HOME/.dvipsrc}, which is in the user's home directory.
! On MS-DOS and MS-Windows, where users generally don't have their private
! directories, the startup file is called @file{dvips.ini} and it is
! searched for along the path for Dvips configuration files (as described
! in @ref{Supported file formats,,, kpathsea, Kpathsea}.); users are
! expected to set this path as they see fit for their taste.
  
  @item
  @opindex -P@var{printer}@r{, and config file searching}
***************
*** 1223,1236 ****
  Thus, the printer configuration file can override anything in the
  site-wide or user configuration file, and it can also override options
  in the command line up to the point that the @samp{-P} option was
! encountered.
  
  @item
  @vindex PRINTER@r{, and config file searching}
  If no @samp{-P} option was specified, and also the @samp{-o} and
  @samp{-f} command line options were not used, Dvips checks the
  environment variable @code{PRINTER}.  If it exists, then
! @file{config.@var{$PRINTER}} is loaded (if it exists).
  
  @end enumerate
  
--- 1248,1264 ----
  Thus, the printer configuration file can override anything in the
  site-wide or user configuration file, and it can also override options
  in the command line up to the point that the @samp{-P} option was
! encountered.  (On MS-DOS, the printer configuration files are called
! @file{@var{device}.cfg}, since DOS doesn't allow more than 3 characters
! after the dot in filenames.)
  
  @item
  @vindex PRINTER@r{, and config file searching}
  If no @samp{-P} option was specified, and also the @samp{-o} and
  @samp{-f} command line options were not used, Dvips checks the
  environment variable @code{PRINTER}.  If it exists, then
! @file{config.@var{$PRINTER}} (@file{@var{$PRINTER}.cfg} on MS-DOS) is
! loaded (if it exists).
  
  @end enumerate
  
***************
*** 1390,1395 ****
--- 1418,1426 ----
  @example
  o |lpr -Pfoo
  @end example
+ The MS-DOS version will emulate spooling to @code{lpr} by printing to
+ the local printer device @file{PRN} if it doesn't find an executable
+ program by that name in the current directory or along the @code{PATH}.
  
  @item O @var{xoff},@var{yoff}
  @opindex O @r{config command (offset)}
***************
*** 2160,2166 ****
  
  PostScript is an excellent page description language---but it does tend
  to be rather verbose.  Compressing PostScript graphics files can reduce
! them by factor of five or more.  For this reason, if a the name of an
  included PostScript file ends with @file{.Z} or @file{.gz}, Dvips
  automatically runs @samp{gzip -d}.  For example:
  
--- 2191,2197 ----
  
  PostScript is an excellent page description language---but it does tend
  to be rather verbose.  Compressing PostScript graphics files can reduce
! them by factor of five or more.  For this reason, if the name of an
  included PostScript file ends with @file{.Z} or @file{.gz}, Dvips
  automatically runs @samp{gzip -d}.  For example:
  
***************
*** 2322,2328 ****
  option @samp{-P @var{header}}; this will read the file
  @file{config.@var{header}}, which in turn can specify a header file to
  be downloaded with the @samp{h} option. @xref{Configuration file
! commands}.
  
  @cindex duplex printers
  @cindex simplex mode on duplex printers
--- 2353,2359 ----
  option @samp{-P @var{header}}; this will read the file
  @file{config.@var{header}}, which in turn can specify a header file to
  be downloaded with the @samp{h} option. @xref{Configuration file
! commands}.  These files are called @file{@var{header}.cfg} on MS-DOS.
  
  @cindex duplex printers
  @cindex simplex mode on duplex printers
***************
*** 2331,2340 ****
  and the downloadable header file, by starting the lines of PostScript
  code with a space, leaving only the @samp{h} line and any comments
  starting in the first column.  As an example, see
! @file{contrib/volker/config.*}.  (These files also perform useful
! functions: controlling duplex/simplex mode on duplex printers, and
! setting various screen frequencies; @file{contrib/volker/README} explains
! further.)
  
  
  @node Headers and memory usage
--- 2362,2371 ----
  and the downloadable header file, by starting the lines of PostScript
  code with a space, leaving only the @samp{h} line and any comments
  starting in the first column.  As an example, see
! @file{contrib/volker/config.*} (@file{contrib/volker/*.cfg} on MS-DOS).
! (These files also perform useful functions: controlling duplex/simplex
! mode on duplex printers, and setting various screen frequencies;
! @file{contrib/volker/README} explains further.)
  
  
  @node Headers and memory usage
***************
*** 4250,4256 ****
  @noindent
  This will then define @samp{Goldenrod} in your device's CMYK values in
  @file{userdict} which is checked before defining it in @file{TeXdict} by
! @file{color.pro}.
  
  This mechanism, together with additions to @file{colordvi.tex} and
  @file{blackdvi.tex} (and the @samp{.sty} files), can also be used to
--- 4281,4288 ----
  @noindent
  This will then define @samp{Goldenrod} in your device's CMYK values in
  @file{userdict} which is checked before defining it in @file{TeXdict} by
! @file{color.pro}.  (On MS-DOS, you will have to call this file
! @file{mycolordev.cfg}.)
  
  This mechanism, together with additions to @file{colordvi.tex} and
  @file{blackdvi.tex} (and the @samp{.sty} files), can also be used to
*** ./dvipsk/output.c~0	Sun Jan 19 19:59:02 1997
--- ./dvipsk/output.c	Thu May 29 15:11:44 1997
***************
*** 17,22 ****
--- 17,26 ----
  #define pclose(pstream) _pclose(pstream)
  #endif
  #endif
+ 
+ #ifdef __DJGPP__
+ #include <unistd.h>	/* for `isatty' */
+ #endif
  /*
   *   The external routines called here:
   */
*************** copyfile(s)
*** 168,174 ****
  #ifndef VMCMS
  #ifndef MVSXA
  #ifndef VMS
! #ifndef MSDOS
  #ifndef ATARIST
  #ifndef __THINK__
     case 2:
--- 172,178 ----
  #ifndef VMCMS
  #ifndef MVSXA
  #ifndef VMS
! #if !defined(MSDOS) || defined(__DJGPP__)
  #ifndef ATARIST
  #ifndef __THINK__
     case 2:
*************** copyfile(s)
*** 179,185 ****
        if (_osmode == OS2_MODE) {
  #endif
        if (secure == 0)
!          f = popen(s, "r") ;
  #ifdef OS2
        }
  #endif
--- 183,189 ----
        if (_osmode == OS2_MODE) {
  #endif
        if (secure == 0)
!          f = popen(s, FOPEN_RBIN_MODE) ;
  #ifdef OS2
        }
  #endif
*************** copyfile(s)
*** 236,246 ****
--- 240,262 ----
        c = getc(f) ;
        if (c == 0x80) {
  #if defined (MSDOS) || defined (OS2) || defined (ATARIST) || defined (WIN32)
+ #ifdef __DJGPP__
+ 	/* How in the world does this work for OS2 and WIN32?  If infigure
+ 	   is 2, they did a `popen', right?  But `headerpath' is only open
+ 	   when `infigure' is 1, so how can they reopen `headerpath' here?
+ 
+ 	   Note that DJGPP opens the pipe in binary mode, so we don't need
+ 	   to do anything here.  */
+ 	if (infigure != 2) {
+ #endif
           (void)close_file(f) ;  /* close MSDOS font file */
           f = search(headerpath, s, READBIN) ;  /* reopen in BINARY mode */
           (void)sprintf(errbuf, "! Couldn't find header file %s", s) ;
           if (f==NULL)
             error(errbuf) ;
+ #ifdef __DJGPP__
+ 	 }
+ #endif
           c = getc(f);
  #endif
           while (1) {
*************** msdosdone:
*** 309,314 ****
--- 325,334 ----
              if ((getc(f)=='P'+0x80) && (getc(f)=='S'+0x80)
  	                            && (getc(f)=='F'+0x80)) {
  #if defined (MSDOS) || defined (OS2) || defined (WIN32)
+ #ifdef __DJGPP__
+ 	      /* See above.  The pipe is already binary in DJGPP.  */
+ 	       if (infigure != 2) {
+ #endif
                 (void)close_file(f) ;  /* close DOS EPS file */
                 f = search(headerpath, s, READBIN) ;
                                                     /* reopen in BINARY mode */
*************** msdosdone:
*** 316,321 ****
--- 336,344 ----
                 if (f==NULL)
                   error(errbuf) ;
                 fseek(f, 4L, 0);
+ #ifdef __DJGPP__
+ 	       }
+ #endif
  #endif
                 doseps = 1;
                 dosepsbegin = getc(f) ;
*************** msdosdone:
*** 328,338 ****
--- 351,367 ----
                 dosepsend += getc(f) * 256L * 65536 ;
                 dosepsend += dosepsbegin;
  #if defined (MSDOS) || defined (OS2) || defined (WIN32)
+ #ifdef __DJGPP__
+ 	       if (infigure != 2) {
+ #endif
                 (void)close_file(f) ;  /* close DOS EPS file */
                 f = search(headerpath, s, READ) ;  /* reopen in TEXT mode */
                 (void)sprintf(errbuf, "! Couldn't find header file %s", s) ;
                 if (f==NULL)
                   error(errbuf) ;
+ #ifdef __DJGPP__
+ 	       }
+ #endif
  #endif
                 fseek(f, dosepsbegin, 0);
                 c = getc(f);
*************** msdosdone:
*** 443,449 ****
  #ifndef VMCMS
  #ifndef MVSXA
  #ifndef VMS
! #ifndef MSDOS
  #ifndef ATARIST
  #ifndef __THINK__
        if (infigure == 2)
--- 472,478 ----
  #ifndef VMCMS
  #ifndef MVSXA
  #ifndef VMS
! #if !defined(MSDOS) || defined(__DJGPP__)
  #ifndef ATARIST
  #ifndef __THINK__
        if (infigure == 2)
*************** integer bop ;
*** 987,999 ****
  static char *isepsf = 0 ;
  static int endprologsent ;
  void open_output() {
     if (*oname != 0) {
  /*
   *   We check to see if the first character is a exclamation
   *   point, and popen if so.
   */
        if (*oname == '!' || *oname == '|') {
! #ifdef MSDOS
              error("! can't open output pipe") ;
  #else
  #ifdef VMS
--- 1016,1029 ----
  static char *isepsf = 0 ;
  static int endprologsent ;
  void open_output() {
+    FILE * pf = NULL;
     if (*oname != 0) {
  /*
   *   We check to see if the first character is a exclamation
   *   point, and popen if so.
   */
        if (*oname == '!' || *oname == '|') {
! #if defined (MSDOS) && !defined (__DJGPP__)
              error("! can't open output pipe") ;
  #else
  #ifdef VMS
*************** void open_output() {
*** 1016,1025 ****
              error("! can't open output pipe") ;
           } else {
  #endif
!          if (secure || (bitfile=popen(oname+1, "w"))==NULL)
              error("! couldn't open output pipe") ;
!          else
!             popened = 1 ;
  #ifdef OS2
           }
  #endif
--- 1046,1084 ----
              error("! can't open output pipe") ;
           } else {
  #endif
! #ifdef __DJGPP__
! 	 if (!secure) {
! 	    /* Feature: if they pipe to "lpr" and there's no executable by
! 	       that name anywhere in sight, write to local printer instead.
! 
! 	       We do this up front, before even trying to popen, because on
! 	       MS-DOS popen always succeeds for writing (it only opens a
! 	       temporary file), and by the time we get to actually run the
! 	       (possibly nonexistent) program in pclose, it's too late to
! 	       fall back.
! 
! 	       We don't use kpathsea functions here because they don't
! 	       know about DOS-specific executable extensions, while we
! 	       want to be able to find "lpr.exe", "lpr.com", "lpr.bat" etc.  */
! 	    extern char *__dosexec_find_on_path(const char *,
! 						char **, char *) ;
! 	    extern char **environ ;
! 	    char *p = oname + 1 ;
! 	    char found[FILENAME_MAX] ;
! 
! 	    while (ISSPACE(*p))
! 	      p++ ;
! 	    if (strncmp(p, "lpr", 3) == 0 && (ISSPACE(p[3]) || p[3] == '\0')
! 		&& !__dosexec_find_on_path(oname+1, (char **)0, found)
! 		&& !__dosexec_find_on_path(oname+1, environ, found))
! 	       pf = fopen("PRN", "w") ;
! 	 }
! #endif
! 	 if (!secure && pf == NULL && (pf = popen(oname+1, "w")) != NULL)
! 	    popened = 1;
!          if (pf == NULL)
              error("! couldn't open output pipe") ;
! 	 bitfile = pf;
  #ifdef OS2
           }
  #endif
*************** void open_output() {
*** 1036,1046 ****
--- 1095,1111 ----
     } else {
        bitfile = stdout ;
     }
+ 
+    /* Even PostScript output may include binary characters, so switch
+       bitfile to binary mode.  */
+    if (O_BINARY && !isatty(fileno(bitfile)))
+       SET_BINARY(fileno(bitfile)) ;
  }
  void
  initprinter(sect)
  sectiontype *sect ;
  {
+    FILE * pf = NULL;
     void tell_needed_fonts() ;
     int n = sect->numpages; /* number of pages if greater than 0 */
     n *= pagecopies * collatedcopies ;
*************** sectiontype *sect ;
*** 1052,1058 ****
   *   point, and popen if so.
   */
        if (*oname == '!' || *oname == '|') {
! #ifdef MSDOS
              error("! can't open output pipe") ;
  #else
  #ifdef VMS
--- 1117,1123 ----
   *   point, and popen if so.
   */
        if (*oname == '!' || *oname == '|') {
! #if defined (MSDOS) && !defined (__DJGPP__)
              error("! can't open output pipe") ;
  #else
  #ifdef VMS
*************** sectiontype *sect ;
*** 1075,1084 ****
              error("! can't open output pipe") ;
           } else {
  #endif
!          if (secure || (bitfile=popen(oname+1, "w"))==NULL)
              error("! couldn't open output pipe") ;
!          else
!             popened = 1 ;
  #ifdef OS2
           }
  #endif
--- 1140,1166 ----
              error("! can't open output pipe") ;
           } else {
  #endif
! #ifdef __DJGPP__
! 	 if (!secure) {
! 	    extern char *__dosexec_find_on_path(const char *,
! 						char **, char *) ;
! 	    extern char **environ ;
! 	    char *p = oname + 1 ;
! 	    char found[FILENAME_MAX] ;
! 
! 	    while (ISSPACE(*p))
! 	      p++ ;
! 	    if (strncmp(p, "lpr", 3) == 0 && (ISSPACE(p[3]) || p[3] == '\0')
! 		&& !__dosexec_find_on_path(oname+1, (char **)0, found)
! 		&& !__dosexec_find_on_path(oname+1, environ, found))
! 	       pf = fopen("PRN", "w") ;
! 	 }
! #endif
! 	 if (!secure && pf == NULL && (pf = popen(oname+1, "w")) != NULL)
! 	    popened = 1;
!          if (pf == NULL)
              error("! couldn't open output pipe") ;
! 	 bitfile = pf;
  #ifdef OS2
           }
  #endif
*************** sectiontype *sect ;
*** 1103,1109 ****
   *   point, and popen if so.
   */
        if (*oname == '!' || *oname == '|') {
! #ifdef MSDOS
              error("! can't open output pipe") ;
  #else
  #ifdef VMS
--- 1185,1191 ----
   *   point, and popen if so.
   */
        if (*oname == '!' || *oname == '|') {
! #if defined (MSDOS) && !defined (__DJGPP__)
              error("! can't open output pipe") ;
  #else
  #ifdef VMS
*************** sectiontype *sect ;
*** 1126,1135 ****
              error("! can't open output pipe") ;
           } else {
  #endif
!          if (secure || (bitfile=popen(oname+1, "w"))==NULL)
              error("! couldn't open output pipe") ;
!          else
!             popened = 1 ;
  #ifdef OS2
           }
  #endif
--- 1208,1234 ----
              error("! can't open output pipe") ;
           } else {
  #endif
! #ifdef __DJGPP__
! 	 if (!secure) {
! 	    extern char *__dosexec_find_on_path(const char *,
! 						char **, char *) ;
! 	    extern char **environ ;
! 	    char *p = oname + 1 ;
! 	    char found[FILENAME_MAX];
! 
! 	    while (ISSPACE(*p))
! 	      p++ ;
! 	    if (strncmp(p, "lpr", 3) == 0 && (ISSPACE(p[3]) || p[3] == '\0')
! 		&& !__dosexec_find_on_path(oname+1, (char **)0, found)
! 		&& !__dosexec_find_on_path(oname+1, environ, found))
! 	       pf = fopen("PRN", "w") ;
! 	 }
! #endif
! 	 if (!secure && pf == NULL && (pf = popen(oname+1, "w")) != NULL)
! 	    popened = 1;
!          if (pf == NULL)
              error("! couldn't open output pipe") ;
! 	 bitfile = pf;
  #ifdef OS2
           }
  #endif
*************** sectiontype *sect ;
*** 1147,1152 ****
--- 1246,1256 ----
        bitfile = stdout ;
     }
  #endif
+ 
+    /* Even PostScript output may include binary characters.  */
+    if (O_BINARY && !isatty(fileno(bitfile)))
+       SET_BINARY(fileno(bitfile)) ;
+ 
     findpapersize() ;
     if (disablecomments)
        (void)fprintf(bitfile,
*************** cleanprinter()
*** 1333,1339 ****
        (void)putc(4, bitfile) ;
     if (ferror(bitfile))
        perror("dvips") ;
! #ifndef MSDOS
  #ifndef VMS
  #ifndef MVSXA
  #ifndef VMCMS
--- 1437,1443 ----
        (void)putc(4, bitfile) ;
     if (ferror(bitfile))
        perror("dvips") ;
! #if !defined(MSDOS) || defined(__DJGPP__)
  #ifndef VMS
  #ifndef MVSXA
  #ifndef VMCMS
*** ./dvipsk/config.h~0	Mon Oct 14 17:25:56 1996
--- ./dvipsk/config.h	Wed Apr 30 11:08:52 1997
***************
*** 10,20 ****
  /* How to open files with fopen.  */
  #include <kpathsea/c-fopen.h>
  
  /* Have to get the enum constants below, sigh.  Still better than
     repeating the definitions everywhere we need them.  */
  #include <kpathsea/tex-file.h>
  
! /* For kpathsea, we don't have have paths, we have formats.  This is so
     we can do lazy evaluation of only the formats we need, instead of
     having to initialize everything in the world.  */
  #define figpath kpse_pict_format
--- 10,23 ----
  /* How to open files with fopen.  */
  #include <kpathsea/c-fopen.h>
  
+ /* How the filenames' parts are separated.  */
+ #include <kpathsea/c-pathch.h>
+ 
  /* Have to get the enum constants below, sigh.  Still better than
     repeating the definitions everywhere we need them.  */
  #include <kpathsea/tex-file.h>
  
! /* For kpathsea, we don't have paths, we have formats.  This is so
     we can do lazy evaluation of only the formats we need, instead of
     having to initialize everything in the world.  */
  #define figpath kpse_pict_format
***************
*** 26,38 ****
  #define headerpath kpse_tex_ps_header_format
  #define type1 kpse_type1_format
  
! 
! #if defined (DOS) || defined (MSDOS)
  #undef DOS
  #undef MSDOS
  #define DOS
  #define MSDOS
  #endif
  
  /* dvips has a different name for this.  */
  #if SIZEOF_INT < 4
--- 29,41 ----
  #define headerpath kpse_tex_ps_header_format
  #define type1 kpse_type1_format
  
! #if (defined (DOS) || defined (MSDOS)) && !defined (__DJGPP__)
  #undef DOS
  #undef MSDOS
  #define DOS
  #define MSDOS
  #endif
+ 
  
  /* dvips has a different name for this.  */
  #if SIZEOF_INT < 4
*** ./dvipsk/search.c~0	Mon Jan  6 21:40:10 1997
--- ./dvipsk/search.c	Wed Apr 30 14:06:26 1997
*************** search(format, file, mode)
*** 51,60 ****
      unsigned len = strlen (found_name);
  #ifndef AMIGA
      if ((format == figpath || format == headerpath)
!         && ((len > 2 && strcmp (found_name + len - 2, ".Z") == 0)
!             || (len > 3 && strcmp (found_name + len - 3, ".gz") == 0))) {
        char *cmd = concat3 (UNCOMPRESS, "<", found_name);
!       ret = popen (cmd, "r");
        to_close = USE_PCLOSE ;
      } else {
  #endif /* not AMIGA */
--- 51,60 ----
      unsigned len = strlen (found_name);
  #ifndef AMIGA
      if ((format == figpath || format == headerpath)
!         && ((len > 2 && FILESTRCASEEQ (found_name + len - 2, ".Z"))
!             || (len > 3 && FILESTRCASEEQ (found_name + len - 3, ".gz")))) {
        char *cmd = concat3 (UNCOMPRESS, "<", found_name);
!       ret = popen (cmd, mode);
        to_close = USE_PCLOSE ;
      } else {
  #endif /* not AMIGA */
*** ./dvipsk/afm2tfm.c~0	Fri Feb  7 20:43:24 1997
--- ./dvipsk/afm2tfm.c	Sun May  4 17:28:50 1997
*************** openfiles(argc, argv)
*** 1505,1512 ****
  int argc ;
  char *argv[] ;
  {
-    register int lastext ;
     register int i ;
     int arginc ;
     tfmout = (FILE *)NULL ;
  
--- 1505,1512 ----
  int argc ;
  char *argv[] ;
  {
     register int i ;
+    char *p ;
     int arginc ;
     tfmout = (FILE *)NULL ;
  
*************** char *argv[] ;
*** 1522,1534 ****
  #endif
  #endif
     (void)strcpy(inname, argv[1]) ;
!    lastext = -1 ;
!    for (i=0; inname[i]; i++)
!       if (inname[i] == '.')
!          lastext = i ;
!       else if (inname[i] == '/' || inname[i] == ':')
!          lastext = -1 ;
!    if (lastext == -1) (void)strcat(inname, ".afm") ;
  
     while (argc>2 && *argv[2]=='-') {
        arginc = 2 ;
--- 1522,1529 ----
  #endif
  #endif
     (void)strcpy(inname, argv[1]) ;
!    if (find_suffix(inname) == NULL)
!        (void)strcat(inname, ".afm") ;
  
     while (argc>2 && *argv[2]=='-') {
        arginc = 2 ;
*************** char *argv[] ;
*** 1539,1551 ****
  case 'V': makevpl++ ;
  case 'v': makevpl++ ;
           (void)strcpy(outname, argv[3]) ;
!          lastext = -1 ;
!          for (i=0; outname[i]; i++)
!             if (outname[i] == '.')
!                lastext = i ;
!             else if (outname[i] == '/' || outname[i] == ':')
!                lastext = -1 ;
!          if (lastext == -1) (void)strcat(outname, ".vpl") ;
  #ifndef VMCMS
  #ifndef ATARIST
           if ((vplout=fopen(outname, WRITEBIN))==NULL)
--- 1534,1541 ----
  case 'V': makevpl++ ;
  case 'v': makevpl++ ;
           (void)strcpy(outname, argv[3]) ;
! 	 if (find_suffix(outname) == NULL)
! 	    (void)strcat(outname, ".vpl") ;
  #ifndef VMCMS
  #ifndef ATARIST
           if ((vplout=fopen(outname, WRITEBIN))==NULL)
*************** default: (void)fprintf(stderr, "Unknown 
*** 1606,1639 ****
     if (argc == 2) (void)strcpy(outname, inname) ;
     else (void)strcpy(outname, argv[2]) ;
  
!    lastext = -1 ;
!    for (i=0; outname[i]; i++)
!       if (outname[i] == '.')
!          lastext = i ;
!       else if (outname[i] == '/' || outname[i] == ':' || outname[i] == '\\')
!          lastext = -1 ;
!    if (argc == 2) {
!       outname[lastext] = 0 ;
!       lastext = -1 ;
!    }
!    if (lastext == -1) {
!       lastext = strlen(outname) ;
        (void)strcat(outname, ".tfm") ;
-    }
     if (tfmout == NULL && (tfmout=fopen(outname, WRITEBIN))==NULL)
        error("! can't open tfm output file") ;
!    outname[lastext] = 0 ;
  /*
   *   Now we strip off any directory information, so we only use the
!  *   base name in the vf file.  We accept any of /, :, or \ as directory
!  *   delimiters, so none of these are available for use inside the
!  *   base name; this shouldn't be a problem.
   */
!    for (i=0, lastext=0; outname[i]; i++)
!       if (outname[i] == '/' || outname[i] == ':' || outname[i] == '\\')
!          lastext = i + 1 ;
!    if (lastext)
!       strcpy(outname, outname + lastext) ;
  }
  /*
   *   Some routines to remove kerns that match certain patterns.
--- 1596,1616 ----
     if (argc == 2) (void)strcpy(outname, inname) ;
     else (void)strcpy(outname, argv[2]) ;
  
!    p = find_suffix(outname) ;
!    if (argc == 2)	/* inname *must* have extension by now; nuke it */
!       *p = 0 ;
!    if (argc == 2 || p == NULL)
        (void)strcat(outname, ".tfm") ;
     if (tfmout == NULL && (tfmout=fopen(outname, WRITEBIN))==NULL)
        error("! can't open tfm output file") ;
!    *p = 0 ;
  /*
   *   Now we strip off any directory information, so we only use the
!  *   base name in the vf file.
   */
!    p = (char *)basename(outname) ;
!    if (p != outname)
!       memmove(outname, p, strlen(p)); /* strcpy is not overlap-safe */
  }
  /*
   *   Some routines to remove kerns that match certain patterns.
*** ./dvipsk/dospecial.c~0	Sun Jan 19 20:04:26 1997
--- ./dvipsk/dospecial.c	Wed Apr 30 12:19:38 1997
*************** char *task, *iname ;
*** 747,753 ****
        close_file(bitfile) ;
        sprintf(cmd, "%s -f %s %s", task, realnameoffile, oname) ;
        system(cmd) ;
!       if ((bitfile=fopen(oname, "a"))==NULL)
           error_with_perror ("! couldn't reopen PostScript file", oname) ;
        linepos = 0 ;
     } else {
--- 747,753 ----
        close_file(bitfile) ;
        sprintf(cmd, "%s -f %s %s", task, realnameoffile, oname) ;
        system(cmd) ;
!       if ((bitfile=fopen(oname, FOPEN_ABIN_MODE))==NULL)
           error_with_perror ("! couldn't reopen PostScript file", oname) ;
        linepos = 0 ;
     } else {
*** ./dvipsk/finclude.c~0	Sun Jan 19 19:46:30 1997
--- ./dvipsk/finclude.c	Wed Apr 30 12:08:56 1997
*************** char* filename ;
*** 422,428 ****
  /*
   *   Allow scanning of ` commands.  Better return same results both times.
   */
!       f = popen(filename+1, "r") ;
        to_close = USE_PCLOSE ;
     } else {
        f = search(figpath, filename, READ) ;
--- 422,428 ----
  /*
   *   Allow scanning of ` commands.  Better return same results both times.
   */
!       f = popen(filename+1, FOPEN_RBIN_MODE) ;
        to_close = USE_PCLOSE ;
     } else {
        f = search(figpath, filename, READ) ;
*** ./dvipsk/header.c~0	Sat Sep  9 17:56:24 1995
--- ./dvipsk/header.c	Wed Apr 30 12:15:00 1997
*************** add_name(s, what)
*** 66,72 ****
  void checkhmem(s)
  char *s ;
  {
!    FILE *f = search(headerpath, s, READ) ;
  
     if (f==0) {
        (void)sprintf(errbuf, "! Couldn't find header file %s", s) ;
--- 66,72 ----
  void checkhmem(s)
  char *s ;
  {
!    FILE *f = search(headerpath, s, READBIN) ;
  
     if (f==0) {
        (void)sprintf(errbuf, "! Couldn't find header file %s", s) ;
*** ./dvipsk/hps.c~0	Sun Jan 19 20:03:06 1997
--- ./dvipsk/hps.c	Wed Apr 30 12:15:30 1997
*************** finish_hps P1H(void)
*** 556,562 ****
  void
  set_bitfile P2C(const_string, s, int,  mode)
  {  
! if ((bitfile=fopen(s, mode ? "a" : "w"))==NULL) {
     error(s) ;
     error("!couldn't open file") ;
    }
--- 556,562 ----
  void
  set_bitfile P2C(const_string, s, int,  mode)
  {  
! if ((bitfile=fopen(s, mode ? FOPEN_ABIN_MODE : FOPEN_WBIN_MODE))==NULL) {
     error(s) ;
     error("!couldn't open file") ;
    }
*** ./dvipsk/squeeze.c~0	Sat May  1 23:02:12 1993
--- ./dvipsk/squeeze.c	Wed Apr 30 14:35:16 1997
***************
*** 6,11 ****
--- 6,15 ----
   *   minimum.  We parse and then output it.
   */
  #include <stdio.h>
+ 
+ #include <kpathsea/config.h>
+ #include <kpathsea/c-fopen.h>
+ 
  #define LINELENGTH (72)
  #define BUFLENGTH (1000)
  #undef putchar
*************** char *argv[] ;
*** 78,83 ****
--- 82,94 ----
        (void)fprintf(stderr, "Usage:  squeeze [infile [outfile]]\n") ;
        exit(1) ;
     }
+    /* Binary output is safer (for those systems which care to know the
+       difference) since PostScript can include non-printable characters.  */
+    if (O_BINARY && !isatty(fileno(in)))
+       SET_BINARY(fileno(in)) ;
+    if (O_BINARY && !isatty(fileno(out)))
+       SET_BINARY(fileno(out)) ;
+ 
     (void)fprintf(out, "%%!\n") ;
     while (1) {
        c = getc(in) ;
*** ./dvipsk/Makefile.i~0	Fri Feb  7 20:43:06 1997
--- ./dvipsk/Makefile.in	Mon Jun  2 14:56:58 1997
***************
*** 44,52 ****
  	$(kpathsea_link) $(objects) $(LOADLIBES)
  afm2tfm: $(kpathsea) afm2tfm.o
  	$(kpathsea_link) afm2tfm.o $(LOADLIBES)
- # Omit LOADLIBES since no need to dynamically link with kpathsea.
  squeeze: squeeze.o
! 	$(link_command) squeeze.o $(LIBS) $(XLOADLIBES)
  
  $(prologues): squeeze
  texc.lpro: texc.script tex.lpro
--- 44,51 ----
  	$(kpathsea_link) $(objects) $(LOADLIBES)
  afm2tfm: $(kpathsea) afm2tfm.o
  	$(kpathsea_link) afm2tfm.o $(LOADLIBES)
  squeeze: squeeze.o
! 	$(kpathsea_link) squeeze.o $(LOADLIBES)
  
  $(prologues): squeeze
  texc.lpro: texc.script tex.lpro
***************
*** 91,97 ****
  	  $(INSTALL_DATA) $(srcdir)/psfonts.map $(psheaderdir)/psfonts.map; \
          else true; fi
  # Info files.
! 	cd $(srcdir) && for i in $(program).info*; do \
  	  $(INSTALL_DATA) $$i $(infodir)/$$i; done
  # Man pages.
  	$(INSTALL_DATA) $(srcdir)/dvips.1 $(mandir)/dvips.$(manext)
--- 90,96 ----
  	  $(INSTALL_DATA) $(srcdir)/psfonts.map $(psheaderdir)/psfonts.map; \
          else true; fi
  # Info files.
! 	cd $(srcdir) && for i in $(program).i*; do \
  	  $(INSTALL_DATA) $$i $(infodir)/$$i; done
  # Man pages.
  	$(INSTALL_DATA) $(srcdir)/dvips.1 $(mandir)/dvips.$(manext)
***************
*** 105,111 ****
  	else true; fi
  
  uninstall-data:
! 	rm -f $(infodir)/dvips.info*
  	for h in $(prologues); do rm -f $(psheaderdir)/$$h; done
  	cd $(srcdir)/reencode && for e in *.enc; do rm -f $(psheaderdir)/$$e; \
  	  done
--- 104,110 ----
  	else true; fi
  
  uninstall-data:
! 	rm -f $(infodir)/dvips.i*
  	for h in $(prologues); do rm -f $(psheaderdir)/$$h; done
  	cd $(srcdir)/reencode && for e in *.enc; do rm -f $(psheaderdir)/$$e; \
  	  done
*** ./klibtool.~0	Sat Dec 28 00:50:26 1996
--- ./klibtool	Wed May 28 17:42:22 1997
***************
*** 221,227 ****
      if test -z "$CC"; then
        for dir in `echo $PATH | tr : ' '`; do
          test -z "$dir" && dir=.
!         if test -f $dir/gcc; then
            CC=gcc
            break
          fi
--- 221,227 ----
      if test -z "$CC"; then
        for dir in `echo $PATH | tr : ' '`; do
          test -z "$dir" && dir=.
!         if test -x $dir/gcc; then
            CC=gcc
            break
          fi
***************
*** 275,280 ****
--- 275,285 ----
          fi
          ;;
  
+       *-*-*djgpp* | *-*-*go32* | *-*-msdos*)
+         shared_support=false
+ 	libpath_var=LIBRARY_PATH
+ 	;;
+ 
        *)
          echo "$0: $host_type not explicitly supported, using defaults." >&2
          ;;
***************
*** 393,399 ****
        
        # Remove old archive file because we recommend `ar q', not `r',
        # and the user can't necessarily know the library name.
!       cmd="cd $lib_dir/$ot && rm -f $lib_base* && $cmdname $args $post"
        $show $cmd
        $chicken eval "($cmd)"
        status=$?
--- 398,407 ----
        
        # Remove old archive file because we recommend `ar q', not `r',
        # and the user can't necessarily know the library name.
!       # $lib_base and $lib_base* are both used for the sake of MS-DOS,
!       # where libkpathsea.a is truncated to libkpath.a and thus
!       # libkpathsea.a* expands to nothing.
!       cmd="cd $lib_dir/$ot && rm -f $lib_base $lib_base* && $cmdname $args $post"
        $show $cmd
        $chicken eval "($cmd)"
        status=$?
*** Makefile.i~0	Fri Feb  7 20:39:38 1997
--- Makefile.in	Thu Jun 26 10:58:52 1997
***************
*** 71,74 ****
  	$(SHELL) config.status
  
  TAGS:
! 	find $(srcdir) -name '*.[cCfFhilsy]' -o -name \*.el | etags -
--- 71,74 ----
  	$(SHELL) config.status
  
  TAGS:
! 	find $(srcdir) \( -name '*.[cCfFhilsy]' -o -name '*.el' \) | etags -
*** kpathsea/lib.h~0	Mon Dec 30 23:48:50 1996
--- kpathsea/lib.h	Fri May 16 18:01:40 1997
***************
*** 72,80 ****
--- 72,82 ----
     done at runtime, per filesystem, but that's painful to program.  */
  #ifdef MONOCASE_FILENAMES
  #define FILESTRCASEEQ(s1, s2) (strcasecmp (s1, s2) == 0)
+ #define FILESTRNCASEEQ(s1, s2, l) (strncasecmp (s1, s2, l) == 0)
  #define FILECHARCASEEQ(c1, c2) (toupper (c1) == toupper (c2))
  #else
  #define FILESTRCASEEQ STREQ
+ #define FILESTRNCASEEQ(s1, s2, l) (strncmp (s1, s2, l) == 0)
  #define FILECHARCASEEQ(c1, c2) ((c1) == (c2))
  #endif
  
*** kpathsea/MakeTeXPK.~0	Sat Feb  8 17:52:00 1997
--- kpathsea/MakeTeXPK	Mon Jun  2 14:27:12 1997
***************
*** 97,105 ****
    exit 0
  fi
  
! $TEXMFCNF_DIR/MakeTeXmkdir $PKDESTDIR
  if test ! -d $PKDESTDIR; then
!   echo "$0: MakeTeXmkdir $PKDESTDIR failed." >&2
    exit 1
  fi
  
--- 97,105 ----
    exit 0
  fi
  
! $TEXMFCNF_DIR/MakeTeX-mkdir $PKDESTDIR
  if test ! -d $PKDESTDIR; then
!   echo "$0: MakeTeX-mkdir $PKDESTDIR failed." >&2
    exit 1
  fi
  
***************
*** 114,122 ****
  fi
  
  # Install the PK file carefully, since others may be working simultaneously.
! mv $PKNAME $PKDESTDIR/pktmp.$$ || exit 1
  cd $PKDESTDIR || exit 1
! test -r $PKNAME || mv pktmp.$$ $PKNAME || exit 1
  chmod $MT_FILE_PERMS $PKNAME
  
  # Update ls-R if necessary.
--- 114,127 ----
  fi
  
  # Install the PK file carefully, since others may be working simultaneously.
! # Put the PID into basename (MS-DOS), so it won't be truncated.
! # Use cp when mv fails, since DOS will fail mv for deeply-nested
! # directories.
! mv $PKNAME $PKDESTDIR/pk$$.tmp 2> /dev/null \
!  || cp $PKNAME $PKDESTDIR/pk$$.tmp || exit 1
! rm -f $PKNAME
  cd $PKDESTDIR || exit 1
! test -r $PKNAME || mv pk$$.tmp $PKNAME || exit 1
  chmod $MT_FILE_PERMS $PKNAME
  
  # Update ls-R if necessary.
*** mkdirchain.~0	Wed Jan  8 00:56:22 1997
--- mkdirchain	Wed May 28 18:41:14 1997
***************
*** 6,15 ****
  
  for file in ${1+"$@"} ; do 
     oIFS="${IFS}"; IFS='/'; set - ${file}; IFS="${oIFS}"
-    # Skip empty arg resulting from an absolute directory.
-    test ".${1}" = "." && shift
  
!    pathcomp=''
  
     while test $# -ne 0 ; do
       pathcomp="${pathcomp}/${1}"
--- 6,20 ----
  
  for file in ${1+"$@"} ; do 
     oIFS="${IFS}"; IFS='/'; set - ${file}; IFS="${oIFS}"
  
!    pathcomp="${1}"
!    if test ".${1}" != "."; then
!      if test ! -d "${pathcomp}"; then
!         echo "mkdir $pathcomp" 1>&2
!         mkdir "${pathcomp}" || exit 1
!      fi
!    fi
!    shift
  
     while test $# -ne 0 ; do
       pathcomp="${pathcomp}/${1}"
*** web2c/help.h~0	Sun Dec 15 22:49:14 1996
--- web2c/help.h	Tue Jun  3 18:33:26 1997
***************
*** 275,281 ****
  \n\
    If no arguments or options are specified, prompt for input.\n\
  \n\
! -extend-jobname=WHEN     remove suffix from \\jobname (WHEN=always/never)\n\
  -fmt=FMTNAME             use FMTNAME instead of program name or a %& line\n\
  -ini                     be initex, for dumping formats; this is implicitly\n\
                            true if the program name is `initex'\n\
--- 275,282 ----
  \n\
    If no arguments or options are specified, prompt for input.\n\
  \n\
! -extend-jobname=WHEN     append (WHEN=always) or replace (WHEN=never) suffix\n\
!                           in \\jobname; WHEN=maybe replaces trivial suffix\n\
  -fmt=FMTNAME             use FMTNAME instead of program name or a %& line\n\
  -ini                     be initex, for dumping formats; this is implicitly\n\
                            true if the program name is `initex'\n\
*** kpathsea/c-pathch.h~0	Fri Feb  7 16:57:30 1997
--- kpathsea/c-pathch.h	Thu Apr 24 19:40:24 1997
***************
*** 35,41 ****
  #define DIR_SEP_STRING "/"
  #define IS_DEVICE_SEP(ch) ((ch) == ':')
  #define NAME_BEGINS_WITH_DEVICE(name) \
!   (ISALPHA(*(name)) && IS_DEVICE_SEP((name)[1]))
  /* On DOS, it's good to allow both \ and / between directories.  */
  #define IS_DIR_SEP(ch) ((ch) == '/' || (ch) == '\\')
  #else
--- 35,41 ----
  #define DIR_SEP_STRING "/"
  #define IS_DEVICE_SEP(ch) ((ch) == ':')
  #define NAME_BEGINS_WITH_DEVICE(name) \
!   (*(name) && IS_DEVICE_SEP((name)[1]))
  /* On DOS, it's good to allow both \ and / between directories.  */
  #define IS_DIR_SEP(ch) ((ch) == '/' || (ch) == '\\')
  #else
*** kpathsea/contrib/maketex.c~2	Tue Jun 24 14:50:32 1997
--- kpathsea/contrib/maketex.c	Tue Jul  8 17:12:00 1997
*************** void do_maketexnames(string name, string
*** 1346,1359 ****
    /* . $TEXMFCNF_DIR/MakeTeXnames.cnf  */
    read_maketexnames_cnf();
  
  #ifdef ENHANCED_MODE
!   if (mt_varfonts == FALSE)
!     mt_destroot = try_to_find_root(name);
!   
!   mt_destroot = concat_pathes(mt_destroot, "/fonts");
  #else  /* !ENHANCED_MODE */
!   mt_destroot = concat_pathes(texmfmain, "/fonts");
  #endif /* !ENHANCED_MODE */
  
    if (dest) {
      if (kpse_absolute_p(dest, false))
--- 1346,1364 ----
    /* . $TEXMFCNF_DIR/MakeTeXnames.cnf  */
    read_maketexnames_cnf();
  
+   /* If $TEXMFLS_R is set, generated fonts go to that tree.
+      If not, fall back to $TEXMFMAIN.  */
+   p = kpse_var_expand(texmfls_r_name);
+   if (!p || !*p) {
  #ifdef ENHANCED_MODE
!     if (mt_varfonts == FALSE)
!       p = try_to_find_root(name);
  #else  /* !ENHANCED_MODE */
!     p = xstrdup(texmfmain);
  #endif /* !ENHANCED_MODE */
+   }
+   mt_destroot = concat_pathes(p, "/fonts");
+   free(p);
  
    if (dest) {
      if (kpse_absolute_p(dest, false))
*** kpathsea/MakeTeXnames.~1	Fri May 16 16:15:30 1997
--- kpathsea/MakeTeXnames	Tue Jul  8 18:18:46 1997
***************
*** 17,22 ****
--- 17,25 ----
  test -n "$TEXMFCNF_DIR" || TEXMFCNF_DIR=$TEXMFMAIN/web2c
  . $TEXMFCNF_DIR/MakeTeXcommon
  
+ : ${TEXMFLS_R=`kpsewhich -expand-var='$TEXMFLS_R'`}
+ test -n "$TEXMFLS_R" || TEXMFLS_R=$TEXMFMAIN
+ 
  NAME=$1
  case $# in
  1|2) DPI=$BDPI; DEST=$2;;
***************
*** 29,35 ****
  
  : ${MT_PKDESTDIR='$MT_DESTROOT/$MT_PKPART/$MT_MODE/$MT_NAMEPART'}
  : ${MT_TFMDESTDIR='$MT_DESTROOT/$MT_TFMPART/$MT_NAMEPART'}
! : ${MT_DESTROOT='$TEXMFMAIN/fonts'}
  : ${MT_DEFAULT_NAMEPART=tmp}
  : ${MT_PKPART='pk'}
  : ${MT_TFMPART='tfm'}
--- 32,38 ----
  
  : ${MT_PKDESTDIR='$MT_DESTROOT/$MT_PKPART/$MT_MODE/$MT_NAMEPART'}
  : ${MT_TFMDESTDIR='$MT_DESTROOT/$MT_TFMPART/$MT_NAMEPART'}
! : ${MT_DESTROOT='$TEXMFLS_R/fonts'}
  : ${MT_DEFAULT_NAMEPART=tmp}
  : ${MT_PKPART='pk'}
  : ${MT_TFMPART='tfm'}
