diff -c diffutils-2.5-org/analyze.c diffutils-2.5-new/analyze.c
*** diffutils-2.5-org/analyze.c	Mon Sep 27 00:20:24 1993
--- diffutils-2.5-new/analyze.c	Mon Oct  4 11:21:05 1993
***************
*** 259,270 ****
        files[0].changed_flag[files[0].realindexes[xoff++]] = 1;
    else
      {
!       int c, d, f, b;
  
        /* Find a point of correspondence in the middle of the files.  */
  
        d = diag (xoff, xlim, yoff, ylim, &c);
!       f = fdiag[d];
        b = bdiag[d];
  
        if (c == 1)
--- 259,270 ----
        files[0].changed_flag[files[0].realindexes[xoff++]] = 1;
    else
      {
!       int c, d, /*f,*/ b;
  
        /* Find a point of correspondence in the middle of the files.  */
  
        d = diag (xoff, xlim, yoff, ylim, &c);
!       /*f = fdiag[d];*/
        b = bdiag[d];
  
        if (c == 1)
diff -c diffutils-2.5-org/context.c diffutils-2.5-new/context.c
*** diffutils-2.5-org/context.c	Fri Aug 27 10:30:26 1993
--- diffutils-2.5-new/context.c	Mon Oct  4 11:21:06 1993
***************
*** 20,26 ****
  #include "diff.h"
  
  static struct change *find_hunk PARAMS((struct change *));
! static void find_function PARAMS((struct file_data const *, int, char const **, size_t *));
  static void mark_ignorable PARAMS((struct change *));
  static void pr_context_hunk PARAMS((struct change *));
  static void pr_unidiff_hunk PARAMS((struct change *));
--- 20,26 ----
  #include "diff.h"
  
  static struct change *find_hunk PARAMS((struct change *));
! static void find_function PARAMS((struct file_data const *, int, char const HUGE **, size_t *));
  static void mark_ignorable PARAMS((struct change *));
  static void pr_context_hunk PARAMS((struct change *));
  static void pr_unidiff_hunk PARAMS((struct change *));
***************
*** 131,137 ****
    int first0, last0, first1, last1, show_from, show_to, i;
    struct change *next;
    char const *prefix;
!   char const *function;
    size_t function_length;
    FILE *out;
  
--- 131,137 ----
    int first0, last0, first1, last1, show_from, show_to, i;
    struct change *next;
    char const *prefix;
!   char const HUGE *function;
    size_t function_length;
    FILE *out;
  
***************
*** 264,270 ****
  {
    int first0, last0, first1, last1, show_from, show_to, i, j, k;
    struct change *next;
!   char const *function;
    size_t function_length;
    FILE *out;
  
--- 264,270 ----
  {
    int first0, last0, first1, last1, show_from, show_to, i, j, k;
    struct change *next;
!   char const HUGE *function;
    size_t function_length;
    FILE *out;
  
***************
*** 428,434 ****
  find_function (file, linenum, linep, lenp)
       struct file_data const *file;
       int linenum;
!      char const **linep;
       size_t *lenp;
  {
    int i = linenum;
--- 428,434 ----
  find_function (file, linenum, linep, lenp)
       struct file_data const *file;
       int linenum;
!      char const HUGE **linep;
       size_t *lenp;
  {
    int i = linenum;
***************
*** 439,445 ****
      {
        /* See if this line is what we want.  */
        struct regexp_list *r;
!       char const *line = file->linbuf[i];
        size_t len = file->linbuf[i + 1] - line;
  
        for (r = function_regexp_list; r; r = r->next)
--- 439,445 ----
      {
        /* See if this line is what we want.  */
        struct regexp_list *r;
!       char const HUGE *line = file->linbuf[i];
        size_t len = file->linbuf[i + 1] - line;
  
        for (r = function_regexp_list; r; r = r->next)
diff -c diffutils-2.5-org/diff.c diffutils-2.5-new/diff.c
*** diffutils-2.5-org/diff.c	Mon Sep 27 00:20:24 1993
--- diffutils-2.5-new/diff.c	Mon Oct  4 11:21:06 1993
***************
*** 147,153 ****
    sip (&f, 1);
    slurp (&f);
  
!   for (p = f.buffer, lim = p + f.buffered_chars;  p < lim;  p = q)
      {
        q = (char *) memchr (p, '\n', lim - p);
        if (!q)
--- 147,153 ----
    sip (&f, 1);
    slurp (&f);
  
!   for (p = (char *)f.buffer, lim = p + f.buffered_chars;  p < lim;  p = q)
      {
        q = (char *) memchr (p, '\n', lim - p);
        if (!q)
***************
*** 852,857 ****
--- 852,861 ----
        val = 2;
  
      }
+ #if defined(__MSDOS__) || defined(__NT__)
+   else if (same_files = 0) /* yes, only ONE equal sign intended! hmo11apr93 */
+     ;
+ #else
    else if ((same_files =    inf[0].stat.st_ino == inf[1].stat.st_ino
  			 && inf[0].stat.st_dev == inf[1].stat.st_dev
  			 && inf[0].stat.st_size == inf[1].stat.st_size
***************
*** 864,869 ****
--- 868,874 ----
  
        val = 0;
      }
+ #endif /*__MSDOS__||__NT__*/
    else if (inf[0].dir_p & inf[1].dir_p)
      {
        if (output_style == OUTPUT_IFDEF)
diff -c diffutils-2.5-org/diff.h diffutils-2.5-new/diff.h
*** diffutils-2.5-org/diff.h	Thu Sep 16 23:29:10 1993
--- diffutils-2.5-new/diff.h	Fri Oct  8 18:30:35 1993
***************
*** 218,231 ****
      int             dir_p;	/* nonzero if file is a directory  */
  
      /* Buffer in which text of file is read.  */
!     char *	    buffer;
      /* Allocated size of buffer.  */
!     size_t	    bufsize;
      /* Number of valid characters now in the buffer. */
!     size_t	    buffered_chars;
  
      /* Array of pointers to lines in the file.  */
!     char const **linbuf;
  
      /* linbuf_base <= buffered_lines <= valid_lines <= alloc_lines.
         linebuf[linbuf_base ... buffered_lines - 1] are possibly differing.
--- 218,231 ----
      int             dir_p;	/* nonzero if file is a directory  */
  
      /* Buffer in which text of file is read.  */
!     char HUGE *	    buffer;
      /* Allocated size of buffer.  */
!     FSIZE	    bufsize;
      /* Number of valid characters now in the buffer. */
!     FSIZE	    buffered_chars;
  
      /* Array of pointers to lines in the file.  */
!     char const HUGE **linbuf;
  
      /* linbuf_base <= buffered_lines <= valid_lines <= alloc_lines.
         linebuf[linbuf_base ... buffered_lines - 1] are possibly differing.
***************
*** 234,240 ****
      int linbuf_base, buffered_lines, valid_lines, alloc_lines;
  
      /* Pointer to end of prefix of this file to ignore when hashing. */
!     char const *prefix_end;
  
      /* Count of lines in the prefix.
         There are this many lines in the file before linbuf[0].  */
--- 234,240 ----
      int linbuf_base, buffered_lines, valid_lines, alloc_lines;
  
      /* Pointer to end of prefix of this file to ignore when hashing. */
!     char const HUGE *prefix_end;
  
      /* Count of lines in the prefix.
         There are this many lines in the file before linbuf[0].  */
***************
*** 241,247 ****
      int prefix_lines;
  
      /* Pointer to start of suffix of this file to ignore when hashing. */
!     char const *suffix_begin;
  
      /* Vector, indexed by line number, containing an equivalence code for
         each line.  It is this vector that is actually compared with that
--- 241,247 ----
      int prefix_lines;
  
      /* Pointer to start of suffix of this file to ignore when hashing. */
!     char const HUGE *suffix_begin;
  
      /* Vector, indexed by line number, containing an equivalence code for
         each line.  It is this vector that is actually compared with that
***************
*** 322,328 ****
  char *concat PARAMS((char const *, char const *, char const *));
  char *dir_file_pathname PARAMS((char const *, char const *));
  int change_letter PARAMS((int, int));
! int line_cmp PARAMS((char const *, size_t, char const *, size_t));
  int translate_line_number PARAMS((struct file_data const *, int));
  struct change *find_change PARAMS((struct change *));
  struct change *find_reverse_change PARAMS((struct change *));
--- 322,328 ----
  char *concat PARAMS((char const *, char const *, char const *));
  char *dir_file_pathname PARAMS((char const *, char const *));
  int change_letter PARAMS((int, int));
! int line_cmp PARAMS((char const HUGE *, size_t, char const HUGE *, size_t));
  int translate_line_number PARAMS((struct file_data const *, int));
  struct change *find_change PARAMS((struct change *));
  struct change *find_reverse_change PARAMS((struct change *));
***************
*** 334,343 ****
  void finish_output PARAMS((void));
  void message PARAMS((char const *, char const *, char const *));
  void message5 PARAMS((char const *, char const *, char const *, char const *, char const *));
! void output_1_line PARAMS((char const *, char const *, char const *, char const *));
  void perror_with_name PARAMS((char const *));
  void pfatal_with_name PARAMS((char const *));
! void print_1_line PARAMS((char const *, char const * const *));
  void print_message_queue PARAMS((void));
  void print_number_range PARAMS((int, struct file_data *, int, int));
  void print_script PARAMS((struct change *, struct change * (*) PARAMS((struct change *)), void (*) PARAMS((struct change *))));
--- 334,343 ----
  void finish_output PARAMS((void));
  void message PARAMS((char const *, char const *, char const *));
  void message5 PARAMS((char const *, char const *, char const *, char const *, char const *));
! void output_1_line PARAMS((char const HUGE *, char const HUGE *, char const *, char const *));
  void perror_with_name PARAMS((char const *));
  void pfatal_with_name PARAMS((char const *));
! void print_1_line PARAMS((char const *, char const HUGE * const *));
  void print_message_queue PARAMS((void));
  void print_number_range PARAMS((int, struct file_data *, int, int));
  void print_script PARAMS((struct change *, struct change * (*) PARAMS((struct change *)), void (*) PARAMS((struct change *))));
diff -c diffutils-2.5-org/diff3.c diffutils-2.5-new/diff3.c
*** diffutils-2.5-org/diff3.c	Mon Sep 27 00:20:24 1993
--- diffutils-2.5-new/diff3.c	Fri Oct  8 18:26:33 1993
***************
*** 1090,1104 ****
       char const *filea, *fileb;
       char **output_placement;
  {
    char const *argv[7];
    char horizon_arg[256];
    char const **ap;
    int fds[2];
-   char *diff_result;
-   size_t bytes, current_chunk_size, total;
    pid_t pid;
    int wstatus;
  
    ap = argv;
    *ap++ = diff_program;
    if (always_text)
--- 1090,1118 ----
       char const *filea, *fileb;
       char **output_placement;
  {
+ #if defined(__MSDOS__) || defined(__NT__)
+   char command[600];
+   FILE *pipe;
+ #else
    char const *argv[7];
    char horizon_arg[256];
    char const **ap;
    int fds[2];
    pid_t pid;
    int wstatus;
+ #endif /*__MSDOS__||__NT__*/
+   char *diff_result;
+   size_t bytes, current_chunk_size, total;
+ 
+ #if defined(__MSDOS__) || defined(__NT__)
+   sprintf(command, "%s%s --horizon-lines=%d -- %s %s",
+ 	diff_program, always_text ? " -a" : "", horizon_lines, filea, fileb);
  
+   if ((pipe = popen(command, "r")) == NULL) {
+     fprintf(stderr, "%s: not found\n", diff_program);
+     _exit (2);
+   }
+ #else
    ap = argv;
    *ap++ = diff_program;
    if (always_text)
***************
*** 1134,1149 ****
--- 1148,1184 ----
      perror_with_exit ("fork failed");
  
    close (fds[1]);		/* Prevent erroneous lack of EOF */
+ #endif /*__MSDOS__||__NT__*/
    current_chunk_size = DIFF_CHUNK_SIZE;
    diff_result = xmalloc (current_chunk_size);
    total = 0;
    do {
+ #if defined(__MSDOS__) || defined(__NT__)
+ #ifdef __TURBOC__
+     bytes = myread (pipe->fd,
+ #else
+     bytes = myread (_fileno(pipe),
+ #endif /*__TURBOC__*/
+ #else
      bytes = myread (fds[0],
+ #endif /*__MSDOS__||__NT__*/
  		    diff_result + total,
  		    current_chunk_size - total);
      total += bytes;
      if (total == current_chunk_size)
+ #if defined(__MSDOS__) || defined(__NT__)
+       {
+       if (2L * (long) current_chunk_size < UINT_MAX)
+         current_chunk_size *= 2;
+       else if (current_chunk_size < UINT_MAX)
+         current_chunk_size = UINT_MAX;
+       else
+         fatal("file too large!");
+       diff_result = (char *) xrealloc (diff_result, current_chunk_size);
+       }
+ #else
        diff_result = xrealloc (diff_result, (current_chunk_size *= 2));
+ #endif /*__MSDOS__||__NT__*/
    } while (bytes);
  
    if (total != 0 && diff_result[total-1] != '\n')
***************
*** 1151,1156 ****
--- 1186,1195 ----
  
    *output_placement = diff_result;
  
+ #if defined(__MSDOS__) || defined(__NT__)
+   if (pclose (pipe))
+     perror_with_exit ("pipe failed");
+ #else
  #if HAVE_WAITPID
    if (waitpid (pid, &wstatus, 0) < 0)
      perror_with_exit ("waitpid failed");
***************
*** 1166,1171 ****
--- 1205,1211 ----
  
    if (! (WIFEXITED (wstatus) && WEXITSTATUS (wstatus) < 2))
      fatal ("subsidiary diff failed");
+ #endif /*__MSDOS__||__NT__*/
  
    return diff_result + total;
  }
diff -c diffutils-2.5-org/ifdef.c diffutils-2.5-new/ifdef.c
*** diffutils-2.5-org/ifdef.c	Fri Sep 17 12:27:09 1993
--- diffutils-2.5-new/ifdef.c	Mon Oct  4 11:21:08 1993
***************
*** 266,272 ****
       struct group const *group;
  {
    struct file_data const *file = group->file;
!   char const * const *linbuf = file->linbuf;
    int from = group->from, upto = group->upto;
  
    if (!out)
--- 266,272 ----
       struct group const *group;
  {
    struct file_data const *file = group->file;
!   char const HUGE * const *linbuf = file->linbuf;
    int from = group->from, upto = group->upto;
  
    if (!out)
diff -c diffutils-2.5-org/io.c diffutils-2.5-new/io.c
*** diffutils-2.5-org/io.c	Fri Aug 27 10:30:26 1993
--- diffutils-2.5-new/io.c	Thu Oct 28 15:12:17 1993
***************
*** 31,37 ****
  #define GUESS_LINES(n,s,t) (((t) - (s)) / ((n) < 10 ? 32 : (s) / ((n)-1)) + 5)
  
  /* Type used for fast prefix comparison in find_identical_ends.  */
! typedef long word;
  
  /* Lines are put into equivalence classes (of lines that match in line_cmp).
     Each equivalence class is represented by one of these structures,
--- 31,37 ----
  #define GUESS_LINES(n,s,t) (((t) - (s)) / ((n) < 10 ? 32 : (s) / ((n)-1)) + 5)
  
  /* Type used for fast prefix comparison in find_identical_ends.  */
! typedef unsigned word;
  
  /* Lines are put into equivalence classes (of lines that match in line_cmp).
     Each equivalence class is represented by one of these structures,
***************
*** 41,47 ****
  {
    int next;	/* Next item in this bucket. */
    unsigned hash;	/* Hash of lines in this class.  */
!   char const *line;	/* A line that fits this class. */
    size_t length;	/* The length of that line.  */
  };
  
--- 41,47 ----
  {
    int next;	/* Next item in this bucket. */
    unsigned hash;	/* Hash of lines in this class.  */
!   char const HUGE *line;	/* A line that fits this class. */
    size_t length;	/* The length of that line.  */
  };
  
***************
*** 54,60 ****
  /* Array in which the equivalence classes are allocated.
     The bucket-chains go through the elements in this array.
     The number of an equivalence class is its index in this array.  */
! static struct equivclass *equivs;
  
  /* Index of first free element in the array `equivs'.  */
  static int equivs_index;
--- 54,60 ----
  /* Array in which the equivalence classes are allocated.
     The bucket-chains go through the elements in this array.
     The number of an equivalence class is its index in this array.  */
! static struct equivclass HUGE *equivs;
  
  /* Index of first free element in the array `equivs'.  */
  static int equivs_index;
***************
*** 103,109 ****
--- 103,115 ----
  	current->bufsize = max (current->bufsize,
  				current->stat.st_size + sizeof (word) + 1);
  
+ #ifdef __MSDOS__
+       if ((current->buffer = (char HUGE *) farmalloc (current->bufsize)) == NULL)
+ 	fatal ("far memory exhausted");
+ #else
        current->buffer = xmalloc (current->bufsize);
+ #endif /*__MSDOS__*/
+ 
        if (skip_test)
  	current->buffered_chars = 0;
        else
***************
*** 111,116 ****
--- 117,125 ----
  	  /* Check first part of file to see if it's a binary file.  */
  	  current->buffered_chars = read (current->desc,
  					  current->buffer,
+ #ifdef __MSDOS__
+ 			(unsigned int)
+ #endif /*__MSDOS__*/
  					  current->buffered_chars);
  	  if (current->buffered_chars == -1)
  	    pfatal_with_name (current->name);
***************
*** 135,140 ****
--- 144,166 ----
    else if (S_ISREG (current->stat.st_mode))
      {
        /* It's a regular file; slurp in the rest all at once.  */
+ #ifdef __MSDOS__
+       /* read inside of segment boundaries */
+       while ((current->stat.st_size - current->buffered_chars) > 0)
+       {
+         unsigned nr;
+         char HUGE *rp;
+ 
+         rp = current->buffer + current->buffered_chars;
+         nr = 0 - (unsigned)((long)rp & 0x0000FFFF);
+         nr = read (current->desc, rp, nr);
+         if (nr == 0)
+           break;
+         if (nr == 0xFFFF)
+           pfatal_with_name (current->name);
+         current->buffered_chars += nr ;
+       }
+ #else
        cc = current->stat.st_size - current->buffered_chars;
        if (cc)
  	{
***************
*** 145,150 ****
--- 171,177 ----
  	    pfatal_with_name (current->name);
  	  current->buffered_chars += cc;
  	}
+ #endif /*__MSDOS__*/
      }
    /* It's not a regular file; read it, growing the buffer as needed.  */
    else if (always_text_flag || current->buffered_chars != 0)
***************
*** 153,160 ****
--- 180,192 ----
  	{
  	  if (current->buffered_chars == current->bufsize)
  	    {
+ #ifdef __MSDOS__
+ 	      current->bufsize += 4096;
+ 	      current->buffer = (char HUGE *) farrealloc (current->buffer, current->bufsize);
+ #else
  	      current->bufsize = current->bufsize * 2;
  	      current->buffer = xrealloc (current->buffer, current->bufsize);
+ #endif /*__MSDOS__*/
  	    }
  	  cc = read (current->desc,
  		     current->buffer + current->buffered_chars,
***************
*** 165,173 ****
--- 197,207 ----
  	    pfatal_with_name (current->name);
  	  current->buffered_chars += cc;
  	}
+ #ifndef __MSDOS__
        /* Allocate just enough room for appended newline and sentinel.  */
        current->bufsize = current->buffered_chars + sizeof (word) + 1;
        current->buffer = xrealloc (current->buffer, current->bufsize);
+ #endif /*!__MSDOS__*/
      }
  }
  
***************
*** 179,208 ****
       struct file_data *current;
  {
    unsigned h;
!   unsigned char const *p = (unsigned char const *) current->prefix_end;
    unsigned char c;
    int i, *bucket;
    size_t length;
  
    /* Cache often-used quantities in local variables to help the compiler.  */
!   char const **linbuf = current->linbuf;
    int alloc_lines = current->alloc_lines;
    int line = 0;
    int linbuf_base = current->linbuf_base;
    int *cureqs = (int *) xmalloc (alloc_lines * sizeof (int));
!   struct equivclass *eqs = equivs;
    int eqs_index = equivs_index;
    int eqs_alloc = equivs_alloc;
!   char const *suffix_begin = current->suffix_begin;
!   char const *bufend = current->buffer + current->buffered_chars;
!   char const *incomplete_tail
      = current->missing_newline && ROBUST_OUTPUT_STYLE (output_style)
!       ? bufend : (char const *) 0;
    int varies = length_varies;
  
!   while ((char const *) p < suffix_begin)
      {
!       char const *ip = (char const *) p;
  
        /* Compute the equivalence class for this line.  */
  
--- 213,242 ----
       struct file_data *current;
  {
    unsigned h;
!   unsigned char const HUGE *p = (unsigned char const HUGE *) current->prefix_end;
    unsigned char c;
    int i, *bucket;
    size_t length;
  
    /* Cache often-used quantities in local variables to help the compiler.  */
!   char const HUGE **linbuf = current->linbuf;
    int alloc_lines = current->alloc_lines;
    int line = 0;
    int linbuf_base = current->linbuf_base;
    int *cureqs = (int *) xmalloc (alloc_lines * sizeof (int));
!   struct equivclass HUGE *eqs = equivs;
    int eqs_index = equivs_index;
    int eqs_alloc = equivs_alloc;
!   char const HUGE *suffix_begin = current->suffix_begin;
!   char const HUGE *bufend = current->buffer + current->buffered_chars;
!   char const HUGE *incomplete_tail
      = current->missing_newline && ROBUST_OUTPUT_STYLE (output_style)
!       ? bufend : (char const HUGE *) 0;
    int varies = length_varies;
  
!   while ((char const HUGE *) p < suffix_begin)
      {
!       char const HUGE *ip = (char const HUGE *) p;
  
        /* Compute the equivalence class for this line.  */
  
***************
*** 262,268 ****
     hashing_done:;
  
        bucket = &buckets[h % nbuckets];
!       length = (char const *) p - ip - ((char const *) p == incomplete_tail);
        for (i = *bucket;  ;  i = eqs[i].next)
  	if (!i)
  	  {
--- 296,302 ----
     hashing_done:;
  
        bucket = &buckets[h % nbuckets];
!       length = (char const HUGE *) p - ip - ((char const HUGE *) p == incomplete_tail);
        for (i = *bucket;  ;  i = eqs[i].next)
  	if (!i)
  	  {
***************
*** 269,276 ****
--- 303,315 ----
  	    /* Create a new equivalence class in this bucket. */
  	    i = eqs_index++;
  	    if (i == eqs_alloc)
+ #ifdef __MSDOS__
+           if ((eqs = (struct equivclass HUGE *) farrealloc (eqs, (long) (eqs_alloc*=2) * sizeof(*eqs))) == NULL)
+             fatal ("far memory exhausted");
+ #else
  	      eqs = (struct equivclass *)
  		      xrealloc (eqs, (eqs_alloc*=2) * sizeof(*eqs));
+ #endif /*__MSDOS__*/
  	    eqs[i].next = *bucket;
  	    eqs[i].hash = h;
  	    eqs[i].line = ip;
***************
*** 290,296 ****
  	  /* Double (alloc_lines - linbuf_base) by adding to alloc_lines.  */
  	  alloc_lines = 2 * alloc_lines - linbuf_base;
  	  cureqs = (int *) xrealloc (cureqs, alloc_lines * sizeof (*cureqs));
! 	  linbuf = (char const **) xrealloc (linbuf + linbuf_base,
  					     (alloc_lines - linbuf_base)
  					     * sizeof (*linbuf))
  		   - linbuf_base;
--- 329,335 ----
  	  /* Double (alloc_lines - linbuf_base) by adding to alloc_lines.  */
  	  alloc_lines = 2 * alloc_lines - linbuf_base;
  	  cureqs = (int *) xrealloc (cureqs, alloc_lines * sizeof (*cureqs));
! 	  linbuf = (char const HUGE **) xrealloc (linbuf + linbuf_base,
  					     (alloc_lines - linbuf_base)
  					     * sizeof (*linbuf))
  		   - linbuf_base;
***************
*** 311,326 ****
  	{
  	  /* Double (alloc_lines - linbuf_base) by adding to alloc_lines.  */
  	  alloc_lines = 2 * alloc_lines - linbuf_base;
! 	  linbuf = (char const **) xrealloc (linbuf + linbuf_base,
  					     (alloc_lines - linbuf_base)
  					     * sizeof (*linbuf))
  		   - linbuf_base;
  	}
!       linbuf[line] = (char const *) p;
      
!       if ((char const *) p == bufend)
  	{
! 	  linbuf[line]  -=  (char const *) p == incomplete_tail;
  	  break;
  	}
  
--- 350,365 ----
  	{
  	  /* Double (alloc_lines - linbuf_base) by adding to alloc_lines.  */
  	  alloc_lines = 2 * alloc_lines - linbuf_base;
! 	  linbuf = (char const HUGE **) xrealloc (linbuf + linbuf_base,
  					     (alloc_lines - linbuf_base)
  					     * sizeof (*linbuf))
  		   - linbuf_base;
  	}
!       linbuf[line] = (char const HUGE *) p;
      
!       if ((char const HUGE *) p == bufend)
  	{
! 	  linbuf[line]  -=  (char const HUGE *) p == incomplete_tail;
  	  break;
  	}
  
***************
*** 351,358 ****
  prepare_text_end (current)
       struct file_data *current;
  {
!   size_t buffered_chars = current->buffered_chars;
!   char *p = current->buffer;
  
    if (buffered_chars == 0 || p[buffered_chars - 1] == '\n')
      current->missing_newline = 0;
--- 390,397 ----
  prepare_text_end (current)
       struct file_data *current;
  {
!   FSIZE buffered_chars = current->buffered_chars;
!   char HUGE *p = current->buffer;
  
    if (buffered_chars == 0 || p[buffered_chars - 1] == '\n')
      current->missing_newline = 0;
***************
*** 375,387 ****
  find_identical_ends (filevec)
       struct file_data filevec[];
  {
!   word *w0, *w1;
!   char *p0, *p1, *buffer0, *buffer1;
!   char const *end0, *beg0;
!   char const **linbuf0, **linbuf1;
    int i, lines;
!   size_t n0, n1, tem;
!   int alloc_lines0, alloc_lines1;
    int buffered_prefix, prefix_count, prefix_mask;
  
    slurp (&filevec[0]);
--- 414,427 ----
  find_identical_ends (filevec)
       struct file_data filevec[];
  {
!   word HUGE *w0, HUGE *w1;
!   char HUGE *p0, HUGE *p1, HUGE *buffer0, HUGE *buffer1;
!   char const HUGE *end0, HUGE *beg0;
!   char const HUGE **linbuf0, HUGE **linbuf1;
    int i, lines;
!   FSIZE n0, n1;
!   FSIZE tem;
!   FSIZE alloc_lines0, alloc_lines1;
    int buffered_prefix, prefix_count, prefix_mask;
  
    slurp (&filevec[0]);
***************
*** 490,496 ****
  	while (*p0++ != '\n')
  	  ;
  
!       p1 += p0 - beg0;
      }
  
    /* Record the suffix.  */
--- 530,536 ----
  	while (*p0++ != '\n')
  	  ;
  
!       p1 += p0 - (char HUGE *)beg0;
      }
  
    /* Record the suffix.  */
***************
*** 517,523 ****
        prefix_mask = prefix_count - 1;
        alloc_lines0
  	= prefix_count
! 	  + GUESS_LINES (0, 0, p0 - filevec[0].prefix_end)
  	  + context;
      }
    else
--- 557,563 ----
        prefix_mask = prefix_count - 1;
        alloc_lines0
  	= prefix_count
! 	  + GUESS_LINES (0, 0, p0 - (char HUGE *)filevec[0].prefix_end)
  	  + context;
      }
    else
***************
*** 528,534 ****
      }
  
    lines = 0;
!   linbuf0 = (char const **) xmalloc (alloc_lines0 * sizeof (*linbuf0));
  
    /* If the prefix is needed, find the prefix lines.  */
    if (! (no_diff_means_no_output
--- 568,574 ----
      }
  
    lines = 0;
!   linbuf0 = (char const HUGE **) xmalloc (alloc_lines0 * sizeof (*linbuf0));
  
    /* If the prefix is needed, find the prefix lines.  */
    if (! (no_diff_means_no_output
***************
*** 541,547 ****
  	{
  	  int l = lines++ & prefix_mask;
  	  if (l == alloc_lines0)
! 	    linbuf0 = (char const **) xrealloc (linbuf0, (alloc_lines0 *= 2)
  							 * sizeof(*linbuf0));
  	  linbuf0[l] = p0;
  	  while (*p0++ != '\n')
--- 581,587 ----
  	{
  	  int l = lines++ & prefix_mask;
  	  if (l == alloc_lines0)
! 	    linbuf0 = (char const HUGE **) xrealloc (linbuf0, (alloc_lines0 *= 2)
  							 * sizeof(*linbuf0));
  	  linbuf0[l] = p0;
  	  while (*p0++ != '\n')
***************
*** 557,563 ****
      = (buffered_prefix
         + GUESS_LINES (lines, filevec[1].prefix_end - buffer1, tem)
         + context);
!   linbuf1 = (char const **) xmalloc (alloc_lines1 * sizeof (*linbuf1));
  
    if (buffered_prefix != lines)
      {
--- 597,603 ----
      = (buffered_prefix
         + GUESS_LINES (lines, filevec[1].prefix_end - buffer1, tem)
         + context);
!   linbuf1 = (char const HUGE **) xmalloc (alloc_lines1 * sizeof (*linbuf1));
  
    if (buffered_prefix != lines)
      {
***************
*** 594,599 ****
--- 634,640 ----
    8191,
    16381,
    32749,
+ #if 32767 < INT_MAX
    65521,
    131071,
    262139,
***************
*** 610,615 ****
--- 651,657 ----
    536870909,
    1073741789,
    2147483647,
+ #endif
    0
  };
  
***************
*** 641,647 ****
--- 683,694 ----
    find_identical_ends (filevec);
  
    equivs_alloc = filevec[0].alloc_lines + filevec[1].alloc_lines + 1;
+ #ifdef __MSDOS__
+   if ((equivs = (struct equivclass HUGE *) farmalloc ((long) equivs_alloc * sizeof(struct equivclass))) == NULL)
+     fatal ("far memory exhausted");
+ #else
    equivs = (struct equivclass *) xmalloc (equivs_alloc * sizeof (struct equivclass));
+ #endif /*__MSDOS__*/
    /* Equivalence class 0 is permanently safe for lines that were not
       hashed.  Real equivalence classes start at 1. */
    equivs_index = 1;
diff -c diffutils-2.5-org/side.c diffutils-2.5-new/side.c
*** diffutils-2.5-org/side.c	Thu Sep 16 22:26:45 1993
--- diffutils-2.5-new/side.c	Mon Oct  4 11:21:10 1993
***************
*** 21,29 ****
  
  #include "diff.h"
  
! static unsigned print_half_line PARAMS((char const * const *, unsigned, unsigned));
  static unsigned tab_from_to PARAMS((unsigned, unsigned));
! static void print_1sdiff_line PARAMS((char const * const *, int, char const * const *));
  static void print_sdiff_common_lines PARAMS((int, int));
  static void print_sdiff_hunk PARAMS((struct change *));
  
--- 21,29 ----
  
  #include "diff.h"
  
! static unsigned print_half_line PARAMS((char const HUGE * const *, unsigned, unsigned));
  static unsigned tab_from_to PARAMS((unsigned, unsigned));
! static void print_1sdiff_line PARAMS((char const HUGE * const *, int, char const HUGE * const *));
  static void print_sdiff_common_lines PARAMS((int, int));
  static void print_sdiff_hunk PARAMS((struct change *));
  
***************
*** 71,84 ****
   */
  static unsigned
  print_half_line (line, indent, out_bound)
!      char const * const *line;
       unsigned indent, out_bound;
  {
    FILE *out = outfile;
    register unsigned in_position = 0, out_position = 0;
    register char const
! 	*text_pointer = line[0],
! 	*text_limit = line[1];
  
    while (text_pointer < text_limit)
      {
--- 71,84 ----
   */
  static unsigned
  print_half_line (line, indent, out_bound)
!      char const HUGE * const *line;
       unsigned indent, out_bound;
  {
    FILE *out = outfile;
    register unsigned in_position = 0, out_position = 0;
    register char const
! 	HUGE *text_pointer = line[0],
! 	HUGE *text_limit = line[1];
  
    while (text_pointer < text_limit)
      {
***************
*** 166,174 ****
  
  static void
  print_1sdiff_line (left, sep, right)
!      char const * const *left;
       int sep;
!      char const * const *right;
  {
    FILE *out = outfile;
    unsigned hw = sdiff_half_width, c2o = sdiff_column2_offset;
--- 166,174 ----
  
  static void
  print_1sdiff_line (left, sep, right)
!      char const HUGE * const *left;
       int sep;
!      char const HUGE * const *right;
  {
    FILE *out = outfile;
    unsigned hw = sdiff_half_width, c2o = sdiff_column2_offset;
diff -c diffutils-2.5-org/system.h diffutils-2.5-new/system.h
*** diffutils-2.5-org/system.h	Mon Sep 27 00:20:24 1993
--- diffutils-2.5-new/system.h	Mon Oct  4 11:21:10 1993
***************
*** 29,35 ****
  #include <sys/types.h>
  #include <sys/stat.h>
  
! #if __STDC__
  #define PARAMS(args) args
  #define VOID void
  #else
--- 29,35 ----
  #include <sys/types.h>
  #include <sys/stat.h>
  
! #if __STDC__ || defined(__MSDOS__) || defined(__NT__)
  #define PARAMS(args) args
  #define VOID void
  #else
***************
*** 211,215 ****
--- 211,237 ----
  extern int errno;
  #endif
  
+ #ifndef min
  #define min(a,b) ((a) <= (b) ? (a) : (b))
  #define max(a,b) ((a) >= (b) ? (a) : (b))
+ #endif
+ 
+ #ifdef __MSDOS__
+ typedef int pid_t;
+ typedef long off_t;
+ #include <stdio.h>
+ #include <malloc.h>
+ FILE *popen(char *, char *);
+ int pclose(FILE *);
+ #define HUGE huge
+ #define FSIZE long
+ #else
+ #define HUGE
+ #define FSIZE size_t
+ #endif
+ 
+ #ifdef __NT__
+ typedef int pid_t;
+ #define popen	_popen
+ #define pclose	_pclose
+ #endif
diff -c diffutils-2.5-org/util.c diffutils-2.5-new/util.c
*** diffutils-2.5-org/util.c	Mon Sep 27 00:20:24 1993
--- diffutils-2.5-new/util.c	Fri Oct  8 18:22:04 1993
***************
*** 179,184 ****
--- 179,191 ----
  
    if (paginate_flag)
      {
+ #if defined(__MSDOS__) || defined(__NT__)
+       char command[120];
+ 
+       sprintf(command, "%s -f -h \"%s\"", PR_FILE_NAME, name);
+       if ((outfile = popen(command, "w")) == NULL)
+         pfatal_with_name ("popen");
+ #else
        int pipes[2];
  
        /* Fork a `pr' and make OUTFILE a pipe to it.  */
***************
*** 209,214 ****
--- 216,222 ----
  	  close (pipes[0]);
  	  outfile = fdopen (pipes[1], "w");
  	}
+ #endif /*__MSDOS__||__NT__*/
      }
    else
      {
***************
*** 249,254 ****
--- 257,266 ----
  {
    if (outfile != 0 && outfile != stdout)
      {
+ #if defined(__MSDOS__) || defined(__NT__)
+       if (pclose (outfile))
+ 	pfatal_with_name ("write error");
+ #else
        int wstatus;
        if (ferror (outfile))
  	fatal ("write error");
***************
*** 268,273 ****
--- 280,286 ----
  #endif
        if (! WIFEXITED (wstatus) || WEXITSTATUS (wstatus) != 0)
  	fatal ("subsidiary pr failed");
+ #endif /*__MSDOS__||__NT__*/
      }
  
    outfile = 0;
***************
*** 279,285 ****
  
  int
  line_cmp (s1, len1, s2, len2)
!      char const *s1, *s2;
       size_t len1, len2;
  {
    register unsigned char const *t1, *t2;
--- 292,298 ----
  
  int
  line_cmp (s1, len1, s2, len2)
!      char const HUGE *s1, HUGE *s2;
       size_t len1, len2;
  {
    register unsigned char const *t1, *t2;
***************
*** 436,444 ****
  void
  print_1_line (line_flag, line)
       char const *line_flag;
!      char const * const *line;
  {
!   char const *text = line[0], *limit = line[1]; /* Help the compiler.  */
    FILE *out = outfile; /* Help the compiler some more.  */
    char const *flag_format = 0;
  
--- 449,457 ----
  void
  print_1_line (line_flag, line)
       char const *line_flag;
!      char const HUGE * const *line;
  {
!   char const HUGE *text = line[0], HUGE *limit = line[1]; /* Help the compiler.  */
    FILE *out = outfile; /* Help the compiler some more.  */
    char const *flag_format = 0;
  
***************
*** 466,472 ****
  
  void
  output_1_line (text, limit, flag_format, line_flag)
!      char const *text, *limit, *flag_format, *line_flag;
  {
    if (!tab_expand_flag)
      fwrite (text, sizeof (char), limit - text, outfile);
--- 479,485 ----
  
  void
  output_1_line (text, limit, flag_format, line_flag)
!      char const HUGE *text, HUGE *limit, *flag_format, *line_flag;
  {
    if (!tab_expand_flag)
      fwrite (text, sizeof (char), limit - text, outfile);
***************
*** 474,480 ****
      {
        register FILE *out = outfile;
        register unsigned char c;
!       register char const *t = text;
        register unsigned column = 0;
  
        while (t < limit)
--- 487,493 ----
      {
        register FILE *out = outfile;
        register unsigned char c;
!       register char const HUGE *t = text;
        register unsigned column = 0;
  
        while (t < limit)
***************
*** 615,621 ****
  	if (!ignore_blank_lines_flag || files[0].linbuf[i][0] != '\n')
  	  {
  	    struct regexp_list *r;
! 	    char const *line = files[0].linbuf[i];
  	    int len = files[0].linbuf[i + 1] - line;
  
  	    for (r = ignore_regexp_list; r; r = r->next)
--- 628,634 ----
  	if (!ignore_blank_lines_flag || files[0].linbuf[i][0] != '\n')
  	  {
  	    struct regexp_list *r;
! 	    char const HUGE *line = files[0].linbuf[i];
  	    int len = files[0].linbuf[i + 1] - line;
  
  	    for (r = ignore_regexp_list; r; r = r->next)
***************
*** 631,637 ****
  	if (!ignore_blank_lines_flag || files[1].linbuf[i][0] != '\n')
  	  {
  	    struct regexp_list *r;
! 	    char const *line = files[1].linbuf[i];
  	    int len = files[1].linbuf[i + 1] - line;
  
  	    for (r = ignore_regexp_list; r; r = r->next)
--- 644,650 ----
  	if (!ignore_blank_lines_flag || files[1].linbuf[i][0] != '\n')
  	  {
  	    struct regexp_list *r;
! 	    char const HUGE *line = files[1].linbuf[i];
  	    int len = files[1].linbuf[i + 1] - line;
  
  	    for (r = ignore_regexp_list; r; r = r->next)
***************
*** 672,678 ****
--- 685,695 ----
    value = (VOID *) malloc (size);
  
    if (!value)
+ #ifdef __MSDOS__
+     fatal ("real memory exhausted");
+ #else
      fatal ("virtual memory exhausted");
+ #endif
    return value;
  }
  
***************
*** 691,697 ****
--- 708,718 ----
    value = (VOID *) realloc (old, size);
  
    if (!value)
+ #ifdef __MSDOS__
+     fatal ("real memory exhausted");
+ #else
      fatal ("virtual memory exhausted");
+ #endif
    return value;
  }
  
***************
*** 714,720 ****
--- 735,746 ----
  dir_file_pathname (dir, file)
       char const *dir, *file;
  {
+ #if defined(__MSDOS__) || defined(__NT__)
+   char sep = dir[strlen(dir) - 1];
+   return concat (dir, "/" + (*dir && ((sep == '/') || (sep == '\\'))), file);
+ #else
    return concat (dir, "/" + (*dir && dir[strlen (dir) - 1] == '/'), file);
+ #endif /*__MSDOS__||__NT__*/
  }
  
  void
