OSDN Git Service

2003-03-29 Mohan Embar <gnustuff@thisiscool.com>
authoraph <aph@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 25 Apr 2003 16:48:13 +0000 (16:48 +0000)
committeraph <aph@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 25 Apr 2003 16:48:13 +0000 (16:48 +0000)
        * include/jvm.h: (_Jv_GetNbArgs) added
        (_Jv_GetSafeArg) added
        (_Jv_SetArgs) added
        * prims.cc: (_Jv_GetNbArgs) implemented
        (_Jv_GetSafeArg) implemented
        (_Jv_SetArgs) implemented
        (_Jv_RunMain) use _Jv_SetArgs() instead of explicitly
        setting _Jv_argc and _Jv_argv
        * posix.cc: (_Jv_ThisExecutable) use _Jv_GetSafeArg()
        instead of _Jv_argv
        * java/lang/natRuntime.cc: (insertSystemProperties) use
        _Jv_GetSafeArg() instead of _Jv_argv

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@66067 138bc75d-0d04-0410-961f-82ee72b054a4

libjava/ChangeLog
libjava/include/jvm.h
libjava/java/lang/natRuntime.cc
libjava/posix.cc
libjava/prims.cc

index 03e855f..6765b0e 100644 (file)
@@ -1,3 +1,18 @@
+2003-03-29  Mohan Embar  <gnustuff@thisiscool.com>
+
+       * include/jvm.h: (_Jv_GetNbArgs) added
+       (_Jv_GetSafeArg) added
+       (_Jv_SetArgs) added
+       * prims.cc: (_Jv_GetNbArgs) implemented
+       (_Jv_GetSafeArg) implemented
+       (_Jv_SetArgs) implemented
+       (_Jv_RunMain) use _Jv_SetArgs() instead of explicitly
+       setting _Jv_argc and _Jv_argv
+       * posix.cc: (_Jv_ThisExecutable) use _Jv_GetSafeArg()
+       instead of _Jv_argv
+       * java/lang/natRuntime.cc: (insertSystemProperties) use
+       _Jv_GetSafeArg() instead of _Jv_argv
+
 2003-04-23  Tom Tromey  <tromey@redhat.com>
 
        * resolve.cc (_Jv_PrepareClass): Round size up to alignment
index 38f675a..9395feb 100644 (file)
@@ -352,7 +352,20 @@ extern "C"
   jlong _Jv_remJ (jlong, jlong);
 }
 
-/* Get the name of the running executable. */
+/* Get the number of arguments (cf. argc) or 0 if our argument
+   list was never initialized.  */
+extern int _Jv_GetNbArgs (void);
+
+/* Get the specified argument (cf. argv[index]) or "" if either
+   our argument list was never initialized or the specified index
+   is out of bounds.  */
+extern const char * _Jv_GetSafeArg (int index);
+
+/* Sets our argument list. Can be used by programs with non-standard
+   entry points.  */
+extern void _Jv_SetArgs (int argc, const char **argv);
+
+/* Get the name of the running executable.  */
 extern const char *_Jv_ThisExecutable (void);
 
 /* Return a pointer to a symbol in executable or loaded library.  */
index 2cf312e..69f78f6 100644 (file)
@@ -108,10 +108,6 @@ _Jv_SetDLLSearchPath (const char *)
 
 \f
 
-extern int _Jv_argc;
-extern const char **_Jv_argv;
-  // our process' command line arguments
-
 void
 java::lang::Runtime::exitInternal (jint status)
 {
@@ -590,7 +586,7 @@ java::lang::Runtime::insertSystemProperties (java::util::Properties *newprops)
     }
 
   // The name used to invoke this process (argv[0] in C).
-  SET ("gnu.gcj.progname", _Jv_argv[0]);
+  SET ("gnu.gcj.progname", _Jv_GetSafeArg (0));
 
   // Allow platform specific settings and overrides.
   _Jv_platform_initProperties (newprops);
index 2f80833..de58ab0 100644 (file)
@@ -25,9 +25,6 @@ details.  */
 extern "C" unsigned long long _clock (void);
 #endif
 
-// platform-specific executable name
-extern const char **_Jv_argv;
-
 #if defined(HAVE_PROC_SELF_EXE)
 static char exec_name[20];
   // initialized in _Jv_platform_initialize()
@@ -41,7 +38,7 @@ const char *_Jv_ThisExecutable (void)
   return exec_name;
     // initialized in _Jv_platform_initialize()
 #else
-  return _Jv_argv[0];
+  return _Jv_GetSafeArg (0);
 #endif
 }
 
index dc05d4b..9ddd1d2 100644 (file)
@@ -90,6 +90,30 @@ property_pair *_Jv_Environment_Properties;
 const char **_Jv_argv;
 int _Jv_argc;
 
+// Argument support.
+int
+_Jv_GetNbArgs (void)
+{
+  // _Jv_argc is 0 if not explicitly initialized.
+  return _Jv_argc;
+}
+
+const char *
+_Jv_GetSafeArg (int index)
+{
+  if (index >=0 && index < _Jv_GetNbArgs ())
+    return _Jv_argv[index];
+  else
+    return "";
+}
+
+void
+_Jv_SetArgs (int argc, const char **argv)
+{
+  _Jv_argc = argc;
+  _Jv_argv = argv;
+}
+
 #ifdef ENABLE_JVMPI
 // Pointer to JVMPI notification functions.
 void (*_Jv_JVMPI_Notify_OBJECT_ALLOC) (JVMPI_Event *event);
@@ -936,8 +960,7 @@ void
 _Jv_RunMain (jclass klass, const char *name, int argc, const char **argv, 
             bool is_jar)
 {
-  _Jv_argv = argv;
-  _Jv_argc = argc;
+  _Jv_SetArgs (argc, argv);
 
   java::lang::Runtime *runtime = NULL;