🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Steve C. Simmons Sat, 08 Jul 1989 20:30
Combining Gnu grep/egrep executables
#283
Author: Steve C. Simmons
Date: Sat, 08 Jul 1989 20:30
112 lines
3400 bytes
Installing gnu grep/egrep it seemed odd that it came as two
separate executables.  A few minutes work changed things such
that they are now the same.  The resulting combined binary
passes all the regression tests on a Unix-pc using both gcc and
the system cc.  The disk space savings on small machines is
considerable!  Patches to Makefile and grep.c for grep-1.3 follow.

Steve

*** /tmp/,RCSt1a15191	Sat Jul  8 15:43:06 1989
--- Makefile	Sat Jul  8 15:42:43 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 = grep.o dfa.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 egrep
! 	ln grep egrep
  
! 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
*** /tmp/,RCSt1a15094	Sat Jul  8 15:36:10 1989
--- grep.c	Sat Jul  8 15:36:15 1989
***************
*** 568,573 ****
--- 568,575 ----
    else
      prog = argv[0];
  
+   /* Compile the regexp according to all the options. */
+ 
    opterr = 0;
    while ((c = getopt(argc, argv, "0123456789A:B:CVbce:f:hilnsvwx")) != EOF)
      switch (c)
***************
*** 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)
--- 682,697 ----
        }
  
    /* Set the syntax depending on whether we are EGREP or not. */
!   if ( 0 == strcmp( prog, "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);
!     }
  
    /* Compile the regexp according to all the options. */
    if (regexp_file)
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads