diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2005-05-21 10:33:49 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2005-05-21 10:33:49 +0000 |
commit | f4d2977359da3a163579c9d9328a71d132bc62b0 (patch) | |
tree | 4eb19072c4a9a271a8f6090b11b14c3ab3775de2 /usr.bin/m4 | |
parent | 8ad0546695ba54da94ce849b6f89d154205f7397 (diff) |
more heuristics to coerce gnu-m4 mode to work like we wish: if a ^ or $
is seen in the regexp, this means we need to take new lines into account.
Otherwise, we don't.
Diffstat (limited to 'usr.bin/m4')
-rw-r--r-- | usr.bin/m4/gnum4.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/usr.bin/m4/gnum4.c b/usr.bin/m4/gnum4.c index e91f1fa5b20..190b2533172 100644 --- a/usr.bin/m4/gnum4.c +++ b/usr.bin/m4/gnum4.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gnum4.c,v 1.29 2005/05/17 20:33:26 espie Exp $ */ +/* $OpenBSD: gnum4.c,v 1.30 2005/05/21 10:33:48 espie Exp $ */ /* * Copyright (c) 1999 Marc Espie @@ -457,9 +457,16 @@ dopatsubst(const char *argv[], int argc) int error; regex_t re; regmatch_t *pmatch; + int mode = REG_EXTENDED; + size_t l = strlen(argv[3]); + + if (!mimic_gnu || + (argv[3][0] == '^') || + (l > 0 && argv[3][l-1] == '$')) + mode |= REG_NEWLINE; error = regcomp(&re, mimic_gnu ? twiddle(argv[3]) : argv[3], - mimic_gnu ? REG_EXTENDED : REG_NEWLINE | REG_EXTENDED); + mode); if (error != 0) exit_regerror(error, &re); |