Skip to content

Commit 534f9a5

Browse files
author
pd
committed
remove warnings about LC_* (differently this time, 88010+88011 confused Alpine Linux)
git-svn-id: https://svn.r-project.org/R/trunk@88077 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent 0ccaaa3 commit 534f9a5

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

src/main/main.c

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -930,50 +930,48 @@ void setup_Rmainloop(void)
930930

931931
{ /* Avoid annoying warnings if LANG and LC_ALL are unset or empty.
932932
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.
933+
like English in Denmark or Germany.
936934
937935
If LANG or LC_ALL has been set to a non-existing locale, we assume
938936
that the user wants to ne informed. */
939937

940938
const char *s;
939+
int quiet;
941940

942-
if (!( (s = getenv("LANG")) && *s) && !( (s = getenv("LC_ALL")) && *s))
943-
setenv("LANG", "C", 1);
944-
}
941+
quiet = !( ((s = getenv("LANG")) && *s) || ((s = getenv("LC_ALL")) && *s) );
945942

946-
if(!setlocale(LC_CTYPE, ""))
943+
if(!setlocale(LC_CTYPE, "") && !quiet)
947944
snprintf(deferred_warnings[ndeferred_warnings++], 250,
948945

949946
"Setting LC_CTYPE failed, using \"C\"\n");
950-
if(!setlocale(LC_COLLATE, ""))
947+
if(!setlocale(LC_COLLATE, "") && !quiet)
951948
snprintf(deferred_warnings[ndeferred_warnings++], 250,
952949
"Setting LC_COLLATE failed, using \"C\"\n");
953-
if(!setlocale(LC_TIME, ""))
950+
if(!setlocale(LC_TIME, "") && !quiet)
954951
snprintf(deferred_warnings[ndeferred_warnings++], 250,
955952
"Setting LC_TIME failed, using \"C\"\n");
956953
# if defined(ENABLE_NLS) && defined(LC_MESSAGES)
957-
if(!setlocale(LC_MESSAGES, ""))
954+
if(!setlocale(LC_MESSAGES, "") && !quiet)
958955
snprintf(deferred_warnings[ndeferred_warnings++], 250,
959956
"Setting LC_MESSAGES failed, using \"C\"\n");
960957
# endif
961958
/* NB: we do not set LC_NUMERIC */
962959
# ifdef LC_MONETARY
963-
if(!setlocale(LC_MONETARY, ""))
960+
if(!setlocale(LC_MONETARY, "") && !quiet)
964961
snprintf(deferred_warnings[ndeferred_warnings++], 250,
965962
"Setting LC_MONETARY failed, using \"C\"\n");
966963
# endif
967964
# ifdef LC_PAPER
968-
if(!setlocale(LC_PAPER, ""))
965+
if(!setlocale(LC_PAPER, "") && !quiet)
969966
snprintf(deferred_warnings[ndeferred_warnings++], 250,
970967
"Setting LC_PAPER failed, using \"C\"\n");
971968
# endif
972969
# ifdef LC_MEASUREMENT
973-
if(!setlocale(LC_MEASUREMENT, ""))
970+
if(!setlocale(LC_MEASUREMENT, "") && !quiet)
974971
snprintf(deferred_warnings[ndeferred_warnings++], 250,
975972
"Setting LC_MEASUREMENT failed, using \"C\"\n");
976973
# endif
974+
}
977975
#endif /* not Win32 */
978976
#endif
979977

0 commit comments

Comments
 (0)