Article View: gnu.utils.bug
Article #283Combining Gnu grep/egrep executables
From: Steve C. Simmons
Date: Sat, 08 Jul 1989 20:30
Date: Sat, 08 Jul 1989 20:30
112 lines
3400 bytes
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)
Technical Details
Message-ID:
<2024@itivax.iti.org>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!mailrus!sharkey!itivax!itivax.iti.org!scsShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!mailrus!sharkey!itivax!itivax.iti.org!scs From: scs@itivax.iti.org (Steve C. Simmons) Newsgroups: gnu.utils.bug,unix-pc.sources Subject: Combining Gnu grep/egrep executables Message-ID: <2024@itivax.iti.org> Date: 8 Jul 89 20:30:09 GMT Sender: scs@itivax.iti.org Reply-To: scs@itivax.iti.org (Steve C. Simmons) Followup-To: gnu.utils.bug Distribution: gnu Organization: Industrial Technology Institute Lines: 112