diff options
author | 2005-05-21 10:33:48 +0000 | |
---|---|---|
committer | 2005-05-21 10:33:48 +0000 | |
commit | bac1930d48ffd723dff815bec214ed274abedd2c (patch) | |
tree | 601913bd3e6b3488516b8eb111fbc6df22b1c7d2 | |
parent | put whole cache info on one line; w/ mods from drahn@; ok drahn@ (diff) | |
download | wireguard-openbsd-bac1930d48ffd723dff815bec214ed274abedd2c.tar.xz wireguard-openbsd-bac1930d48ffd723dff815bec214ed274abedd2c.zip |
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.
-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); |