From:	MX%"roberts@nsrl31.nsrl.rochester.edu"  3-DEC-1993 15:17:09.03
To:	GOATHUNTER
CC:	
Subj:	VMS GNU grep v2.0, mods for gcc

Return-Path: <roberts@nsrl31.nsrl.rochester.edu>
Received: from wkuvx1.wku.edu by alpha.wku.edu (MX V3.3 AXP) with SMTP; Fri, 03
          Dec 1993 15:17:03 CST
Received: from nsvs35.nsrl.rochester.edu by wkuvx1.wku.edu (MX V3.3 VAX) with
          SMTP; Fri, 03 Dec 1993 15:15:24 CDT
Received: by nsrl31.nsrl.rochester.edu (MX V3.3 VAX) id 4037; Fri, 03 Dec 1993
          16:11:05 EST
Date: Fri, 03 Dec 1993 16:10:54 EST
From: Roland B Roberts <roberts@nsrl31.nsrl.rochester.edu>
To: goathunter@WKUVX1.WKU.EDU
Subject: VMS GNU grep v2.0, mods for gcc

Hunter,

I'm attaching a set of patches for GNU grep v2.0 to allow it to compile
under gcc (I'm running VMS 5.5-2, gcc 2.3.3, VAXC 3.2); it still builds
fine with VAXC.

Here is a description of why the changes were made:

dfa.c: loading stdlib.h gets several prototypes that silence warning
    errors.  However, the gcc header includes a prototype to delete();
    therefore, the local function conflicts.  The cure was a "temporary"
    define when stdlib.h is loaded.

getpagesize.h: I haven't quite figured out the logic in the #ifdefs, but
    gcc ends up definining getpagesize() twice---the second time
    catching the "#define getpagesize() 8192".

regex.c: gcc has the bstring functions as builtins; therefore,
    #define-ing these as macros is no good.

shell_mung.c: stdlib.h eliminates some warning errors.  Also, the
    GLOBALDEF macros are needed for gcc.  I initializes gopher_setup to
    FALSE, just like for VAXC.

vmsmake.com: I eliminated the HAVE_STRING_H so the includes will use
    strings.h.  This eliminates some errors, and avoids conflicts with
    the bstring functions in regex.c.  I also added a "define sys
    sys$library" so this still works for VAXC.  The "lib=..." picks up
    gcclib for gcc.  I changes "say" to "write sys$output", the symbol
    was undefined.

[.tests]vmsregress.com: `diff' is ambiguous is the unix-like diff
    command is defined (it is on our system).  In this case,
    vmsregress.com erroneously reports a failure on the khadafy test.

The context diffs follow.  If another format is better for you, let me
know....

roland
--
Roland B Roberts                          Nuclear Structure Research Laboratory
roberts@uornsrl.bitnet                                      271 East River Road
roberts@nsrl.rochester.edu                                  Rochester, NY 14627
--                                                               (716) 275-8962
I'm job hunting; tips and leads are appreciated!


$ diff -c dfa.c-orig dfa.c
*** dfa.c-orig
--- dfa.c
**************
*** 23,28
  #include <stdio.h>
  
  #ifdef STDC_HEADERS
  #include <stdlib.h>
  #else
  #include <sys/types.h>
--- 23,30 -----
  #include <stdio.h>
  
  #ifdef STDC_HEADERS
+ #ifdef VMS
+ #define delete sys_delete
  #include <stdlib.h>
  #undef delete
  #else
**************
*** 24,29
  
  #ifdef STDC_HEADERS
  #include <stdlib.h>
  #else
  #include <sys/types.h>
  extern char *calloc(), *malloc(), *realloc();
--- 26,35 -----
  #ifdef VMS
  #define delete sys_delete
  #include <stdlib.h>
+ #undef delete
+ #else
+ #include <stdlib.h>
+ #endif /* VMS */
  #else
  #include <sys/types.h>
  extern char *calloc(), *malloc(), *realloc();

*** getpagesize.h-orig
--- getpagesize.h
**************
*** 7,12
  #ifndef HAVE_GETPAGESIZE
  
  #ifdef VMS
  #define getpagesize() 512
  #endif
  
--- 7,15 -----
  #ifndef HAVE_GETPAGESIZE
  
  #ifdef VMS
+ #ifdef __GNUC__
+ #define HAVE_SYS_PARAM_H
+ #else
  #define getpagesize() 512
  #endif
  #endif
**************
*** 8,13
  
  #ifdef VMS
  #define getpagesize() 512
  #endif
  
  #ifdef HAVE_UNISTD_H
--- 11,17 -----
  #define HAVE_SYS_PARAM_H
  #else
  #define getpagesize() 512
+ #endif
  #endif
  
  #ifdef HAVE_UNISTD_H

*** regex.c-orig
--- regex.c
**************
*** 48,54
  
  /* We used to test for `BSTRING' here, but only GCC and Emacs define
     `BSTRING', as far as I know, and neither of them use this code.  */
! #if HAVE_STRING_H || STDC_HEADERS
  #include <string.h>
  #ifndef bcmp
  #define bcmp(s1, s2, n)	memcmp ((s1), (s2), (n))
--- 48,54 -----
  
  /* We used to test for `BSTRING' here, but only GCC and Emacs define
     `BSTRING', as far as I know, and neither of them use this code.  */
! #if HAVE_STRING_H || STDC_HEADERS && !defined(__GNUC__)
  #include <string.h>
  #ifndef bcmp
  #define bcmp(s1, s2, n)	memcmp ((s1), (s2), (n))

*** shell_mung.c-orig
--- shell_mung.c
**************
*** 140,145
  #include <errno.h>
  #include <stdio.h>
  #include <string.h>
  
  #include <fab.h>
  #include <nam.h>
--- 140,146 -----
  #include <errno.h>
  #include <stdio.h>
  #include <string.h>
+ #include <stdlib.h>
  
  #include <fab.h>
  #include <nam.h>
**************
*** 145,150
  #include <nam.h>
  #include <rmsdef.h>
  #include <stsdef.h>
  
  #ifndef VAXC				/* v1.2-004 */
  #define _tolower(c)     ((c) >= 'A' && (c) <= 'Z' ? (c) | 0x20:(c))
--- 146,154 -----
  #include <nam.h>
  #include <rmsdef.h>
  #include <stsdef.h>
+ #ifdef __GNUC__
+ #include <gnu_hacks.h>
+ #endif
  
  #ifndef VAXC				/* v1.2-004 */
  #define _tolower(c)     ((c) >= 'A' && (c) <= 'Z' ? (c) | 0x20:(c))
**************
*** 174,179
   */
  #ifdef VAXC				/* v1.2-004 */
  globaldef char shell_default[NAM$C_MAXRSS+1] = "";
  static char gopher_setup = FALSE;
  #else
  char shell_default[NAM$C_MAXRSS+1] = "";
--- 178,187 -----
   */
  #ifdef VAXC				/* v1.2-004 */
  globaldef char shell_default[NAM$C_MAXRSS+1] = "";
+ static char gopher_setup = FALSE;
+ #elif __GNUC__
+ typedef char charvec[NAM$C_MAXRSS+1];
+ GLOBALDEF(charvec,shell_default,{0});
  static char gopher_setup = FALSE;
  #else
  char shell_default[NAM$C_MAXRSS+1] = "";

*** vmsmake.com-orig
--- vmsmake.com
**************
*** 2,9
  $!
  $!  VMSMAKE.COM - DCL command procedure to build GNU grep on VMS
  $!
! $!  To use VAX C, define CC = "CC"
! $!  To use GNU C, define CC = "GCC"
  $!
  $ axp = f$getsyi("HW_MODEL").ge.1024
  $ CC = "CC/DEFINE=(HAVE_STRING_H,HAVE_MEMCHR,HAVE_STRERROR)"
--- 2,9 -----
  $!
  $!  VMSMAKE.COM - DCL command procedure to build GNU grep on VMS
  $!
! $!  Uses VAXC by default
! $!  To use GNU C, run this file as `@vmsmake gcc'
  $!
  $ axp = f$getsyi("HW_MODEL").ge.1024
  $ if p1 .eqs. "GCC"
**************
*** 6,12
  $!  To use GNU C, define CC = "GCC"
  $!
  $ axp = f$getsyi("HW_MODEL").ge.1024
! $ CC = "CC/DEFINE=(HAVE_STRING_H,HAVE_MEMCHR,HAVE_STRERROR)"
  $ if axp then cc = "''cc'/STANDARD=VAXC"
  $ call compile_it GREP.C
  $ call compile_it ALLOCA.C
--- 6,20 -----
  $!  To use GNU C, run this file as `@vmsmake gcc'
  $!
  $ axp = f$getsyi("HW_MODEL").ge.1024
! $ if p1 .eqs. "GCC"
! $ then
! $   cc = "GCC/DEFINE=(HAVE_MEMCHR,HAVE_STRERROR,STDC_HEADERS)"
! $   lib = "gnu_cc:[000000]gcclib/lib,"
! $ else
! $   CC = "CC/DEFINE=(HAVE_STRING_H,HAVE_MEMCHR,HAVE_STRERROR)"
! $   lib = ""
! $   define sys sys$library
! $ endif
  $ if axp then cc = "''cc'/STANDARD=VAXC"
  $ call compile_it GREP.C
  $ call compile_it ALLOCA.C
**************
*** 20,26
  $ write sys$output "Linking GREP...."
  $ if axp
  $ then	link/notrace grep.olb/include=(grep,search)/library
! $ else	link/notrace grep.olb/include=(grep,search)/library,sys$input/options
  sys$share:vaxcrtl.exe/share
  $ endif
  $ say "Generating on-line help"
--- 28,34 -----
  $ write sys$output "Linking GREP...."
  $ if axp
  $ then	link/notrace grep.olb/include=(grep,search)/library
! $ else	link/notrace grep.olb/include=(grep,search)/library,'lib'sys$input/options
  sys$share:vaxcrtl.exe/share
  $ endif
  $ if f$trnlnm("SYS").nes."" then deassign sys
**************
*** 23,29
  $ else	link/notrace grep.olb/include=(grep,search)/library,sys$input/options
  sys$share:vaxcrtl.exe/share
  $ endif
! $ say "Generating on-line help"
  $ runoff grep.rnh
  $ say "Build completed"
  $ exit 1.or.f$verify(save_verify)
--- 31,38 -----
  $ else	link/notrace grep.olb/include=(grep,search)/library,'lib'sys$input/options
  sys$share:vaxcrtl.exe/share
  $ endif
! $ if f$trnlnm("SYS").nes."" then deassign sys
! $ write sys$output "Generating on-line help"
  $ runoff grep.rnh
  $ write sys$output "Build completed"
  $ exit 1.or.f$verify(save_verify)
**************
*** 25,31
  $ endif
  $ say "Generating on-line help"
  $ runoff grep.rnh
! $ say "Build completed"
  $ exit 1.or.f$verify(save_verify)
  $ Compile_It: SUBROUTINE
  $   write sys$output "Compiling ''p1'...."
--- 34,40 -----
  $ if f$trnlnm("SYS").nes."" then deassign sys
  $ write sys$output "Generating on-line help"
  $ runoff grep.rnh
! $ write sys$output "Build completed"
  $ exit 1.or.f$verify(save_verify)
  $ Compile_It: SUBROUTINE
  $   write sys$output "Compiling ''p1'...."

*** [.tests]vmsregress.com-orig
--- NSRL31$DUA0:[USERSITE1.TOOLS.GREP.TESTS]VMSREGRESS.COM;1
**************
*** 18,24
  $!
  $ define/user sys$output nl:
  $ define/user sys$error nl:
! $ diff khadafy.lines khadafy.out
  $ if $status.eq.%X006C8009
  $ then	write sys$output "egrep passed the khadafy test"
  $	delete/nolog khadafy.out;
--- 18,24 -----
  $!
  $ define/user sys$output nl:
  $ define/user sys$error nl:
! $ differences khadafy.lines khadafy.out
  $ if $status.eq.%X006C8009
  $ then	write sys$output "egrep passed the khadafy test"
  $	delete/nolog khadafy.out;
$ deassign sys$output
