From 1801957473afd6bac6acaabbb823b12cea8ef1d2 Mon Sep 17 00:00:00 2001 From: Ondřej Vašík Date: Feb 20 2013 15:33:47 +0000 Subject: fix multibyte issue in unexpand(by R.Kollar, #821262) --- diff --git a/coreutils-i18n.patch b/coreutils-i18n.patch index 5932f29..430a22c 100644 --- a/coreutils-i18n.patch +++ b/coreutils-i18n.patch @@ -3401,7 +3401,7 @@ diff -urNp coreutils-8.21-orig/src/unexpand.c coreutils-8.21/src/unexpand.c /* The official name of this program (e.g., no 'g' prefix). */ #define PROGRAM_NAME "unexpand" -@@ -103,6 +120,208 @@ static struct option const longopts[] = +@@ -103,6 +120,210 @@ static struct option const longopts[] = {NULL, 0, NULL, 0} }; @@ -3421,6 +3421,7 @@ diff -urNp coreutils-8.21-orig/src/unexpand.c coreutils-8.21/src/unexpand.c + wint_t wc; /* A gotten wide character. */ + size_t mblength; /* The byte size of a multibyte character + which shows as same character as WC. */ ++ bool prev_tab = false; + + /* Index in `tab_list' of next tabstop: */ + int tab_index = 0; /* For calculating width of pending tabs. */ @@ -3499,7 +3500,7 @@ diff -urNp coreutils-8.21-orig/src/unexpand.c coreutils-8.21/src/unexpand.c +flush_pend_mb: + /* Flush pending spaces. Print as many tabs as possible, + then print the rest as spaces. */ -+ if (pending == 1) ++ if (pending == 1 && column != 1 && !prev_tab) + { + putchar (' '); + pending = 0; @@ -3600,6 +3601,7 @@ diff -urNp coreutils-8.21-orig/src/unexpand.c coreutils-8.21/src/unexpand.c + fwrite (bufpos, sizeof(char), mblength, stdout); + } + } ++ prev_tab = wc == L'\t'; + buflen -= mblength; + bufpos += mblength; + } diff --git a/coreutils.spec b/coreutils.spec index 11b9822..2de4feb 100644 --- a/coreutils.spec +++ b/coreutils.spec @@ -1,7 +1,7 @@ Summary: A set of basic GNU tools commonly used in shell scripts Name: coreutils Version: 8.21 -Release: 3%{?dist} +Release: 4%{?dist} License: GPLv3+ Group: System Environment/Base Url: http://www.gnu.org/software/coreutils/ @@ -376,6 +376,9 @@ fi %{_sbindir}/chroot %changelog +* Wed Feb 20 2013 Ondrej Vasik 8.21-4 +- fix multibyte issue in unexpand(by R.Kollar, #821262) + * Mon Feb 18 2013 Mark Wielaard 8.21-3 - fix coreutils-i18n.patch to terminate mbdelim string (#911929)