aboutsummaryrefslogtreecommitdiff
path: root/libjava/java
diff options
context:
space:
mode:
authorBryce McKinlay <bryce@albatross.co.nz>2000-11-29 04:53:37 +0000
committerBryce McKinlay <bryce@gcc.gnu.org>2000-11-29 04:53:37 +0000
commit5662d5333acd122c452c6f1a69e180d5c1ed1efe (patch)
tree3c6a848f28f77b64bcb40a956df2db902c406ab7 /libjava/java
parent56f8f4fb753b4583b7041f65616b417231cb7c7b (diff)
downloadgcc-5662d5333acd122c452c6f1a69e180d5c1ed1efe.zip
gcc-5662d5333acd122c452c6f1a69e180d5c1ed1efe.tar.gz
gcc-5662d5333acd122c452c6f1a69e180d5c1ed1efe.tar.bz2
natSystem.cc (init_properties): Set user.language and user.region.
2000-11-29 Bryce McKinlay <bryce@albatross.co.nz> * java/lang/natSystem.cc (init_properties): Set user.language and user.region. * configure.in: Check for setlocale. * configure: Rebuilt. * include/config.h.in: Rebuilt. From-SVN: r37842
Diffstat (limited to 'libjava/java')
-rw-r--r--libjava/java/lang/natSystem.cc27
1 files changed, 26 insertions, 1 deletions
diff --git a/libjava/java/lang/natSystem.cc b/libjava/java/lang/natSystem.cc
index 57133fb..a987e8d 100644
--- a/libjava/java/lang/natSystem.cc
+++ b/libjava/java/lang/natSystem.cc
@@ -339,6 +339,31 @@ java::lang::System::init_properties (void)
#endif /* HAVE_UNISTD_H */
#endif /* HAVE_GETCWD */
+ // Set user locale properties based on setlocale()
+#ifdef HAVE_SETLOCALE
+ char *locale = setlocale (LC_ALL, "");
+ if (locale && strlen (locale) >= 2)
+ {
+ char buf[3];
+ buf[2] = '\0';
+ // copy the first two chars to user.language
+ strncpy (buf, locale, 2);
+ SET ("user.language", buf);
+ // if the next char is a '_', copy the two after that to user.region
+ locale += 2;
+ if (locale[0] == '_')
+ {
+ locale++;
+ strncpy (buf, locale, 2);
+ SET ("user.region", buf);
+ }
+ }
+ else
+#endif /* HAVE_SETLOCALE */
+ {
+ SET ("user.language", "en");
+ }
+
// Set some properties according to whatever was compiled in with
// `-D'.
for (int i = 0; _Jv_Compiler_Properties[i]; ++i)
@@ -382,7 +407,7 @@ java::lang::System::init_properties (void)
sb->append ((jchar) ';');
#else
sb->append ((jchar) ':');
-#endif;
+#endif
}
if (cp != NULL)
sb->append (cp);