[kaffe] CVS kaffe (hkraemer): don't crash when setlocale returns NULL
Kaffe CVS
cvs-commits at kaffe.org
Thu Oct 14 04:16:35 PDT 2004
PatchSet 5285
Date: 2004/10/14 11:12:06
Author: hkraemer
Branch: HEAD
Tag: (none)
Log:
don't crash when setlocale returns NULL
Members:
ChangeLog:1.2837->1.2838
libraries/clib/native/System.c:1.58->1.59
Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.2837 kaffe/ChangeLog:1.2838
--- kaffe/ChangeLog:1.2837 Thu Oct 14 09:35:59 2004
+++ kaffe/ChangeLog Thu Oct 14 11:12:06 2004
@@ -1,3 +1,8 @@
+2004-10-14 Helmer Kraemer <hkraemer at freenet.de>
+
+ * libraries/clib/native/System.c (java_lang_System_initProperties):
+ don't crash if setlocale returns NULL
+
2004-10-12 Dalibor Topic <robilad at kaffe.org>
* libraries/javalib/java/lang/SecurityManager.java:
Index: kaffe/libraries/clib/native/System.c
diff -u kaffe/libraries/clib/native/System.c:1.58 kaffe/libraries/clib/native/System.c:1.59
--- kaffe/libraries/clib/native/System.c:1.58 Tue Oct 12 02:00:24 2004
+++ kaffe/libraries/clib/native/System.c Thu Oct 14 11:12:10 2004
@@ -359,25 +359,24 @@
}
{
- char *tmp;
char *locale;
char lang[3];
#if defined(HAVE_LC_MESSAGES)
locale = setlocale (LC_MESSAGES, "");
-
- tmp = strchr (locale, '_');
#else
- tmp = NULL;
+ locale = NULL;
#endif
- if (tmp != NULL) {
+ if ((locale != NULL) && (strlen(locale)>2)) {
lang[2] = '\0';
strncpy (lang, locale, 2);
setProperty (p, "user.language", lang);
- strncpy (lang, tmp+1, 2);
- setProperty (p, "user.region", lang);
+ if (locale[2] == '_') {
+ strncpy (lang, &locale[3], 2);
+ setProperty (p, "user.region", lang);
+ }
} else {
/* locale not set or not of the form <lang>_<region> */
setProperty (p, "user.language", "en");
More information about the kaffe
mailing list