From: zoo@cygnus.com (david d `zoo' zuhn)
Subject: clean code patches for bison
Organization: Cygnus Support -- +1 415 903 1434
Distribution: gnu
Date: Wed, 11 Nov 1992 01:10:03 GMT

These patches to bison 1.19 remove all references to the macro USG from the
bison source code.  This macro is obsolete, and usage of it has been
inconsistent.  It has been replaced by two specific checks, for <string.h>
and <memory.h>.   The bulk of these patches are changes to the configure
script, which should be regenerated from configure.in anyway.

Yours for cleaner code.....

  david d 'zoo' zuhn |    There is great disorder under the heavens,
    cygnus support   |         and the situation is excellent.
    zoo@cygnus.com   |    


---------- slice 'n' dice ---------------------------------- file: bison-diffs

diff -rc2 bison-1.19/ChangeLog bison-1.19-zoo/ChangeLog
*** bison-1.19/ChangeLog	Mon Sep 28 07:33:52 1992
--- bison-1.19-zoo/ChangeLog	Tue Nov 10 16:59:53 1992
***************
*** 1,2 ****
--- 1,13 ----
+ Tue Nov 10 16:57:54 1992  david d `zoo' zuhn  (zoo at cirdan.cygnus.com)
+ 
+ 	* configure.in: added a check for <memory.h>
+ 
+ 	* conflicts.c: use HAVE_MEMORY_H instead of USG for <memory.h>,
+ 	remove test for USG by <alloca.h>
+ 
+ 	* getopt.c: remove test for USG for <alloca.h>
+ 
+ 	* system.h: rework so that testing for USG is no longer needed
+ 
  Fri Sep 25 18:06:28 1992  Richard Stallman  (rms@mole.gnu.ai.mit.edu)
  
diff -rc2 bison-1.19/configure bison-1.19-zoo/configure
*** bison-1.19/configure	Fri Sep 18 12:02:58 1992
--- bison-1.19-zoo/configure	Tue Nov 10 16:54:49 1992
***************
*** 81,85 ****
    # Try the directory containing this script, then `..'.
    prog=$0
!   confdir=`echo $prog|sed 's,/[^/][^/]*$,,'`
    test "X$confdir" = "X$prog" && confdir=.
    srcdir=$confdir
--- 81,85 ----
    # Try the directory containing this script, then `..'.
    prog=$0
!   confdir=`echo $prog|sed 's%/[^/][^/]*$%%'`
    test "X$confdir" = "X$prog" && confdir=.
    srcdir=$confdir
***************
*** 148,152 ****
  # Make sure to not get the incompatible SysV /etc/install and
  # /usr/sbin/install, which might be in PATH before a BSD-like install,
! # or the SunOS /usr/etc/install directory.
  if test -z "$INSTALL"; then
    echo checking for install
--- 148,152 ----
  # Make sure to not get the incompatible SysV /etc/install and
  # /usr/sbin/install, which might be in PATH before a BSD-like install,
! # or the SunOS /usr/etc/install directory, or the AIX /bin/install.
  if test -z "$INSTALL"; then
    echo checking for install
***************
*** 158,165 ****
      *)
        if test -f $dir/install; then
! 	INSTALL="$dir/install -c"
! 	INSTALL_PROGRAM='$(INSTALL)'
! 	INSTALL_DATA='$(INSTALL) -m 644'
! 	break
        fi
        ;;
--- 158,169 ----
      *)
        if test -f $dir/install; then
! 	if grep dspmsg $dir/install >/dev/null 2>&1; then
! 	  : # AIX
! 	else
! 	  INSTALL="$dir/install -c"
! 	  INSTALL_PROGRAM='$(INSTALL)'
! 	  INSTALL_DATA='$(INSTALL) -m 644'
! 	  break
! 	fi
        fi
        ;;
***************
*** 218,228 ****
  rm -f conftest*
  
! echo checking for BSD string and memory functions
! echo "#include <strings.h>
! main() { exit(0); } t() { rindex(0, 0); bzero(0, 0); }" > conftest.c
! if eval $compile; then
!   :
! else
!   DEFS="$DEFS -DUSG=1"
  fi
  rm -f conftest*
--- 222,233 ----
  rm -f conftest*
  
! echo checking for memory.h
! cat <<EOF > conftest.c
! 
! #include <memory.h>
! EOF
! err=`eval "$CPP $DEFS conftest.c 2>&1 >/dev/null"`
! if test -z "$err"; then
!   DEFS="$DEFS -DHAVE_MEMORY_H=1"
  fi
  rm -f conftest*
***************
*** 306,314 ****
  if test -n "$prefix"; then
    test -z "$exec_prefix" && exec_prefix='$(prefix)'
!   prsub="s,^prefix[ 	]*=.*$,prefix = $prefix,"
  fi
  if test -n "$exec_prefix"; then
    prsub="$prsub
! s,^exec_prefix[ 	]*=.*$,exec_prefix = $exec_prefix,"
  fi
  
--- 311,319 ----
  if test -n "$prefix"; then
    test -z "$exec_prefix" && exec_prefix='$(prefix)'
!   prsub="s%^prefix[ 	]*=.*$%prefix = $prefix%"
  fi
  if test -n "$exec_prefix"; then
    prsub="$prsub
! s%^exec_prefix[ 	]*=.*$%exec_prefix = $exec_prefix%"
  fi
  
***************
*** 350,354 ****
    srcdir=$top_srcdir
    # Remove last slash and all that follows it.  Not all systems have dirname.
!   dir=`echo $file|sed 's,/[^/][^/]*$,,'`
    if test "$dir" != "$file"; then
      test "$top_srcdir" != . && srcdir=$top_srcdir/$dir
--- 355,359 ----
    srcdir=$top_srcdir
    # Remove last slash and all that follows it.  Not all systems have dirname.
!   dir=`echo $file|sed 's%/[^/][^/]*$%%'`
    if test "$dir" != "$file"; then
      test "$top_srcdir" != . && srcdir=$top_srcdir/$dir
***************
*** 360,372 ****
    sed -e "
  $prsub
! s,@CC@,$CC,g
! s,@CPP@,$CPP,g
! s,@INSTALL@,$INSTALL,g
! s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,g
! s,@INSTALL_DATA@,$INSTALL_DATA,g
! s,@ALLOCA@,$ALLOCA,g
! s,@LIBS@,$LIBS,g
! s,@srcdir@,$srcdir,g
! s,@DEFS@,$DEFS," $top_srcdir/${file}.in >> $file
  done
  
--- 365,377 ----
    sed -e "
  $prsub
! s%@CC@%$CC%g
! s%@CPP@%$CPP%g
! s%@INSTALL@%$INSTALL%g
! s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
! s%@INSTALL_DATA@%$INSTALL_DATA%g
! s%@ALLOCA@%$ALLOCA%g
! s%@LIBS@%$LIBS%g
! s%@srcdir@%$srcdir%g
! s%@DEFS@%$DEFS%" $top_srcdir/${file}.in >> $file
  done
  
diff -rc2 bison-1.19/configure.in bison-1.19-zoo/configure.in
*** bison-1.19/configure.in	Mon Jul 13 23:39:22 1992
--- bison-1.19-zoo/configure.in	Tue Nov 10 17:01:56 1992
***************
*** 7,11 ****
  AC_ISC_POSIX
  AC_STDC_HEADERS
! AC_USG
  AC_HAVE_FUNCS(strerror)
  AC_ALLOCA
--- 7,12 ----
  AC_ISC_POSIX
  AC_STDC_HEADERS
! AC_HEADER_CHECK(string.h,AC_DEFINE(HAVE_STRING_H))
! AC_HEADER_CHECK(memory.h,AC_DEFINE(HAVE_MEMORY_H))
  AC_HAVE_FUNCS(strerror)
  AC_ALLOCA
diff -rc2 bison-1.19/conflicts.c bison-1.19-zoo/conflicts.c
*** bison-1.19/conflicts.c	Thu Sep 24 13:23:12 1992
--- bison-1.19-zoo/conflicts.c	Tue Nov 10 16:57:19 1992
***************
*** 33,37 ****
  #define bcopy(s, d, n) memcpy ((d), (s), (n))
  #else
! #ifdef USG
  #include <memory.h>
  #define bcopy(src, dst, num) memcpy((dst), (src), (num))
--- 33,37 ----
  #define bcopy(s, d, n) memcpy ((d), (s), (n))
  #else
! #ifdef HAVE_MEMORY_H
  #include <memory.h>
  #define bcopy(src, dst, num) memcpy((dst), (src), (num))
***************
*** 42,46 ****
  #define alloca __builtin_alloca
  #else
! #if defined (HAVE_ALLOCA_H) || (defined(sparc) && (defined(sun) || (!defined(USG) && !defined(SVR4) && !defined(__svr4__))))
  #include <alloca.h>
  #else
--- 42,46 ----
  #define alloca __builtin_alloca
  #else
! #if defined (HAVE_ALLOCA_H) || (defined(sparc) && (defined(sun) || (!defined(SVR4) && !defined(__svr4__))))
  #include <alloca.h>
  #else
diff -rc2 bison-1.19/getopt.c bison-1.19-zoo/getopt.c
*** bison-1.19/getopt.c	Mon Aug 24 10:00:50 1992
--- bison-1.19-zoo/getopt.c	Tue Nov 10 17:06:52 1992
***************
*** 24,28 ****
  #define alloca __builtin_alloca
  #else /* not __GNUC__ */
! #if defined (HAVE_ALLOCA_H) || (defined(sparc) && (defined(sun) || (!defined(USG) && !defined(SVR4) && !defined(__svr4__))))
  #include <alloca.h>
  #else
--- 24,28 ----
  #define alloca __builtin_alloca
  #else /* not __GNUC__ */
! #if defined (HAVE_ALLOCA_H) || (defined(sparc) && (defined(sun) || (!defined(SVR4) && !defined(__svr4__))))
  #include <alloca.h>
  #else
***************
*** 37,41 ****
  #include <stdio.h>
  
! #if defined(USG) || defined(STDC_HEADERS) || defined(__GNU_LIBRARY__)
  #include <string.h>
  #endif
--- 37,41 ----
  #include <stdio.h>
  
! #if defined(HAVE_STRING_H) || defined(STDC_HEADERS) || defined(__GNU_LIBRARY__)
  #include <string.h>
  #endif
diff -rc2 bison-1.19/system.h bison-1.19-zoo/system.h
*** bison-1.19/system.h	Sun Jun 21 21:07:21 1992
--- bison-1.19-zoo/system.h	Tue Nov 10 16:54:01 1992
***************
*** 4,14 ****
  #endif /* MSDOS */
  
! #if defined(USG) || defined(VMS)
  #include <string.h>
! #else /* not USG */
! #ifdef MSDOS
! #include <string.h>
  #else
  #include <strings.h>
! #endif /* not MSDOS */
! #endif /* not USG */
--- 4,15 ----
  #endif /* MSDOS */
  
! #if HAVE_STRING_H || STDC_HEADERS
  #include <string.h>
! #define index strchr
! #define rindex strrchr
! #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))
  #else
  #include <strings.h>
! #endif

Newsgroups: gnu.utils.bug