diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2001-09-28 00:46:03 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2001-09-28 00:46:03 +0000 |
commit | 729be02b6710288385051ce0df83204172b85814 (patch) | |
tree | 2e505417cfa3514e1e58fff104b8372c1a16e95e /usr.bin | |
parent | 5d3a868b2e1f2eb3950c0a03b757633193b0a717 (diff) |
more emacs regexps in -g mode. Ok millert@
With this, some autoconf 2.52 scripts are now working completely.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/m4/gnum4.c | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/usr.bin/m4/gnum4.c b/usr.bin/m4/gnum4.c index abcc5e3179a..edaca999413 100644 --- a/usr.bin/m4/gnum4.c +++ b/usr.bin/m4/gnum4.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gnum4.c,v 1.13 2001/09/27 12:35:20 espie Exp $ */ +/* $OpenBSD: gnum4.c,v 1.14 2001/09/28 00:46:02 espie Exp $ */ /* * Copyright (c) 1999 Marc Espie @@ -207,6 +207,7 @@ static void do_regexpindex __P((const char *, regex_t *, regmatch_t *)); static void do_regexp __P((const char *, regex_t *, const char *, regmatch_t *)); static void add_sub __P((int, const char *, regex_t *, regmatch_t *)); static void add_replace __P((const char *, regex_t *, const char *, regmatch_t *)); +#define addconstantstring(s) addchars((s), sizeof(s)-1) static void addchars(c, n) @@ -419,12 +420,33 @@ twiddle(p) { /* This could use strcspn for speed... */ while (*p != '\0') { - if (*p == '\\' && (p[1] == '(' || p[1] == ')')) { - addchar(p[1]); + if (*p == '\\') { + switch(p[1]) { + case '(': + case ')': + case '|': + addchar(p[1]); + break; + case 'w': + addconstantstring("[_a-zA-Z0-9]"); + break; + case 'W': + addconstantstring("[^_a-zA-Z0-9]"); + break; + case '<': + addconstantstring("[[:<:]]"); + break; + case '>': + addconstantstring("[[:>:]]"); + break; + default: + addchars(p, 2); + break; + } p+=2; continue; } - if (*p == '(' || *p == ')') + if (*p == '(' || *p == ')' || *p == '|') addchar('\\'); addchar(*p); |