This is the mail archive of the
java-patches@sources.redhat.com
mailing list for the Java project.
Re: patch to add -classpath option to gij
- To: Oskar Liljeblad <osk at hem dot passagen dot se>
- Subject: Re: patch to add -classpath option to gij
- From: Jeff Sturm <jsturm at detroit dot appnet dot com>
- Date: Mon, 24 Jul 2000 10:20:46 -0400
- CC: java-patches at sourceware dot cygnus dot com
- Organization: AppNet Inc.
- References: <20000724150008.A1399@oskar>
- Reply-To: jeff dot sturm at appnet dot com
Oskar Liljeblad wrote:
>
> Here's a patch that add the -classpath option to gij. It was
> originally written by me but Jeff Sturm refurbished it a
> bit (and added support for -classpath=FOO as well -classpath FOO).
>
> 2000-07-24 Oskar Liljeblad <osk@hem.passagen.se>
>
> * gij.cc: Implemented parsing of -classpath option.
Oskar, I think my suggestion caused a bug in the argument processing. The line
strcat (cp_env, argv[i]);
should have been
strcat (cp_env, classpath);
I've retested this and it seems OK. Attached is a revised patch.
--
Jeff Sturm
jeff.sturm@appnet.com
Index: gij.cc
===================================================================
RCS file: /cvs/java/libgcj/libjava/gij.cc,v
retrieving revision 1.9
diff -u -p -r1.9 gij.cc
--- gij.cc 2000/05/31 22:49:18 1.9
+++ gij.cc 2000/07/24 14:06:26
@@ -27,6 +27,7 @@ help ()
printf ("Usage: gij [OPTION] ... CLASS [ARGS] ...\n\n");
printf ("Interpret Java bytecodes\n\n");
printf (" -DVAR=VAL define property VAR with value VAL\n");
+ printf (" --classpath=PATH set path to find .class files\n");
printf (" --help print this help, then exit\n");
printf (" --ms=NUMBER set initial heap size\n");
printf (" --mx=NUMBER set maximum heap size\n");
@@ -51,6 +52,7 @@ main (int argc, const char **argv)
/* We rearrange ARGV so that all the -D options appear near the
beginning. */
int last_D_option = 0;
+ const char *classpath = NULL;
int i;
for (i = 1; i < argc; ++i)
@@ -106,6 +108,14 @@ main (int argc, const char **argv)
goto no_arg;
_Jv_SetMaximumHeapSize (argv[++i]);
}
+ else if (! strncmp (arg, "-classpath=", 11))
+ classpath = arg + 11;
+ else if (! strcmp (arg, "-classpath"))
+ {
+ if (i >= argc - 1)
+ goto no_arg;
+ classpath = argv[++i];
+ }
else
{
fprintf (stderr, "gij: unrecognized option -- `%s'\n", argv[i]);
@@ -116,6 +126,15 @@ main (int argc, const char **argv)
argv[last_D_option] = NULL;
_Jv_Compiler_Properties = argv;
+
+ if (classpath)
+ {
+ char *cp_env;
+ cp_env = (char *) _Jv_Malloc(strlen (classpath) + 10 + 1);
+ strcpy (cp_env, "CLASSPATH=");
+ strcat (cp_env, classpath);
+ putenv (cp_env);
+ }
if (argc - i < 1)
{