summaryrefslogtreecommitdiff
path: root/system/coreutils/sort-debug-locale.patch
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2018-06-08 02:02:24 -0500
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2018-06-08 02:02:24 -0500
commitfd2bb2f751c13b3c0c002b8e012810902b9da364 (patch)
tree17b2e38c966c9f96cfa568c1f572261a289590e6 /system/coreutils/sort-debug-locale.patch
parentb0a5136bf3326ba38b360be288d06f9a27f2a4d2 (diff)
downloadpackages-fd2bb2f751c13b3c0c002b8e012810902b9da364.tar.gz
packages-fd2bb2f751c13b3c0c002b8e012810902b9da364.tar.bz2
packages-fd2bb2f751c13b3c0c002b8e012810902b9da364.tar.xz
packages-fd2bb2f751c13b3c0c002b8e012810902b9da364.zip
harmony -> system
Diffstat (limited to 'system/coreutils/sort-debug-locale.patch')
-rw-r--r--system/coreutils/sort-debug-locale.patch79
1 files changed, 79 insertions, 0 deletions
diff --git a/system/coreutils/sort-debug-locale.patch b/system/coreutils/sort-debug-locale.patch
new file mode 100644
index 000000000..27921abbd
--- /dev/null
+++ b/system/coreutils/sort-debug-locale.patch
@@ -0,0 +1,79 @@
+From b938d8966c3d1afec9730d403fd6a6eb4d856b85 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?P=C3=A1draig=20Brady?= <P@draigBrady.com>
+Date: Sun, 13 Aug 2017 00:45:32 -0700
+Subject: [PATCH] sort: handle musl locale differences in --debug reporting
+
+* src/sort.c (main): Don't assume hard_LC_COLLATE implies
+a successful setting of the locale as musl defaults to
+UTF8 when failing to set the specified locale.
+* tests/misc/sort-debug-warn.sh: Adjust for the now
+separated locale debug info and map the musl specific
+message back to the common case.
+Reported by A. Wilcox.
+---
+ src/sort.c | 17 +++++++++--------
+ tests/misc/sort-debug-warn.sh | 9 +++++++--
+ 2 files changed, 16 insertions(+), 10 deletions(-)
+
+diff --git a/src/sort.c b/src/sort.c
+index 015e40e..ba6ceac 100644
+--- a/src/sort.c
++++ b/src/sort.c
+@@ -4675,18 +4675,19 @@ main (int argc, char **argv)
+
+ /* Always output the locale in debug mode, since this
+ is such a common source of confusion. */
++
++ /* OpenBSD can only set some categories with LC_ALL above,
++ so set LC_COLLATE explicitly to flag errors. */
++ if (locale_ok)
++ locale_ok = !! setlocale (LC_COLLATE, "");
++ if (! locale_ok)
++ error (0, 0, "%s", _("failed to set locale"));
+ if (hard_LC_COLLATE)
+ error (0, 0, _("using %s sorting rules"),
+ quote (setlocale (LC_COLLATE, NULL)));
+ else
+- {
+- /* OpenBSD can only set some categories with LC_ALL above,
+- so set LC_COLLATE explicitly to flag errors. */
+- if (locale_ok)
+- locale_ok = !! setlocale (LC_COLLATE, "");
+- error (0, 0, "%s%s", locale_ok ? "" : _("failed to set locale; "),
+- _("using simple byte comparison"));
+- }
++ error (0, 0, "%s", _("using simple byte comparison"));
++
+ key_warnings (&gkey, gkey_only);
+ }
+
+diff --git a/tests/misc/sort-debug-warn.sh b/tests/misc/sort-debug-warn.sh
+index 3602c84..8119693 100755
+--- a/tests/misc/sort-debug-warn.sh
++++ b/tests/misc/sort-debug-warn.sh
+@@ -71,7 +71,8 @@ sort: using simple byte comparison
+ 17
+ sort: using simple byte comparison
+ 18
+-sort: failed to set locale; using simple byte comparison
++sort: failed to set locale
++sort: using simple byte comparison
+ EOF
+
+ echo 1 >> out
+@@ -109,7 +110,11 @@ sort -rM --debug /dev/null 2>>out #no warning
+ echo 17 >> out
+ sort -rM -k1,1 --debug /dev/null 2>>out #no warning
+ echo 18 >> out
+-LC_ALL=missing sort --debug /dev/null 2>>out
++LC_ALL=missing sort --debug /dev/null 2>>out.t
++# musl libc accepts "missing" and implicitly uses UTF8,
++# so adjust the expected message accordingly.
++sed 's/using .*missing.* sorting rules/using simple byte comparison/' \
++ out.t >>out
+
+ compare exp out || fail=1
+
+--
+2.9.3
+