[comp.os.minix] egrep part4 - final

dono@killer.Dallas.TX.US (Don OConnell) (03/18/89)

----------------------------Cut Here-------------------------------------
#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 4 (of 4)."
# Contents:  Makefile getopt.c grep.1m grep.man
# Wrapped by dono@killer on Sat Mar 18 00:05:35 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f Makefile -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"Makefile\"
else
echo shar: Extracting \"Makefile\" \(792 characters\)
sed "s/^X//" >Makefile <<'END_OF_Makefile'
X#
X# Makefile for GNU e?grep
X#
X
X# Add -DUSG for System V.
XCFLAGS = -O -DUSG
X
X#
X# You may add getopt.o if your C library lacks getopt(); note that
X# 4.3BSD getopt() is said to be somewhat broken.
X#
X# Add alloca.o if your machine does not support alloca().
X#
XOBJS = dfa.o regex.o alloca.o
XGOBJ = grep.o
XEOBJ = egrep.o
X
X# Space provided for machine dependent libraries.
XLIBS =
X
Xall: regress
X
Xregress: egrep grep
X	cd tests; sh regress.sh
X
Xegrep: $(OBJS) $(EOBJ)
X	$(CC) $(CFLAGS) -o egrep $(OBJS) $(EOBJ) $(LIBS)
X
Xegrep.o: grep.c
X	$(CC) $(CFLAGS) -DEGREP -c grep.c
X	mv grep.o egrep.o
X
Xgrep: $(OBJS) $(GOBJ)
X	$(CC) $(CFLAGS) -o grep $(OBJS) $(GOBJ) $(LIBS)
X
Xclean:
X	rm -f grep egrep *.o core tests/core tests/tmp.script tests/khadafy.out
X
Xdfa.o egrep.o grep.o: dfa.h
Xegrep.o grep.o regex.o: regex.h
END_OF_Makefile
if test 792 -ne `wc -c <Makefile`; then
    echo shar: \"Makefile\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f getopt.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"getopt.c\"
else
echo shar: Extracting \"getopt.c\" \(16593 characters\)
sed "s/^X//" >getopt.c <<'END_OF_getopt.c'
X/* Getopt for GNU.
X   Copyright (C) 1987 Free Software Foundation, Inc.
X
X		       NO WARRANTY
X
X  BECAUSE THIS PROGRAM IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY
XNO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW.  EXCEPT
XWHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC,
XRICHARD M. STALLMAN AND/OR OTHER PARTIES PROVIDE THIS PROGRAM "AS IS"
XWITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
XBUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
XFITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY
XAND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE PROGRAM PROVE
XDEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
XCORRECTION.
X
X IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M.
XSTALLMAN, THE FREE SOFTWARE FOUNDATION, INC., AND/OR ANY OTHER PARTY
XWHO MAY MODIFY AND REDISTRIBUTE THIS PROGRAM AS PERMITTED BELOW, BE
XLIABLE TO YOU FOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR
XOTHER SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
XUSE OR INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR
XDATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR
XA FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) THIS
XPROGRAM, EVEN IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH
XDAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY.
X
X		GENERAL PUBLIC LICENSE TO COPY
X
X  1. You may copy and distribute verbatim copies of this source file
Xas you receive it, in any medium, provided that you conspicuously and
Xappropriately publish on each copy a valid copyright notice "Copyright
X (C) 1987 Free Software Foundation, Inc."; and include following the
Xcopyright notice a verbatim copy of the above disclaimer of warranty
Xand of this License.  You may charge a distribution fee for the
Xphysical act of transferring a copy.
X
X  2. You may modify your copy or copies of this source file or
Xany portion of it, and copy and distribute such modifications under
Xthe terms of Paragraph 1 above, provided that you also do the following:
X
X    a) cause the modified files to carry prominent notices stating
X    that you changed the files and the date of any change; and
X
X    b) cause the whole of any work that you distribute or publish,
X    that in whole or in part contains or is a derivative of this
X    program or any part thereof, to be licensed at no charge to all
X    third parties on terms identical to those contained in this
X    License Agreement (except that you may choose to grant more
X    extensive warranty protection to third parties, at your option).
X
X    c) You may charge a distribution fee for the physical act of
X    transferring a copy, and you may at your option offer warranty
X    protection in exchange for a fee.
X
X  3. You may copy and distribute this program or any portion of it in
Xcompiled, executable or object code form under the terms of Paragraphs
X1 and 2 above provided that you do the following:
X
X    a) cause each such copy to be accompanied by the
X    corresponding machine-readable source code, which must
X    be distributed under the terms of Paragraphs 1 and 2 above; or,
X
X    b) cause each such copy to be accompanied by a
X    written offer, with no time limit, to give any third party
X    free (except for a nominal shipping charge) a machine readable
X    copy of the corresponding source code, to be distributed
X    under the terms of Paragraphs 1 and 2 above; or,
X
X    c) in the case of a recipient of this program in compiled, executable
X    or object code form (without the corresponding source code) you
X    shall cause copies you distribute to be accompanied by a copy
X    of the written offer of source code which you received along
X    with the copy you received.
X
X  4. You may not copy, sublicense, distribute or transfer this program
Xexcept as expressly provided under this License Agreement.  Any attempt
Xotherwise to copy, sublicense, distribute or transfer this program is void and
Xyour rights to use the program under this License agreement shall be
Xautomatically terminated.  However, parties who have received computer
Xsoftware programs from you with this License Agreement will not have
Xtheir licenses terminated so long as such parties remain in full compliance.
X
X  5. If you wish to incorporate parts of this program into other free
Xprograms whose distribution conditions are different, write to the Free
XSoftware Foundation at 675 Mass Ave, Cambridge, MA 02139.  We have not yet
Xworked out a simple rule that can be stated here, but we will often permit
Xthis.  We will be guided by the two goals of preserving the free status of
Xall derivatives of our free software and of promoting the sharing and reuse of
Xsoftware.
X
X
XIn other words, you are welcome to use, share and improve this program.
XYou are forbidden to forbid anyone else to use, share and improve
Xwhat you give them.   Help stamp out software-hoarding!  */
X
X/* This version of `getopt' appears to the caller like standard Unix `getopt'
X   but it behaves differently for the user, since it allows the user
X   to intersperse the options with the other arguments.
X
X   As `getopt' works, it permutes the elements of `argv' so that,
X   when it is done, all the options precede everything else.  Thus
X   all application programs are extended to handle flexible argument order.
X
X   Setting the environment variable _POSIX_OPTION_ORDER disables permutation.
X   Then the behavior is completely standard.
X
X   GNU application programs can use a third alternative mode in which
X   they can distinguish the relative order of options and other arguments.  */
X
X#include <stdio.h>
X
X#ifdef sparc
X#include <alloca.h>
X#endif
X#ifdef USG
X#define bcopy(s, d, l) memcpy((d), (s), (l))
X#endif
X
X/* For communication from `getopt' to the caller.
X   When `getopt' finds an option that takes an argument,
X   the argument value is returned here.
X   Also, when `ordering' is RETURN_IN_ORDER,
X   each non-option ARGV-element is returned here.  */
X
Xchar *optarg = 0;
X
X/* Index in ARGV of the next element to be scanned.
X   This is used for communication to and from the caller
X   and for communication between successive calls to `getopt'.
X
X   On entry to `getopt', zero means this is the first call; initialize.
X
X   When `getopt' returns EOF, this is the index of the first of the
X   non-option elements that the caller should itself scan.
X
X   Otherwise, `optind' communicates from one call to the next
X   how much of ARGV has been scanned so far.  */
X
Xint optind = 0;
X
X/* The next char to be scanned in the option-element
X   in which the last option character we returned was found.
X   This allows us to pick up the scan where we left off.
X
X   If this is zero, or a null string, it means resume the scan
X   by advancing to the next ARGV-element.  */
X
Xstatic char *nextchar;
X
X/* Callers store zero here to inhibit the error message
X   for unrecognized options.  */
X
Xint opterr = 1;
X
X/* Describe how to deal with options that follow non-option ARGV-elements.
X
X   UNSPECIFIED means the caller did not specify anything;
X   the default is then REQUIRE_ORDER if the environment variable
X   _OPTIONS_FIRST is defined, PERMUTE otherwise.
X
X   REQUIRE_ORDER means don't recognize them as options.
X   Stop option processing when the first non-option is seen.
X   This is what Unix does.
X
X   PERMUTE is the default.  We permute the contents of `argv' as we scan,
X   so that eventually all the options are at the end.  This allows options
X   to be given in any order, even with programs that were not written to
X   expect this.
X
X   RETURN_IN_ORDER is an option available to programs that were written
X   to expect options and other ARGV-elements in any order and that care about
X   the ordering of the two.  We describe each non-option ARGV-element
X   as if it were the argument of an option with character code zero.
X   Using `-' as the first character of the list of option characters
X   requests this mode of operation.
X
X   The special argument `--' forces an end of option-scanning regardless
X   of the value of `ordering'.  In the case of RETURN_IN_ORDER, only
X   `--' can cause `getopt' to return EOF with `optind' != ARGC.  */
X
Xstatic enum { REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER } ordering;
X
X/* Handle permutation of arguments.  */
X
X/* Describe the part of ARGV that contains non-options that have
X   been skipped.  `first_nonopt' is the index in ARGV of the first of them;
X   `last_nonopt' is the index after the last of them.  */
X
Xstatic int first_nonopt;
Xstatic int last_nonopt;
X
X/* Exchange two adjacent subsequences of ARGV.
X   One subsequence is elements [first_nonopt,last_nonopt)
X    which contains all the non-options that have been skipped so far.
X   The other is elements [last_nonopt,optind), which contains all
X    the options processed since those non-options were skipped.
X
X   `first_nonopt' and `last_nonopt' are relocated so that they describe
X    the new indices of the non-options in ARGV after they are moved.  */
X
Xstatic void
Xexchange (argv)
X     char **argv;
X{
X  int nonopts_size
X    = (last_nonopt - first_nonopt) * sizeof (char *);
X  char **temp = (char **) alloca (nonopts_size);
X
X  /* Interchange the two blocks of data in argv.  */
X
X  bcopy (&argv[first_nonopt], temp, nonopts_size);
X  bcopy (&argv[last_nonopt], &argv[first_nonopt],
X	 (optind - last_nonopt) * sizeof (char *));
X  bcopy (temp, &argv[first_nonopt + optind - last_nonopt],
X	 nonopts_size);
X
X  /* Update records for the slots the non-options now occupy.  */
X
X  first_nonopt += (optind - last_nonopt);
X  last_nonopt = optind;
X}
X
X/* Scan elements of ARGV (whose length is ARGC) for option characters
X   given in OPTSTRING.
X
X   If an element of ARGV starts with '-', and is not exactly "-" or "--",
X   then it is an option element.  The characters of this element
X   (aside from the initial '-') are option characters.  If `getopt'
X   is called repeatedly, it returns successively each of theoption characters
X   from each of the option elements.
X
X   If `getopt' finds another option character, it returns that character,
X   updating `optind' and `nextchar' so that the next call to `getopt' can
X   resume the scan with the following option character or ARGV-element.
X
X   If there are no more option characters, `getopt' returns `EOF'.
X   Then `optind' is the index in ARGV of the first ARGV-element
X   that is not an option.  (The ARGV-elements have been permuted
X   so that those that are not options now come last.)
X
X   OPTSTRING is a string containing the legitimate option characters.
X   A colon in OPTSTRING means that the previous character is an option
X   that wants an argument.  The argument is taken from the rest of the
X   current ARGV-element, or from the following ARGV-element,
X   and returned in `optarg'.
X
X   If an option character is seen that is not listed in OPTSTRING,
X   return '?' after printing an error message.  If you set `opterr' to
X   zero, the error message is suppressed but we still return '?'.
X
X   If a char in OPTSTRING is followed by a colon, that means it wants an arg,
X   so the following text in the same ARGV-element, or the text of the following
X   ARGV-element, is returned in `optarg.  Two colons mean an option that
X   wants an optional arg; if there is text in the current ARGV-element,
X   it is returned in `optarg'.
X
X   If OPTSTRING starts with `-', it requests a different method of handling the
X   non-option ARGV-elements.  See the comments about RETURN_IN_ORDER, above.  */
X
Xint
Xgetopt (argc, argv, optstring)
X     int argc;
X     char **argv;
X     char *optstring;
X{
X  /* Initialize the internal data when the first call is made.
X     Start processing options with ARGV-element 1 (since ARGV-element 0
X     is the program name); the sequence of previously skipped
X     non-option ARGV-elements is empty.  */
X
X  if (optind == 0)
X    {
X      first_nonopt = last_nonopt = optind = 1;
X
X      nextchar = 0;
X
X      /* Determine how to handle the ordering of options and nonoptions.  */
X
X      if (optstring[0] == '-')
X	ordering = RETURN_IN_ORDER;
X      else if (getenv ("_POSIX_OPTION_ORDER") != 0)
X	ordering = REQUIRE_ORDER;
X      else
X	ordering = PERMUTE;
X    }
X
X  if (nextchar == 0 || *nextchar == 0)
X    {
X      if (ordering == PERMUTE)
X	{
X	  /* If we have just processed some options following some non-options,
X	     exchange them so that the options come first.  */
X
X	  if (first_nonopt != last_nonopt && last_nonopt != optind)
X	    exchange (argv);
X	  else if (last_nonopt != optind)
X	    first_nonopt = optind;
X
X	  /* Now skip any additional non-options
X	     and extend the range of non-options previously skipped.  */
X
X	  while (optind < argc
X		 && (argv[optind][0] != '-'
X		     || argv[optind][1] == 0))
X	    optind++;
X	  last_nonopt = optind;
X	}
X
X      /* Special ARGV-element `--' means premature end of options.
X	 Skip it like a null option,
X	 then exchange with previous non-options as if it were an option,
X	 then skip everything else like a non-option.  */
X
X      if (optind != argc && !strcmp (argv[optind], "--"))
X	{
X	  optind++;
X
X	  if (first_nonopt != last_nonopt && last_nonopt != optind)
X	    exchange (argv);
X	  else if (first_nonopt == last_nonopt)
X	    first_nonopt = optind;
X	  last_nonopt = argc;
X
X	  optind = argc;
X	}
X
X      /* If we have done all the ARGV-elements, stop the scan
X	 and back over any non-options that we skipped and permuted.  */
X
X      if (optind == argc)
X	{
X	  /* Set the next-arg-index to point at the non-options
X	     that we previously skipped, so the caller will digest them.  */
X	  if (first_nonopt != last_nonopt)
X	    optind = first_nonopt;
X	  return EOF;
X	}
X	 
X      /* If we have come to a non-option and did not permute it,
X	 either stop the scan or describe it to the caller and pass it by.  */
X
X      if (argv[optind][0] != '-' || argv[optind][1] == 0)
X	{
X	  if (ordering == REQUIRE_ORDER)
X	    return EOF;
X	  optarg = argv[optind++];
X	  return 0;
X	}
X
X      /* We have found another option-ARGV-element.
X	 Start decoding its characters.  */
X
X      nextchar = argv[optind] + 1;
X    }
X
X  /* Look at and handle the next option-character.  */
X
X  {
X    char c = *nextchar++;
X    char *temp = (char *) index (optstring, c);
X
X    /* Increment `optind' when we start to process its last character.  */
X    if (*nextchar == 0)
X      optind++;
X
X    if (temp == 0 || c == ':')
X      {
X	if (opterr != 0)
X	  {
X	    if (c < 040 || c >= 0177)
X	      fprintf (stderr, "%s: unrecognized option, character code 0%o\n",
X		       argv[0], c);
X	    else
X	      fprintf (stderr, "%s: unrecognized option `-%c'\n",
X		       argv[0], c);
X	  }
X	return '?';
X      }
X    if (temp[1] == ':')
X      {
X	if (temp[2] == ':')
X	  {
X	    /* This is an option that accepts an argument optionally.  */
X	    if (*nextchar != 0)
X	      {
X	        optarg = nextchar;
X		optind++;
X	      }
X	    else
X	      optarg = 0;
X	    nextchar = 0;
X	  }
X	else
X	  {
X	    /* This is an option that requires an argument.  */
X	    if (*nextchar != 0)
X	      {
X		optarg = nextchar;
X		/* If we end this ARGV-element by taking the rest as an arg,
X		   we must advance to the next element now.  */
X		optind++;
X	      }
X	    else if (optind == argc)
X	      {
X		if (opterr != 0)
X		  fprintf (stderr, "%s: no argument for `-%c' option\n",
X			   argv[0], c);
X		c = '?';
X	      }
X	    else
X	      /* We already incremented `optind' once;
X		 increment it again when taking next ARGV-elt as argument.  */
X	      optarg = argv[optind++];
X	    nextchar = 0;
X	  }
X      }
X    return c;
X  }
X}
X
X#ifdef TEST
X
X/* Compile with -DTEST to make an executable for use in testing
X   the above definition of `getopt'.  */
X
Xint
Xmain (argc, argv)
X     int argc;
X     char **argv;
X{
X  char c;
X  int digit_optind = 0;
X
X  while (1)
X    {
X      int this_option_optind = optind;
X      if ((c = getopt (argc, argv, "abc:d:0123456789")) == EOF)
X	break;
X
X      switch (c)
X	{
X	case '0':
X	case '1':
X	case '2':
X	case '3':
X	case '4':
X	case '5':
X	case '6':
X	case '7':
X	case '8':
X	case '9':
X	  if (digit_optind != 0 && digit_optind != this_option_optind)
X	    printf ("digits occur in two different argv-elements.\n");
X	  digit_optind = this_option_optind;
X	  printf ("option %c\n", c);
X	  break;
X
X	case 'a':
X	  printf ("option a\n");
X	  break;
X
X	case 'b':
X	  printf ("option b\n");
X	  break;
X
X	case 'c':
X	  printf ("option c with value `%s'\n", optarg);
X	  break;
X
X	case '?':
X	  break;
X
X	default:
X	  printf ("?? getopt returned character code 0%o ??\n", c);
X	}
X    }
X
X  if (optind < argc)
X    {
X      printf ("non-option ARGV-elements: ");
X      while (optind < argc)
X	printf ("%s ", argv[optind++]);
X      printf ("\n");
X    }
X
X  return 0;
X}
X
X#endif /* TEST */
END_OF_getopt.c
if test 16593 -ne `wc -c <getopt.c`; then
    echo shar: \"getopt.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f grep.1m -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"grep.1m\"
else
echo shar: Extracting \"grep.1m\" \(11453 characters\)
sed "s/^X//" >grep.1m <<'END_OF_grep.1m'
X
X
X
X     GGGGRRRREEEEPPPP((((1111))))          GGGGNNNNUUUU PPPPrrrroooojjjjeeeecccctttt ((((1111999988888888 DDDDeeeecccceeeemmmmbbbbeeeerrrr 11113333))))           GGGGRRRREEEEPPPP((((1111))))
X
X
X
X     NNNNAAAAMMMMEEEE
X          grep, egrep - print lines matching a regular expression
X
X     SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
X          ggggrrrreeeepppp [ ----CCCCVVVVbbbbcccchhhhiiiillllnnnnssssvvvvwwwwxxxx ] [ ----_n_u_m ] [ ----AAAABBBB _n_u_m ] [ [ ----eeee ] _e_x_p_r |
X          ----ffff _f_i_l_e ] [ _f_i_l_e_s ... ]
X
X     DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
X          _G_r_e_p searches the files listed in the arguments (or standard
X          input if no files are given) for all lines that contain a
X          match for the given _e_x_p_r.  If any lines match, they are
X          printed.
X
X          Also, if any matches were found, _g_r_e_p will exit with a
X          status of 0, but if no matches were found it will exit with
X          a status of 1.  This is useful for building shell scripts
X          that use _g_r_e_p as a condition for, for example, the _i_f
X          statement.
X
X          When invoked as _e_g_r_e_p the syntax of the _e_x_p_r is slightly
X          different; See below.
X
X     RRRREEEEGGGGUUUULLLLAAAARRRR EEEEXXXXPPPPRRRREEEESSSSSSSSIIIIOOOONNNNSSSS
X               (grep)    (egrep)   (explanation)
X
X               _c         _c         a single (non-meta) character
X                                   matches itself.
X
X               .         .         matches any single character except
X                                   newline.
X
X               \?        ?         postfix operator; preceeding item
X                                   is optional.
X
X               *         *         postfix operator; preceeding item 0
X                                   or more times.
X
X               \+        +         postfix operator; preceeding item 1
X                                   or more times.
X
X               \|        |         infix operator; matches either
X                                   argument.
X
X               ^         ^         matches the empty string at the
X                                   beginning of a line.
X
X               $         $         matches the empty string at the end
X                                   of a line.
X
X               \<        \<        matches the empty string at the
X                                   beginning of a word.
X
X
X
X
X     Page 1                                          (printed 3/18/89)
X
X
X
X
X
X
X     GGGGRRRREEEEPPPP((((1111))))          GGGGNNNNUUUU PPPPrrrroooojjjjeeeecccctttt ((((1111999988888888 DDDDeeeecccceeeemmmmbbbbeeeerrrr 11113333))))           GGGGRRRREEEEPPPP((((1111))))
X
X
X
X               \>        \>        matches the empty string at the end
X                                   of a word.
X
X               [_c_h_a_r_s]   [_c_h_a_r_s]   match any character in the given
X                                   class; if the first character after
X                                   [ is ^, match any character not in
X                                   the given class; a range of
X                                   characters may be specified by
X                                   _f_i_r_s_t-_l_a_s_t; for example, \W (below)
X                                   is equivalent to the class
X                                   [^A-Za-z0-9]
X
X               \( \)     ( )       parentheses are used to override
X                                   operator precedence.
X
X               \_d_i_g_i_t    \_d_i_g_i_t    \_n matches a repeat of the text
X                                   matched earlier in the regexp by
X                                   the subexpression inside the nth
X                                   opening parenthesis.
X
X               \         \         any special character may be
X                                   preceded by a backslash to match it
X                                   literally.
X
X               (the following are for compatibility with GNU Emacs)
X
X               \b        \b        matches the empty string at the
X                                   edge of a word.
X
X               \B        \B        matches the empty string if not at
X                                   the edge of a word.
X
X               \w        \w        matches word-constituent characters
X                                   (letters & digits).
X
X               \W        \W        matches characters that are not
X                                   word-constituent.
X
X          Operator precedence is (highest to lowest) ?, *, and +,
X          concatenation, and finally |.  All other constructs are
X          syntactically identical to normal characters.  For the truly
X          interested, the file dfa.c describes (and implements) the
X          exact grammar understood by the parser.
X
X     OOOOPPPPTTTTIIIIOOOONNNNSSSS
X          ----AAAA _n_u_m
X               print <num> lines of context after every matching line
X
X          ----BBBB _n_u_m
X               print _n_u_m lines of context before every matching line
X
X          ----CCCC   print 2 lines of context on each side of every match
X
X
X
X     Page 2                                          (printed 3/18/89)
X
X
X
X
X
X
X     GGGGRRRREEEEPPPP((((1111))))          GGGGNNNNUUUU PPPPrrrroooojjjjeeeecccctttt ((((1111999988888888 DDDDeeeecccceeeemmmmbbbbeeeerrrr 11113333))))           GGGGRRRREEEEPPPP((((1111))))
X
X
X
X          ----_n_u_m print _n_u_m lines of context on each side of every match
X
X          ----VVVV   print the version number on the diagnostic output
X
X          ----bbbb   print every match preceded by its byte offset
X
X          ----cccc   print a total count of matching lines only
X
X          ----eeee _e_x_p_r
X               search for _e_x_p_r; useful if _e_x_p_r begins with -
X
X          ----ffff _f_i_l_e
X               search for the expression contained in _f_i_l_e
X
X          ----hhhh   don't display filenames on matches
X
X          ----iiii   ignore case difference when comparing strings
X
X          ----llll   list files containing matches only
X
X          ----nnnn   print each match preceded by its line number
X
X          ----ssss   run silently producing no output except error messages
X
X          ----vvvv   print only lines that contain no matches for the <expr>
X
X          ----wwww   print only lines where the match is a complete word
X
X          ----xxxx   print only lines where the match is a whole line
X
X     SSSSEEEEEEEE AAAALLLLSSSSOOOO
X          emacs(1), ed(1), sh(1), _G_N_U _E_m_a_c_s _M_a_n_u_a_l
X
X     IIIINNNNCCCCOOOOMMMMPPPPAAAATTTTIIIIBBBBIIIILLLLIIIITTTTIIIIEEEESSSS
X          The following incompatibilities with UNIX _g_r_e_p exist:
X
X               The context-dependent meaning of * is not quite the
X               same (grep only).
X
X               ----bbbb prints a byte offset instead of a block offset.
X
X               The {_m,_n} construct of System V grep is not
X               implemented.
X
X     BBBBUUUUGGGGSSSS
X          GNU _e?_g_r_e_p has been thoroughly debugged and tested by
X          several people over a period of several months; we think
X          it's a reliable beast or we wouldn't distribute it.  If by
X          some fluke of the universe you discover a bug, send a
X          detailed description (including options, regular
X          expressions, and a copy of an input file that can reproduce
X          it) to me, mike@wheaties.ai.mit.edu.
X
X
X
X     Page 3                                          (printed 3/18/89)
X
X
X
X
X
X
X     GGGGRRRREEEEPPPP((((1111))))          GGGGNNNNUUUU PPPPrrrroooojjjjeeeecccctttt ((((1111999988888888 DDDDeeeecccceeeemmmmbbbbeeeerrrr 11113333))))           GGGGRRRREEEEPPPP((((1111))))
X
X
X
X          There is also a newsgroup, gnu.utils.bug, for reporting FSF
X          utility programs' bugs and fixes; but before reporting
X          something as a bug, please try to be sure that it really is
X          a bug, not a misunderstanding or a deliberate feature.
X          Also, include the version number of the utility program you
X          are running in _e_v_e_r_y bug report that you send in.  Please do
X          not send anything but bug reports to this newsgroup.
X
X     AAAAVVVVAAAAIIIILLLLAAAABBBBIIIILLLLIIIITTTTYYYY
X          GNU _g_r_e_p is free; anyone may redistribute copies of _g_r_e_p to
X          anyone under the terms stated in the GNU General Public
X          License, a copy of which may be found in each copy of _G_N_U
X          _E_m_a_c_s.  See also the comment at the beginning of the source
X          code file grep.c.
X
X          Copies of GNU _g_r_e_p may sometimes be received packaged with
X          distributions of Unix systems, but it is never included in
X          the scope of any license covering those systems.  Such
X          inclusion violates the terms on which distribution is
X          permitted.  In fact, the primary purpose of the General
X          Public License is to prohibit anyone from attaching any
X          other restrictions to redistribution of any of the Free
X          Software Foundation programs.
X
X     AAAAUUUUTTTTHHHHOOOORRRRSSSS
X          Mike Haertel wrote the deterministic regexp code and the
X          bulk of the program.
X
X          James A. Woods is responsible for the hybridized search
X          strategy of using Boyer-Moore-Gosper fixed-string search as
X          a filter before calling the general regexp matcher.
X
X          Arthur David Olson contributed code that finds fixed strings
X          for the aforementioned BMG search for a large class of
X          regexps.
X
X          Richard Stallman wrote the backtracking regexp matcher that
X          is used for \_d_i_g_i_t backreferences, as well as the getopt
X          that is provided for 4.2BSD sites.  The backtracking matcher
X          was originally written for GNU Emacs.
X
X          D. A. Gwyn wrote the C alloca emulation that is provided so
X          System V machines can run this program.  (Alloca is used
X          only by RMS' backtracking matcher, and then only rarely, so
X          there is no loss if your machine doesn't have a "real"
X          alloca.)
X
X          Scott Anderson and Henry Spencer designed the regression
X          tests used in the "regress" script.
X
X          Paul Placeway wrote the original version of this manual
X          page.
X
X
X
X     Page 4                                          (printed 3/18/89)
X
X
X
END_OF_grep.1m
echo shar: 1113 control characters may be missing from \"grep.1m\"
if test 11453 -ne `wc -c <grep.1m`; then
    echo shar: \"grep.1m\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f grep.man -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"grep.man\"
else
echo shar: Extracting \"grep.man\" \(6850 characters\)
sed "s/^X//" >grep.man <<'END_OF_grep.man'
X.TH GREP 1 "1988 December 13" "GNU Project"
X.UC 4
X.SH NAME
Xgrep, egrep \- print lines matching a regular expression
X.SH SYNOPSIS
X.B grep
X[
X.B \-CVbchilnsvwx
X] [
X.BI \- num
X] [
X.B \-AB
X.I num
X] [ [
X.B \-e
X]
X.I expr
X|
X.B \-f
X.I file
X] [
X.I "files ..."
X]
X.SH DESCRIPTION
X.I Grep
Xsearches the files listed in the arguments (or standard
Xinput if no files are given) for all lines that contain a match for
Xthe given
X.IR expr .
XIf any lines match, they are printed.
X.PP
XAlso, if any matches were found,
X.I grep
Xwill exit with a status of 0, but if no matches were found it will exit
Xwith a status of 1.  This is useful for building shell scripts that
Xuse
X.I grep
Xas a condition for, for example, the
X.I if
Xstatement.
X.PP
XWhen invoked as
X.I egrep
Xthe syntax of the
X.I expr
Xis slightly different; See below.
X.br
X.SH "REGULAR EXPRESSIONS"
X.RS 2.5i
X.ta 1i; 2i
X.sp
X.ti -2.0i
X(grep)	(egrep)		(explanation)
X.sp
X.ti -2.0i
X\fIc\fP	\fIc\fP	a single (non-meta) character matches itself.
X.sp
X.ti -2.0i
X\&.	.	matches any single character except newline.
X.sp
X.ti -2.0i
X\\?	?	postfix operator; preceeding item is optional.
X.sp
X.ti -2.0i
X\(**	\(**	postfix operator; preceeding item 0 or
Xmore times.
X.sp
X.ti -2.0i
X\\+	+	postfix operator; preceeding item 1 or
Xmore times.
X.sp
X.ti -2.0i
X\\|	|	infix operator; matches either
Xargument.
X.sp
X.ti -2.0i
X^	^	matches the empty string at the beginning of a line.
X.sp
X.ti -2.0i
X$	$	matches the empty string at the end of a line.
X.sp
X.ti -2.0i
X\\<	\\<	matches the empty string at the beginning of a word.
X.sp
X.ti -2.0i
X\\>	\\>	matches the empty string at the end of a word.
X.sp
X.ti -2.0i
X[\fIchars\fP]	[\fIchars\fP]	match any character in the given class; if the
Xfirst character after [ is ^, match any character
Xnot in the given class; a range of characters may
Xbe specified by \fIfirst\-last\fP; for example, \\W
X(below) is equivalent to the class [^A\-Za\-z0\-9]
X.sp
X.ti -2.0i
X\\( \\)	( )	parentheses are used to override operator precedence.
X.sp
X.ti -2.0i
X\\\fIdigit\fP	\\\fIdigit\fP	\\\fIn\fP matches a repeat of the text
Xmatched earlier in the regexp by the subexpression inside the nth
Xopening parenthesis.
X.sp
X.ti -2.0i
X\\	\\	any special character may be preceded
Xby a backslash to match it literally.
X.sp
X.ti -2.0i
X(the following are for compatibility with GNU Emacs)
X.sp
X.ti -2.0i
X\\b	\\b	matches the empty string at the edge of a word.
X.sp
X.ti -2.0i
X\\B	\\B	matches the empty string if not at the edge of a word.
X.sp
X.ti -2.0i
X\\w	\\w	matches word-constituent characters (letters & digits).
X.sp
X.ti -2.0i
X\\W	\\W	matches characters that are not word-constituent.
X.RE
X.PP
XOperator precedence is (highest to lowest) ?, \(**, and +, concatenation,
Xand finally |.  All other constructs are syntactically identical to
Xnormal characters.  For the truly interested, the file dfa.c describes
X(and implements) the exact grammar understood by the parser.
X.SH OPTIONS
X.TP
X.BI \-A " num"
Xprint <num> lines of context after every matching line
X.TP
X.BI \-B " num"
Xprint
X.I num
Xlines of context before every matching line
X.TP
X.B \-C
Xprint 2 lines of context on each side of every match
X.TP
X.BI \- num
Xprint
X.I num
Xlines of context on each side of every match
X.TP
X.B \-V
Xprint the version number on the diagnostic output
X.TP
X.B \-b
Xprint every match preceded by its byte offset
X.TP
X.B \-c
Xprint a total count of matching lines only
X.TP
X.BI \-e " expr"
Xsearch for
X.IR expr ;
Xuseful if
X.I expr
Xbegins with \-
X.TP
X.BI \-f " file"
Xsearch for the expression contained in
X.I file
X.TP
X.B \-h
Xdon't display filenames on matches
X.TP
X.B \-i
Xignore case difference when comparing strings
X.TP
X.B \-l
Xlist files containing matches only
X.TP
X.B \-n
Xprint each match preceded by its line number
X.TP
X.B \-s
Xrun silently producing no output except error messages
X.TP
X.B \-v
Xprint only lines that contain no matches for the <expr>
X.TP
X.B \-w
Xprint only lines where the match is a complete word
X.TP
X.B \-x
Xprint only lines where the match is a whole line
X.SH "SEE ALSO"
Xemacs(1), ed(1), sh(1),
X.I "GNU Emacs Manual"
X.SH INCOMPATIBILITIES
XThe following incompatibilities with UNIX
X.I grep
Xexist:
X.PP
X.RS 0.5i
XThe context-dependent meaning of \(** is not quite the same (grep only).
X.PP
X.B \-b
Xprints a byte offset instead of a block offset.
X.PP
XThe {\fIm,n\fP} construct of System V grep is not implemented.
X.PP
X.SH BUGS
XGNU \fIe?grep\fP has been thoroughly debugged and tested by several people
Xover a period of several months; we think it's a reliable beast or we
Xwouldn't distribute it.  If by some fluke of the universe you discover
Xa bug, send a detailed description (including options, regular
Xexpressions, and a copy of an input file that can reproduce it) to me,
Xmike@wheaties.ai.mit.edu.
X.PP
XThere is also a newsgroup, gnu.utils.bug, for reporting FSF utility
Xprograms' bugs and fixes; but before reporting something as a bug,
Xplease try to be sure that it really is a bug, not a misunderstanding
Xor a deliberate feature.  Also, include the version number of the
Xutility program you are running in \fIevery\fR bug report that you
Xsend in.  Please do not send anything but bug reports to this
Xnewsgroup.
X.PP
X.SH AVAILABILITY
X.PP
XGNU
X.I grep
Xis free; anyone may redistribute copies of 
X.I grep
Xto
Xanyone under the terms stated in the 
XGNU General Public License,
Xa copy of which may be found in each copy of 
X.IR "GNU Emacs" .
XSee also the comment at the beginning of the source code file grep.c.
X.PP
XCopies of GNU
X.I grep
Xmay sometimes be received packaged with distributions of Unix systems,
Xbut it is never included in the scope of any license covering those
Xsystems.  Such inclusion violates the terms on which distribution
Xis permitted.  In fact, the primary purpose of the General Public
XLicense is to prohibit anyone from attaching any other restrictions
Xto redistribution of any of the Free Software Foundation programs.
X.SH AUTHORS
XMike Haertel wrote the deterministic regexp code and the bulk
Xof the program.
X.PP
XJames A. Woods is responsible for the hybridized search strategy
Xof using Boyer-Moore-Gosper fixed-string search as a filter
Xbefore calling the general regexp matcher.
X.PP
XArthur David Olson contributed code that finds fixed strings for
Xthe aforementioned BMG search for a large class of regexps.
X.PP
XRichard Stallman wrote the backtracking regexp matcher that is
Xused for \\\fIdigit\fP backreferences, as well as the getopt that
Xis provided for 4.2BSD sites.  The backtracking matcher was
Xoriginally written for GNU Emacs.
X.PP
XD. A. Gwyn wrote the C alloca emulation that is provided so
XSystem V machines can run this program.  (Alloca is used only
Xby RMS' backtracking matcher, and then only rarely, so there
Xis no loss if your machine doesn't have a "real" alloca.)
X.PP
XScott Anderson and Henry Spencer designed the regression tests
Xused in the "regress" script.
X.PP
XPaul Placeway wrote the original version of this manual page.
END_OF_grep.man
if test 6850 -ne `wc -c <grep.man`; then
    echo shar: \"grep.man\" unpacked with wrong size!
fi
# end of overwriting check
fi
echo shar: End of archive 4 \(of 4\).
cp /dev/null ark4isdone
MISSING=""
for I in 1 2 3 4 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 4 archives.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0