From 45e6cd5a60165859b17d3f8f0472d95ebc16eb25 Mon Sep 17 00:00:00 2001 From: JET Date: Tue, 5 Oct 2010 17:53:17 -0600 Subject: [PATCH] The localization properties are now functional. Only 16 languages are currently reported on Windows. --- classpath/java-lang.cpp | 15 ++++++++------- makefile | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/classpath/java-lang.cpp b/classpath/java-lang.cpp index 06bc4e0c2d..e0b45b1388 100644 --- a/classpath/java-lang.cpp +++ b/classpath/java-lang.cpp @@ -231,8 +231,9 @@ Java_java_lang_Runtime_waitFor(JNIEnv* e, jclass, jlong pid) } void getLocale(char* language, char* region) { - const char* lang = 0; - const char* reg = 0; + const char dummy = '\0'; + const char* lang = &dummy; + const char* reg = &dummy; unsigned locale = GetUserDefaultUILanguage(); unsigned prilang = locale & 0x3ff; @@ -266,7 +267,7 @@ void getLocale(char* language, char* region) { case 0x00a: { lang = "es"; switch (sublang) { - case 0x01: case: 0x03: reg = "ES"; break; + case 0x01: case 0x03: reg = "ES"; break; case 0x02: reg = "MX"; break; } } break; @@ -302,8 +303,8 @@ void getLocale(char* language, char* region) { case 0x01d: lang = "sv"; reg = "SE"; break; } - if (language) memcpy(language, lang, strlen(lang) * sizeof(char)); - if (region) memcpy(region, reg, strlen(reg) * sizeof(char)); + if (language) memcpy(language, lang, (strlen(lang) + 1) * sizeof(char)); + if (region) memcpy(region, reg, (strlen(reg) + 1) * sizeof(char)); } #else extern "C" JNIEXPORT void JNICALL @@ -451,8 +452,8 @@ void getLocale(char* language, char* region) { lang[underscore] = reg[reglen] = '\0'; } - if (language) memcpy(language, lang, strlen(lang) * sizeof(char)); - if (region) memcpy(region, reg, strlen(reg) * sizeof(char)); + if (language) memcpy(language, lang, (strlen(lang) + 1) * sizeof(char)); + if (region) memcpy(region, reg, (strlen(reg) + 1) * sizeof(char)); } #endif diff --git a/makefile b/makefile index f0dcab31a5..a8b450a7ed 100644 --- a/makefile +++ b/makefile @@ -190,7 +190,7 @@ ifeq ($(platform),windows) exe-suffix = .exe lflags = -L$(lib) $(common-lflags) -lws2_32 -mwindows -mconsole - cflags = -I$(inc) $(common-cflags) + cflags = -I$(inc) $(common-cflags) -DWINVER=0x0500 ifeq (,$(filter mingw32 cygwin,$(build-platform))) cxx = i586-mingw32msvc-g++