summaryrefslogtreecommitdiffstats
path: root/lib/libc/regex/regcomp.c
diff options
context:
space:
mode:
authortedu <tedu@openbsd.org>2014-09-08 15:45:20 +0000
committertedu <tedu@openbsd.org>2014-09-08 15:45:20 +0000
commit3e0ebe0f9c4548d57b9b2f4a35824ddf95dfe79b (patch)
tree2a2a4bb622bc3a23813a8f013711aaff1f05d0d0 /lib/libc/regex/regcomp.c
parentAdd window_last_flag and window_zoomed_flag. From John Morrissey. (diff)
downloadwireguard-openbsd-3e0ebe0f9c4548d57b9b2f4a35824ddf95dfe79b.tar.xz
wireguard-openbsd-3e0ebe0f9c4548d57b9b2f4a35824ddf95dfe79b.zip
add \<word\> support to regcomp. prompted by renewed interest from jsg
because such support is reportedly common and in somewhat wide use. undocumented for now because we don't endorse this. ok jsg millert
Diffstat (limited to 'lib/libc/regex/regcomp.c')
-rw-r--r--lib/libc/regex/regcomp.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/lib/libc/regex/regcomp.c b/lib/libc/regex/regcomp.c
index d49b921302d..d52febf337d 100644
--- a/lib/libc/regex/regcomp.c
+++ b/lib/libc/regex/regcomp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: regcomp.c,v 1.24 2014/05/06 15:48:38 tedu Exp $ */
+/* $OpenBSD: regcomp.c,v 1.25 2014/09/08 15:45:20 tedu Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994 Henry Spencer.
* Copyright (c) 1992, 1993, 1994
@@ -81,6 +81,7 @@ static char p_b_coll_elem(struct parse *, int);
static char othercase(int);
static void bothcases(struct parse *, int);
static void ordinary(struct parse *, int);
+static void backslash(struct parse *, int);
static void nonnewline(struct parse *);
static void repeat(struct parse *, sopno, int, int);
static int seterr(struct parse *, int);
@@ -349,7 +350,7 @@ p_ere_exp(struct parse *p)
case '\\':
REQUIRE(MORE(), REG_EESCAPE);
c = GETNEXT();
- ordinary(p, c);
+ backslash(p, c);
break;
case '{': /* okay as ordinary except if digit follows */
REQUIRE(!MORE() || !isdigit((uch)PEEK()), REG_BADRPT);
@@ -501,6 +502,12 @@ p_simp_re(struct parse *p,
case '[':
p_bracket(p);
break;
+ case BACKSL|'<':
+ EMIT(OBOW, 0);
+ break;
+ case BACKSL|'>':
+ EMIT(OEOW, 0);
+ break;
case BACKSL|'{':
SETERROR(REG_BADRPT);
break;
@@ -896,6 +903,25 @@ ordinary(struct parse *p, int ch)
}
/*
+ * do something magic with this character, but only if it's extra magic
+ */
+static void
+backslash(struct parse *p, int ch)
+{
+ switch (ch) {
+ case '<':
+ EMIT(OBOW, 0);
+ break;
+ case '>':
+ EMIT(OEOW, 0);
+ break;
+ default:
+ ordinary(p, ch);
+ break;
+ }
+}
+
+/*
- nonnewline - emit REG_NEWLINE version of OANY
*
* Boy, is this implementation ever a kludge...