[gnu.utils.bug] Fix for diff 1.7 for '286

toy@ecse.rpi.edu (Ray Toy) (07/09/89)

Newsgroups: gnu.utils.bug
Subject:Fixes for Gnudiff 1.7 on 286
I've found a few minor bugs with diff 1.7 when compiling
for a '286 machine.  The first is that not every compiler
knows what to do with 'void *' functions.  The second is
that 0 is not the same as '(char *) 0)', as usual on a 286.

Here are the patches that fix these minor bugs.  I hope
someone finds them useful.

Thanks for the world's fastest diff!

Ray

*** diff.c	Wed Apr 26 15:38:27 1989
--- ../new-diff/diff.c	Thu Jul  6 20:52:06 1989
***************
*** 314,320 ****
  
    switch_string = option_list (argv + 1, optind - 1);
  
!   val = compare_files (0, argv[optind], 0, argv[optind + 1], 0);
  
    /* Print any messages that were saved up for last.  */
    print_message_queue ();
--- 314,320 ----
  
    switch_string = option_list (argv + 1, optind - 1);
  
!   val = compare_files ((char *) NULL, argv[optind], (char *) NULL, argv[optind + 1], 0);
  
    /* Print any messages that were saved up for last.  */
    print_message_queue ();
*** diff.h	Fri Feb 24 12:42:05 1989
--- ../new-diff/diff.h	Thu Jul  6 21:30:04 1989
***************
*** 41,46 ****
--- 41,47 ----
  #ifdef USG
  /* Define needed BSD functions in terms of sysV library.  */
  
+ #include <memory.h>
  #define bcopy(s,d,n)	memcpy((d),(s),(n))
  #define bcmp(s1,s2,n)	memcmp((s1),(s2),(n))
  #define bzero(s,n)	memset((s),0,(n))
***************
*** 72,79 ****
  #if defined (__STDC__) || defined (__GNUC__)
  #include "limits.h"
  #else
! #define INT_MAX 2147483647
! #define CHAR_BIT 8
  #endif
  
  /* Support old-fashioned C compilers.  */
--- 73,85 ----
  #if defined (__STDC__) || defined (__GNUC__)
  #include "limits.h"
  #else
! #ifdef	iAPX286
! #  define	INT_MAX 32767
! #  define	CHAR_BIT 8
! #else
! #  define INT_MAX 2147483647
! #  define CHAR_BIT 8
! #endif
  #endif
  
  /* Support old-fashioned C compilers.  */
***************
*** 308,317 ****
  EXTERN FILE *outfile;
  
  /* Declare various functions.  */
  
! void *xmalloc ();
! void *xrealloc ();
! void *xcalloc();
  char *concat ();
  void free ();
  char *rindex ();
--- 314,328 ----
  EXTERN FILE *outfile;
  
  /* Declare various functions.  */
+ #ifdef	HAVE_VOID_PTR
+ #define	VOID	void
+ #else
+ #define	VOID	char
+ #endif
  
! VOID *xmalloc ();
! VOID *xrealloc ();
! VOID *xcalloc();
  char *concat ();
  void free ();
  char *rindex ();
*** diff3.c	Sat Apr  8 15:56:10 1989
--- ../new-diff/diff3.c	Fri Jul  7 09:00:50 1989
***************
*** 24,32 ****
--- 24,46 ----
  #include <stdio.h>
  #include <ctype.h>
  
+ /*
+  * Do we have void pointers?
+  */
+ 
+ #ifdef	HAVE_VOID_PTR
+ #define	VOID	void
+ #else
+ #define	VOID	char
+ #endif
+ 
  #ifdef USG
  /* Define needed BSD functions in terms of sysV library.  */
  
+ #include <malloc.h>
+ #include <memory.h>
+ #include <fcntl.h>
+ 
  #define bcopy(s,d,n)	memcpy((d),(s),(n))
  #define bcmp(s1,s2,n)	memcmp((s1),(s2),(n))
  #define bzero(s,n)	memset((s),0,(n))
***************
*** 204,211 ****
  
  struct diff3_block *reverse_diff3_blocklist ();
  
! void *xmalloc ();
! void *xrealloc ();
  
  /*
   * No options take arguments.  "i" is my own addition; it stands for
--- 218,225 ----
  
  struct diff3_block *reverse_diff3_blocklist ();
  
! VOID *xmalloc ();
! VOID *xrealloc ();
  
  /*
   * No options take arguments.  "i" is my own addition; it stands for
***************
*** 1127,1133 ****
    do {
      bytes = myread (fds[0],
  		    diff_result + total,
! 		    current_chunk_size - total);
      total += bytes;
      if (total == current_chunk_size)
        diff_result = (char *) xrealloc (diff_result, (current_chunk_size *= 2));
--- 1141,1147 ----
    do {
      bytes = myread (fds[0],
  		    diff_result + total,
! 		    (int) current_chunk_size - total);
      total += bytes;
      if (total == current_chunk_size)
        diff_result = (char *) xrealloc (diff_result, (current_chunk_size *= 2));
***************
*** 1450,1471 ****
    return result;
  }
  
! void *
  xmalloc (size)
       int size;
  {
!   void *result = (void *) malloc (size);
    if (!result)
      fatal ("Malloc failed");
    return result;
  }
  
! void *
  xrealloc (ptr, size)
!      void *ptr;
       int size;
  {
!   void *result = (void *) realloc (ptr, size);
    if (!result)
      fatal ("Malloc failed");
    return result;
--- 1464,1485 ----
    return result;
  }
  
! VOID *
  xmalloc (size)
       int size;
  {
!   VOID *result = (VOID *) malloc (size);
    if (!result)
      fatal ("Malloc failed");
    return result;
  }
  
! VOID *
  xrealloc (ptr, size)
!      VOID *ptr;
       int size;
  {
!   VOID *result = (VOID *) realloc (ptr, size);
    if (!result)
      fatal ("Malloc failed");
    return result;
*** regex.c	Sat Apr 22 19:10:31 1989
--- ../new-diff/regex.c	Thu Jul  6 21:52:48 1989
***************
*** 39,45 ****
--- 39,47 ----
  #else  /* not emacs */
  
  #ifdef USG
+ #include <malloc.h>
  #ifndef BSTRING
+ #include <memory.h>
  #define bcopy(s,d,n)	memcpy((d),(s),(n))
  #define bcmp(s1,s2,n)	memcmp((s1),(s2),(n))
  #define bzero(s,n)	memset((s),0,(n))
*** util.c	Fri Feb 24 12:41:08 1989
--- ../new-diff/util.c	Fri Jul  7 00:11:16 1989
***************
*** 563,575 ****
    *inserts = show_to;
  }
  
  /* malloc a block of memory, with fatal error message if we can't do it. */
  
! void *
  xmalloc (size)
       unsigned size;
  {
!   register void *value = (void *) malloc (size);
  
    if (!value)
      fatal ("virtual memory exhausted");
--- 563,582 ----
    *inserts = show_to;
  }
  
+ #ifdef	USG
+ /*
+  * Need to declare malloc routines!
+  */
+ #include <malloc.h>
+ #endif
+ 
  /* malloc a block of memory, with fatal error message if we can't do it. */
  
! VOID *
  xmalloc (size)
       unsigned size;
  {
!   register VOID *value = (VOID *) malloc (size);
  
    if (!value)
      fatal ("virtual memory exhausted");
***************
*** 578,589 ****
  
  /* realloc a block of memory, with fatal error message if we can't do it. */
  
! void *
  xrealloc (old, size)
!      void *old;
       unsigned int size;
  {
!   register void *value = (void *) realloc (old, size);
  
    if (!value)
      fatal ("virtual memory exhausted");
--- 585,596 ----
  
  /* realloc a block of memory, with fatal error message if we can't do it. */
  
! VOID *
  xrealloc (old, size)
!      VOID *old;
       unsigned int size;
  {
!   register VOID *value = (VOID *) realloc (old, size);
  
    if (!value)
      fatal ("virtual memory exhausted");
***************
*** 590,600 ****
    return value;
  }
  
! void *
  xcalloc (nitems, size)
       int nitems, size;
  {
!   void *value = (void *) calloc (nitems, size);
  
    if (! value)
      fatal ("virtual memory exhausted");
--- 597,607 ----
    return value;
  }
  
! VOID *
  xcalloc (nitems, size)
       int nitems, size;
  {
!   VOID *value = (VOID *) calloc (nitems, size);
  
    if (! value)
      fatal ("virtual memory exhausted");

Newsgroups: gnu.utils.bugs
Subject: Fixes for diff 1.7 on a '286
Expires: 
References: 
Sender: 
Followup-To: 
Distribution: gnu
Organization: Rensselaer Polytechnic Institute, Troy, NY
Keywords: