summaryrefslogtreecommitdiff
path: root/src/sort.c
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2016-01-14 01:17:57 +0000
committerPádraig Brady <P@draigBrady.com>2016-01-14 01:26:00 +0000
commit611e7e02bff8898e622d6ad582a92f2de746b614 (patch)
treeb44094081df40b9e73d36eaa40d9f8aa5a98ce8a /src/sort.c
parent4ab8704dc0c63a62076155f73439c8e11e9d5b6a (diff)
downloadcoreutils-611e7e02bff8898e622d6ad582a92f2de746b614.tar.xz
sort: with --debug, flag setlocale() failures on OpenBSD
Locale categories are not equivalent on OpenBSD, and LC_COLLATE only supports "C" for example. Now LC_ALL is supported to set multiple other categories on OpenBSD, so setlocale(LC_ALL, "") returns a string indicating which categories were updated and which ignored. Therefore... * src/sort.c (main): ...Call setlocale(LC_COLLATE, "") to explicitly check whether a specified LC_ALL or LC_COLLATE environment variable value is supported for the LC_COLLATE category. Also use !! to explicitly convert to bool to support c89 systems where bool is an int, and thus would get values > 1. Reported by Assaf Gordon.
Diffstat (limited to 'src/sort.c')
-rw-r--r--src/sort.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/sort.c b/src/sort.c
index 575877d22..62acb6298 100644
--- a/src/sort.c
+++ b/src/sort.c
@@ -4192,7 +4192,7 @@ main (int argc, char **argv)
initialize_main (&argc, &argv);
set_program_name (argv[0]);
- locale_ok = setlocale (LC_ALL, "");
+ locale_ok = !! setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
@@ -4667,6 +4667,10 @@ main (int argc, char **argv)
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"));
}