X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/f34427874df972004ce8a285145f6fc738f08595..b1722537108cceec472480a551b9a7fb9c660c55:/sbr/utils.c?ds=inline diff --git a/sbr/utils.c b/sbr/utils.c index 73061709..fff1aacd 100644 --- a/sbr/utils.c +++ b/sbr/utils.c @@ -383,10 +383,8 @@ void TrimSuffixC(char *s, int c) int nmh_init(const char *argv0, int read_context) { - if (! setlocale(LC_ALL, "")) { - admonish(NULL, "setlocale failed, check your LC_ALL, LC_CTYPE, and " - "LANG environment variables"); - } + int status = OK; + char *locale; invo_name = r1bindex ((char *) argv0, '/'); @@ -439,15 +437,24 @@ nmh_init(const char *argv0, int read_context) { putchar ('\n'); } } - - return OK; } else { - int status = context_foil(NULL); - if (status != OK) { + if ((status = context_foil(NULL)) != OK) { advise("", "failed to create minimal profile/context"); } - return status; } + + /* Allow the user to set a locale in their profile. Otherwise, use the + "" string to pull it from their environment, see setlocale(3). */ + if ((locale = context_find ("locale")) == NULL) { + locale = ""; + } + + if (! setlocale (LC_ALL, locale)) { + admonish (NULL, "setlocale failed, check your LC_ALL, LC_CTYPE, and " + "LANG environment variables"); + } + + return status; }