3
0
forked from pool/coreutils

Accepting request 334151 from Base:System

Automatic submission by obs-autosubmit

OBS-URL: https://build.opensuse.org/request/show/334151
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/coreutils?expand=0&rev=116
This commit is contained in:
Dominique Leuenberger 2015-10-06 11:23:07 +00:00 committed by Git OBS Bridge
parent 157dcc1a5e
commit e4697fb591
4 changed files with 84 additions and 19 deletions

View File

@ -7,8 +7,9 @@
src/sort.c | 763 +++++++++++++++++++++++++++++++++++++++++---
src/unexpand.c | 228 +++++++++++++
src/uniq.c | 265 ++++++++++++++-
tests/i18n/sort-month.sh | 34 +
tests/i18n/sort.sh | 29 +
tests/local.mk | 2
tests/local.mk | 3
tests/misc/cut.pl | 7
tests/misc/expand.pl | 40 ++
tests/misc/fold.pl | 50 ++
@ -19,7 +20,7 @@
tests/misc/unexpand.pl | 39 ++
tests/misc/uniq.pl | 55 +++
tests/pr/pr-tests.pl | 49 ++
21 files changed, 3255 insertions(+), 180 deletions(-)
22 files changed, 3290 insertions(+), 180 deletions(-)
Index: lib/linebuffer.h
===================================================================
@ -3076,8 +3077,8 @@ Index: src/sort.c
+ register int lo = 0, hi = MONTHS_PER_YEAR, result;
+ char *tmp;
+ size_t wclength, mblength;
+ const char **pp;
+ const wchar_t **wpp;
+ const char *pp;
+ const wchar_t *wpp;
+ wchar_t *month_wcs;
+ mbstate_t state;
+
@ -3090,17 +3091,19 @@ Index: src/sort.c
+ if (len == 0)
+ return 0;
+
+ month = (char *) xmalloc (len + 1);
+ if (SIZE_MAX - len < 1)
+ xalloc_die ();
+
+ tmp = (char *) xmalloc (len + 1);
+ month = (char *) xnmalloc (len + 1, MB_CUR_MAX);
+
+ pp = tmp = (char *) xnmalloc (len + 1, MB_CUR_MAX);
+ memcpy (tmp, s, len);
+ tmp[len] = '\0';
+ pp = (const char **)&tmp;
+ month_wcs = (wchar_t *) xmalloc ((len + 1) * sizeof (wchar_t));
+ memset (&state, '\0', sizeof(mbstate_t));
+ wpp = month_wcs = (wchar_t *) xnmalloc (len + 1, sizeof (wchar_t));
+ memset (&state, '\0', sizeof (mbstate_t));
+
+ wclength = mbsrtowcs (month_wcs, pp, len + 1, &state);
+ if (wclength == (size_t)-1 || *pp != NULL)
+ wclength = mbsrtowcs (month_wcs, &pp, len + 1, &state);
+ if (wclength == (size_t)-1 || pp != NULL)
+ error (SORT_FAILURE, 0, _("Invalid multibyte input %s."), quote(s));
+
+ for (i = 0; i < wclength; i++)
@ -3113,10 +3116,8 @@ Index: src/sort.c
+ }
+ }
+
+ wpp = (const wchar_t **)&month_wcs;
+
+ mblength = wcsrtombs (month, wpp, len + 1, &state);
+ assert (mblength != (-1) && *wpp == NULL);
+ mblength = wcsrtombs (month, &wpp, (len + 1) * MB_CUR_MAX, &state);
+ assert (mblength != (-1) && wpp == NULL);
+
+ do
+ {
@ -4167,12 +4168,13 @@ Index: tests/local.mk
===================================================================
--- tests/local.mk.orig
+++ tests/local.mk
@@ -341,6 +341,8 @@ all_tests = \
@@ -341,6 +341,9 @@ all_tests = \
tests/misc/sort-discrim.sh \
tests/misc/sort-files0-from.pl \
tests/misc/sort-float.sh \
+ tests/misc/sort-mb-tests.sh \
+ tests/i18n/sort.sh \
+ tests/i18n/sort-month.sh \
tests/misc/sort-merge.pl \
tests/misc/sort-merge-fdlimit.sh \
tests/misc/sort-month.sh \
@ -4783,3 +4785,42 @@ Index: tests/pr/pr-tests.pl
my $save_temps = $ENV{DEBUG};
my $verbose = $ENV{VERBOSE};
Index: tests/i18n/sort-month.sh
===================================================================
--- /dev/null
+++ tests/i18n/sort-month.sh
@@ -0,0 +1,34 @@
+#!/bin/sh
+# Verify sort -M multi-byte support.
+
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
+print_ver_ sort
+require_valgrind_
+
+# Skip this test if some deallocations are
+# avoided at process end.
+grep '^#define lint 1' $CONFIG_HEADER > /dev/null ||
+ skip_ 'Allocation checks only work reliably in "lint" mode'
+
+export LC_ALL=en_US.UTF-8
+locale -k LC_CTYPE | grep -q "charmap.*UTF-8" \
+ || skip_ "No UTF-8 locale available"
+
+# Note the use of ɑ here which expands to
+# a wider representation upon case conversion
+# which triggered an assertion in sort -M
+cat <<EOF > exp
+.
+ɑ
+EOF
+
+
+# check large mem leak with --month-sort
+# https://bugzilla.redhat.com/show_bug.cgi?id=1259942
+valgrind --leak-check=full \
+ --error-exitcode=1 --errors-for-leak-kinds=definite \
+ sort -M < exp > out || fail=1
+compare exp out || { fail=1; cat out; }
+
+
+Exit $fail

View File

@ -14,9 +14,9 @@ or arm6l. Strip the tests down from 37 to 3.
Index: tests/local.mk
===================================================================
--- tests/local.mk.orig 2015-07-09 15:10:56.769806990 +0200
+++ tests/local.mk 2015-07-09 15:10:56.839805334 +0200
@@ -678,14 +678,9 @@ all_tests = \
--- tests/local.mk.orig
+++ tests/local.mk
@@ -679,14 +679,9 @@ all_tests = \
# See tests/factor/create-test.sh.
tf = tests/factor
factor_tests = \

View File

@ -1,3 +1,15 @@
-------------------------------------------------------------------
Sun Sep 20 15:22:45 UTC 2015 - mail@bernhard-voelker.de
- coreutils-i18n.patch: Sync I18N patch from semi-official repository
(shared among distributions, maintained by Padraig Brady):
https://github.com/pixelb/coreutils/tree/i18n
This fixes the following issues in multi-byte locales:
* sort: fix large mem leak with --month-sort (boo#945361, rh#1259942):
https://github.com/pixelb/coreutils/commit/b429f5d8c7
* sort: fix assertion with some inputs to --month-sort
https://github.com/pixelb/coreutils/commit/31e8211aca
-------------------------------------------------------------------
Sun Aug 30 21:52:13 UTC 2015 - mail@bernhard-voelker.de

View File

@ -1,3 +1,15 @@
-------------------------------------------------------------------
Sun Sep 20 15:22:45 UTC 2015 - mail@bernhard-voelker.de
- coreutils-i18n.patch: Sync I18N patch from semi-official repository
(shared among distributions, maintained by Padraig Brady):
https://github.com/pixelb/coreutils/tree/i18n
This fixes the following issues in multi-byte locales:
* sort: fix large mem leak with --month-sort (boo#945361, rh#1259942):
https://github.com/pixelb/coreutils/commit/b429f5d8c7
* sort: fix assertion with some inputs to --month-sort
https://github.com/pixelb/coreutils/commit/31e8211aca
-------------------------------------------------------------------
Sun Aug 30 21:52:13 UTC 2015 - mail@bernhard-voelker.de