main (int argc, char **argv)
{
int valid_numbers = 1;
+ bool locale_ok;
initialize_main (&argc, &argv);
set_program_name (argv[0]);
- setlocale (LC_ALL, "");
+ locale_ok = setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
if (format_str != NULL && grouping)
error (EXIT_FAILURE, 0, _("--grouping cannot be combined with --format"));
+ if (debug && ! locale_ok)
+ error (0, 0, _("failed to set locale"));
+
/* Warn about no-op. */
if (debug && scale_from == scale_none && scale_to == scale_none
&& !grouping && (padding_width == 0) && (format_str == NULL))
char *files_from = NULL;
struct Tokens tok;
char const *outfile = NULL;
+ bool locale_ok;
initialize_main (&argc, &argv);
set_program_name (argv[0]);
- setlocale (LC_ALL, "");
+ locale_ok = setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
error (0, 0, _("using %s sorting rules"),
quote (setlocale (LC_COLLATE, NULL)));
else
- error (0, 0, _("using simple byte comparison"));
+ {
+ error (0, 0, "%s%s", locale_ok ? "" : _("failed to set locale; "),
+ _("using simple byte comparison"));
+ }
key_warnings (&gkey, gkey_only);
}
sort: using simple byte comparison
sort: using simple byte comparison
sort: using simple byte comparison
+sort: failed to set locale; using simple byte comparison
EOF
sort -s -k2,1 --debug /dev/null 2>>out
sort -r --debug /dev/null 2>>out #no warning
sort -rM --debug /dev/null 2>>out #no warning
sort -rM -k1,1 --debug /dev/null 2>>out #no warning
+LC_ALL=missing sort --debug /dev/null 2>>out
compare exp out || fail=1