From 611e7e02bff8898e622d6ad582a92f2de746b614 Mon Sep 17 00:00:00 2001 From: Pádraig Brady Date: Thu, 14 Jan 2016 01:17:57 +0000 Subject: 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. --- src/sort.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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")); } -- cgit v1.2.3-70-g09d2