From: David Levine Date: Tue, 17 Jun 2014 02:04:47 +0000 (-0500) Subject: Check return value of setlocale(3) and admonish on failure. X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/8387304e3f32d745a7b4ed4ee1c350477d0d513a?ds=inline;hp=-c Check return value of setlocale(3) and admonish on failure. --- 8387304e3f32d745a7b4ed4ee1c350477d0d513a diff --git a/sbr/utils.c b/sbr/utils.c index 4405f4c9..610f7904 100644 --- a/sbr/utils.c +++ b/sbr/utils.c @@ -328,7 +328,10 @@ nmh_strcasestr (const char *s1, const char *s2) { int nmh_init(const char *argv0, int read_context) { - setlocale(LC_ALL, ""); + if (! setlocale(LC_ALL, "")) { + admonish(NULL, "setlocale failed, check your LC_ALL, LC_CTYPE, and " + "LANG environment variables"); + } invo_name = r1bindex ((char *) argv0, '/'); diff --git a/test/getcwidth.c b/test/getcwidth.c index 4a8122b6..2c4755b1 100644 --- a/test/getcwidth.c +++ b/test/getcwidth.c @@ -38,7 +38,10 @@ main(int argc, char *argv[]) wchar_t c; int i; - setlocale(LC_ALL, ""); + if (! setlocale(LC_ALL, "")) { + fprintf(stderr, "setlocale failed, check your LC_ALL, " + "LC_CTYPE, and LANG environment variables\n"); + } if (argc < 2) usage(argv[0]);