]> diplodocus.org Git - nmh/commitdiff
Check return value of setlocale(3) and admonish on failure.
authorDavid Levine <levinedl@acm.org>
Tue, 17 Jun 2014 02:04:47 +0000 (21:04 -0500)
committerDavid Levine <levinedl@acm.org>
Tue, 17 Jun 2014 02:04:47 +0000 (21:04 -0500)
sbr/utils.c
test/getcwidth.c

index 4405f4c95a5c52d5cf406d52cc95535479b71781..610f79049e16af3b4b1e3feb24c106ae02413a50 100644 (file)
@@ -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, '/');
 
index 4a8122b6e9170b0e085981962706d65b74f24f88..2c4755b1c924d5a60f223c54ae62efeec571c888 100644 (file)
@@ -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]);