[patch] HAVE_LC_MESSAGES for natSystem.cc
Tom Tromey
tromey@redhat.com
Thu Jan 10 11:16:00 GMT 2002
>>>>> "Andreas" == Andreas Tobler <toa@pop.agri.ch> writes:
Andreas> this patch makes it possible to check whether a system has
Andreas> LC_MESSAGES defined or not. On darwin this isn't the case,
Andreas> so I check in natSystem.cc if not HAVE_LC_MESSAGES and then
Andreas> define LC_MESSAGES with a ?number?.
We can't arbitrarily define LC_MESSAGES like that.
Here's the patch I came up with.
Unfortunately this will have the effect of assuming the en_US locale
on Darwin. Any better suggestions?
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* aclocal.m4, configure, include/config.h.in: Rebuilt.
* configure.in: Call AM_LC_MESSAGES.
* acinclude.m4 (AM_LC_MESSAGES): New macro.
Index: acinclude.m4
===================================================================
RCS file: /cvs/gcc/gcc/libjava/acinclude.m4,v
retrieving revision 1.13
diff -u -r1.13 acinclude.m4
--- acinclude.m4 2001/10/31 00:48:15 1.13
+++ acinclude.m4 2002/01/10 19:12:52
@@ -191,3 +191,28 @@
fi
AC_SUBST(LIBICONV)
])
+
+# Check whether LC_MESSAGES is available in <locale.h>.
+# Ulrich Drepper <drepper@cygnus.com>, 1995.
+#
+# This file can be copied and used freely without restrictions. It can
+# be used in projects which are not available under the GNU General Public
+# License or the GNU Library General Public License but which still want
+# to provide support for the GNU gettext functionality.
+# Please note that the actual code of the GNU gettext library is covered
+# by the GNU Library General Public License, and the rest of the GNU
+# gettext package package is covered by the GNU General Public License.
+# They are *not* in the public domain.
+
+# serial 2
+
+AC_DEFUN([AM_LC_MESSAGES],
+ [if test $ac_cv_header_locale_h = yes; then
+ AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
+ [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
+ am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
+ if test $am_cv_val_LC_MESSAGES = yes; then
+ AC_DEFINE(HAVE_LC_MESSAGES, 1,
+ [Define if your <locale.h> file defines LC_MESSAGES.])
+ fi
+ fi])
Index: configure.in
===================================================================
RCS file: /cvs/gcc/gcc/libjava/configure.in,v
retrieving revision 1.104
diff -u -r1.104 configure.in
--- configure.in 2002/01/06 21:38:14 1.104
+++ configure.in 2002/01/10 19:12:58
@@ -450,6 +450,7 @@
AC_DEFINE(HAVE_PROC_SELF_EXE)])
AM_ICONV
+ AM_LC_MESSAGES
AC_STRUCT_TIMEZONE
AC_CHECK_FUNCS(gethostbyname_r, [
Index: java/lang/natSystem.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/natSystem.cc,v
retrieving revision 1.43
diff -u -r1.43 natSystem.cc
--- java/lang/natSystem.cc 2002/01/08 21:59:32 1.43
+++ java/lang/natSystem.cc 2002/01/10 19:12:58
@@ -414,11 +414,12 @@
#endif /* HAVE_GETCWD */
// Set user locale properties based on setlocale()
-#ifdef HAVE_SETLOCALE
+#if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
// We let the user choose the locale. However, since Java differs
// from POSIX, we arbitrarily pick LC_MESSAGES as determining the
// Java locale. We can't use LC_ALL because it might return a full
- // list of all the settings.
+ // list of all the settings. If we don't have LC_MESSAGES then we
+ // just default to `en_US'.
setlocale (LC_ALL, "");
char *locale = setlocale (LC_MESSAGES, "");
if (locale && strlen (locale) >= 2)
@@ -438,7 +439,7 @@
}
}
else
-#endif /* HAVE_SETLOCALE */
+#endif /* HAVE_SETLOCALE and HAVE_LC_MESSAGES */
{
SET ("user.language", "en");
SET ("user.region", "US");
More information about the Java-patches
mailing list