From dfbc945a562f870f6647672374c00d4f1ffb6097 Mon Sep 17 00:00:00 2001 From: Kamil Dudka Date: Mon, 18 Jul 2016 19:04:44 +0200 Subject: sort: make -h work with -k and blank used as thousands separator * src/sort.c (traverse_raw_number): Allow to skip only one occurrence of thousands_sep to avoid finding the unit in the next column in case thousands_sep matches as blank and is used as column delimiter. * tests/misc/sort-h-thousands-sep.sh: Add regression test for this bug. * tests/local.mk: Reference the test. * NEWS: Mention the bug fix. Reported at https://bugzilla.redhat.com/1355780 Fixes http://bugs.gnu.org/24015 --- tests/misc/sort-h-thousands-sep.sh | 47 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 tests/misc/sort-h-thousands-sep.sh (limited to 'tests/misc') diff --git a/tests/misc/sort-h-thousands-sep.sh b/tests/misc/sort-h-thousands-sep.sh new file mode 100755 index 000000000..17f1b6c98 --- /dev/null +++ b/tests/misc/sort-h-thousands-sep.sh @@ -0,0 +1,47 @@ +#!/bin/sh +# exercise 'sort -h' in locales where thousands separator is blank + +# Copyright (C) 2016 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src +print_ver_ sort +test "$(LC_ALL=sv_SE locale thousands_sep)" = ' ' \ + || skip_ 'The Swedish locale with blank thousands separator is unavailable.' + +tee exp1 > in << _EOF_ +1 1k 4 003 1M +2k 2M 4 002 2 +3M 3 4 001 3k +_EOF_ + +cat > exp2 << _EOF_ +3M 3 4 001 3k +1 1k 4 003 1M +2k 2M 4 002 2 +_EOF_ + +cat > exp3 << _EOF_ +3M 3 4 001 3k +2k 2M 4 002 2 +1 1k 4 003 1M +_EOF_ + +for i in 1 2 3; do + LC_ALL="sv_SE.utf8" sort -h -k $i "in" > "out${i}" || fail=1 + compare "exp${i}" "out${i}" || fail=1 +done + +Exit $fail -- cgit v1.2.3-70-g09d2