diff -acprNC5 enscript-1.6.2.orig/afmlib/afm.c enscript-1.6.2.djgpp/afmlib/afm.c
*** enscript-1.6.2.orig/afmlib/afm.c	Wed Dec 23 08:23:10 1998
--- enscript-1.6.2.djgpp/afmlib/afm.c	Sun May 27 23:37:42 2001
***************
*** 27,37 ****
--- 27,45 ----
  
  /*
   * Static variables
   */
  
+ #ifdef DOSLIKE
+ # if ((__DJGPP__ >= 2) && (__DJGPP_MINOR__ >= 3))
+ static char *default_path = "/dev/env/DJDIR/bin;/dev/env/DJDIR/lib/ps;c:/enscript;c:/gs;c:/ps;c:/usr/lib/ps";
+ # else
+ static char *default_path = "c:/enscript;c:/gs;c:/ps;c:/usr/lib/ps";
+ # endif
+ #else
  static char *default_path = "/usr/local/lib/ps:/usr/lib/ps";
+ #endif
  
  static char *error_names[] =
  {
    "AFM Success",
    "AFM Error",
*************** afm_create (const char *path, unsigned i
*** 137,147 ****
        else
  	len = strlen (cp);
  
        memcpy (buf, cp, len);
        buf[len] = '\0';
!       if (len > 0 && buf[len - 1] == '/')
  	buf[len - 1] = '\0';
  
        strcat (buf, "/font.map");
  
        if (stat (buf, &stat_st) == 0)
--- 145,164 ----
        else
  	len = strlen (cp);
  
        memcpy (buf, cp, len);
        buf[len] = '\0';
! 
!       /* The case of "D:".  Convert into "D:.", so appending
! 	       "/font.map" won't take it into the root on drive D:.  */
!       if (NAME_WITH_DRIVE (buf) && len == 2)
!       {
!         buf[len++] = '.';
!         buf[len] = '\0';
!       }
! 
!       if (len > 0 && IS_SLASH (buf[len - 1]))
  	buf[len - 1] = '\0';
  
        strcat (buf, "/font.map");
  
        if (stat (buf, &stat_st) == 0)
*************** read_font_map (AFMHandle handle, char *n
*** 731,740 ****
--- 748,762 ----
        afm_message (handle, 1, msg);
        return;
      }
  
    /* Get directory */
+   /*
+    * DOSLIKE systems can have backslashes, but in this
+    * case '/' is good enough, since we just appended
+    * "/font.map" before this function was called.
+    */
    cp = strrchr (name, '/');
    if (cp)
      {
        dirlen = cp - name + 1;
        memcpy (fullname, name, dirlen);
diff -acprNC5 enscript-1.6.2.orig/afmlib/afmint.h enscript-1.6.2.djgpp/afmlib/afmint.h
*** enscript-1.6.2.orig/afmlib/afmint.h	Wed Dec 23 07:59:54 1998
--- enscript-1.6.2.djgpp/afmlib/afmint.h	Sun May 27 23:37:42 2001
*************** extern char *strerror ___P ((int));
*** 84,93 ****
--- 84,95 ----
  #include <errno.h>
  
  #include <sys/types.h>
  #include <sys/stat.h>
  
+ #include "system.h"
+ 
  #include "afm.h"
  #include "strhash.h"
  
  
  /*
diff -acprNC5 enscript-1.6.2.orig/afmlib/system.h enscript-1.6.2.djgpp/afmlib/system.h
*** enscript-1.6.2.orig/afmlib/system.h	Thu Jan  1 00:00:00 1970
--- enscript-1.6.2.djgpp/afmlib/system.h	Mon May 28 08:20:54 2001
***************
*** 0 ****
--- 1,52 ----
+ /* Pathnames and other system-dependent stuff.  */
+ 
+ #if defined(__MSDOS__) || defined(WIN32) || defined(MSDOS)
+ # define DOSLIKE
+ # include <fcntl.h>
+ # ifdef __DJGPP__
+ #  include <io.h>
+ #  include <unistd.h>
+ # endif
+ #endif
+ 
+ #ifdef DOSLIKE
+ # undef  PATH_SEPARATOR
+ # define PATH_SEPARATOR       ';'
+ # define IS_SLASH(c)          ((c) == '/' || (c) == '\\')
+ # define NAME_WITH_DRIVE(fn)  (*(fn) && (fn)[1] == ':')
+ # define POPEN_READ           "rb"
+ # ifdef __DJGPP__
+ #  define SETBIN(fd)          if (!isatty((fd)))setmode((fd), O_BINARY)
+ #  define ENSCRIPTSITE_CFG    "site-enscript.cfg"
+ # else
+ #  define SETBIN(fd)          if (!isatty((fd)))_setmode((fd), _O_BINARY)
+ #  define ENSCRIPTSITE_CFG    "enscriptsite.cfg"
+ # endif
+ # ifdef WIN32
+ #  define ENSCRIPTSITE_CFG    "enscriptsite.cfg"
+ # else
+ #  define ENSCRIPTSITE_CFG    "site-enscript.cfg"
+ # endif
+ # define PROGNAME(fn)                                             \
+    basename((fn));                                                \
+    do {                                                           \
+      char *exe = (fn) + strlen ((fn)) - 4;                        \
+                                                                   \
+      /* Drop the .exe suffix, if any.  */                         \
+      if (strcmp (exe, ".exe") == 0 || strcmp (exe, ".EXE") == 0)  \
+        *exe = '\0';                                               \
+    } while (0)
+ # define BASENAME(fn)         basename((fn))
+ #else
+ # undef  PATH_SEPARATOR
+ # define PATH_SEPARATOR       ':'
+ # define IS_SLASH(c)          ((c) == '/')
+ # define NAME_WITH_DRIVE(fn)  0
+ # define POPEN_READ           "r"
+ # define SETBIN(fd)           (void)0
+ # define PROGNAME(fn)         (strrchr((fn), '/') == NULL) \
+                               ? (char *) (strrchr((fn), '/') + 1) : (fn)
+ # define BASENAME(fn)         (strrchr((fn), '/') == NULL) \
+                               ? (char *) (strrchr((fn), '/') + 1) : (fn)
+ # define ENSCRIPTSITE_CFG     "enscriptsite.cfg"
+ #endif
diff -acprNC5 enscript-1.6.2.orig/lib/enscript.cfg.in enscript-1.6.2.djgpp/lib/enscript.cfg.in
*** enscript-1.6.2.orig/lib/enscript.cfg.in	Mon Oct 26 14:54:44 1998
--- enscript-1.6.2.djgpp/lib/enscript.cfg.in	Sun May 27 23:41:16 2001
***************
*** 27,37 ****
  # Do we accept PostScript font's composite characters?  As a default,
  # this is false because I think this is GhostScript dependant.
  AcceptCompositeCharacters: 0
  
  # Lookup path for the AFM files.
! AFMPath: @DATADIR@/enscript/afm:/usr/local/lib/ps:/usr/lib/ps
  
  # Append ^D character to the end of the output.  Some printers like HP
  # LaserJet 5 require this but the default is `false'.
  AppendCtrlD: 0
  
--- 27,37 ----
  # Do we accept PostScript font's composite characters?  As a default,
  # this is false because I think this is GhostScript dependant.
  AcceptCompositeCharacters: 0
  
  # Lookup path for the AFM files.
! AFMPath: @DATADIR@/enscript@PATH_SEPARATOR@/usr/local/lib/ps@PATH_SEPARATOR@/usr/lib/ps
  
  # Append ^D character to the end of the output.  Some printers like HP
  # LaserJet 5 require this but the default is `false'.
  AppendCtrlD: 0
  
diff -acprNC5 enscript-1.6.2.orig/src/gsint.h enscript-1.6.2.djgpp/src/gsint.h
*** enscript-1.6.2.orig/src/gsint.h	Wed Dec 23 08:29:14 1998
--- enscript-1.6.2.djgpp/src/gsint.h	Sun May 27 23:37:42 2001
*************** extern double atan2 ___P ((double, doubl
*** 120,129 ****
--- 120,131 ----
  #if HAVE_GETWD
  #define getcwd(buf, len) getwd(buf)
  #endif /* HAVE_GETWD */
  #endif /* not HAVE_GETCWD */
  
+ #include "system.h"
+ 
  #include "afm.h"
  #include "strhash.h"
  #include "xalloc.h"
  
  /*
diff -acprNC5 enscript-1.6.2.orig/src/main.c enscript-1.6.2.djgpp/src/main.c
*** enscript-1.6.2.orig/src/main.c	Wed Dec 23 08:28:44 1998
--- enscript-1.6.2.djgpp/src/main.c	Mon May 28 08:17:52 2001
*************** main (int argc, char *argv[])
*** 893,907 ****
    AFMError afm_error;
    char *cp, *cp2;
    int retval = 0;
  
    /* Get program's name. */
!   program = strrchr (argv[0], '/');
!   if (program == NULL)
!     program = argv[0];
!   else
!     program++;
  
    /* Make getopt_long() to use our modified programname. */
    argv[0] = program;
  
    /* Create version strings. */
--- 893,903 ----
    AFMError afm_error;
    char *cp, *cp2;
    int retval = 0;
  
    /* Get program's name. */
!   program = PROGNAME (argv[0]);
  
    /* Make getopt_long() to use our modified programname. */
    argv[0] = program;
  
    /* Create version strings. */
*************** main (int argc, char *argv[])
*** 1009,1024 ****
  	   * Ok, we are not installed yet.  Here is a small kludge to
  	   * conform the GNU coding standards: we must be able to run
  	   * without being installed, so we must append the "../lib"
  	   * directory to the libpath.
  	   */
! 	  strcat (libpath, ":../lib");
  	}
      }
  
    /* Site config. */
!   (void) read_config (SYSCONFDIR, "enscriptsite.cfg");
  
    /* Personal config. */
    (void) read_config (passwd->pw_dir, ".enscriptrc");
  
    /*
--- 1005,1036 ----
  	   * Ok, we are not installed yet.  Here is a small kludge to
  	   * conform the GNU coding standards: we must be able to run
  	   * without being installed, so we must append the "../lib"
  	   * directory to the libpath.
  	   */
! 	  sprintf (libpath + strlen (libpath), "%c../lib", PATH_SEPARATOR);
  	}
      }
+   /*
+    * If LIBRARY/enscript.st doesn't exist, maybe they've put it into
+    * our library directory.  This is likely to be the case for the
+    * micro ports, since the binary was probably configured elsewhere
+    * and so the default paths might be incorrect.
+    */
+   if (access (states_config_file, R_OK) != 0
+       && strcmp (LIBRARY, enscript_library) != 0)
+     {
+       char try_cfg[FILENAME_MAX];
+ 
+       sprintf (try_cfg, "%s/enscript.st", enscript_library);
+       /* Use it if it's readable, but not a directory.  */
+       if (access (try_cfg, R_OK) == 0 && access (try_cfg, D_OK) != 0)
+         strcpy (states_config_file, try_cfg);
+     }
  
    /* Site config. */
!   (void) read_config (SYSCONFDIR, ENSCRIPTSITE_CFG);
  
    /* Personal config. */
    (void) read_config (passwd->pw_dir, ".enscriptrc");
  
    /*
*************** name             width\theight\tllx\tlly
*** 1457,1469 ****
--- 1469,1487 ----
  	  toc_fp = fopen (toc_fname, "w+b");
  	  if (toc_fp == NULL)
  	    FATAL ((stderr, _("couldn't create toc file \"%s\": %s"),
  		    toc_fname, strerror (errno)));
  
+ #ifndef DOSLIKE
+       /*
+        * This only works on Unix, where the file won't be actually removed
+        * until it is closed.  On micro ports, this is nothing but trouble.
+        */
  	  if (remove (toc_fname) == 0)
  	    /* Remove successfull, no need to remove file at exit. */
  	    toc_fname[0] = '\0';
+ #endif
  	}
  
  
        /*
         * Process files.
*************** open_output_file ()
*** 1648,1657 ****
--- 1666,1716 ----
  {
    if (ofp)
      /* Output file has already been opened, do nothing. */
      return;
  
+ #ifdef __DJGPP__
+   /*
+    * Feature: if the spooler is nowhere to be found,
+    * try to open the local printer device.
+    */
+   if (output_file == OUTPUT_FILE_NONE)
+ 	{
+     int fd = -1;
+     char found[FILENAME_MAX];
+     extern char **environ;
+     extern char *__dosexec_find_on_path (const char *, char *[], char *);
+ 
+     if (!__dosexec_find_on_path (spooler_command, (char **)0, found)
+         && !__dosexec_find_on_path (spooler_command, environ, found))
+     {
+       /*
+        * Need to call `open', so it fails if the file doesn't
+        * already exist.  Printer device *must* already exist.
+        */
+       if (printer)
+       {
+         output_file = printer;
+         fd = open (output_file, O_WRONLY);
+       }
+       if (fd == -1)
+       {
+         output_file = "PRN";
+         fd = open (output_file, O_WRONLY);
+       }
+       if (fd == -1)
+       {
+         FATAL ((stderr, _("couldn't open printer `%s': %s"), printer,
+         strerror (errno)));
+         output_file = OUTPUT_FILE_NONE;
+       }
+       else
+         ofp = fdopen (fd, "w");
+     }
+   }
+ #endif
+ 
    if (output_file == OUTPUT_FILE_NONE)
      {
        char spooler_options[512];
  
        /* Format spooler options. */
*************** open_output_file ()
*** 1680,1689 ****
--- 1739,1754 ----
        ofp = fopen (output_file, "w");
        if (ofp == NULL)
  	FATAL ((stderr, _("couldn't create output file \"%s\": %s"),
  		output_file, strerror (errno)));
      }
+ 
+   /*
+    * PS output might include binary characters.  DOSLIKE systems
+    * care about the difference.
+    */
+   SETBIN (fileno (ofp));
  }
  
  
  static void
  close_output_file ()
diff -acprNC5 enscript-1.6.2.orig/src/mkafmmap.c enscript-1.6.2.djgpp/src/mkafmmap.c
*** enscript-1.6.2.orig/src/mkafmmap.c	Thu Jul  3 11:14:58 1997
--- enscript-1.6.2.djgpp/src/mkafmmap.c	Sun May 27 23:37:42 2001
***************
*** 47,56 ****
--- 47,58 ----
  
  #if HAVE_LC_MESSAGES
  #include <locale.h>
  #endif
  
+ #include "system.h"
+ 
  #include "afm.h"
  #include "getopt.h"
  
  
  /*
*************** main (int argc, char *argv[])
*** 111,125 ****
    AFMFont font;
    int i;
    FILE *ofp;
    FILE *mfp;
  
!   program = strrchr (argv[0], '/');
!   if (program == NULL)
!     program = argv[0];
!   else
!     program++;
  
    /* Make getopt_long() to use our modified programname. */
    argv[0] = program;
  
    /* Internationalization. */
--- 113,123 ----
    AFMFont font;
    int i;
    FILE *ofp;
    FILE *mfp;
  
!   program = PROGNAME (argv[0]);
  
    /* Make getopt_long() to use our modified programname. */
    argv[0] = program;
  
    /* Internationalization. */
*************** main (int argc, char *argv[])
*** 202,216 ****
  	{
  	  char *cp;
  	  char *sf;
  	  int len;
  
! 	  cp = strrchr (argv[i], '/');
! 	  if (cp == NULL)
! 	    cp = argv[i];
! 	  else
! 	    cp++;
  
  	  sf = strrchr (argv[i], '.');
  	  if (sf)
  	    len = sf - cp;
  	  else
--- 200,210 ----
  	{
  	  char *cp;
  	  char *sf;
  	  int len;
  
! 	  cp = BASENAME (argv[i]);
  
  	  sf = strrchr (argv[i], '.');
  	  if (sf)
  	    len = sf - cp;
  	  else
diff -acprNC5 enscript-1.6.2.orig/src/psgen.c enscript-1.6.2.djgpp/src/psgen.c
*** enscript-1.6.2.orig/src/psgen.c	Wed Dec 23 07:37:14 1998
--- enscript-1.6.2.djgpp/src/psgen.c	Sun May 27 23:37:42 2001
*************** dump_ps_header ()
*** 283,293 ****
--- 283,301 ----
  
    OUTPUT ((cofp, "%s\n", output_first_line));
    OUTPUT ((cofp, "%%%%BoundingBox: %d %d %d %d\n", media->llx, media->lly,
  	   media->urx, media->ury));
    OUTPUT ((cofp, "%%%%Title: %s\n", title));
+ #ifdef HAVE_PW_GECOS
    OUTPUT ((cofp, "%%%%For: %s\n", passwd->pw_gecos));
+ #else
+   cp = getenv ("FULLNAME");
+   if (cp)
+     OUTPUT ((cofp, "%%%%For: %s\n", cp));
+   else
+     OUTPUT ((cofp, "%%%%For: %s\n", passwd->pw_name));
+ #endif
    OUTPUT ((cofp, "%%%%Creator: %s\n", version_string));
    OUTPUT ((cofp, "%%%%CreationDate: %s\n", date_string));
    OUTPUT ((cofp, "%%%%Orientation: %s\n",
  	   ((nup > 1) && nup_landscape)
  	   || ((nup == 1) && landscape) ? "Landscape" : "Portrait"));
*************** dump_ps_page_header (char *fname, int em
*** 1960,1971 ****
    int got, i;
    char *cp, *cp2;
    char *cstr = "%%";
    unsigned int nup_subpage;
  
!   /* The N-up printing sub-page. */
!   nup_subpage = (total_pages - 1) % nup;
  
    /* Create fdir and ftail. */
    ftail = strrchr (fname, '/');
  
  #if defined(WIN32)
--- 1968,1994 ----
    int got, i;
    char *cp, *cp2;
    char *cstr = "%%";
    unsigned int nup_subpage;
  
! #ifdef DOSLIKE
!   /* PostScript interpreters don't like pathnames with backslashes.
!      So we convert everything to Unix-style forward slashes, but
!      leave FNAME we got in its original shape, and work on a copy.  */
!   char slashified_fname[sizeof buf];
! 
!   for (cp = fname, cp2 = slashified_fname; (*cp2 = *cp) != 0; cp++, cp2++)
!     if (*cp2 == '\\')
!       *cp2 = '/';
! 
!   fname = slashified_fname;
! 
!   /* The case of d:file  */
!   if (fname[0] && fname[1] == ':' && fname[2] != '/')
!     ftail = fname + 1;
!   else
! #endif
  
    /* Create fdir and ftail. */
    ftail = strrchr (fname, '/');
  
  #if defined(WIN32)
*************** dump_ps_page_header (char *fname, int em
*** 1980,1992 ****
      }
    else
      {
        ftail++;
        strncpy (buf, fname, ftail - fname);
!       buf[ftail - fname] = '\0';
      }
  
    if (nup > 1)
      {
        /* N-up printing is active. */
        cstr = "%";
  
--- 2003,2025 ----
      }
    else
      {
        ftail++;
        strncpy (buf, fname, ftail - fname);
!       /* MS-DOS: make "D:" to be "D:.", so current directory is explicit.  */
!       if (NAME_WITH_DRIVE (buf) && ftail - fname == 2)
!       {
!         buf[ftail - fname] = '.';
!         buf[ftail - fname + 1] = '\0';
!       }
!       else
!         buf[ftail - fname] = '\0';
      }
  
+   /* The N-up printing sub-page. */
+   nup_subpage = (total_pages - 1) % nup;
+ 
    if (nup > 1)
      {
        /* N-up printing is active. */
        cstr = "%";
  
*************** recognize_eps_file (Token *token)
*** 2286,2296 ****
    if (i > 0 && token->u.epsf.filename[i - 1] == '|')
      {
        /* Read EPS data from pipe. */
        token->u.epsf.pipe = 1;
        token->u.epsf.filename[i - 1] = '\0';
!       token->u.epsf.fp = popen (token->u.epsf.filename, "r");
        if (token->u.epsf.fp == NULL)
  	{
  	  MESSAGE (0, (stderr,
  		       _("epsf: couldn't open pipe to command \"%s\": %s\n"),
  		       token->u.epsf.filename, strerror (errno)));
--- 2319,2329 ----
    if (i > 0 && token->u.epsf.filename[i - 1] == '|')
      {
        /* Read EPS data from pipe. */
        token->u.epsf.pipe = 1;
        token->u.epsf.filename[i - 1] = '\0';
!       token->u.epsf.fp = popen (token->u.epsf.filename, POPEN_READ);
        if (token->u.epsf.fp == NULL)
  	{
  	  MESSAGE (0, (stderr,
  		       _("epsf: couldn't open pipe to command \"%s\": %s\n"),
  		       token->u.epsf.filename, strerror (errno)));
*************** recognize_eps_file (Token *token)
*** 2303,2313 ****
        tilde_subst (token->u.epsf.filename, filename);
  
        token->u.epsf.fp = fopen (filename, "rb");
        if (token->u.epsf.fp == NULL)
  	{
! 	  if (token->u.epsf.filename[0] != '/')
  	    {
  	      /* Name is not absolute, let's lookup path. */
  	      FileLookupCtx ctx;
  
  	      strcpy (ctx.name, token->u.epsf.filename);
--- 2336,2347 ----
        tilde_subst (token->u.epsf.filename, filename);
  
        token->u.epsf.fp = fopen (filename, "rb");
        if (token->u.epsf.fp == NULL)
  	{
! 	  if (!IS_SLASH (token->u.epsf.filename[0])
! 	      && !NAME_WITH_DRIVE (token->u.epsf.filename))
  	    {
  	      /* Name is not absolute, let's lookup path. */
  	      FileLookupCtx ctx;
  
  	      strcpy (ctx.name, token->u.epsf.filename);
*************** divert ()
*** 2712,2724 ****
--- 2746,2764 ----
    divertfp = fopen (divertfname, "w+b");
    if (divertfp == NULL)
      FATAL ((stderr, _("couldn't create divert file \"%s\": %s"), divertfname,
  	    strerror (errno)));
  
+ #ifndef DOSLIKE
+   /*
+    * Unix will leave the actual removal pending until the file is closed
+    * On MS-DOS and MS-Windows, doing this is just inviting trouble.
+    */
    if (remove (divertfname) == 0)
      /* Remove successfull, no need to remove file in undivert(). */
      divertfname[0] = '\0';
+ #endif
  
    /* Free the buffer allocated by tempnam(). */
    free (cp);
  
    cofp = divertfp;
*************** undivert ()
*** 2732,2741 ****
--- 2772,2790 ----
    int doc_level = 0;
    char *cp;
  
    assert (divertfp != NULL);
  
+   /*
+    * Divert file is on temporary filesystem, which might become full.
+    * In particular, on MS-DOS/MS-Windows this might be a RAM drive.
+    * Thus, it can become full while diversion is in effect.
+    */
+   if (ferror (divertfp))
+     FATAL ((stderr, _("error while writing to divert file (disk full?): %s"),
+ 	   strerror (errno)));
+ 
    if (fseek (divertfp, 0, SEEK_SET) != 0)
      FATAL ((stderr, _("couldn't rewind divert file: %s"), strerror (errno)));
  
    while (fgets (buf, sizeof (buf), divertfp))
      {
diff -acprNC5 enscript-1.6.2.orig/src/util.c enscript-1.6.2.djgpp/src/util.c
*** enscript-1.6.2.orig/src/util.c	Wed Dec 23 08:29:04 1998
--- enscript-1.6.2.djgpp/src/util.c	Sun May 27 23:37:42 2001
*************** read_config (char *path, char *file)
*** 103,112 ****
--- 103,123 ----
    char *token, *token2;
    int line = 0;
  
    sprintf (fname, "%s/%s", path, file);
    fp = fopen (fname, "r");
+ #ifdef DOSLIKE
+   /*
+    * Some DOSLIKE systems don't allow leading dots in filenames.
+    * Give them another chance with `_' replacing the dot.
+    */
+   if (fp == NULL && file[0] == '.')
+   {
+     sprintf (fname, "%s/_%s", path, file + 1);
+     fp = fopen (fname, "r");
+   }
+ #endif
    if (fp == NULL)
      return 0;
  
    while (fgets (buf, sizeof (buf), fp))
      {
*************** format_user_string (char *context_name, 
*** 1304,1318 ****
  		  APPEND_CH ('%');
  		  break;
  
  		case 'c':	/* `%c' trailing component of pwd. */
  		  getcwd (buf, sizeof (buf));
! 		  cp = strrchr (buf, '/');
! 		  if (cp)
! 		    cp++;
! 		  else
! 		    cp = buf;
  		  APPEND_STR (cp);
  		  break;
  
  		case 'C':	/* `%C' runtime in `hh:mm:ss' format */
  		  sprintf (buf, "%02d:%02d:%02d", run_tm.tm_hour,
--- 1315,1325 ----
  		  APPEND_CH ('%');
  		  break;
  
  		case 'c':	/* `%c' trailing component of pwd. */
  		  getcwd (buf, sizeof (buf));
! 		  cp = BASENAME (buf);
  		  APPEND_STR (cp);
  		  break;
  
  		case 'C':	/* `%C' runtime in `hh:mm:ss' format */
  		  sprintf (buf, "%02d:%02d:%02d", run_tm.tm_hour,
*************** format_user_string (char *context_name, 
*** 1384,1394 ****
--- 1391,1409 ----
  		case 'n':	/* `%n' username */
  		  APPEND_STR (passwd->pw_name);
  		  break;
  
  		case 'N':	/* `%N' pw_gecos up to the first `,' char */
+ #ifdef HAVE_PW_GECOS
  		  strcpy (buf, passwd->pw_gecos);
+ #else
+ 		  cp = getenv ("FULLNAME");
+ 		  if (cp)
+ 		    strcpy (buf, cp);
+ 		  else
+ 		    strcpy (buf, passwd->pw_name);
+ #endif
  		  cp = strchr (buf, ',');
  		  if (cp)
  		    *cp = '\0';
  		  APPEND_STR (buf);
  		  break;
*************** format_user_string (char *context_name, 
*** 1554,1568 ****
  		case 'N':	/* `$N' the full name of the printed file */
  		  APPEND_STR (fname);
  		  break;
  
  		case 'n':	/* `$n' input file name without directory */
! 		  cp = strrchr (fname, '/');
! 		  if (cp)
! 		    cp++;
! 		  else
! 		    cp = fname;
  		  APPEND_STR (cp);
  		  break;
  
  		case 'L':	/* `$L' number of lines in this file. */
  		  /* This is valid only for TOC-strings. */
--- 1569,1579 ----
  		case 'N':	/* `$N' the full name of the printed file */
  		  APPEND_STR (fname);
  		  break;
  
  		case 'n':	/* `$n' input file name without directory */
! 		  cp = BASENAME (fname);
  		  APPEND_STR (cp);
  		  break;
  
  		case 'L':	/* `$L' number of lines in this file. */
  		  /* This is valid only for TOC-strings. */
*************** file_lookup (char *path, void *context)
*** 1672,1682 ****
  
    MESSAGE (2, (stderr, "file_lookup(): %s/%s%s\t", path, ctx->name,
  	       ctx->suffix));
  
    len = strlen (path);
!   if (len && path[len - 1] == '/')
      len--;
  
    sprintf (ctx->fullname, "%.*s/%s%s", len, path, ctx->name, ctx->suffix);
  
    i = stat (ctx->fullname, &stat_st) == 0;
--- 1683,1693 ----
  
    MESSAGE (2, (stderr, "file_lookup(): %s/%s%s\t", path, ctx->name,
  	       ctx->suffix));
  
    len = strlen (path);
!   if (len && IS_SLASH (path[len - 1]))
      len--;
  
    sprintf (ctx->fullname, "%.*s/%s%s", len, path, ctx->name, ctx->suffix);
  
    i = stat (ctx->fullname, &stat_st) == 0;
*************** is_open (InputStream *is, FILE *fp, char
*** 1847,1857 ****
  	  else
  	    cmd[pos++] = input_filter[i];
  	}
        cmd[pos++] = '\0';
  
!       is->fp = popen (cmd, "r");
        xfree (cmd);
  
        if (is->fp == NULL)
  	{
  	  ERROR ((stderr,
--- 1858,1868 ----
  	  else
  	    cmd[pos++] = input_filter[i];
  	}
        cmd[pos++] = '\0';
  
!       is->fp = popen (cmd, POPEN_READ);
        xfree (cmd);
  
        if (is->fp == NULL)
  	{
  	  ERROR ((stderr,
diff -acprNC5 enscript-1.6.2.orig/states/defs.h enscript-1.6.2.djgpp/states/defs.h
*** enscript-1.6.2.orig/states/defs.h	Wed Nov 11 12:08:58 1998
--- enscript-1.6.2.djgpp/states/defs.h	Sun May 27 23:37:42 2001
*************** extern void *memcpy ___P ((void *, void 
*** 105,114 ****
--- 105,116 ----
  
  #if HAVE_LC_MESSAGES
  #include <locale.h>
  #endif
  
+ #include "system.h"
+ 
  #include "regex.h"
  #include "xalloc.h"
  #include "strhash.h"
  
  /*
diff -acprNC5 enscript-1.6.2.orig/states/main.c enscript-1.6.2.djgpp/states/main.c
*** enscript-1.6.2.orig/states/main.c	Fri Oct 23 09:01:18 1998
--- enscript-1.6.2.djgpp/states/main.c	Sun May 27 23:37:42 2001
*************** main (argc, argv)
*** 184,198 ****
  
    /* Set defaults for options. */
    ofp = stdout;
  
    /* Get program's name. */
!   program = strrchr (argv[0], '/');
!   if (program == NULL)
!     program = argv[0];
!   else
!     program++;
  
    /* Make getopt_long() to use our modified program name. */
    argv[0] = program;
  
    /* Format version string. */
--- 184,194 ----
  
    /* Set defaults for options. */
    ofp = stdout;
  
    /* Get program's name. */
!   program = PROGNAME (argv[0]);
  
    /* Make getopt_long() to use our modified program name. */
    argv[0] = program;
  
    /* Format version string. */
diff -acprNC5 enscript-1.6.2.orig/states/process.c enscript-1.6.2.djgpp/states/process.c
*** enscript-1.6.2.orig/states/process.c	Wed Oct 28 10:41:56 1998
--- enscript-1.6.2.djgpp/states/process.c	Sun May 27 23:37:42 2001
*************** process_file (fname)
*** 65,76 ****
--- 65,85 ----
    /* Enter build-in variables. */
    enter_system_variable ("filename", fname);
  
    /* Read in the first block of data. */
    data_in_buffer = fread (inbuf, 1, INBUFSIZE, ifp);
+ #ifdef DOSLIKE
+   /*
+    * DOSLIKE systems always get less than a bufferful, because
+    * they drop the CR characters from text files.
+    */
+   if (feof (ifp))
+     eof_seen = 1;
+ #else
    if (data_in_buffer < INBUFSIZE)
      eof_seen = 1;
+ #endif
  
    if (start_state_arg)
      start_state = start_state_arg;
  
    /* Execute start block. */
*************** execute_state (name)
*** 135,146 ****
--- 144,165 ----
  	    /* All done. */
  	    break;
  
  	  /* Read more data. */
  	  data_in_buffer = fread (inbuf, 1, INBUFSIZE, ifp);
+ #ifdef DOSLIKE
+ 	  /*
+ 	   * DOSLIKE systems always get less than a bufferful, because
+ 	   * they drop the CR characters from text files.  They get
+ 	   * punished here by an extra walk through the reading loop.
+ 	   */
+ 	  if (feof (ifp))
+ 	    eof_seen = 1;
+ #else
  	  if (data_in_buffer < INBUFSIZE)
  	    eof_seen = 1;
+ #endif
  
  	  bufpos = 0;
  	  continue;
  	}
  
*************** execute_state (name)
*** 160,171 ****
--- 179,195 ----
  	  data_in_buffer = eol - bufpos;
  	  bufpos = 0;
  
  	  to_read = INBUFSIZE - data_in_buffer;
  	  got = fread (inbuf + data_in_buffer, 1, to_read, ifp);
+ #ifdef DOSLIKE
+ 	  if (feof (ifp))
+ 	    eof_seen = 1;
+ #else
  	  if (got < to_read)
  	    eof_seen = 1;
+ #endif
  
  	  data_in_buffer += got;
  	  continue;
  	}
  
diff -acprNC5 enscript-1.6.2.orig/tests/defs enscript-1.6.2.djgpp/tests/defs
*** enscript-1.6.2.orig/tests/defs	Tue Jan 21 16:42:04 1997
--- enscript-1.6.2.djgpp/tests/defs	Sun May 27 23:37:42 2001
*************** output=testout.ps
*** 12,21 ****
--- 12,32 ----
  asciifiles="$srcdir/defs $srcdir/ascii.test $srcdir/../src/psgen.c"
  binaryfiles="../src/enscript ../src/mkafmmap"
  
  enscript="../src/enscript"
  
+ # Find the correct LINK command. Usually this is `ln -s',
+ # but DJGPP 2.03 and prior can only link binary files
+ # text files must be copied.
+ if test "X${LN_S+set}" != Xset; then
+   UNAME=${UNAME-`uname 2>/dev/null`}
+   case X$UNAME in
+     *-DOS) LN_S='cp -pf' ;;
+     *)     LN_S='ln -s'  ;;
+   esac
+ fi
+ 
  # Check that $srcdir is set correctly.
  test -f $srcdir/defs || {
    echo "defs: installation error" 1>&2
    exit 1
  }
diff -acprNC5 enscript-1.6.2.orig/tests/escapes.test enscript-1.6.2.djgpp/tests/escapes.test
*** enscript-1.6.2.orig/tests/escapes.test	Tue Jan 21 15:35:54 1997
--- enscript-1.6.2.djgpp/tests/escapes.test	Sun May 27 23:37:42 2001
***************
*** 6,16 ****
  . $srcdir/defs || exit 1
  
  links="README.ESCAPES mtr.eps mtr_small.eps mtr_tiny.eps"
  
  for i in $links; do
!   ln -s $srcdir/../$i .
  done
  
  $enscript --quiet -G2r -p$output -e README.ESCAPES
  
  for i in $links; do
--- 6,16 ----
  . $srcdir/defs || exit 1
  
  links="README.ESCAPES mtr.eps mtr_small.eps mtr_tiny.eps"
  
  for i in $links; do
!   $LN_S $srcdir/../$i .
  done
  
  $enscript --quiet -G2r -p$output -e README.ESCAPES
  
  for i in $links; do
