From 643f692bc7b02086e91c2afd12bf9ac8b40b6fe4 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Thu, 4 Sep 2014 20:52:12 -0700 Subject: 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. --- sed/execute.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sed') 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) { -- cgit v1.2.1