X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=src%2Fvm%2Fproperties.cpp;h=c1029c660d602f7c5c399b0c9bbbbeb4177f5949;hb=bfcfa2e191ac88ffae3b62a33464c30df608f3ff;hp=b5868faa95817d1b857be2dc3ec9ef4fa01bd139;hpb=219e4a46e3d127d3c0883ee2e8635b4fe3c94d60;p=cacao.git diff --git a/src/vm/properties.cpp b/src/vm/properties.cpp index b5868faa9..c1029c660 100644 --- a/src/vm/properties.cpp +++ b/src/vm/properties.cpp @@ -1,6 +1,6 @@ /* src/vm/properties.cpp - handling commandline properties - Copyright (C) 1996-2005, 2006, 2007, 2008 + Copyright (C) 1996-2010 CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -32,17 +32,14 @@ #include #include #include -#include -#include "mm/memory.h" +#include "mm/memory.hpp" #include "native/llni.h" -#include "toolbox/util.h" - -#include "vm/class.h" +#include "vm/class.hpp" #include "vm/global.h" -#include "vm/method.h" +#include "vm/method.hpp" #include "vm/options.h" #include "vm/os.hpp" #include "vm/properties.hpp" @@ -51,6 +48,9 @@ #include "vm/jit/asmpart.h" +#ifdef HAVE_LOCALE_H +#include +#endif /** * Constructor fills the properties list with default values. @@ -75,7 +75,7 @@ Properties::Properties() p = MNEW(char, 4096); if (os::readlink("/proc/self/exe", p, 4095) == -1) - VM::get_current()->abort_errno("readlink failed"); + os::abort_errno("readlink failed"); /* We have a path like: @@ -317,7 +317,7 @@ Properties::Properties() put("java.vm.specification.version", "1.0"); put("java.vm.specification.vendor", "Sun Microsystems Inc."); put("java.vm.specification.name", "Java Virtual Machine Specification"); - put("java.vm.version", VERSION); + put("java.vm.version", VERSION_FULL); put("java.vm.vendor", "CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO"); put("java.vm.name", "CACAO"); @@ -332,14 +332,22 @@ Properties::Properties() { /* XXX We don't support java.lang.Compiler */ /* put("java.compiler", "cacao.jit"); */ - put("java.vm.info", "JIT mode"); + put("java.vm.info", "compiled mode"); } + // Get and set java.library.path. + const char* java_library_path = os::getenv("LD_LIBRARY_PATH"); + + if (java_library_path == NULL) + java_library_path = ""; + + put("java.library.path", java_library_path); + # if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) /* Get properties from system. */ - char* cwd = _Jv_getcwd(); + char* cwd = os::getcwd(); char* env_user = os::getenv("USER"); char* env_home = os::getenv("HOME"); @@ -349,7 +357,7 @@ Properties::Properties() uname(utsnamebuf); - put("java.runtime.version", VERSION); + put("java.runtime.version", VERSION_FULL); put("java.runtime.name", "CACAO"); put("java.specification.version", "1.5"); @@ -364,14 +372,6 @@ Properties::Properties() put("gnu.classpath.boot.library.path", boot_library_path); - // Get and set java.library.path. - const char* java_library_path = os::getenv("LD_LIBRARY_PATH"); - - if (java_library_path == NULL) - java_library_path = ""; - - put("java.library.path", java_library_path); - put("java.io.tmpdir", "/tmp"); # if defined(ENABLE_INTRP) @@ -436,28 +436,33 @@ Properties::Properties() /* get locale */ + bool use_en_US = true; if (env_lang != NULL) { - /* get the local stuff from the environment */ - - if (strlen(env_lang) <= 2) { - put("user.language", env_lang); - } - else { - if ((env_lang[2] == '_') && (strlen(env_lang) >= 5)) { +#if defined(HAVE_SETLOCALE) && defined(HAVE_LC_MESSAGES) + /* get the locale stuff from the environment */ + char *locale; + + if ((locale = setlocale(LC_MESSAGES, ""))) { + int len = strlen(locale); + if (((len >= 5) && (locale[2] == '_')) || len == 2) { + use_en_US = false; char* lang = MNEW(char, 3); - strncpy(lang, (char*) &env_lang[0], 2); + strncpy(lang, (char*) &locale[0], 2); lang[2] = '\0'; + put("user.language", lang); - char* country = MNEW(char, 3); - strncpy(country, (char*) &env_lang[3], 2); - country[2] = '\0'; + if (len >= 5) { + char* country = MNEW(char, 3); + strncpy(country, (char*) &locale[3], 2); + country[2] = '\0'; - put("user.language", lang); - put("user.country", country); + put("user.country", country); + } } } +#endif } - else { + if (use_en_US) { /* if no default locale was specified, use `en_US' */ put("user.language", "en"); @@ -650,13 +655,6 @@ void Properties::dump() #endif -// Legacy C interface. -extern "C" { - void Properties_put(const char *key, const char *value) { VM::get_current()->get_properties().put(key, value); } - const char *Properties_get(const char *key) { return VM::get_current()->get_properties().get(key); } -} - - /* * These are local overrides for various environment variables in Emacs. * Please do not remove this and leave it at the end of the file, where