home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-09-23 | 38.8 KB | 1,018 lines |
- *** e:\tmp/RCSt1006359 Sat Sep 22 22:33:42 1990
- --- dfa.c Sat Sep 22 22:28:26 1990
- ***************
- *** 4,109 ****
- Modified July, 1988 by Arthur David Olson
- to assist BMG speedups
-
- ! NO WARRANTY
-
- ! BECAUSE THIS PROGRAM IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY
- ! NO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW. EXCEPT
- ! WHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC,
- ! RICHARD M. STALLMAN AND/OR OTHER PARTIES PROVIDE THIS PROGRAM "AS IS"
- ! WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
- ! BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- ! FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY
- ! AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE
- ! DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
- ! CORRECTION.
- !
- ! IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M.
- ! STALLMAN, THE FREE SOFTWARE FOUNDATION, INC., AND/OR ANY OTHER PARTY
- ! WHO MAY MODIFY AND REDISTRIBUTE THIS PROGRAM AS PERMITTED BELOW, BE
- ! LIABLE TO YOU FOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR
- ! OTHER SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
- ! USE OR INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR
- ! DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR
- ! A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) THIS
- ! PROGRAM, EVEN IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH
- ! DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY.
- !
- ! GENERAL PUBLIC LICENSE TO COPY
- !
- ! 1. You may copy and distribute verbatim copies of this source file
- ! as you receive it, in any medium, provided that you conspicuously and
- ! appropriately publish on each copy a valid copyright notice "Copyright
- ! (C) 1988 Free Software Foundation, Inc."; and include following the
- ! copyright notice a verbatim copy of the above disclaimer of warranty
- ! and of this License. You may charge a distribution fee for the
- ! physical act of transferring a copy.
- !
- ! 2. You may modify your copy or copies of this source file or
- ! any portion of it, and copy and distribute such modifications under
- ! the terms of Paragraph 1 above, provided that you also do the following:
- !
- ! a) cause the modified files to carry prominent notices stating
- ! that you changed the files and the date of any change; and
- !
- ! b) cause the whole of any work that you distribute or publish,
- ! that in whole or in part contains or is a derivative of this
- ! program or any part thereof, to be licensed at no charge to all
- ! third parties on terms identical to those contained in this
- ! License Agreement (except that you may choose to grant more extensive
- ! warranty protection to some or all third parties, at your option).
- !
- ! c) You may charge a distribution fee for the physical act of
- ! transferring a copy, and you may at your option offer warranty
- ! protection in exchange for a fee.
- !
- ! Mere aggregation of another unrelated program with this program (or its
- ! derivative) on a volume of a storage or distribution medium does not bring
- ! the other program under the scope of these terms.
- !
- ! 3. You may copy and distribute this program or any portion of it in
- ! compiled, executable or object code form under the terms of Paragraphs
- ! 1 and 2 above provided that you do the following:
- !
- ! a) accompany it with the complete corresponding machine-readable
- ! source code, which must be distributed under the terms of
- ! Paragraphs 1 and 2 above; or,
- !
- ! b) accompany it with a written offer, valid for at least three
- ! years, to give any third party free (except for a nominal
- ! shipping charge) a complete machine-readable copy of the
- ! corresponding source code, to be distributed under the terms of
- ! Paragraphs 1 and 2 above; or,
- !
- ! c) accompany it with the information you received as to where the
- ! corresponding source code may be obtained. (This alternative is
- ! allowed only for noncommercial distribution and only if you
- ! received the program in object code or executable form alone.)
- !
- ! For an executable file, complete source code means all the source code for
- ! all modules it contains; but, as a special exception, it need not include
- ! source code for modules which are standard libraries that accompany the
- ! operating system on which the executable file runs.
- !
- ! 4. You may not copy, sublicense, distribute or transfer this program
- ! except as expressly provided under this License Agreement. Any attempt
- ! otherwise to copy, sublicense, distribute or transfer this program is void and
- ! your rights to use the program under this License agreement shall be
- ! automatically terminated. However, parties who have received computer
- ! software programs from you with this License Agreement will not have
- ! their licenses terminated so long as such parties remain in full compliance.
- !
- ! 5. If you wish to incorporate parts of this program into other free
- ! programs whose distribution conditions are different, write to the Free
- ! Software Foundation at 675 Mass Ave, Cambridge, MA 02139. We have not yet
- ! worked out a simple rule that can be stated here, but we will often permit
- ! this. We will be guided by the two goals of preserving the free status of
- ! all derivatives our free software and of promoting the sharing and reuse of
- ! software.
- !
-
- ! In other words, you are welcome to use, share and improve this program.
- ! You are forbidden to forbid anyone else to use, share and improve
- ! what you give them. Help stamp out software-hoarding! */
-
- #include <stdio.h>
- #include <assert.h>
- --- 4,34 ----
- Modified July, 1988 by Arthur David Olson
- to assist BMG speedups
-
- ! This program is free software; you can redistribute it and/or modify
- ! it under the terms of the GNU General Public License as published by
- ! the Free Software Foundation; either version 1, or (at your option)
- ! any later version.
-
- ! This program is distributed in the hope that it will be useful,
- ! but WITHOUT ANY WARRANTY; without even the implied warranty of
- ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ! GNU General Public License for more details.
- !
- ! You should have received a copy of the GNU General Public License
- ! along with this program; if not, write to the Free Software
- ! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
- !
- ! /* MS-DOS port (c) 1990 by Thorsten Ohl <td12@ddagsi3.bitnet>
- !
- ! This port is also distributed under the terms of the
- ! GNU General Public License as published by the
- ! Free Software Foundation.
- !
- ! Please note that this file is not identical to the
- ! original GNU release, you should have received this
- ! code as patch to the official release.
-
- ! $Header: e:/gnu/grep/RCS/dfa.c 1.5.0.4 90/09/21 11:48:02 tho Exp $ */
-
- #include <stdio.h>
- #include <assert.h>
- ***************
- *** 112,120 ****
-
- #ifdef __STDC__
- typedef void *ptr_t;
- ! #else
- typedef char *ptr_t;
- ! #endif
-
- static void regmust();
-
- --- 37,85 ----
-
- #ifdef __STDC__
- typedef void *ptr_t;
- !
- ! #ifdef MSDOS
- ! #include <stdlib.h>
- ! static void *xcalloc (int n, unsigned int s);
- ! static void *xmalloc (unsigned int n);
- ! static void *xrealloc (void *p, unsigned int n);
- ! static int tstbit (int b, int *c);
- ! static void setbit (int b, int *c);
- ! static void clrbit (int b, int *c);
- ! static void copyset (const _charset src, _charset dst);
- ! static void zeroset (int *s);
- ! static void notset (int *s);
- ! static int equal (const _charset s1, const _charset s2);
- ! static int charset_index (const _charset s);
- ! static void atom (void);
- ! static void closure (void);
- ! static void branch (void);
- ! static void regexp (void);
- ! static void build_state (int s, struct regexp * r);
- ! static void build_state_zero (struct regexp * r);
- ! static char *icatalloc (char *old, char *new);
- ! static char *icpyalloc (char *string);
- ! static char *istrstr (char *lookin, char *lookfor);
- ! static void ifree (char *cp);
- ! static void freelist (char **cpp);
- ! static char **enlist (char **cpp, char *new, int len);
- ! static char **comsubs (char *left, char *right);
- ! static char **addlists (char **old, char **new);
- ! static char **inboth (char **left, char **right);
- ! static void regmust (struct regexp * r);
- ! static void copy (_position_set const * src, _position_set * dst);
- ! static void insert (_position p, _position_set * s);
- ! static void merge (_position_set * s1, _position_set * s2, _position_set * m);
- ! static void delete (_position p, _position_set * s);
- ! static int state_index (struct regexp * r, _position_set * s,
- ! int newline, int letter);
- ! static void epsclosure (_position_set * s, struct regexp * r);
- ! static void addtok (_token t);
- ! static _token lex (void);
- ! #endif /* MSDOS */
- ! #else /* not __STDC__ */
- typedef char *ptr_t;
- ! #endif /* not __STDC__ */
-
- static void regmust();
-
- ***************
- *** 261,267 ****
- }
-
- /* Syntax bits controlling the behavior of the lexical analyzer. */
- ! static syntax_bits, syntax_bits_set;
-
- /* Flag for case-folding letters into sets. */
- static case_fold;
- --- 226,233 ----
- }
-
- /* Syntax bits controlling the behavior of the lexical analyzer. */
- ! static LONG syntax_bits;
- ! static int syntax_bits_set;
-
- /* Flag for case-folding letters into sets. */
- static case_fold;
- ***************
- *** 269,275 ****
- /* Entry point to set syntax options. */
- void
- regsyntax(bits, fold)
- ! int bits;
- int fold;
- {
- syntax_bits_set = 1;
- --- 235,241 ----
- /* Entry point to set syntax options. */
- void
- regsyntax(bits, fold)
- ! LONG bits;
- int fold;
- {
- syntax_bits_set = 1;
- ***************
- *** 861,866 ****
- --- 827,835 ----
- that position with the elements of its follow labeled with an appropriate
- constraint. Repeat exhaustively until no funny positions are left.
- S->elems must be large enough to hold the result. */
- + #ifdef MSDOS
- + void
- + #endif
- epsclosure(s, r)
- _position_set *s;
- struct regexp *r;
- ***************
- *** 1834,1840 ****
- --- 1803,1813 ----
-
- static char *
- icpyalloc(string)
- + #ifdef MSDOS
- + char * string;
- + #else
- const char * string;
- + #endif
- {
- return icatalloc((char *) NULL, string);
- }
- ***************
- *** 2021,2026 ****
- --- 1994,2003 ----
- char * right;
- char * is;
- } must;
- +
- + #ifdef __STDC__
- + static void resetmust (must *mp);
- + #endif
-
- static void
- resetmust(mp)
- *** e:\tmp/RCSt1006359 Sat Sep 22 22:33:46 1990
- --- dfa.h Sat Sep 22 22:26:56 1990
- ***************
- *** 2,112 ****
- Copyright (C) 1988 Free Software Foundation, Inc.
- Written June, 1988 by Mike Haertel
-
- ! NO WARRANTY
-
- ! BECAUSE THIS PROGRAM IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY
- ! NO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW. EXCEPT
- ! WHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC,
- ! RICHARD M. STALLMAN AND/OR OTHER PARTIES PROVIDE THIS PROGRAM "AS IS"
- ! WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
- ! BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- ! FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY
- ! AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE
- ! DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
- ! CORRECTION.
- !
- ! IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M.
- ! STALLMAN, THE FREE SOFTWARE FOUNDATION, INC., AND/OR ANY OTHER PARTY
- ! WHO MAY MODIFY AND REDISTRIBUTE THIS PROGRAM AS PERMITTED BELOW, BE
- ! LIABLE TO YOU FOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR
- ! OTHER SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
- ! USE OR INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR
- ! DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR
- ! A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) THIS
- ! PROGRAM, EVEN IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH
- ! DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY.
- !
- ! GENERAL PUBLIC LICENSE TO COPY
- !
- ! 1. You may copy and distribute verbatim copies of this source file
- ! as you receive it, in any medium, provided that you conspicuously and
- ! appropriately publish on each copy a valid copyright notice "Copyright
- ! (C) 1988 Free Software Foundation, Inc."; and include following the
- ! copyright notice a verbatim copy of the above disclaimer of warranty
- ! and of this License. You may charge a distribution fee for the
- ! physical act of transferring a copy.
- !
- ! 2. You may modify your copy or copies of this source file or
- ! any portion of it, and copy and distribute such modifications under
- ! the terms of Paragraph 1 above, provided that you also do the following:
- !
- ! a) cause the modified files to carry prominent notices stating
- ! that you changed the files and the date of any change; and
- !
- ! b) cause the whole of any work that you distribute or publish,
- ! that in whole or in part contains or is a derivative of this
- ! program or any part thereof, to be licensed at no charge to all
- ! third parties on terms identical to those contained in this
- ! License Agreement (except that you may choose to grant more extensive
- ! warranty protection to some or all third parties, at your option).
- !
- ! c) You may charge a distribution fee for the physical act of
- ! transferring a copy, and you may at your option offer warranty
- ! protection in exchange for a fee.
- !
- ! Mere aggregation of another unrelated program with this program (or its
- ! derivative) on a volume of a storage or distribution medium does not bring
- ! the other program under the scope of these terms.
- !
- ! 3. You may copy and distribute this program or any portion of it in
- ! compiled, executable or object code form under the terms of Paragraphs
- ! 1 and 2 above provided that you do the following:
- !
- ! a) accompany it with the complete corresponding machine-readable
- ! source code, which must be distributed under the terms of
- ! Paragraphs 1 and 2 above; or,
- !
- ! b) accompany it with a written offer, valid for at least three
- ! years, to give any third party free (except for a nominal
- ! shipping charge) a complete machine-readable copy of the
- ! corresponding source code, to be distributed under the terms of
- ! Paragraphs 1 and 2 above; or,
- !
- ! c) accompany it with the information you received as to where the
- ! corresponding source code may be obtained. (This alternative is
- ! allowed only for noncommercial distribution and only if you
- ! received the program in object code or executable form alone.)
- !
- ! For an executable file, complete source code means all the source code for
- ! all modules it contains; but, as a special exception, it need not include
- ! source code for modules which are standard libraries that accompany the
- ! operating system on which the executable file runs.
- !
- ! 4. You may not copy, sublicense, distribute or transfer this program
- ! except as expressly provided under this License Agreement. Any attempt
- ! otherwise to copy, sublicense, distribute or transfer this program is void and
- ! your rights to use the program under this License agreement shall be
- ! automatically terminated. However, parties who have received computer
- ! software programs from you with this License Agreement will not have
- ! their licenses terminated so long as such parties remain in full compliance.
- !
- ! 5. If you wish to incorporate parts of this program into other free
- ! programs whose distribution conditions are different, write to the Free
- ! Software Foundation at 675 Mass Ave, Cambridge, MA 02139. We have not yet
- ! worked out a simple rule that can be stated here, but we will often permit
- ! this. We will be guided by the two goals of preserving the free status of
- ! all derivatives our free software and of promoting the sharing and reuse of
- ! software.
-
- !
- ! In other words, you are welcome to use, share and improve this program.
- ! You are forbidden to forbid anyone else to use, share and improve
- ! what you give them. Help stamp out software-hoarding! */
-
-
- #ifdef USG
- #include <string.h>
- ! extern char *index();
- #else
- #include <strings.h>
- extern char *strchr(), *strrchr(), *memcpy();
- --- 2,50 ----
- Copyright (C) 1988 Free Software Foundation, Inc.
- Written June, 1988 by Mike Haertel
-
- ! This program is free software; you can redistribute it and/or modify
- ! it under the terms of the GNU General Public License as published by
- ! the Free Software Foundation; either version 1, or (at your option)
- ! any later version.
-
- ! This program is distributed in the hope that it will be useful,
- ! but WITHOUT ANY WARRANTY; without even the implied warranty of
- ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ! GNU General Public License for more details.
- !
- ! You should have received a copy of the GNU General Public License
- ! along with this program; if not, write to the Free Software
- ! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
- !
- ! /* MS-DOS port (c) 1990 by Thorsten Ohl <td12@ddagsi3.bitnet>
- !
- ! This port is also distributed under the terms of the
- ! GNU General Public License as published by the
- ! Free Software Foundation.
- !
- ! Please note that this file is not identical to the
- ! original GNU release, you should have received this
- ! code as patch to the official release.
-
- ! $Header: e:/gnu/grep/RCS/dfa.h 1.5.0.5 90/09/21 11:48:25 tho Exp $ */
-
- + #ifdef MSDOS
- + #define LONG long
- + #define ONE 1L
- + #else /* not MSDOS */
- + #define LONG int
- + #define ONE 1
- + #endif /* not MSDOS */
-
- #ifdef USG
- #include <string.h>
- !
- ! #define bcopy(s,d,n) memcpy((d),(s),(n))
- ! #define bcmp(s1,s2,n) memcmp((s1),(s2),(n))
- ! #define bzero(s,n) memset((s),0,(n))
- ! #define index strchr
- ! #define rindex strrchr
- !
- #else
- #include <strings.h>
- extern char *strchr(), *strrchr(), *memcpy();
- ***************
- *** 116,128 ****
-
- /* Missing include files for GNU C. */
- /* #include <stdlib.h> */
- ! typedef int size_t;
- extern void *calloc(int, size_t);
- extern void *malloc(size_t);
- extern void *realloc(void *, size_t);
- extern void free(void *);
-
- extern char *bcopy(), *bzero();
-
- #ifdef SOMEDAY
- #define ISALNUM(c) isalnum(c)
- --- 54,70 ----
-
- /* Missing include files for GNU C. */
- /* #include <stdlib.h> */
- ! #ifndef MSDOS
- ! typedef int size_t; /* long !!!! */
- extern void *calloc(int, size_t);
- extern void *malloc(size_t);
- extern void *realloc(void *, size_t);
- extern void free(void *);
- + #endif /* MSDOS */
-
- + #ifndef USG
- extern char *bcopy(), *bzero();
- + #endif /* not USG */
-
- #ifdef SOMEDAY
- #define ISALNUM(c) isalnum(c)
- ***************
- *** 134,140 ****
- #define ISUPPER(c) (isascii(c) && isupper(c))
- #endif
-
- ! #else /* ! __STDC__ */
-
- #define const
- typedef int size_t;
- --- 76,82 ----
- #define ISUPPER(c) (isascii(c) && isupper(c))
- #endif
-
- ! #else /* not __STDC__ */
-
- #define const
- typedef int size_t;
- ***************
- *** 147,193 ****
- #define ISALPHA(c) (isascii(c) && isalpha(c))
- #define ISUPPER(c) (isascii(c) && isupper(c))
-
- ! #endif /* ! __STDC__ */
-
- ! /* 1 means plain parentheses serve as grouping, and backslash
- parentheses are needed for literal searching.
- ! 0 means backslash-parentheses are grouping, and plain parentheses
- are for literal searching. */
- ! #define RE_NO_BK_PARENS 1
- !
- ! /* 1 means plain | serves as the "or"-operator, and \| is a literal.
- ! 0 means \| serves as the "or"-operator, and | is a literal. */
- ! #define RE_NO_BK_VBAR 2
- !
- ! /* 0 means plain + or ? serves as an operator, and \+, \? are literals.
- ! 1 means \+, \? are operators and plain +, ? are literals. */
- ! #define RE_BK_PLUS_QM 4
- !
- ! /* 1 means | binds tighter than ^ or $.
- ! 0 means the contrary. */
- ! #define RE_TIGHT_VBAR 8
- !
- ! /* 1 means treat \n as an _OR operator
- ! 0 means treat it as a normal character */
- ! #define RE_NEWLINE_OR 16
- !
- ! /* 0 means that a special characters (such as *, ^, and $) always have
- ! their special meaning regardless of the surrounding context.
- ! 1 means that special characters may act as normal characters in some
- ! contexts. Specifically, this applies to:
- ! ^ - only special at the beginning, or after ( or |
- ! $ - only special at the end, or before ) or |
- ! *, +, ? - only special when not after the beginning, (, or | */
- ! #define RE_CONTEXT_INDEP_OPS 32
-
- ! /* Now define combinations of bits for the standard possibilities. */
- ! #define RE_SYNTAX_AWK (RE_NO_BK_PARENS | RE_NO_BK_VBAR | RE_CONTEXT_INDEP_OPS)
- ! #define RE_SYNTAX_EGREP (RE_SYNTAX_AWK | RE_NEWLINE_OR)
- #define RE_SYNTAX_GREP (RE_BK_PLUS_QM | RE_NEWLINE_OR)
- #define RE_SYNTAX_EMACS 0
-
- /* The NULL pointer. */
- ! #define NULL 0
-
- /* Number of bits in an unsigned char. */
- #define CHARBITS 8
- --- 89,222 ----
- #define ISALPHA(c) (isascii(c) && isalpha(c))
- #define ISUPPER(c) (isascii(c) && isupper(c))
-
- ! #endif /* not __STDC__ */
-
- !
- ! /* If this bit is set, plain parentheses serve as grouping, and backslash
- parentheses are needed for literal searching.
- ! If not set, backslash-parentheses are grouping, and plain parentheses
- are for literal searching. */
- ! #define RE_NO_BK_PARENS ONE
-
- ! /* If this bit is set, plain | serves as the `or'-operator, and \| is a
- ! literal.
- ! If not set, \| serves as the `or'-operator, and | is a literal. */
- ! #define RE_NO_BK_VBAR (ONE << 1)
- !
- ! /* If this bit is not set, plain + or ? serves as an operator, and \+, \? are
- ! literals.
- ! If set, \+, \? are operators and plain +, ? are literals. */
- ! #define RE_BK_PLUS_QM (ONE << 2)
- !
- ! /* If this bit is set, | binds tighter than ^ or $.
- ! If not set, the contrary. */
- ! #define RE_TIGHT_VBAR (ONE << 3)
- !
- ! /* If this bit is set, then treat newline as an OR operator.
- ! If not set, treat it as a normal character. */
- ! #define RE_NEWLINE_OR (ONE << 4)
- !
- ! /* If this bit is set, then special characters may act as normal
- ! characters in some contexts. Specifically, this applies to:
- ! ^ -- only special at the beginning, or after ( or |;
- ! $ -- only special at the end, or before ) or |;
- ! *, +, ? -- only special when not after the beginning, (, or |.
- ! If this bit is not set, special characters (such as *, ^, and $)
- ! always have their special meaning regardless of the surrounding
- ! context. */
- ! #define RE_CONTEXT_INDEP_OPS (ONE << 5)
- !
- ! /* If this bit is not set, then \ before anything inside [ and ] is taken as
- ! a real \.
- ! If set, then such a \ escapes the following character. This is a
- ! special case for awk. */
- ! #define RE_AWK_CLASS_HACK (ONE << 6)
- !
- ! /* If this bit is set, then \{ and \} or { and } serve as interval operators.
- ! If not set, then \{ and \} and { and } are treated as literals. */
- ! #define RE_INTERVALS (ONE << 7)
- !
- ! /* If this bit is not set, then \{ and \} serve as interval operators and
- ! { and } are literals.
- ! If set, then { and } serve as interval operators and \{ and \} are
- ! literals. */
- ! #define RE_NO_BK_CURLY_BRACES (ONE << 8)
- !
- ! /* If this bit is set, then character classes are supported; they are:
- ! [:alpha:], [:upper:], [:lower:], [:digit:], [:alnum:], [:xdigit:],
- ! [:space:], [:print:], [:punct:], [:graph:], and [:cntrl:].
- ! If not set, then character classes are not supported. */
- ! #define RE_CHAR_CLASSES (ONE << 9)
- !
- ! /* If this bit is set, then the dot re doesn't match a null byte.
- ! If not set, it does. */
- ! #define RE_DOT_NOT_NULL (ONE << 10)
- !
- ! /* If this bit is set, then [^...] doesn't match a newline.
- ! If not set, it does. */
- ! #define RE_HAT_NOT_NEWLINE (ONE << 11)
- !
- ! /* If this bit is set, back references are recognized.
- ! If not set, they aren't. */
- ! #define RE_NO_BK_REFS (ONE << 12)
- !
- ! /* If this bit is set, back references must refer to a preceding
- ! subexpression. If not set, a back reference to a nonexistent
- ! subexpression is treated as literal characters. */
- ! #define RE_NO_EMPTY_BK_REF (ONE << 13)
- !
- ! /* If this bit is set, bracket expressions can't be empty.
- ! If it is set, they can be empty. */
- ! #define RE_NO_EMPTY_BRACKETS (ONE << 14)
- !
- ! /* If this bit is set, then *, +, ? and { cannot be first in an re or
- ! immediately after a |, or a (. Furthermore, a | cannot be first or
- ! last in an re, or immediately follow another | or a (. Also, a ^
- ! cannot appear in a nonleading position and a $ cannot appear in a
- ! nontrailing position (outside of bracket expressions, that is). */
- ! #define RE_CONTEXTUAL_INVALID_OPS (ONE << 15)
- !
- ! /* If this bit is set, then +, ? and | aren't recognized as operators.
- ! If it's not, they are. */
- ! #define RE_LIMITED_OPS (ONE << 16)
- !
- ! /* If this bit is set, then an ending range point has to collate higher
- ! or equal to the starting range point.
- ! If it's not set, then when the ending range point collates higher
- ! than the starting range point, the range is just considered empty. */
- ! #define RE_NO_EMPTY_RANGES (ONE << 17)
- !
- ! /* If this bit is set, then a hyphen (-) can't be an ending range point.
- ! If it isn't, then it can. */
- ! #define RE_NO_HYPHEN_RANGE_END (ONE << 18)
- !
- !
- ! /* Define combinations of bits for the standard possibilities. */
- ! #define RE_SYNTAX_POSIX_AWK (RE_NO_BK_PARENS | RE_NO_BK_VBAR \
- ! | RE_CONTEXT_INDEP_OPS)
- ! #define RE_SYNTAX_AWK (RE_NO_BK_PARENS | RE_NO_BK_VBAR \
- ! | RE_CONTEXT_INDEP_OPS | RE_AWK_CLASS_HACK)
- ! #define RE_SYNTAX_EGREP (RE_NO_BK_PARENS | RE_NO_BK_VBAR \
- ! | RE_CONTEXT_INDEP_OPS | RE_NEWLINE_OR)
- #define RE_SYNTAX_GREP (RE_BK_PLUS_QM | RE_NEWLINE_OR)
- #define RE_SYNTAX_EMACS 0
- + #define RE_SYNTAX_POSIX_BASIC (RE_INTERVALS | RE_BK_PLUS_QM \
- + | RE_CHAR_CLASSES | RE_DOT_NOT_NULL \
- + | RE_HAT_NOT_NEWLINE | RE_NO_EMPTY_BK_REF \
- + | RE_NO_EMPTY_BRACKETS | RE_LIMITED_OPS \
- + | RE_NO_EMPTY_RANGES | RE_NO_HYPHEN_RANGE_END)
- +
- + #define RE_SYNTAX_POSIX_EXTENDED (RE_INTERVALS | RE_NO_BK_CURLY_BRACES \
- + | RE_NO_BK_VBAR | RE_NO_BK_PARENS \
- + | RE_HAT_NOT_NEWLINE | RE_CHAR_CLASSES \
- + | RE_NO_EMPTY_BRACKETS | RE_CONTEXTUAL_INVALID_OPS \
- + | RE_NO_BK_REFS | RE_NO_EMPTY_RANGES \
- + | RE_NO_HYPHEN_RANGE_END)
-
- /* The NULL pointer. */
- ! #ifndef MSDOS
- ! #define NULL 0 /* we have it in stdio.h */
- ! #endif /* not MSDOS */
-
- /* Number of bits in an unsigned char. */
- #define CHARBITS 8
- ***************
- *** 295,301 ****
- class of characters. */
- } _token;
-
- ! #else /* ! __STDC__ */
-
- typedef short _token;
-
- --- 324,330 ----
- class of characters. */
- } _token;
-
- ! #else /* not __STDC__ */
-
- typedef short _token;
-
- ***************
- *** 319,325 ****
- #define _RPAREN (_EMPTY + 16)
- #define _SET (_EMPTY + 17)
-
- ! #endif /* ! __STDC__ */
-
- /* Sets are stored in an array in the compiled regexp; the index of the
- array corresponding to a given set token is given by _SET_INDEX(t). */
- --- 348,354 ----
- #define _RPAREN (_EMPTY + 16)
- #define _SET (_EMPTY + 17)
-
- ! #endif /* not __STDC__ */
-
- /* Sets are stored in an array in the compiled regexp; the index of the
- array corresponding to a given set token is given by _SET_INDEX(t). */
- ***************
- *** 499,505 ****
-
- /* Regsyntax() takes two arguments; the first sets the syntax bits described
- earlier in this file, and the second sets the case-folding flag. */
- ! extern void regsyntax(int, int);
-
- /* Compile the given string of the given length into the given struct regexp.
- Final argument is a flag specifying whether to build a searching or an
- --- 528,534 ----
-
- /* Regsyntax() takes two arguments; the first sets the syntax bits described
- earlier in this file, and the second sets the case-folding flag. */
- ! extern void regsyntax (LONG, int);
-
- /* Compile the given string of the given length into the given struct regexp.
- Final argument is a flag specifying whether to build a searching or an
- ***************
- *** 547,554 ****
- The user can provide a different regfree() if so desired. */
- extern void regerror(const char *);
-
- ! #else /* ! __STDC__ */
- extern void regsyntax(), regcompile(), regfree(), reginit(), regparse();
- extern void reganalyze(), regstate(), regerror();
- extern char *regexecute();
- ! #endif
- --- 576,583 ----
- The user can provide a different regfree() if so desired. */
- extern void regerror(const char *);
-
- ! #else /* not __STDC__ */
- extern void regsyntax(), regcompile(), regfree(), reginit(), regparse();
- extern void reganalyze(), regstate(), regerror();
- extern char *regexecute();
- ! #endif /* not __STDC__ */
- *** e:\tmp/RCSt1006359 Sat Sep 22 22:33:54 1990
- --- grep.c Sat Sep 22 22:26:48 1990
- ***************
- *** 4,109 ****
- BMG speedups added July, 1988
- by James A. Woods and Arthur David Olson
-
- ! NO WARRANTY
-
- ! BECAUSE THIS PROGRAM IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY
- ! NO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW. EXCEPT
- ! WHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC,
- ! RICHARD M. STALLMAN AND/OR OTHER PARTIES PROVIDE THIS PROGRAM "AS IS"
- ! WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
- ! BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- ! FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY
- ! AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE
- ! DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
- ! CORRECTION.
- !
- ! IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M.
- ! STALLMAN, THE FREE SOFTWARE FOUNDATION, INC., AND/OR ANY OTHER PARTY
- ! WHO MAY MODIFY AND REDISTRIBUTE THIS PROGRAM AS PERMITTED BELOW, BE
- ! LIABLE TO YOU FOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR
- ! OTHER SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
- ! USE OR INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR
- ! DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR
- ! A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) THIS
- ! PROGRAM, EVEN IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH
- ! DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY.
- !
- ! GENERAL PUBLIC LICENSE TO COPY
- !
- ! 1. You may copy and distribute verbatim copies of this source file
- ! as you receive it, in any medium, provided that you conspicuously and
- ! appropriately publish on each copy a valid copyright notice "Copyright
- ! (C) 1988 Free Software Foundation, Inc."; and include following the
- ! copyright notice a verbatim copy of the above disclaimer of warranty
- ! and of this License. You may charge a distribution fee for the
- ! physical act of transferring a copy.
- !
- ! 2. You may modify your copy or copies of this source file or
- ! any portion of it, and copy and distribute such modifications under
- ! the terms of Paragraph 1 above, provided that you also do the following:
- !
- ! a) cause the modified files to carry prominent notices stating
- ! that you changed the files and the date of any change; and
- !
- ! b) cause the whole of any work that you distribute or publish,
- ! that in whole or in part contains or is a derivative of this
- ! program or any part thereof, to be licensed at no charge to all
- ! third parties on terms identical to those contained in this
- ! License Agreement (except that you may choose to grant more extensive
- ! warranty protection to some or all third parties, at your option).
- !
- ! c) You may charge a distribution fee for the physical act of
- ! transferring a copy, and you may at your option offer warranty
- ! protection in exchange for a fee.
- !
- ! Mere aggregation of another unrelated program with this program (or its
- ! derivative) on a volume of a storage or distribution medium does not bring
- ! the other program under the scope of these terms.
- !
- ! 3. You may copy and distribute this program or any portion of it in
- ! compiled, executable or object code form under the terms of Paragraphs
- ! 1 and 2 above provided that you do the following:
- !
- ! a) accompany it with the complete corresponding machine-readable
- ! source code, which must be distributed under the terms of
- ! Paragraphs 1 and 2 above; or,
- !
- ! b) accompany it with a written offer, valid for at least three
- ! years, to give any third party free (except for a nominal
- ! shipping charge) a complete machine-readable copy of the
- ! corresponding source code, to be distributed under the terms of
- ! Paragraphs 1 and 2 above; or,
- !
- ! c) accompany it with the information you received as to where the
- ! corresponding source code may be obtained. (This alternative is
- ! allowed only for noncommercial distribution and only if you
- ! received the program in object code or executable form alone.)
- !
- ! For an executable file, complete source code means all the source code for
- ! all modules it contains; but, as a special exception, it need not include
- ! source code for modules which are standard libraries that accompany the
- ! operating system on which the executable file runs.
- !
- ! 4. You may not copy, sublicense, distribute or transfer this program
- ! except as expressly provided under this License Agreement. Any attempt
- ! otherwise to copy, sublicense, distribute or transfer this program is void and
- ! your rights to use the program under this License agreement shall be
- ! automatically terminated. However, parties who have received computer
- ! software programs from you with this License Agreement will not have
- ! their licenses terminated so long as such parties remain in full compliance.
- !
- ! 5. If you wish to incorporate parts of this program into other free
- ! programs whose distribution conditions are different, write to the Free
- ! Software Foundation at 675 Mass Ave, Cambridge, MA 02139. We have not yet
- ! worked out a simple rule that can be stated here, but we will often permit
- ! this. We will be guided by the two goals of preserving the free status of
- ! all derivatives our free software and of promoting the sharing and reuse of
- ! software.
-
- !
- ! In other words, you are welcome to use, share and improve this program.
- ! You are forbidden to forbid anyone else to use, share and improve
- ! what you give them. Help stamp out software-hoarding! */
-
- #include <ctype.h>
- #include <stdio.h>
- --- 4,34 ----
- BMG speedups added July, 1988
- by James A. Woods and Arthur David Olson
-
- ! This program is free software; you can redistribute it and/or modify
- ! it under the terms of the GNU General Public License as published by
- ! the Free Software Foundation; either version 1, or (at your option)
- ! any later version.
-
- ! This program is distributed in the hope that it will be useful,
- ! but WITHOUT ANY WARRANTY; without even the implied warranty of
- ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ! GNU General Public License for more details.
- !
- ! You should have received a copy of the GNU General Public License
- ! along with this program; if not, write to the Free Software
- ! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
- !
- ! /* MS-DOS port (c) 1990 by Thorsten Ohl <td12@ddagsi3.bitnet>
- !
- ! This port is also distributed under the terms of the
- ! GNU General Public License as published by the
- ! Free Software Foundation.
- !
- ! Please note that this file is not identical to the
- ! original GNU release, you should have received this
- ! code as patch to the official release.
-
- ! $Header: e:/gnu/grep/RCS/grep.c 1.5.0.6 90/09/21 11:48:14 tho Exp $ */
-
- #include <ctype.h>
- #include <stdio.h>
- ***************
- *** 117,135 ****
- #include "regex.h"
-
- #ifdef __STDC__
- ! extern getopt(int, char **, const char *);
- ! extern read(int, void *, int);
- ! extern open(const char *, int, ...);
- ! extern void close();
- ! #else
- extern char *strrchr();
- - #endif
-
- - extern char *optarg;
- - extern optind, opterr;
- extern errno;
- extern char *sys_errlist[];
-
- #define MAX(a, b) ((a) > (b) ? (a) : (b))
-
- /* Exit status codes. */
- --- 42,79 ----
- #include "regex.h"
-
- #ifdef __STDC__
- !
- ! #ifdef MSDOS
- ! #include <stdlib.h>
- ! extern getopt (int, char **, const char *);
- ! extern read (int, void *, int);
- ! extern open (const char *, int,...);
- ! extern void close (int fd);
- ! static void initialize_buffer (void);
- ! static int fill_buffer_retaining (int n);
- ! static int print_line (char *p, int number, int matching);
- ! static int grep (void);
- ! extern void usage_and_die (void);
- ! extern void main (int argc, char **argv);
- ! extern void regerror (char const * s);
- ! extern char *execute (struct regexp * r, char *begin, char *end, int newline,
- ! int *count, int *try_backref);
- ! extern char *bmg_search (unsigned char *buffer, int buflen);
- ! extern void bmg_setup (char *pat, int folded);
- ! #endif /* MSDOS */
- !
- ! #else /* not __STDC__ */
- !
- extern char *strrchr();
-
- extern errno;
- extern char *sys_errlist[];
-
- + #endif /* not __STDC__ */
- +
- + extern char *optarg;
- + extern optind, opterr;
- +
- #define MAX(a, b) ((a) > (b) ? (a) : (b))
-
- /* Exit status codes. */
- ***************
- *** 542,549 ****
- --- 486,499 ----
- exit(ERROR);
- }
-
- + #ifndef MSDOS
- static char version[] = "GNU e?grep, version 1.5";
- + #else /* MSDOS */
- + static char version[] =
- + "GNU e?grep, version 1.5 (compiled " __DATE__ " " __TIME__ " for MS-DOS)";
-
- + void
- + #endif /* MSDOS */
- main(argc, argv)
- int argc;
- char **argv;
- ***************
- *** 954,959 ****
- --- 904,912 ----
- return(NULL);
- }
-
- + #ifdef MSDOS
- + void
- + #endif
- bmg_setup(pat, folded) /* compute "boyer-moore" delta table */
- char *pat;
- int folded;
- ***************
- *** 1015,1047 ****
- return bcopy(s, d, n);
- }
-
- ! #else
- !
- ! char *
- ! index(s, c)
- ! char *s;
- ! {
- ! return strchr(s, c);
- ! }
- !
- ! char *
- ! bcopy(s, d, n)
- ! char *s, *d;
- ! {
- ! return memcpy(d, s, n);
- ! }
- !
- ! char *
- ! bzero(s, n)
- ! char *s;
- ! {
- ! return memset(s, 0, n);
- ! }
- !
- ! bcmp(s, t, n)
- ! char *s, *t;
- ! {
- ! return memcmp(s, t, n);
- ! }
- !
- ! #endif
- --- 968,971 ----
- return bcopy(s, d, n);
- }
-
- ! #endif /* not USG */
-