diff options
Diffstat (limited to 'lib/libc/regex')
-rw-r--r-- | lib/libc/regex/COPYRIGHT | 2 | ||||
-rw-r--r-- | lib/libc/regex/Makefile.inc | 3 | ||||
-rw-r--r-- | lib/libc/regex/Symbol.map | 4 | ||||
-rw-r--r-- | lib/libc/regex/WHATSNEW | 1 | ||||
-rw-r--r-- | lib/libc/regex/cname.h | 3 | ||||
-rw-r--r-- | lib/libc/regex/engine.c | 5 | ||||
-rw-r--r-- | lib/libc/regex/grot/Makefile | 1 | ||||
-rw-r--r-- | lib/libc/regex/grot/debug.c | 3 | ||||
-rw-r--r-- | lib/libc/regex/grot/main.c | 3 | ||||
-rwxr-xr-x | lib/libc/regex/grot/mkh | 1 | ||||
-rw-r--r-- | lib/libc/regex/grot/split.c | 3 | ||||
-rw-r--r-- | lib/libc/regex/grot/tests | 1 | ||||
-rw-r--r-- | lib/libc/regex/re_format.7 | 3 | ||||
-rw-r--r-- | lib/libc/regex/regcomp.c | 65 | ||||
-rw-r--r-- | lib/libc/regex/regerror.c | 8 | ||||
-rw-r--r-- | lib/libc/regex/regex.3 | 3 | ||||
-rw-r--r-- | lib/libc/regex/regex2.h | 3 | ||||
-rw-r--r-- | lib/libc/regex/regexec.c | 8 | ||||
-rw-r--r-- | lib/libc/regex/regfree.c | 8 | ||||
-rw-r--r-- | lib/libc/regex/utils.h | 3 |
20 files changed, 45 insertions, 86 deletions
diff --git a/lib/libc/regex/COPYRIGHT b/lib/libc/regex/COPYRIGHT index 574f6bcec6c7..9f3893e48f98 100644 --- a/lib/libc/regex/COPYRIGHT +++ b/lib/libc/regex/COPYRIGHT @@ -51,6 +51,4 @@ to the following restrictions: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)COPYRIGHT 8.1 (Berkeley) 3/16/94 */ diff --git a/lib/libc/regex/Makefile.inc b/lib/libc/regex/Makefile.inc index 19c2ffcee5ab..89468f1317f6 100644 --- a/lib/libc/regex/Makefile.inc +++ b/lib/libc/regex/Makefile.inc @@ -1,6 +1,3 @@ -# from @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 -# $FreeBSD$ - # regex sources .PATH: ${LIBC_SRCTOP}/regex diff --git a/lib/libc/regex/Symbol.map b/lib/libc/regex/Symbol.map index 1da7b81ba11b..436398f639c7 100644 --- a/lib/libc/regex/Symbol.map +++ b/lib/libc/regex/Symbol.map @@ -1,7 +1,3 @@ -/* - * $FreeBSD$ - */ - FBSD_1.0 { regerror; regexec; diff --git a/lib/libc/regex/WHATSNEW b/lib/libc/regex/WHATSNEW index f4301d300dd3..0bd305c32cb9 100644 --- a/lib/libc/regex/WHATSNEW +++ b/lib/libc/regex/WHATSNEW @@ -1,4 +1,3 @@ -# @(#)WHATSNEW 8.3 (Berkeley) 3/18/94 New in alpha3.4: The complex bug alluded to below has been fixed (in a slightly kludgey temporary way that may hurt efficiency a bit; this is diff --git a/lib/libc/regex/cname.h b/lib/libc/regex/cname.h index 3419181aac97..e1b76d36e589 100644 --- a/lib/libc/regex/cname.h +++ b/lib/libc/regex/cname.h @@ -31,9 +31,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)cname.h 8.3 (Berkeley) 3/20/94 - * $FreeBSD$ */ /* character-name table */ diff --git a/lib/libc/regex/engine.c b/lib/libc/regex/engine.c index bb40018c07e1..9e1935dc4d4a 100644 --- a/lib/libc/regex/engine.c +++ b/lib/libc/regex/engine.c @@ -31,13 +31,8 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)engine.c 8.5 (Berkeley) 3/20/94 */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <stdbool.h> /* diff --git a/lib/libc/regex/grot/Makefile b/lib/libc/regex/grot/Makefile index d0123883cd2e..ec6a1b48b1e7 100644 --- a/lib/libc/regex/grot/Makefile +++ b/lib/libc/regex/grot/Makefile @@ -1,4 +1,3 @@ -# $FreeBSD$ # You probably want to take -DREDEBUG out of CFLAGS, and put something like # -O in, *after* testing (-DREDEBUG strengthens testing by enabling a lot of # internal assertion checking). Take -Dconst= out for an ANSI compiler. diff --git a/lib/libc/regex/grot/debug.c b/lib/libc/regex/grot/debug.c index af8e4f5a1d72..f5984366f3c6 100644 --- a/lib/libc/regex/grot/debug.c +++ b/lib/libc/regex/grot/debug.c @@ -1,6 +1,3 @@ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <stdio.h> #include <string.h> #include <ctype.h> diff --git a/lib/libc/regex/grot/main.c b/lib/libc/regex/grot/main.c index eee541bac171..e9d57c84e6f4 100644 --- a/lib/libc/regex/grot/main.c +++ b/lib/libc/regex/grot/main.c @@ -1,6 +1,3 @@ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/types.h> #include <assert.h> #include <regex.h> diff --git a/lib/libc/regex/grot/mkh b/lib/libc/regex/grot/mkh index 1deba7983d5c..252b246c7bd2 100755 --- a/lib/libc/regex/grot/mkh +++ b/lib/libc/regex/grot/mkh @@ -1,6 +1,5 @@ #! /bin/sh # mkh - pull headers out of C source -# $FreeBSD$ PATH=/bin:/usr/bin ; export PATH # egrep pattern to pick out marked lines diff --git a/lib/libc/regex/grot/split.c b/lib/libc/regex/grot/split.c index c5d5264ab711..37d593e5eb4f 100644 --- a/lib/libc/regex/grot/split.c +++ b/lib/libc/regex/grot/split.c @@ -1,6 +1,3 @@ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <stdio.h> #include <string.h> diff --git a/lib/libc/regex/grot/tests b/lib/libc/regex/grot/tests index 050e7b25ab14..7bd81706bed4 100644 --- a/lib/libc/regex/grot/tests +++ b/lib/libc/regex/grot/tests @@ -1,5 +1,4 @@ # regular expression test set -# $FreeBSD$ # Lines are at least three fields, separated by one or more tabs. "" stands # for an empty field. First field is an RE. Second field is flags. If # C flag given, regcomp() is expected to fail, and the third field is the diff --git a/lib/libc/regex/re_format.7 b/lib/libc/regex/re_format.7 index 8380fd89e222..ed8572b17e62 100644 --- a/lib/libc/regex/re_format.7 +++ b/lib/libc/regex/re_format.7 @@ -33,9 +33,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)re_format.7 8.3 (Berkeley) 3/20/94 -.\" $FreeBSD$ -.\" .Dd June 30, 2014 .Dt RE_FORMAT 7 .Os diff --git a/lib/libc/regex/regcomp.c b/lib/libc/regex/regcomp.c index 970a448b649a..f34dc322d0bb 100644 --- a/lib/libc/regex/regcomp.c +++ b/lib/libc/regex/regcomp.c @@ -6,7 +6,7 @@ * The Regents of the University of California. All rights reserved. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -36,16 +36,8 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)regcomp.c 8.5 (Berkeley) 3/20/94 */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)regcomp.c 8.5 (Berkeley) 3/20/94"; -#endif /* LIBC_SCCS and not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/types.h> #include <stdio.h> #include <string.h> @@ -329,7 +321,7 @@ regcomp_internal(regex_t * __restrict preg, computejumps(p, g); computematchjumps(p, g); if(g->matchjump == NULL && g->charjump != NULL) { - free(g->charjump); + free(&g->charjump[CHAR_MIN]); g->charjump = NULL; } } @@ -461,7 +453,9 @@ p_ere_exp(struct parse *p, struct branchc *bc) case '*': case '+': case '?': +#ifndef NO_STRICT_REGEX case '{': +#endif SETERROR(REG_BADRPT); break; case '.': @@ -544,6 +538,11 @@ p_ere_exp(struct parse *p, struct branchc *bc) break; } break; +#ifdef NO_STRICT_REGEX + case '{': /* okay as ordinary except if digit follows */ + (void)REQUIRE(!MORE() || !isdigit((uch)PEEK()), REG_BADRPT); + /* FALLTHROUGH */ +#endif default: if (p->error != 0) return (false); @@ -557,11 +556,19 @@ p_ere_exp(struct parse *p, struct branchc *bc) return (false); c = PEEK(); /* we call { a repetition if followed by a digit */ - if (!( c == '*' || c == '+' || c == '?' || c == '{')) + if (!( c == '*' || c == '+' || c == '?' || +#ifdef NO_STRICT_REGEX + (c == '{' && MORE2() && isdigit((uch)PEEK2())) +#else + c == '{' +#endif + )) return (false); /* no repetition, we're done */ +#ifndef NO_STRICT_REGEX else if (c == '{') (void)REQUIRE(MORE2() && \ (isdigit((uch)PEEK2()) || PEEK2() == ','), REG_BADRPT); +#endif NEXT(); (void)REQUIRE(!wascaret, REG_BADRPT); @@ -830,10 +837,10 @@ p_simp_re(struct parse *p, struct branchc *bc) handled = false; assert(MORE()); /* caller should have ensured this */ - c = GETNEXT(); + c = (uch)GETNEXT(); if (c == '\\') { (void)REQUIRE(MORE(), REG_EESCAPE); - cc = GETNEXT(); + cc = (uch)GETNEXT(); c = BACKSL | cc; #ifdef LIBREGEX if (p->gnuext) { @@ -900,6 +907,9 @@ p_simp_re(struct parse *p, struct branchc *bc) (void)REQUIRE(EATTWO('\\', ')'), REG_EPAREN); break; case BACKSL|')': /* should not get here -- must be user */ +#ifdef NO_STRICT_REGEX + case BACKSL|'}': +#endif SETERROR(REG_EPAREN); break; case BACKSL|'1': @@ -994,7 +1004,7 @@ p_count(struct parse *p) int ndigits = 0; while (MORE() && isdigit((uch)PEEK()) && count <= DUPMAX) { - count = count*10 + (GETNEXT() - '0'); + count = count*10 + ((uch)GETNEXT() - '0'); ndigits++; } @@ -1304,7 +1314,7 @@ may_escape(struct parse *p, const wint_t ch) if ((p->pflags & PFLAG_LEGACY_ESC) != 0) return (true); - if (isalpha(ch) || ch == '\'' || ch == '`') + if (iswalpha(ch) || ch == '\'' || ch == '`') return (false); return (true); #ifdef NOTYET @@ -1594,17 +1604,32 @@ singleton(cset *cs) { wint_t i, s, n; + /* Exclude the complicated cases we don't want to deal with */ + if (cs->nranges != 0 || cs->ntypes != 0 || cs->icase != 0) + return (OUT); + + if (cs->nwides > 1) + return (OUT); + + /* Count the number of characters present in the bitmap */ for (i = n = 0; i < NC; i++) if (CHIN(cs, i)) { n++; s = i; } - if (n == 1) - return (s); - if (cs->nwides == 1 && cs->nranges == 0 && cs->ntypes == 0 && - cs->icase == 0) + + if (n > 1) + return (OUT); + + if (n == 1) { + if (cs->nwides == 0) + return (s); + else + return (OUT); + } + if (cs->nwides == 1) return (cs->wides[0]); - /* Don't bother handling the other cases. */ + return (OUT); } diff --git a/lib/libc/regex/regerror.c b/lib/libc/regex/regerror.c index 0e555784f0dc..b21e7ac3517b 100644 --- a/lib/libc/regex/regerror.c +++ b/lib/libc/regex/regerror.c @@ -31,16 +31,8 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)regerror.c 8.4 (Berkeley) 3/20/94 */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)regerror.c 8.4 (Berkeley) 3/20/94"; -#endif /* LIBC_SCCS and not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/types.h> #include <stdio.h> #include <string.h> diff --git a/lib/libc/regex/regex.3 b/lib/libc/regex/regex.3 index d22dec1e87f7..3c9fb4da4185 100644 --- a/lib/libc/regex/regex.3 +++ b/lib/libc/regex/regex.3 @@ -29,9 +29,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)regex.3 8.4 (Berkeley) 3/20/94 -.\" $FreeBSD$ -.\" .Dd April 15, 2017 .Dt REGEX 3 .Os diff --git a/lib/libc/regex/regex2.h b/lib/libc/regex/regex2.h index 38bbed90fd8f..f5854d916a2c 100644 --- a/lib/libc/regex/regex2.h +++ b/lib/libc/regex/regex2.h @@ -31,9 +31,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)regex2.h 8.4 (Berkeley) 3/20/94 - * $FreeBSD$ */ /* diff --git a/lib/libc/regex/regexec.c b/lib/libc/regex/regexec.c index d7aa46f45b2b..784e596d5f8a 100644 --- a/lib/libc/regex/regexec.c +++ b/lib/libc/regex/regexec.c @@ -31,16 +31,8 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)regexec.c 8.3 (Berkeley) 3/20/94 */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)regexec.c 8.3 (Berkeley) 3/20/94"; -#endif /* LIBC_SCCS and not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * the outer shell of regexec() * diff --git a/lib/libc/regex/regfree.c b/lib/libc/regex/regfree.c index 859c2a4b37b2..e87314772a6c 100644 --- a/lib/libc/regex/regfree.c +++ b/lib/libc/regex/regfree.c @@ -31,16 +31,8 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)regfree.c 8.3 (Berkeley) 3/20/94 */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)regfree.c 8.3 (Berkeley) 3/20/94"; -#endif /* LIBC_SCCS and not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/types.h> #include <stdio.h> #include <stdlib.h> diff --git a/lib/libc/regex/utils.h b/lib/libc/regex/utils.h index 72f2286a0260..611decbb3b38 100644 --- a/lib/libc/regex/utils.h +++ b/lib/libc/regex/utils.h @@ -31,9 +31,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)utils.h 8.3 (Berkeley) 3/20/94 - * $FreeBSD$ */ /* utility definitions */ |