Re: sed bug: ASCII NUL doesn't work on the rhs of y// commands
Jim Meyering <[email protected]>
| Newsgroups | gmane.comp.gnu.utils.bugs |
|---|---|
| Message-ID | <CA+8g5KHgTctfsrAVaTzKK0aFR7RKUWRJx1rS_7pgW5UAqWj97g@mail.gmail.com> |
On Fri, Sep 5, 2014 at 10:41 PM, Jim Meyering <[email protected]> wrote: > On Wed, Sep 3, 2014 at 4:19 AM, Paolo Bonzini <[email protected]> wrote: >> Il 03/09/2014 03:09, [email protected] ha scritto: >>> Hi, >>> >>> The subject pretty much says it all for this bug. Compare the output of >>> "echo abc | sed -e 's/b/\x00/' | hexdump -c" and "echo abc | sed -e >>> 'y/b/\x00/' | hexdump -c". The s command behaves correctly (as I would >>> expect, it replaces the 'b' with a NUL character), while the y command >>> fails to output anything when it should print NUL, resulting in an >>> output file shorter than the input was. >> >> Looks like the bug was introduced when "y" was extended to support >> multibyte characters. The minimal patch should be to change >> >> int trans_len = strlen(trans[2*i+1]); >> >> to >> >> char *trans = trans[2*i+1]; >> int trans_len = *trans == '\0' ? 1 : strlen(trans); >> >> in sed/execute.c > > Hi Paolo, > Thanks for the suggestion. > Here's a complete patch (can't reuse the name > "trans" that way, and I prefer to s/int/size_t/). > I expect to find the precise commit that introduced > the bug, adjust the log and NEWS, > and then push tomorrow. I updated NEWS, but didn't take the time to find the precise commit. I was surprised to see there is only one git tag. I've also pushed the following to fix the trivial "version" test failure:
0001-maint-correct-failing-version-test.patch
(application/octet-stream, 2.1 KB)
From be11175d493cf735420774b09705a31275325950 Mon Sep 17 00:00:00 2001 From: Jim Meyering <[email protected]> Date: Sat, 6 Sep 2014 09:24:23 -0700 Subject: [PATCH] maint: correct failing "version" test * configure.ac (COPYRIGHT_YEAR): Update to 2014, so the "version" test passes once again. * doc/sed.1: Also commit this auto-generated-yet-VC'd file. --- ChangeLog | 7 +++++++ configure.ac | 2 +- doc/sed.1 | 4 ++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index c90b83c..8bf8843 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2014-09-06 Jim Meyering <[email protected]> + + maint: correct failing "version" test + * configure.ac (COPYRIGHT_YEAR): Update to 2014, so + the "version" test passes once again. + * doc/sed.1: Also commit this auto-generated-yet-VC'd file. + 2014-09-04 Jim Meyering <[email protected]> fix "y" to work with NUL in the RHS diff --git a/configure.ac b/configure.ac index e3558b2..d838514 100644 --- a/configure.ac +++ b/configure.ac @@ -11,7 +11,7 @@ AC_DEFINE_UNQUOTED(SED_FEATURE_VERSION, "$SED_FEATURE_VERSION", [Define to the version of GNU sed whose features are supported by this sed.]) AC_SUBST(SED_FEATURE_VERSION) -COPYRIGHT_YEAR=2013 +COPYRIGHT_YEAR=2014 AC_SUBST(COPYRIGHT_YEAR) AC_PROG_CC diff --git a/doc/sed.1 b/doc/sed.1 index 2f02e64..c80f961 100644 --- a/doc/sed.1 +++ b/doc/sed.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.28. -.TH SED "1" "October 2013" "sed 4.2.2" "User Commands" +.TH SED "1" "September 2014" "sed 4.2.2" "User Commands" .SH NAME sed \- stream editor for filtering and transforming text .SH SYNOPSIS @@ -385,7 +385,7 @@ General help using GNU software: <http://www.gnu.org/gethelp/>. E-mail bug reports to: <[email protected]>. Be sure to include the word ``sed'' somewhere in the ``Subject:'' field. .SH COPYRIGHT -Copyright \(co 2013 Free Software Foundation, Inc. +Copyright \(co 2014 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. .br This is free software: you are free to change and redistribute it. -- 2.0.0.421.g786a89d