diff -c info/dribble.c c:info/dribble.c
*** info/dribble.c	Fri Jun 16 18:59:30 1995
--- c:info/dribble.c	Wed Sep  4 18:08:58 1996
***************
*** 1,4 ****
--- 1,5 ----
  /* dribble.c -- Dribble files for Info. */
+ /* Changed for emx by Kai Uwe Rommel & Eberhard Mattes -- Sep 1996 */
  
  /* This file is part of GNU Info, a program for reading online documentation
     stored in Info format.
***************
*** 37,43 ****
--- 38,48 ----
    /* Perhaps close existing dribble file. */
    close_dribble_file ();
  
+ #ifdef EMX
+   info_dribble_file = fopen (name, "wb");
+ #else
    info_dribble_file = fopen (name, "w");
+ #endif
  
  #if defined (HAVE_SETVBUF)
    if (info_dribble_file)
diff -c info/filesys.c c:info/filesys.c
*** info/filesys.c	Fri Jun 16 18:59:40 1995
--- c:info/filesys.c	Wed Sep  4 18:09:10 1996
***************
*** 1,4 ****
--- 1,5 ----
  /* filesys.c -- File system specific functions for hacking this system. */
+ /* Changed for emx by Kai Uwe Rommel & Eberhard Mattes -- Sep 1996 */
  
  /* This file is part of GNU Info, a program for reading online documentation
     stored in Info format.
***************
*** 32,37 ****
--- 33,47 ----
  #include "tilde.h"
  #include "filesys.h"
  
+ #ifdef EMX
+ #define COLONCHR ';'
+ #define COLONSTR ";"
+ #include <ctype.h>
+ #else /* !EMX */
+ #define COLONCHR ':'
+ #define COLONSTR ":"
+ #endif /* !EMX */
+ 
  #if !defined (O_RDONLY)
  #if defined (HAVE_SYS_FCNTL_H)
  #include <sys/fcntl.h>
***************
*** 57,62 ****
--- 67,75 ----
  
  /* Local to this file. */
  static char *info_file_in_path (), *lookup_info_filename ();
+ #ifdef EMX
+ static char *info_check_file ();
+ #endif /* EMX */
  static void remember_info_filename (), maybe_initialize_infopath ();
  
  #if !defined (NULL)
***************
*** 72,85 ****
--- 85,108 ----
    "",
    ".info",
    "-info",
+ #ifdef EMX
+   ".inf",
+ #endif /* EMX */
    (char *)NULL
  };
  
  static COMPRESSION_ALIST compress_suffixes[] = {
+ #ifdef EMX
+   { ".Z", "compress -d" },
+   { ".Y", "yabba -d" },
+   { ".z", "gzip -d" },
+   { ".gz", "gzip -d" },
+ #else /* !EMX */
    { ".Z", "uncompress" },
    { ".Y", "unyabba" },
    { ".z", "gunzip" },
    { ".gz", "gunzip" },
+ #endif /* !EMX */
    { (char *)NULL, (char *)NULL }
  };
  
***************
*** 120,132 ****
--- 143,165 ----
  	 various extensions to it.  I guess we have to stat this file
  	 after all. */
        if (initial_character == '/')
+ #ifdef EMX
+ 	temp = info_check_file (partial);
+       else if (_fngetdrive (partial) != 0)
+ 	temp = info_check_file (partial);
+ #else /* !EMX */
  	temp = info_file_in_path (partial + 1, "/");
+ #endif /* !EMX */
        else if (initial_character == '~')
  	{
  	  expansion = tilde_expand_word (partial);
  	  if (*expansion == '/')
  	    {
+ #ifdef EMX
+ 	      temp = info_check_file (expansion);
+ #else /* !EMX */
  	      temp = info_file_in_path (expansion + 1, "/");
+ #endif /* !EMX */
  	      free (expansion);
  	    }
  	  else
***************
*** 150,156 ****
--- 183,195 ----
  
  	  strcat (local_temp_filename, "/");
  	  strcat (local_temp_filename, partial);
+ #ifdef EMX
+ 	  temp = info_check_file (local_temp_filename);
+ 	  free (local_temp_filename);
+ 	  return (temp);
+ #else /* !EMX */
  	  return (local_temp_filename);
+ #endif /* !EMX */
  	}
        else
  	temp = info_file_in_path (partial, infopath);
***************
*** 177,191 ****
--- 216,237 ----
  info_file_in_path (filename, path)
       char *filename, *path;
  {
+ #ifdef EMX
+   char *temp_dirname, *final_name;
+   int dirname_index;
+ #else /* !EMX */
    struct stat finfo;
    char *temp_dirname;
    int statable, dirname_index;
+ #endif /* !EMX */
  
    dirname_index = 0;
  
    while (temp_dirname = extract_colon_unit (path, &dirname_index))
      {
+ #ifndef EMX
        register int i, pre_suffix_length;
+ #endif /* !EMX */
        char *temp;
  
        /* Expand a leading tilde if one is present. */
***************
*** 204,213 ****
--- 250,285 ----
  	strcat (temp, "/");
        strcat (temp, filename);
  
+ #ifndef EMX
        pre_suffix_length = strlen (temp);
+ #endif /* !EMX */
  
        free (temp_dirname);
  
+ #ifdef EMX
+       final_name = info_check_file (temp);
+       free (temp);
+       if (final_name)
+ 	return (final_name);
+     }
+   return ((char *)NULL);
+ }
+ 
+ /* check if the file exists, possibly trying the compressed file suffixes */
+ static char *
+ info_check_file (filename)
+      char *filename;
+ {
+   register int i, statable, pre_suffix_length;
+   struct stat finfo;
+   char *temp;
+ 
+   temp = (char *)xmalloc (30 + strlen (filename));
+   strcpy (temp, filename);
+ 
+   pre_suffix_length = strlen (temp);
+ #endif /* EMX */
+ 
        for (i = 0; info_suffixes[i]; i++)
  	{
  	  strcpy (temp + pre_suffix_length, info_suffixes[i]);
***************
*** 256,263 ****
--- 328,337 ----
  		    return (temp);
  		}
  	    }
+ #ifndef EMX
  	}
        free (temp);
+ #endif /* !EMX */
      }
    return ((char *)NULL);
  }
***************
*** 276,282 ****
    if ((i >= strlen (string)) || !string)
      return ((char *) NULL);
  
!   while (string[i] && string[i] != ':')
      i++;
    if (i == start)
      {
--- 350,356 ----
    if ((i >= strlen (string)) || !string)
      return ((char *) NULL);
  
!   while (string[i] && string[i] != COLONCHR)
      i++;
    if (i == start)
      {
***************
*** 387,400 ****
      strcpy (infopath, path);
    else if (where == INFOPATH_APPEND)
      {
!       strcat (infopath, ":");
        strcat (infopath, path);
      }
    else if (where == INFOPATH_PREPEND)
      {
        char *temp = strdup (infopath);
        strcpy (infopath, path);
!       strcat (infopath, ":");
        strcat (infopath, temp);
        free (temp);
      }
--- 461,474 ----
      strcpy (infopath, path);
    else if (where == INFOPATH_APPEND)
      {
!       strcat (infopath, COLONSTR);
        strcat (infopath, path);
      }
    else if (where == INFOPATH_PREPEND)
      {
        char *temp = strdup (infopath);
        strcpy (infopath, path);
!       strcat (infopath, COLONSTR);
        strcat (infopath, temp);
        free (temp);
      }
***************
*** 444,450 ****
--- 518,529 ----
        /* Try to read the contents of this file. */
        st_size = (long) finfo->st_size;
        contents = (char *)xmalloc (1 + st_size);
+ #ifdef EMX
+       st_size = read (descriptor, contents, finfo->st_size);
+       if (st_size == -1)
+ #else /* !EMX */
        if ((read (descriptor, contents, st_size)) != st_size)
+ #endif /* !EMX */
  	{
  	  filesys_error_number = errno;
  	  close (descriptor);
***************
*** 453,459 ****
  	}
  
        close (descriptor);
! 
        *filesize = st_size;
        return (contents);
      }
--- 532,540 ----
  	}
  
        close (descriptor);
! #ifdef EMX
!       finfo->st_size = st_size;
! #endif /* !EMX */
        *filesize = st_size;
        return (contents);
      }
diff -c info/general.h c:info/general.h
*** info/general.h	Fri Jun 16 19:01:50 1995
--- c:info/general.h	Wed Sep  4 18:09:26 1996
***************
*** 1,4 ****
--- 1,5 ----
  /* general.h -- Some generally useful defines. */
+ /* Changed for emx by Kai Uwe Rommel & Eberhard Mattes -- Sep 1996 */
  
  /* This file is part of GNU Info, a program for reading online documentation
     stored in Info format.
***************
*** 23,28 ****
--- 24,33 ----
  
  #if !defined (_GENERAL_H_)
  #define _GENERAL_H_
+ 
+ #ifdef EMX
+ #define whitespace_or_newline(c) (whitespace (c) || (c == '\n') || (c == '\r'))
+ #endif /* EMX */
  
  extern void *xmalloc (), *xrealloc ();
  
diff -c info/info.c c:info/info.c
*** info/info.c	Sat Dec 23 21:50:58 1995
--- c:info/info.c	Wed Sep  4 18:09:36 1996
***************
*** 1,4 ****
--- 1,5 ----
  /* info.c -- Display nodes of Info files in multiple windows. */
+ /* Changed for emx by Kai Uwe Rommel & Eberhard Mattes -- Sep 1996 */
  
  /* This file is part of GNU Info, a program for reading online documentation
     stored in Info format.
***************
*** 85,91 ****
--- 86,96 ----
  };
  
  /* String describing the shorthand versions of the long options found above. */
+ #ifdef EMX
+ static char *short_options = "d:n:f:o:sh?";
+ #else /* !EMX */
  static char *short_options = "d:n:f:o:s";
+ #endif /* !EMX */
  
  /* When non-zero, the Info window system has been initialized. */
  int info_windows_initialized_p = 0;
***************
*** 109,114 ****
--- 114,122 ----
    NODE *initial_node;		/* First node loaded by Info. */
  
    remember_info_program_name (argv[0]);
+ #ifdef EMX
+   setvbuf(stdout, NULL, _IOFBF, BUFSIZ);
+ #endif /* EMX */
  
    while (1)
      {
***************
*** 150,155 ****
--- 158,170 ----
  	  user_filename = strdup (optarg);
  	  break;
  
+ #ifdef EMX
+ 	  /* User is requesting help. */
+ 	case 'h':
+ 	  print_help_p = 1;
+ 	  break;
+ #endif /* EMX */
+ 
  	  /* User is specifying the name of a file to output to. */
  	case 'o':
  	  if (user_output_filename)
***************
*** 523,528 ****
--- 538,546 ----
  static void
  usage ()
  {
+ #ifdef EMX
+   fprintf (stderr,"\nGNU Info, Version %s.", version_string ());
+ #endif /* EMX */
    fprintf (stderr,"%s\n%s\n%s\n%s\n%s\n",
  "Usage: info [-d dir-path] [-f info-file] [-o output-file] [-n node-name]...",
  "            [--directory dir-path] [--file info-file] [--node node-name]...",
diff -c info/makedoc.c c:info/makedoc.c
*** info/makedoc.c	Fri Jun 16 19:00:26 1995
--- c:info/makedoc.c	Wed Sep  4 18:09:44 1996
***************
*** 1,4 ****
--- 1,5 ----
  /* makedoc.c -- Make DOC.C and FUNS.H from input files. */
+ /* Changed for emx by Eberhard Mattes -- Sep 1996 */
  
  /* This file is part of GNU Info, a program for reading online documentation
     stored in Info format.
***************
*** 276,282 ****
--- 277,287 ----
  
    file_size = (long) finfo.st_size;
    buffer = (char *)xmalloc (1 + file_size);
+ #ifdef EMX
+   file_size = read (descriptor, buffer, file_size);
+ #else /* !EMX */
    read (descriptor, buffer, file_size);
+ #endif /* !EMX */
    close (descriptor);
  
    offset = 0;
diff -c info/man.c c:info/man.c
*** info/man.c	Sat Dec 23 22:23:40 1995
--- c:info/man.c	Wed Sep  4 18:09:52 1996
***************
*** 1,4 ****
--- 1,5 ----
  /*  man.c: How to read and format man files. */
+ /* Changed for emx by Kai Uwe Rommel & Eberhard Mattes -- Sep 1996 */
  
  /* This file is part of GNU Info, a program for reading online documentation
     stored in Info format.
***************
*** 31,36 ****
--- 32,41 ----
  #if defined (HAVE_SYS_WAIT_H)
  #include <sys/wait.h>
  #endif
+ #ifdef EMX
+ #include <process.h>
+ #include <sys/wait.h>
+ #endif /* EMX */
  #include "tilde.h"
  
  #include "man.h"
***************
*** 160,166 ****
--- 165,181 ----
  
        free (temp_dirname);
  
+ #ifdef EMX
+       strcat (temp, ".cmd");
+       statable = (stat (temp, &finfo) == 0);
+       if (!statable)
+       {
+ 	strcpy(temp + strlen (temp) - 4, ".exe");
        statable = (stat (temp, &finfo) == 0);
+       }
+ #else /* !EMX */
+       statable = (stat (temp, &finfo) == 0);
+ #endif /* !EMX */
  
        /* If we have found a regular executable file, then use it. */
        if ((statable) && (S_ISREG (finfo.st_mode)) &&
***************
*** 255,260 ****
--- 270,307 ----
       writer end is pipes[1]. */
    pipe (pipes);
  
+ #ifdef EMX
+   {
+     int pid, old_stdout, old_stderr;
+     
+     old_stdout = dup (fileno (stdout));
+     fcntl (old_stdout, F_SETFD, FD_CLOEXEC);
+     dup2 (pipes[1], fileno (stdout));
+ 
+     old_stderr = dup (fileno (stderr));
+     fcntl (old_stderr, F_SETFD, FD_CLOEXEC);
+     close (fileno (stderr));
+     
+     close (pipes[1]);
+     fcntl (pipes[0], F_SETFD, FD_CLOEXEC);
+ 
+     pid = spawnv (P_NOWAIT, formatter_args[0], formatter_args);
+ 
+     close (fileno (stdout));
+     dup2 (old_stdout, fileno (stdout));
+     close (old_stdout);
+ 
+     dup2 (old_stderr, fileno (stderr));
+     close (old_stderr);
+ 
+     if (pid != -1)
+       formatted_page = read_from_fd (pipes[0]);
+ 
+     close (pipes[0]);
+ 
+     waitpid (pid, NULL, WNOHANG);
+   }
+ #else /* !EMX */
    signal (SIGCHLD, reap_children);
  
    child = fork ();
***************
*** 286,291 ****
--- 333,339 ----
        close (pipes[1]);
        exit (0);
      }
+ #endif /* !EMX */
  
    /* If we have the page, then clean it up. */
    if (formatted_page)
diff -c info/nodes.c c:info/nodes.c
*** info/nodes.c	Fri Jun 16 19:00:40 1995
--- c:info/nodes.c	Wed Sep  4 18:09:58 1996
***************
*** 1,4 ****
--- 1,5 ----
  /* nodes.c -- How to get an Info file and node. */
+ /* Changed for emx by Eberhard Mattes -- Sep 1996 */
  
  /* This file is part of GNU Info, a program for reading online documentation
     stored in Info format.
***************
*** 294,301 ****
--- 295,306 ----
  
  	    old_info = &file_buffer->finfo;
  
+ #ifdef EMX
+ 	    if (new_info.st_mtime != old_info->st_mtime)
+ #else /* not EMX */
  	    if ((new_info.st_size != old_info->st_size) ||
  		(new_info.st_mtime != old_info->st_mtime))
+ #endif
  	      {
  		/* The file has changed.  Forget that we ever had loaded it
  		   in the first place. */
diff -c info/session.c c:info/session.c
*** info/session.c	Sat Dec 23 22:13:18 1995
--- c:info/session.c	Wed Sep  4 18:10:06 1996
***************
*** 1,4 ****
--- 1,5 ----
  /* session.c -- The user windowing interface to Info. */
+ /* Changed for emx by Kai Uwe Rommel & Eberhard Mattes -- Sep 1996 */
  
  /* This file is part of GNU Info, a program for reading online documentation
     stored in Info format.
***************
*** 28,33 ****
--- 29,38 ----
  #include <sys/ioctl.h>
  #include <fcntl.h>
  
+ #ifdef EMX
+ #  include <pc.h>
+ #endif /* EMX */
+ 
  #if defined (HAVE_SYS_TIME_H)
  #  include <sys/time.h>
  #  define HAVE_STRUCT_TIMEVAL
***************
*** 303,309 ****
--- 308,318 ----
  {
    FILE *stream;
  
+ #ifdef EMX
+   stream = fopen (filename, "rb");
+ #else /* !EMX */
    stream = fopen (filename, "r");
+ #endif /* !EMX */
  
    if (!stream)
      return;
***************
*** 2493,2499 ****
--- 2502,2512 ----
    if (strcmp (output_filename, "-") == 0)
      output_stream = stdout;
    else
+ #ifdef EMX
+     output_stream = fopen (output_filename, "wb");
+ #else /* !EMX */
      output_stream = fopen (output_filename, "w");
+ #endif
  
    if (!output_stream)
      {
***************
*** 2618,2624 ****
--- 2631,2641 ----
    if (strcmp (filename, "-") == 0)
      output_stream = stdout;
    else
+ #ifdef EMX
+     output_stream = fopen (filename, "wb");
+ #else /* !EMX */
      output_stream = fopen (filename, "w");
+ #endif /* !EMX */
  
    if (!output_stream)
      {
***************
*** 4177,4182 ****
--- 4194,4203 ----
  
    space_avail = info_input_buffer_space_available ();
  
+ #ifdef EMX
+   while (chars_avail < space_avail && (tty = pc_getc (0)) != -1)
+     input[chars_avail++] = tty;
+ #else /* !EMX */
    /* If we can just find out how many characters there are to read, do so. */
  #if defined (FIONREAD)
    {
***************
*** 4204,4209 ****
--- 4225,4231 ----
    }
  #  endif /* O_NDELAY */
  #endif /* !FIONREAD */
+ #endif /* !EMX */
  
    /* Store the input characters just read into our input buffer. */
    {
diff -c info/terminal.c c:info/terminal.c
*** info/terminal.c	Fri Jun 16 19:01:00 1995
--- c:info/terminal.c	Wed Sep  4 18:10:50 1996
***************
*** 1,4 ****
--- 1,5 ----
  /* terminal.c -- How to handle the physical terminal for Info. */
+ /* Changed for emx by Kai Uwe Rommel & Eberhard Mattes -- Sep 1996 */
  
  /* This file is part of GNU Info, a program for reading online documentation
     stored in Info format.
***************
*** 135,140 ****
--- 136,146 ----
  static void
  terminal_end_using_terminal ()
  {
+ #ifdef EMX
+   terminal_goto_xy (0, screenheight - 2); /* cmd.exe writes extra newline */
+ #else /* !EMX */
+   terminal_goto_xy (0, screenheight - 1);
+ #endif /* !EMX */
    send_to_terminal (term_end_use);
  }
  
***************
*** 410,415 ****
--- 416,429 ----
      {
        screenwidth = screenheight = 0;
  
+ #ifdef EMX
+       {
+ 	int size[2];
+ 	_scrsize (size);
+ 	screenwidth  = size[0];
+ 	screenheight = size[1];
+       }
+ #else /* !EMX */
  #if defined (TIOCGWINSZ)
        {
  	struct winsize window_size;
***************
*** 421,426 ****
--- 435,441 ----
  	  }
        }
  #endif				/* TIOCGWINSZ */
+ #endif /* !EMX*/
  
        /* Environment variable COLUMNS overrides setting of "co". */
        if (screenwidth <= 0)
***************
*** 619,624 ****
--- 634,645 ----
  
    tty = fileno (stdin);
  
+ #ifdef EMX
+ 
+   pc_init ();
+ 
+ #else /* !EMX */
+ 
  #if defined (HAVE_TERMIO_H)
    ioctl (tty, TCGETA, &original_termio);
    ioctl (tty, TCGETA, &ttybuff);
***************
*** 703,708 ****
--- 724,731 ----
    ttybuff.sg_flags |= CBREAK;
    ioctl (tty, TIOCSETN, &ttybuff);
  #endif /* !HAVE_TERMIO_H */
+ 
+ #endif /* !EMX */
  }
  
  /* Restore the tty settings back to what they were before we started using
***************
*** 720,725 ****
--- 743,754 ----
  
    tty = fileno (stdin);
  
+ #ifdef EMX
+ 
+   pc_exit ();
+ 
+ #else
+ 
  #if defined (HAVE_TERMIO_H)
    ioctl (tty, TCSETA, &original_termio);
  #else /* !HAVE_TERMIO_H */
***************
*** 740,745 ****
--- 769,777 ----
  #endif /* TIOCLGET && LPASS8 */
  
  #endif /* !HAVE_TERMIO_H */
+ 
+ #endif /* !EMX */
+ 
    terminal_end_using_terminal ();
  }
  
diff -c makeinfo/makeinfo.c c:makeinfo/makeinfo.c
*** makeinfo/makeinfo.c	Sat Dec 23 23:18:36 1995
--- c:makeinfo/makeinfo.c	Wed Sep  4 18:11:08 1996
***************
*** 18,23 ****
--- 18,30 ----
     rights and responsibilities.  It should be in a file named COPYING.
     Among other things, the copyright notice and this notice must be
     preserved on all copies.  */
+ 
+ /* emx port and enhancements (c) 1992-1996 Kai Uwe Rommel,
+    rommel@ars.de, rommel@leo.org
+ 
+    This port is also distributed under the terms of the
+    GNU General Public License as published by the
+    Free Software Foundation. */
  
  /* This is Makeinfo version 1.64.  If you change the version number of
     Makeinfo, please change it here and at the lines reading:
***************
*** 91,96 ****
--- 98,111 ----
  #include <perror.h>
  #endif
  
+ #ifdef EMX
+ #include <stdlib.h>
+ #include <stdlib.h>
+ #include <stdarg.h>
+ #include <assert.h>
+ #include <io.h>
+ #endif /* EMX */
+ 
  #if defined (HAVE_STRING_H)
  #include <string.h>
  #else
***************
*** 925,930 ****
--- 940,950 ----
    int c, ind;
    int reading_from_stdin = 0;
  
+ #ifdef EMX
+   _response(&argc, &argv);
+   _wildcard(&argc, &argv);
+ #endif /* EMX */
+   
    /* The name of this program is the last filename in argv[0]. */
    progname = filename_part (argv[0]);
  
***************
*** 1074,1079 ****
--- 1094,1102 ----
  void
  print_version_info ()
  {
+ #ifdef EMX
+   putchar('\n');
+ #endif /* EMX */
    printf ("This is GNU Makeinfo version %d.%d, from texinfo-3.7.\n",
  	  major_version, minor_version);
  }
***************
*** 1152,1157 ****
--- 1175,1184 ----
       FILE *stream;
       int exit_value;
  {
+ #ifdef EMX
+   fprintf (stderr, "\nGNU makeinfo, version %d.%d.\n\n",
+ 	   major_version, minor_version);
+ #endif /* EMX */
    fprintf (stream, "Usage: %s [options] texinfo-file...\n\
  \n\
  This program accepts as input files of texinfo commands and text\n\
***************
*** 1236,1241 ****
--- 1263,1271 ----
    struct stat fileinfo;
    long file_size;
    int file = -1, n, i, count = 0;
+ #ifdef EMX
+   int bytes_read;
+ #endif /* EMX */
    char *fullpath, *result, *get_file_info_in_path ();
  
    result = fullpath = (char *)NULL;
***************
*** 1248,1254 ****
--- 1278,1288 ----
    filename = fullpath;
    file_size = (long) fileinfo.st_size;
  
+ #ifdef EMX
+   file = open (filename, O_RDONLY|O_TEXT);
+ #else
    file = open (filename, O_RDONLY);
+ #endif
    if (file < 0)
      goto error_exit;
  
***************
*** 1265,1271 ****
--- 1299,1310 ----
    if (n == -1)
  #else /* !VMS */
      count = file_size;
+ #ifdef EMX
+     bytes_read = read (file, result, file_size);
+     if (bytes_read <= 0 || bytes_read > file_size)
+ #else /* !EMX */
      if (read (file, result, file_size) != file_size)
+ #endif /* !EMX */
  #endif /* !VMS */
    error_exit:
      {
***************
*** 1284,1290 ****
--- 1323,1333 ----
  
    /* Set the globals to the new file. */
    input_text = result;
+ #ifdef EMX
+   size_of_input_text = bytes_read;
+ #else /* !EMX */
    size_of_input_text = count;
+ #endif /* !EMX */
    input_filename = fullpath;
    node_filename = strdup (fullpath);
    input_text_offset = 0;
***************
*** 1583,1588 ****
--- 1626,1635 ----
  	}
        else
  	{
+ #ifdef EMX
+ 	  result = xmalloc (strlen (filename) + 1);
+ 	  strcpy (result, filename);
+ #else /* !EMX */
  	  struct passwd *user_entry;
  	  int i, c;
  	  char *username = (char *)xmalloc (257);
***************
*** 1606,1611 ****
--- 1653,1659 ----
  				    + strlen (&filename[i]));
  	  strcpy (result, user_entry->pw_dir);
  	  strcat (result, &filename[i]);
+ #endif /* !EMX */
  	}
      }
    return (result);
***************
*** 2012,2017 ****
--- 2060,2068 ----
    ".texinfo",
    ".texi",
    ".txinfo",
+ #ifdef EMX
+   ".tex",
+ #endif /* EMX */
    (char *)NULL
  };
  
***************
*** 2210,2216 ****
--- 2261,2271 ----
        else
  	real_output_filename = strdup (real_output_filename);
  
+ #ifdef EMX
+       output_stream = fopen (real_output_filename, "wb");
+ #else /* !EMX */
        output_stream = fopen (real_output_filename, "w");
+ #endif /* !EMX */
      }
  
    if (output_stream != stdout)
***************
*** 3122,3127 ****
--- 3177,3185 ----
  {
    last_inserted_character = '\n';
    last_char_was_newline = 1;
+ #ifdef EMX
+   last_inserted_character = 0;
+ #endif /* EMX */
  }
  
  /* Align the end of the text in output_paragraph with fill_column. */
***************
*** 4062,4068 ****
--- 4120,4130 ----
  cm_bold (arg, start, end)
       int arg, start, end;
  {
+ #ifdef EMX
+   cm_italic (arg, start, end);
+ #else /* !EMX */
    cm_italic (arg);
+ #endif /* !EMX */
  }
  
  /* Current text is in roman font. */
***************
*** 4084,4090 ****
--- 4146,4156 ----
  cm_title (arg, start, end)
       int arg, start, end;
  {
+ #ifdef EMX
+   cm_italic (arg, start, end);
+ #else /* !EMX */
    cm_italic (arg);
+ #endif /* !EMX */
  }
  
  /* @refill is a NOP. */
***************
*** 5352,5361 ****
--- 5418,5435 ----
  		    (10 + strlen (root_pathname) + strlen (root_filename));
  		  sprintf
  		    (split_filename,
+ #ifdef EMX
+ 		     "%s%s.i%.2d", root_pathname, root_filename, which_file);
+ #else /* !EMX */
  		     "%s%s-%d", root_pathname, root_filename, which_file);
+ #endif /* !EMX */
  
  		  fd = open
+ #ifdef EMX
+ 		    (split_filename, O_WRONLY | O_TRUNC | O_CREAT | O_BINARY, 0666);
+ #else
  		    (split_filename, O_WRONLY | O_TRUNC | O_CREAT, 0666);
+ #endif
  
  		  if ((fd < 0) ||
  		      (write (fd, the_header, header_size) != header_size) ||
***************
*** 5376,5382 ****
--- 5450,5460 ----
  		      indirect_info += strlen (indirect_info);
  		    }
  
+ #ifdef EMX
+ 		  sprintf (indirect_info, "%s.i%.2d: %ld\n",
+ #else /* !EMX */
  		  sprintf (indirect_info, "%s-%d: %d\n",
+ #endif /* !EMX */
  			   root_filename, which_file, file_top);
  
  		  free (split_filename);
***************
*** 5391,5397 ****
--- 5469,5479 ----
      /* We have sucessfully created the subfiles.  Now write out the
         original again.  We must use `output_stream', or
         write_tag_table_indirect () won't know where to place the output. */
+ #ifdef EMX
+     output_stream = fopen (filename, "wb");
+ #else /* !EMX */
      output_stream = fopen (filename, "w");
+ #endif /* !EMX */
      if (!output_stream)
        {
  	perror (filename);
diff -c texindex/texindex.c c:texindex/texindex.c
*** texindex/texindex.c	Fri Jun 16 19:14:36 1995
--- c:texindex/texindex.c	Wed Sep  4 18:11:26 1996
***************
*** 17,22 ****
--- 17,31 ----
     You should have received a copy of the GNU General Public License
     along with this program; if not, write to the Free Software
     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307. */
+ 
+ char *version = "1.45";
+ 
+    /* emx port (c) 1991-1996 Kai Uwe Rommel,
+    rommel@ars.de
+ 
+    This port is also distributed under the terms of the
+    GNU General Public License as published by the
+    Free Software Foundation. */
  
  
  #include <stdio.h>
***************
*** 35,40 ****
--- 44,58 ----
  #  undef open
  #endif
  
+ #ifdef EMX
+ #include <stdarg.h>
+ #include <stdlib.h>
+ #include <assert.h>
+ #include <io.h>
+ #include <sys/types.h>
+ #include <fcntl.h>
+ #endif /* EMX */
+ 
  #if defined (HAVE_STRING_H)
  #  include <string.h>
  #endif /* HAVE_STRING_H */
***************
*** 205,210 ****
--- 223,233 ----
  {
    int i;
  
+ #ifdef EMX
+   _response(&argc, &argv);
+   _wildcard(&argc, &argv);
+ #endif /* EMX */
+   
    tempcount = 0;
    last_deleted_tempcount = 0;
  
***************
*** 235,241 ****
--- 258,268 ----
  
    decode_command (argc, argv);
  
+ #ifdef EMX
+   tempbase = mktemp (concat ("tiXXXXXX", "", ""));
+ #else /* !EMX */
    tempbase = mktemp (concat ("txiXXXXXX", "", ""));
+ #endif /* !EMX */
  
    /* Process input files completely, one by one.  */
  
***************
*** 299,304 ****
--- 326,334 ----
  {
    register int i;
  
+ #ifdef EMX
+   fprintf (stderr, "\nGNU texindex %s\n\n", version);
+ #endif /* EMX */
    fprintf (stderr, "Usage: %s [OPTIONS] FILE...\n", program_name);
    fprintf (stderr, "  Generate a permuted index for the TeX files given.\n");
    fprintf (stderr, "  Usually FILE... is `foo.??' for the source file `foo.tex'.\n");
***************
*** 341,350 ****
--- 371,389 ----
    if (tempdir == NULL)
      tempdir = "sys$scratch:";
  #else
+ #ifdef EMX
+   if (tempdir == NULL)
+     tempdir = getenv("TMP");
+   if (!tempdir )
+     tempdir = "/";
+   else
+     tempdir = concat (tempdir, "/", "");
+ #else /* !EMX */
    if (tempdir == NULL)
      tempdir = "/tmp/";
    else
      tempdir = concat (tempdir, "/", "");
+ #endif /* !EMX */
  #endif
  
    keep_tempfiles = 0;
***************
*** 916,924 ****
  /* Sort an input file too big to sort in core.  */
  
  void
! sort_offline (infile, nfiles, total, outfile)
       char *infile;
-      int nfiles;
       long total;
       char *outfile;
  {
--- 955,962 ----
  /* Sort an input file too big to sort in core.  */
  
  void
! sort_offline (infile, total, outfile)
       char *infile;
       long total;
       char *outfile;
  {
***************
*** 997,1003 ****
    for (i = 0; i < ntemps; i++)
      {
        char *newtemp = maketempname (++tempcount);
!       sort_in_core (&tempfiles[i], MAX_IN_CORE_SORT, newtemp);
        if (!keep_tempfiles)
  	unlink (tempfiles[i]);
        tempfiles[i] = newtemp;
--- 1035,1041 ----
    for (i = 0; i < ntemps; i++)
      {
        char *newtemp = maketempname (++tempcount);
!       sort_in_core (tempfiles[i], MAX_IN_CORE_SORT, newtemp);
        if (!keep_tempfiles)
  	unlink (tempfiles[i]);
        tempfiles[i] = newtemp;
***************
*** 1087,1093 ****
       Make a `struct lineinfo' for each line, which records the keyfield
       as well as the line, and sort them.  */
  
!   lineinfo = (struct lineinfo *) malloc ((nextline - linearray) * sizeof (struct lineinfo));
  
    if (lineinfo)
      {
--- 1125,1131 ----
       Make a `struct lineinfo' for each line, which records the keyfield
       as well as the line, and sort them.  */
  
!   lineinfo = (struct lineinfo *) xmalloc ((nextline - linearray) * sizeof (struct lineinfo));
  
    if (lineinfo)
      {
***************
*** 1779,1785 ****
  	   "Virtual memory exhausted in %s ()!  Needed %d bytes.",
  	   callers_name, bytes_wanted);
  
!   error (printable_string);
    abort ();
  }
  
--- 1817,1823 ----
  	   "Virtual memory exhausted in %s ()!  Needed %d bytes.",
  	   callers_name, bytes_wanted);
  
!   error (printable_string, "");
    abort ();
  }
  
