Skip to content

Commit e26c860

Browse files
author
pd
committed
avoid message about defaulting LC_* to "C" in some cases
git-svn-id: https://svn.r-project.org/R/trunk@88010 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent 09b7888 commit e26c860

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/main/main.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,8 +927,25 @@ void setup_Rmainloop(void)
927927
putenv(Rarch);
928928
}
929929
#else /* not Win32 */
930+
931+
{ /* Avoid annoying warnings if LANG and LC_ALL are unset or empty.
932+
This happens e.g. on Mac when primary language clash with region,
933+
like English in Denmark or Germany. Use LANG, not LC_ALL in case
934+
some of the other LC_* variables are set - Apple Terminal can e.g.
935+
set LC_CTYPE=UTF-8.
936+
937+
If LANG or LC_ALL has been set to a non-existing locale, we assume
938+
that the user wants to ne informed. */
939+
940+
char *s;
941+
942+
if (!(s = getenv("LANG") && *s) && !(s = getenv("LC_ALL") && *s))
943+
setenv("LANG", "C", 1);
944+
}
945+
930946
if(!setlocale(LC_CTYPE, ""))
931947
snprintf(deferred_warnings[ndeferred_warnings++], 250,
948+
932949
"Setting LC_CTYPE failed, using \"C\"\n");
933950
if(!setlocale(LC_COLLATE, ""))
934951
snprintf(deferred_warnings[ndeferred_warnings++], 250,

0 commit comments

Comments
 (0)