summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorNorihiro Tanaka <noritnk@kcn.ne.jp>2016-10-06 08:14:10 +0900
committerAssaf Gordon <assafgordon@gmail.com>2016-11-04 21:03:46 -0400
commit7c5b3bed65dd5f4399b35aeffc7152534a29c5d2 (patch)
tree912bcc99924aeda2b351e94165f9c51327627f76 /m4
parent6dea75e7084eabdd15d8fbbbe05d870eddc98370 (diff)
downloadsed-7c5b3bed65dd5f4399b35aeffc7152534a29c5d2.tar.gz
sed: fix multi-line regex matching with -z
Sed incorrectly matches the anchor '^' to a newline character (ASCII 10) despite using NUL line terminators (-z). See https://bugs.gnu.org/24615 . Previous (incorrect) behavior: $ printf "a\0b\0" | sed -z 'N;s/^/X/mg;' | od -An -a X a nul b nul With this fix: $ printf "a\0b\0" | sed -z 'N;s/^/X/mg;' | od -An -a X a nul X b nul Current regex engine can not handle NUL multiline anchors. Implement such search manually (by breaking the pattern into separate NUL-terminated lines) and searching each one individually. * NEWS: Mention it. * sed/regexp.c (compile_regex_1): Don't use newline_anchor of regex, if the buffer delimiter is not newline character. (match_regex): Do above case line-by-line. * testsuite/zero-anchor.good, testsuite/zero-anchor.inp, testsuite/zero-anchor.sed: New test. * testsuite/local.mk: Add the test. * testsuite/Makefile.tests: Add the test. * bootstrap.conf: Add memrchr. * lib/.gitignore, m4/.gitignore: Ignore memrchr files.
Diffstat (limited to 'm4')
-rw-r--r--m4/.gitignore1
1 files changed, 1 insertions, 0 deletions
diff --git a/m4/.gitignore b/m4/.gitignore
index 20ee276..492f9bb 100644
--- a/m4/.gitignore
+++ b/m4/.gitignore
@@ -223,3 +223,4 @@ xstrndup.m4
/getprogname.m4
/isblank.m4
/limits-h.m4
+/memrchr.m4