From 76ed0c0a4bd74a140e0de578eb94f2fd969646bd Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Fri, 15 Oct 1999 16:53:41 +0000 Subject: [PATCH] gij.cc (main): Formatting fixes. * gij.cc (main): Formatting fixes. (_Jv_Compiler_Properties): Define. * java/lang/natSystem.cc (_Jv_Environment_Properties): Don't declare. (init_properties): Set properites from _Jv_Compiler_Properties. * include/java-props.h (_Jv_Compiler_Properties, _Jv_Environment_Properties): Declare. From-SVN: r30020 --- libjava/ChangeLog | 8 ++++++++ libjava/gij.cc | 13 ++++++++++--- libjava/include/java-props.h | 6 ++++++ libjava/java/lang/natSystem.cc | 18 +++++++++++++++--- 4 files changed, 39 insertions(+), 6 deletions(-) diff --git a/libjava/ChangeLog b/libjava/ChangeLog index ae6a17d8468..4f37d8a66f2 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,5 +1,13 @@ 1999-10-15 Tom Tromey + * gij.cc (main): Formatting fixes. + (_Jv_Compiler_Properties): Define. + * java/lang/natSystem.cc (_Jv_Environment_Properties): Don't + declare. + (init_properties): Set properites from _Jv_Compiler_Properties. + * include/java-props.h (_Jv_Compiler_Properties, + _Jv_Environment_Properties): Declare. + * include/java-props.h: Added copyright. 1999-10-13 Anthony Green diff --git a/libjava/gij.cc b/libjava/gij.cc index ffe1515037d..b851b77dcd8 100644 --- a/libjava/gij.cc +++ b/libjava/gij.cc @@ -15,13 +15,20 @@ details. */ #include #include -int main (int argc, const char **argv) +// This is used to initialize the compiled-in system properties. +const char *_Jv_Compiler_Properties[] = +{ + NULL +}; + +int +main (int argc, const char **argv) { if (argc < 2) { - printf ("usage: %s args\n", argv[0]); + printf ("usage: %s CLASS [ARGS]...\n", argv[0]); exit (1); } - _Jv_RunMain (argv[1], argc-1, argv+1); + _Jv_RunMain (argv[1], argc - 1, argv + 1); } diff --git a/libjava/include/java-props.h b/libjava/include/java-props.h index 53ecb0990ae..65130da8814 100644 --- a/libjava/include/java-props.h +++ b/libjava/include/java-props.h @@ -19,5 +19,11 @@ typedef struct size_t value_length; } property_pair; +// The compiler generates this declaration. +extern char *_Jv_Compiler_Properties[]; + +// Properties taken from the user's environment. +extern property_pair *_Jv_Environment_Properties; + #endif diff --git a/libjava/java/lang/natSystem.cc b/libjava/java/lang/natSystem.cc index f146f3e198e..268c1cc4803 100644 --- a/libjava/java/lang/natSystem.cc +++ b/libjava/java/lang/natSystem.cc @@ -53,7 +53,6 @@ details. */ #define SystemClass _CL_Q34java4lang6System extern java::lang::Class SystemClass; -extern property_pair *_Jv_Environment_Properties; #if defined (ECOS) @@ -336,8 +335,8 @@ java::lang::System::init_properties (void) while (buf_r != NULL) { - int r = getpwuid_adaptor - (getpwuid_r, user_id, &pwd_r, buf_r, len_r, &pwd_entry); + int r = getpwuid_adaptor (getpwuid_r, user_id, &pwd_r, + buf_r, len_r, &pwd_entry); if (r == 0) break; else if (r != ERANGE) @@ -379,6 +378,19 @@ java::lang::System::init_properties (void) free (buffer); #endif + // Set some properties according to whatever was compiled in with + // `-D'. + for (int i = 0; _Jv_Compiler_Properties[i]; ++i) + { + const char *s, *p; + // Find the `='. + for (s = p = _Jv_Compiler_Properties[i]; *s && *s != '='; ++s) + ; + jstring name = JvNewStringLatin1 (p, s - p); + jstring val = JvNewStringLatin1 (*s == '=' ? s + 1 : s); + properties->put (name, val); + } + // Set the system properties from the user's environment. if (_Jv_Environment_Properties) {