diff options
author | Zack Weinberg <zack@wolery.cumb.org> | 2000-01-20 18:25:12 +0000 |
---|---|---|
committer | Zack Weinberg <zack@gcc.gnu.org> | 2000-01-20 18:25:12 +0000 |
commit | 52c207e293ff4337278208ed3638e3b5be78ae63 (patch) | |
tree | 088b6ad9fd2e111425c3ac61d68bf0b55e82c712 /gcc/fixinc/gnu-regex.c | |
parent | d3de1cf7f0f0e2c98460a3fb50b2aee18ddbdc51 (diff) | |
download | gcc-52c207e293ff4337278208ed3638e3b5be78ae63.zip gcc-52c207e293ff4337278208ed3638e3b5be78ae63.tar.gz gcc-52c207e293ff4337278208ed3638e3b5be78ae63.tar.bz2 |
Makefile.in (fixinc.sh): Depend on specs.
* Makefile.in (fixinc.sh): Depend on specs.
* fixinc/Makefile.in: Add rule to create machname.h.
(fixlib.o): Depend on machname.h.
* fixinc/fixtests.c (machine_name): New test.
* fixinc/fixfixes.c (machine_name): New fix.
* fixinc/fixlib.c (mn_get_regexps): New helper function for
the machine_name test and fix.
* fixinc/fixlib.h: Prototype it.
* fixinc/inclhack.def (machine_name): Use the C test and fix.
* fixinc/fixincl.x, fixinc/inclhack.sh: Rebuild.
* gcc.c (do_spec_1) [case P]: Take care not to create
identifiers with three leading or trailing underscores.
* fixinc/Makefile.in (FIXINC_DEFS): Add -DIN_GCC.
(fixincl): Don't specify libraries twice on link line.
(gnu-regex.o): Remove special rule.
* fixinc/gnu-regex.c: Define REGEX_MALLOC if C_ALLOCA was
defined by config.h. Do not define _REGEX_RE_COMP.
(regcomp): Allocate and initialize a fastmap.
* fixinc/gnu-regex.h: Do not define _REGEX_RE_COMP.
From-SVN: r31542
Diffstat (limited to 'gcc/fixinc/gnu-regex.c')
-rw-r--r-- | gcc/fixinc/gnu-regex.c | 43 |
1 files changed, 27 insertions, 16 deletions
diff --git a/gcc/fixinc/gnu-regex.c b/gcc/fixinc/gnu-regex.c index b24845b..007aec1 100644 --- a/gcc/fixinc/gnu-regex.c +++ b/gcc/fixinc/gnu-regex.c @@ -21,11 +21,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* AIX requires this to be the first thing in the file. */ -#if defined _AIX && !defined REGEX_MALLOC - #pragma alloca -#endif - #undef _GNU_SOURCE #define _GNU_SOURCE @@ -33,6 +28,16 @@ # include <config.h> #endif +/* Do not use a C alloca, we will leak memory and crash. */ +#ifdef C_ALLOCA +# define REGEX_MALLOC +#endif + +/* AIX requires this to be the first thing in the file. */ +#if defined _AIX && !defined REGEX_MALLOC + #pragma alloca +#endif + #ifndef PARAMS # if defined __GNUC__ || (defined __STDC__ && __STDC__) # define PARAMS(args) args @@ -153,11 +158,6 @@ char *realloc (); /* How many characters in the character set. */ # define CHAR_SET_SIZE 256 -/* GDB LOCAL: define _REGEX_RE_COMP to get BSD style re_comp and re_exec */ -#ifndef _REGEX_RE_COMP -#define _REGEX_RE_COMP -#endif - # ifdef SYNTAX_TABLE extern char *re_syntax_table; @@ -5561,7 +5561,8 @@ re_exec (s) REG_EXTENDED bit in CFLAGS is set; otherwise, to RE_SYNTAX_POSIX_BASIC; `newline_anchor' to REG_NEWLINE being set in CFLAGS; - `fastmap' and `fastmap_accurate' to zero; + `fastmap' to an allocated space for the fastmap; + `fastmap_accurate' to 1; `re_nsub' to the number of subexpressions in PATTERN. PATTERN is the address of the pattern string. @@ -5600,11 +5601,8 @@ regcomp (preg, pattern, cflags) preg->allocated = 0; preg->used = 0; - /* Don't bother to use a fastmap when searching. This simplifies the - REG_NEWLINE case: if we used a fastmap, we'd have to put all the - characters after newlines into the fastmap. This way, we just try - every character. */ - preg->fastmap = 0; + /* Try to allocate space for the fastmap. */ + preg->fastmap = (char *) malloc (1 << BYTEWIDTH); if (cflags & REG_ICASE) { @@ -5644,6 +5642,19 @@ regcomp (preg, pattern, cflags) unmatched close-group: both are REG_EPAREN. */ if (ret == REG_ERPAREN) ret = REG_EPAREN; + if (ret == REG_NOERROR && preg->fastmap) + { + /* Compute the fastmap now, since regexec cannot modify the pattern + buffer. */ + if (re_compile_fastmap (preg) == -2) + { + /* Some error occured while computing the fastmap, just forget + about it. */ + free (preg->fastmap); + preg->fastmap = NULL; + } + } + return (int) ret; } #ifdef _LIBC |