emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[debbugs-tracker] bug#24015: closed ([PATCH] sort: make -h work with -k


From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#24015: closed ([PATCH] sort: make -h work with -k and blank used as thousands separator)
Date: Mon, 18 Jul 2016 21:08:01 +0000

Your message dated Mon, 18 Jul 2016 22:07:34 +0100
with message-id <address@hidden>
and subject line Re: [PATCH v2 1/3] sort: deduplicate code for traversing 
numbers
has caused the debbugs.gnu.org bug report #24015,
regarding [PATCH] sort: make -h work with -k and blank used as thousands 
separator
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
24015: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=24015
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: [PATCH] sort: make -h work with -k and blank used as thousands separator Date: Sun, 17 Jul 2016 18:02:06 +0200
* src/sort.c (find_unit_order): 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.
Reported at https://bugzilla.redhat.com/1355780
---
 src/sort.c                         | 12 ++++++----
 tests/local.mk                     |  1 +
 tests/misc/sort-h-thousands-sep.sh | 45 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 54 insertions(+), 4 deletions(-)
 create mode 100755 tests/misc/sort-h-thousands-sep.sh

diff --git a/src/sort.c b/src/sort.c
index f717604..a2cadda 100644
--- a/src/sort.c
+++ b/src/sort.c
@@ -1904,12 +1904,16 @@ find_unit_order (char const *number)
      to be lacking in units.
      FIXME: add support for multibyte thousands_sep and decimal_point.  */
 
-  do
+  while (ISDIGIT (ch = *p++))
     {
-      while (ISDIGIT (ch = *p++))
-        nonzero |= ch - '0';
+      nonzero |= ch - '0';
+
+      /* 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.  */
+      if (*p == thousands_sep)
+        ++p;
     }
-  while (ch == thousands_sep);
 
   if (ch == decimal_point)
     while (ISDIGIT (ch = *p++))
diff --git a/tests/local.mk b/tests/local.mk
index 27cbf6e..889142a 100644
--- a/tests/local.mk
+++ b/tests/local.mk
@@ -348,6 +348,7 @@ all_tests =                                 \
   tests/misc/sort-discrim.sh                   \
   tests/misc/sort-files0-from.pl               \
   tests/misc/sort-float.sh                     \
+  tests/misc/sort-h-thousands-sep.sh           \
   tests/misc/sort-merge.pl                     \
   tests/misc/sort-merge-fdlimit.sh             \
   tests/misc/sort-month.sh                     \
diff --git a/tests/misc/sort-h-thousands-sep.sh 
b/tests/misc/sort-h-thousands-sep.sh
new file mode 100755
index 0000000..a1e02de
--- /dev/null
+++ b/tests/misc/sort-h-thousands-sep.sh
@@ -0,0 +1,45 @@
+#!/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 <http://www.gnu.org/licenses/>.
+
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
+print_ver_ sort
+
+tee in > exp1 << _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
-- 
2.5.5




--- End Message ---
--- Begin Message --- Subject: Re: [PATCH v2 1/3] sort: deduplicate code for traversing numbers Date: Mon, 18 Jul 2016 22:07:34 +0100 User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0
Excellent. I'll push all three patches.

I'll adjust the first summary like s/sort:/maint: sort.c:/
since there is no functionality change

I'll also add the check for the sv_SE locale in the test.

thanks!
Pádraig.



--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]