[gnu.utils.bug] grep 1.4 nits: another ISUPPER bug; separate executables

eggert@twinsun.com (Paul Eggert) (11/14/89)

In GNU grep 1.4, dfa.h says ISUPPER(C) where it should say ISUPPER(c).  This
buglet is separate from the buglet reported 9 Nov by Arnold D. Robbins; it's in
code compiled SOMEDAY:

	130c130
	< #define ISUPPER(C) isupper(c)
	---
	> #define ISUPPER(c) isupper(c)

scs@itivax.iti.org (Steve C. Simmons) 8 Jul 89 20:30:09 <2024@itivax.iti.org>
suggested that grep and egrep be the same executable.  This simplifies the
code, saves space, and costs very little execution time.  Here is his
suggestion again, upgraded for grep 1.4.

*** grep-1.4/grep.c	Mon Nov 13 13:06:09 1989
--- grep-new/grep.c	Mon Nov 13 12:52:57 1989
***************
*** 549,554 ****
--- 549,555 ----
       char **argv;
  {
    int c;
+   int syntax = RE_SYNTAX_GREP;	/* Which RE syntax to use. */
    int ignore_case = 0;		/* Compile the regexp to ignore case. */
    char *the_regexp = 0;		/* The regular expression. */
    int regexp_len;		/* Length of the regular expression. */
***************
*** 567,572 ****
--- 568,575 ----
      ++prog;
    else
      prog = argv[0];
+   if (*prog == 'e')
+     syntax = RE_SYNTAX_EGREP;
  
    opterr = 0;
    while ((c = getopt(argc, argv, "0123456789A:B:CVbce:f:hilnsvwx")) != EOF)
***************
*** 680,692 ****
        }
  
    /* Set the syntax depending on whether we are EGREP or not. */
! #ifdef EGREP
!   regsyntax(RE_SYNTAX_EGREP, ignore_case);
!   re_set_syntax(RE_SYNTAX_EGREP);
! #else
!   regsyntax(RE_SYNTAX_GREP, ignore_case);
!   re_set_syntax(RE_SYNTAX_GREP);
! #endif
  
    /* Compile the regexp according to all the options. */
    if (regexp_file)
--- 683,690 ----
        }
  
    /* Set the syntax depending on whether we are EGREP or not. */
!   regsyntax(syntax, ignore_case);
!   re_set_syntax(syntax);
  
    /* Compile the regexp according to all the options. */
    if (regexp_file)
***************
*** 734,748 ****
  	n[i++] = '^';
        else
  	n[i++] = '\\', n[i++] = '<';
! #ifndef EGREP
!       n[i++] = '\\';
! #endif
        n[i++] = '(';
        memcpy(n + i, the_regexp, regexp_len);
        i += regexp_len;
! #ifndef EGREP
!       n[i++] = '\\';
! #endif
        n[i++] = ')';
        if (whole_line)
  	n[i++] = '$';
--- 732,744 ----
  	n[i++] = '^';
        else
  	n[i++] = '\\', n[i++] = '<';
!       if (syntax == RE_SYNTAX_GREP)
! 	n[i++] = '\\';
        n[i++] = '(';
        memcpy(n + i, the_regexp, regexp_len);
        i += regexp_len;
!       if (syntax == RE_SYNTAX_GREP)
! 	n[i++] = '\\';
        n[i++] = ')';
        if (whole_line)
  	n[i++] = '$';


*** grep-1.4/Makefile	Mon Nov 13 13:06:09 1989
--- grep-new/Makefile	Mon Nov 13 12:52:55 1989
***************
*** 11,19 ****
  #
  # Add alloca.o if your machine does not support alloca().
  #
! OBJS = dfa.o regex.o
! GOBJ = grep.o
! EOBJ = egrep.o
  
  # Space provided for machine dependent libraries.
  LIBS =
--- 11,17 ----
  #
  # Add alloca.o if your machine does not support alloca().
  #
! OBJS = dfa.o grep.o regex.o
  
  # Space provided for machine dependent libraries.
  LIBS =
***************
*** 23,40 ****
  regress: egrep grep
  	cd tests; sh regress.sh
  
! egrep: $(OBJS) $(EOBJ)
! 	$(CC) $(CFLAGS) -o egrep $(OBJS) $(EOBJ) $(LIBS)
  
! egrep.o: grep.c
! 	$(CC) $(CFLAGS) -DEGREP -c grep.c
! 	mv grep.o egrep.o
  
- grep: $(OBJS) $(GOBJ)
- 	$(CC) $(CFLAGS) -o grep $(OBJS) $(GOBJ) $(LIBS)
- 
  clean:
  	rm -f grep egrep *.o core tests/core tests/tmp.script tests/khadafy.out
  
! dfa.o egrep.o grep.o: dfa.h
! egrep.o grep.o regex.o: regex.h
--- 21,35 ----
  regress: egrep grep
  	cd tests; sh regress.sh
  
! egrep: grep
! 	rm -f $@
! 	ln grep $@
  
! grep: $(OBJS)
! 	$(CC) $(CFLAGS) -o grep $(OBJS) $(LIBS)
  
  clean:
  	rm -f grep egrep *.o core tests/core tests/tmp.script tests/khadafy.out
  
! dfa.o grep.o: dfa.h
! grep.o regex.o: regex.h