summaryrefslogtreecommitdiff
path: root/sed
diff options
context:
space:
mode:
authorJim Meyering <meyering@fb.com>2014-09-04 20:52:12 -0700
committerJim Meyering <meyering@fb.com>2014-09-06 09:21:05 -0700
commit643f692bc7b02086e91c2afd12bf9ac8b40b6fe4 (patch)
tree5f47bfeef407e51a8d8d6ca0100f2616b09ec174 /sed
parente146d2a52d4a527a11a79d9b46551fbd9fdca62b (diff)
downloadsed-643f692bc7b02086e91c2afd12bf9ac8b40b6fe4.tar.gz
fix "y" to work with NUL in the RHS
* sed/execute.c (do_list) [case 'y']: Handle NUL bytes in the RHS of a y/LHS/RHS/ transliteration. * testsuite/y-zero.good: New test-related files. * testsuite/y-zero.inp: * testsuite/y-zero.sed: * testsuite/Makefile.am (SEDTESTS): Add y-zero here. * testsuite/Makefile.tests: And here. * NEWS (Bug fixes): Describe it. The bug was reported by table@inventati.org, with the execute.c change mostly by Paolo Bonzini.
Diffstat (limited to 'sed')
-rw-r--r--sed/execute.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/sed/execute.c b/sed/execute.c
index cb84192..2e13ee2 100644
--- a/sed/execute.c
+++ b/sed/execute.c
@@ -1567,7 +1567,8 @@ execute_program(vec, input)
if (strncmp(line.active + idx, trans[2*i], mbclen) == 0)
{
bool move_remain_buffer = false;
- int trans_len = strlen(trans[2*i+1]);
+ const char *tr = trans[2*i+1];
+ size_t trans_len = *tr == '\0' ? 1 : strlen (tr);
if (mbclen < trans_len)
{