This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: -classpath switch patch


Attached is the patch for the classpath switch stuff.

The patch simply swaps the meaning of the -classpath and --CLASSPATH
switches so that the -classpath switch does NOT override the system
classpath (but the -CLASSPATH switch does).



Here's a changelog description:         

        * gcc/java/gcj.texi (Input options): ditto.
        * gcc/java/gjavah.c (struct option, help, main): ditto.
        * jcf-dump.c (struct options, help, main): ditto.
        * jv-spec.c (jvgenmain_spec, lang_specific_driver): ditto.
        * lang-options.h: ditto.
        * lang.c (java_decode_option): ditto. 
        * jcf.h, jcf-path.c (struct entry): change meaning of options.
          (jcf_path_classpath_arg): changed meaning of option.
          (jcf_path_bootclasspath_arg): new function.
          (jcf_path_CLASSPATH_arg): removed. 


Comments are most welcome (including about the format of my changelog
entry).


Nic


Index: gcc/java/gcj.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/gcj.texi,v
retrieving revision 1.21
diff -u -r1.21 gcj.texi
--- gcj.texi	2002/02/07 19:39:27	1.21
+++ gcj.texi	2002/02/20 13:45:49
@@ -141,7 +141,7 @@
 @ignore
 @c man begin SYNOPSIS gcj
 gcj [@option{-I}@var{dir}@dots{}] [@option{-d} @var{dir}@dots{}]
-    [@option{--classpath}=@var{path}] [@option{--CLASSPATH}=@var{path}]
+    [@option{--CLASSPATH}=@var{path}] [@option{--classpath}=@var{path}]
     [@option{-f}@var{option}@dots{}] [@option{--encoding}=@var{name}]
     [@option{--main}=@var{classname}] [@option{-D}@var{name}[=@var{value}]@dots{}]
     [@option{-C}] [@option{-R} @var{resource-name}] [@option{-d} @var{directory}]
@@ -240,11 +240,12 @@
 always using @code{-I} instead of the other options for manipulating the
 class path.
 
-@item --classpath=@var{path}
+@item --CLASSPATH=@var{path}
 This sets the class path to @var{path}, a colon-separated list of paths
-(on Windows-based systems, a semicolon-separate list of paths).
+(on Windows-based systems, a semicolon-separate list of paths). Using
+this option causes the built in path to be suppressed.
 
-@item --CLASSPATH=@var{path}
+@item --classpath=@var{path}
 This sets the class path to @var{path}, a colon-separated list of paths
 (on Windows-based systems, a semicolon-separate list of paths).  This
 differs from the @code{--classpath} option in that it does not suppress
@@ -261,17 +262,18 @@
 First come all directories specified via @code{-I}.
 
 @item
-If @code{--classpath} is specified, its value is appended and processing
-stops.  That is, @code{--classpath} suppresses all the options mentioned
+If @option{--CLASSPATH} is specified, its value is appended and processing
+stops.  That is, @option{--CLASSPATH} suppresses all the options mentioned
 later in this list.
 
 @item
-If @code{--CLASSPATH} is specified, its value is appended and the
+If @option{--classpath} is specified, its value is appended and the
 @code{CLASSPATH} environment variable is suppressed.
 
 @item
 If the @code{CLASSPATH} environment variable is specified (and was not
-suppressed by @code{--CLASSPATH}), then its value is appended.
+suppressed by @option{--classpath} or @option{--CLASSPATH}), then its
+value is appended.
 
 @item
 Finally, the built-in system directory, @file{libgcj.jar}, is appended.
Index: gcc/java/gjavah.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/gjavah.c,v
retrieving revision 1.83
diff -u -r1.83 gjavah.c
--- gjavah.c	2002/01/31 19:36:25	1.83
+++ gjavah.c	2002/02/20 13:45:54
@@ -2101,41 +2101,41 @@
 /* This is used to mark options with no short value.  */
 #define LONG_OPT(Num)  ((Num) + 128)
 
-#define OPT_classpath LONG_OPT (0)
-#define OPT_CLASSPATH LONG_OPT (1)
-#define OPT_HELP      LONG_OPT (2)
-#define OPT_TEMP      LONG_OPT (3)
-#define OPT_VERSION   LONG_OPT (4)
-#define OPT_PREPEND   LONG_OPT (5)
-#define OPT_FRIEND    LONG_OPT (6)
-#define OPT_ADD       LONG_OPT (7)
-#define OPT_APPEND    LONG_OPT (8)
-#define OPT_M         LONG_OPT (9)
-#define OPT_MM        LONG_OPT (10)
-#define OPT_MG        LONG_OPT (11)
-#define OPT_MD        LONG_OPT (12)
-#define OPT_MMD       LONG_OPT (13)
+#define OPT_classpath     LONG_OPT (0)
+#define OPT_CLASSPATH     LONG_OPT (1)
+#define OPT_HELP          LONG_OPT (2)
+#define OPT_TEMP          LONG_OPT (3)
+#define OPT_VERSION       LONG_OPT (4)
+#define OPT_PREPEND       LONG_OPT (5)
+#define OPT_FRIEND        LONG_OPT (6)
+#define OPT_ADD           LONG_OPT (7)
+#define OPT_APPEND        LONG_OPT (8)
+#define OPT_M             LONG_OPT (9)
+#define OPT_MM            LONG_OPT (10)
+#define OPT_MG            LONG_OPT (11)
+#define OPT_MD            LONG_OPT (12)
+#define OPT_MMD           LONG_OPT (13)
 
 static const struct option options[] =
 {
-  { "classpath", required_argument, NULL, OPT_classpath },
-  { "CLASSPATH", required_argument, NULL, OPT_CLASSPATH },
-  { "help",      no_argument,       NULL, OPT_HELP },
-  { "stubs",     no_argument,       &stubs, 1 },
-  { "td",        required_argument, NULL, OPT_TEMP },
-  { "verbose",   no_argument,       NULL, 'v' },
-  { "version",   no_argument,       NULL, OPT_VERSION },
-  { "prepend",   required_argument, NULL, OPT_PREPEND },
-  { "friend",    required_argument, NULL, OPT_FRIEND },
-  { "add",       required_argument, NULL, OPT_ADD },
-  { "append",    required_argument, NULL, OPT_APPEND },
-  { "M",         no_argument,       NULL, OPT_M   },
-  { "MM",        no_argument,       NULL, OPT_MM  },
-  { "MG",        no_argument,       NULL, OPT_MG  },
-  { "MD",        no_argument,       NULL, OPT_MD  },
-  { "MMD",       no_argument,       NULL, OPT_MMD },
-  { "jni",       no_argument,       &flag_jni, 1 },
-  { NULL,        no_argument,       NULL, 0 }
+  { "classpath",     required_argument, NULL, OPT_classpath },
+  { "CLASSPATH",     required_argument, NULL, OPT_CLASSPATH },
+  { "help",          no_argument,       NULL, OPT_HELP },
+  { "stubs",         no_argument,       &stubs, 1 },
+  { "td",            required_argument, NULL, OPT_TEMP },
+  { "verbose",       no_argument,       NULL, 'v' },
+  { "version",       no_argument,       NULL, OPT_VERSION },
+  { "prepend",       required_argument, NULL, OPT_PREPEND },
+  { "friend",        required_argument, NULL, OPT_FRIEND },
+  { "add",           required_argument, NULL, OPT_ADD },
+  { "append",        required_argument, NULL, OPT_APPEND },
+  { "M",             no_argument,       NULL, OPT_M   },
+  { "MM",            no_argument,       NULL, OPT_MM  },
+  { "MG",            no_argument,       NULL, OPT_MG  },
+  { "MD",            no_argument,       NULL, OPT_MD  },
+  { "MMD",           no_argument,       NULL, OPT_MMD },
+  { "jni",           no_argument,       &flag_jni, 1 },
+  { NULL,            no_argument,       NULL, 0 }
 };
 
 static void
@@ -2158,8 +2158,9 @@
   printf ("  -friend TEXT            Insert TEXT as `friend' declaration\n");
   printf ("  -prepend TEXT           Insert TEXT before start of class\n");
   printf ("\n");
+  printf ("  --CLASSPATH PATH        Set path to find .class files, overriding\n\
+                          built-in class path\n");
   printf ("  --classpath PATH        Set path to find .class files\n");
-  printf ("  --CLASSPATH PATH        Set path to find .class files\n");
   printf ("  -IDIR                   Append directory to class path\n");
   printf ("  -d DIRECTORY            Set output directory name\n");
   printf ("  -o FILE                 Set output file name\n");
Index: gcc/java/jcf-dump.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/jcf-dump.c,v
retrieving revision 1.41
diff -u -r1.41 jcf-dump.c
--- jcf-dump.c	2002/02/18 04:55:07	1.41
+++ jcf-dump.c	2002/02/20 13:45:57
@@ -773,22 +773,22 @@
 /* This is used to mark options with no short value.  */
 #define LONG_OPT(Num)  ((Num) + 128)
 
-#define OPT_classpath LONG_OPT (0)
-#define OPT_CLASSPATH LONG_OPT (1)
-#define OPT_HELP      LONG_OPT (2)
-#define OPT_VERSION   LONG_OPT (3)
-#define OPT_JAVAP     LONG_OPT (4)
+#define OPT_classpath     LONG_OPT (0)
+#define OPT_CLASSPATH     LONG_OPT (1)
+#define OPT_HELP          LONG_OPT (2)
+#define OPT_VERSION       LONG_OPT (3)
+#define OPT_JAVAP         LONG_OPT (4)
 
 static const struct option options[] =
 {
-  { "classpath", required_argument, NULL, OPT_classpath },
-  { "CLASSPATH", required_argument, NULL, OPT_CLASSPATH },
-  { "help",      no_argument,       NULL, OPT_HELP },
-  { "verbose",   no_argument,       NULL, 'v' },
-  { "version",   no_argument,       NULL, OPT_VERSION },
-  { "javap",     no_argument,       NULL, OPT_JAVAP },
-  { "print-main", no_argument,      &flag_print_main, 1 },
-  { NULL,        no_argument,       NULL, 0 }
+  { "classpath",     required_argument, NULL, OPT_classpath },
+  { "CLASSPATH",     required_argument, NULL, OPT_CLASSPATH },
+  { "help",          no_argument,       NULL, OPT_HELP },
+  { "verbose",       no_argument,       NULL, 'v' },
+  { "version",       no_argument,       NULL, OPT_VERSION },
+  { "javap",         no_argument,       NULL, OPT_JAVAP },
+  { "print-main",    no_argument,      &flag_print_main, 1 },
+  { NULL,            no_argument,       NULL, 0 }
 };
 
 static void
@@ -806,8 +806,9 @@
   printf ("  -c                      Disassemble method bodies\n");
   printf ("  --javap                 Generate output in `javap' format\n");
   printf ("\n");
+  printf ("  --CLASSPATH PATH        Set path to find .class files, overriding\n\
+                          built-in class path\n");
   printf ("  --classpath PATH        Set path to find .class files\n");
-  printf ("  --CLASSPATH PATH        Set path to find .class files\n");
   printf ("  -IDIR                   Append directory to class path\n");
   printf ("  -o FILE                 Set output file name\n");
   printf ("\n");
Index: gcc/java/jcf-path.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/jcf-path.c,v
retrieving revision 1.17
diff -u -r1.17 jcf-path.c
--- jcf-path.c	2001/08/16 21:52:14	1.17
+++ jcf-path.c	2002/02/20 13:45:57
@@ -71,8 +71,8 @@
 
    built-in system directory (only libgcj.jar)
    CLASSPATH environment variable
-   -CLASSPATH overrides CLASSPATH
-   -classpath option - overrides CLASSPATH, -CLASSPATH, and built-in
+   -classpath option overrides $CLASSPATH
+   -CLASSPATH option overrides $CLASSPATH, -classpath, and built-in
    -I prepends path to list
 
    We implement this by keeping several path lists, and then simply
@@ -84,10 +84,10 @@
 /* This holds the CLASSPATH environment variable.  */
 static struct entry *classpath_env;
 
-/* This holds the -CLASSPATH command-line option.  */
+/* This holds the -classpath command-line option.  */
 static struct entry *classpath_u;
 
-/* This holds the -classpath command-line option.  */
+/* This holds the -CLASSPATH command-line option.  */
 static struct entry *classpath_l;
 
 /* This holds the default directories.  Some of these will have the
@@ -284,18 +284,23 @@
   add_path (&classpath_env, cp, 0);
 }
 
-/* Call this when -classpath is seen on the command line.  */
+/* Call this when -CLASSPATH is seen on the command line.
+   This is the override-all switch, even the built in classes
+   are overridden.
+ */
 void
-jcf_path_classpath_arg (path)
+jcf_path_CLASSPATH_arg (path)
      const char *path;
 {
   free_entry (&classpath_l);
   add_path (&classpath_l, path, 0);
 }
 
-/* Call this when -CLASSPATH is seen on the command line.  */
+/* Call this when -classpath is seen on the command line.
+   This overrides only the $CLASSPATH environment variable.
+ */
 void
-jcf_path_CLASSPATH_arg (path)
+jcf_path_classpath_arg (path)
      const char *path;
 {
   free_entry (&classpath_u);
Index: gcc/java/jcf.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/jcf.h,v
retrieving revision 1.27
diff -u -r1.27 jcf.h
--- jcf.h	2002/02/18 04:55:07	1.27
+++ jcf.h	2002/02/20 13:45:58
@@ -271,8 +271,8 @@
 
 /* Declarations for path handling code.  */
 extern void jcf_path_init PARAMS ((void));
-extern void jcf_path_classpath_arg PARAMS ((const char *));
 extern void jcf_path_CLASSPATH_arg PARAMS ((const char *));
+extern void jcf_path_classpath_arg PARAMS ((const char *));
 extern void jcf_path_include_arg PARAMS ((const char *));
 extern void jcf_path_seal PARAMS ((int));
 extern void *jcf_path_start PARAMS ((void));
Index: gcc/java/lang-options.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/lang-options.h,v
retrieving revision 1.28
diff -u -r1.28 lang-options.h
--- lang-options.h	2001/08/09 04:19:12	1.28
+++ lang-options.h	2002/02/20 13:45:58
@@ -32,9 +32,9 @@
     N_("Disable automatic array bounds checking") },
   { "-fjni",
     N_("Assume native functions are implemented using JNI") },
-  { "--classpath",
-    N_("Set class path and suppress system path") },
   { "--CLASSPATH",
+    N_("Set class path and suppress system path") },
+  { "--classpath",
     N_("Set class path") },
   { "--main",
     N_("Choose class whose main method should be used") },
Index: gcc/java/lang.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/lang.c,v
retrieving revision 1.84
diff -u -r1.84 lang.c
--- lang.c	2002/01/01 01:42:15	1.84
+++ lang.c	2002/02/20 13:46:00
@@ -299,17 +299,17 @@
       return 1;
     }
 #undef CLARG
-#define CLARG "-fclasspath="
+#define CLARG "-fCLASSPATH="
   if (strncmp (p, CLARG, sizeof (CLARG) - 1) == 0)
     {
-      jcf_path_classpath_arg (p + sizeof (CLARG) - 1);
+      jcf_path_CLASSPATH_arg (p + sizeof (CLARG) - 1);
       return 1;
     }
 #undef CLARG
-#define CLARG "-fCLASSPATH="
+#define CLARG "-fclasspath="
   if (strncmp (p, CLARG, sizeof (CLARG) - 1) == 0)
     {
-      jcf_path_CLASSPATH_arg (p + sizeof (CLARG) - 1);
+      jcf_path_classpath_arg (p + sizeof (CLARG) - 1);
       return 1;
     }
 #undef CLARG

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]