diff --git a/SOURCES/mbsubstitution.patch b/SOURCES/mbsubstitution.patch new file mode 100644 index 0000000..17e73e6 --- /dev/null +++ b/SOURCES/mbsubstitution.patch @@ -0,0 +1,96 @@ +--- a/sed/execute.c 2015-12-28 07:36:47.000000000 +0100 ++++ b/sed/execute.c 2019-07-30 10:37:49.369052072 +0200 +@@ -213,58 +220,42 @@ + while (length) + { + wchar_t wc; +- size_t n = MBRTOWC (&wc, string, length, &from_stat); ++ int n = MBRTOWC (&wc, string, length, &from_stat); + +- /* Treat an invalid sequence like a single-byte character. */ +- if (n == (size_t) -1) ++ /* An invalid sequence is treated like a singlebyte character. */ ++ if (n == -1) + { +- type &= ~(REPL_LOWERCASE_FIRST | REPL_UPPERCASE_FIRST); +- if (type == REPL_ASIS) +- { +- str_append(to, string, length); +- return; +- } +- +- str_append (to, string, 1); + memset (&to->mbstate, 0, sizeof (from_stat)); + n = 1; +- string += n, length -= n; +- continue; +- } +- +- if (n == 0 || n == (size_t) -2) +- { +- /* L'\0' or an incomplete sequence: copy it manually. */ +- str_append(to, string, length); +- return; + } + +- string += n, length -= n; ++ if (n > 0) ++ string += n, length -= n; ++ else ++ { ++ /* Incomplete sequence, copy it manually. */ ++ str_append(to, string, length); ++ return; ++ } + + /* Convert the first character specially... */ + if (type & (REPL_UPPERCASE_FIRST | REPL_LOWERCASE_FIRST)) +- { ++ { + if (type & REPL_UPPERCASE_FIRST) + wc = towupper(wc); + else + wc = towlower(wc); + + type &= ~(REPL_LOWERCASE_FIRST | REPL_UPPERCASE_FIRST); +- if (type == REPL_ASIS) +- { +- /* Copy the new wide character to the end of the string. */ +- n = WCRTOMB (to->active + to->length, wc, &to->mbstate); +- to->length += n; +- if (n == (size_t) -1 || n == (size_t) -2) +- { +- fprintf (stderr, +- _("case conversion produced an invalid character")); +- abort (); +- } +- str_append(to, string, length); +- return; +- } ++ if (type == REPL_ASIS) ++ { ++ n = WCRTOMB (to->active + to->length, wc, &to->mbstate); ++ to->length += n; ++ str_append(to, string, length); ++ return; ++ } + } ++ + else if (type & REPL_UPPERCASE) + wc = towupper(wc); + else +@@ -274,10 +265,10 @@ + n = WCRTOMB (to->active + to->length, wc, &to->mbstate); + to->length += n; + if (n == -1 || n == -2) +- { +- fprintf (stderr, _("case conversion produced an invalid character")); +- abort (); +- } ++ { ++ fprintf (stderr, "Case conversion produced an invalid character!"); ++ abort (); ++ } + } + } + diff --git a/SPECS/sed.spec b/SPECS/sed.spec index 1db9c7c..607d937 100644 --- a/SPECS/sed.spec +++ b/SPECS/sed.spec @@ -6,13 +6,14 @@ Summary: A GNU stream text editor Name: sed Version: 4.2.2 -Release: 5%{?dist} +Release: 6%{?dist} License: GPLv3+ Group: Applications/Text URL: http://sed.sourceforge.net/ Source0: ftp://ftp.gnu.org/pub/gnu/sed/sed-%{version}.tar.bz2 Source1: http://sed.sourceforge.net/sedfaq.txt Patch0: sed-4.2.2-binary_copy_args.patch +Patch1: mbsubstitution.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: glibc-devel, libselinux-devel Requires(post): /sbin/install-info @@ -31,6 +32,7 @@ specified in a script file or from the command line. %prep %setup -q %patch0 -p1 -b .copy +%patch1 -p1 -R -b .copy %build %configure --without-included-regex @@ -71,6 +73,10 @@ rm -rf ${RPM_BUILD_ROOT} %{_mandir}/man*/* %changelog +* Tue Jul 30 2019 Jakub Martisko - 4.2.2-6 +- Fix an issue, where some multibyte sequence substitutions were not applied + Resolves: #1733877 + * Mon Feb 10 2014 Jan Pacner - 4.2.2-5 - Related: #948598 (Man page scan results for sed; introduce -c argument, add help for -b --binary arguments, cleanup arguments & help)