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


Here is a revised version of my path-handling patch.  It drops support
for --wholeclasspath.  It also removes the internal routine
jcf_path_CLASSPATH_arg - callers that see --CLASSPATH now just call
jcf_path_classpath_arg directly.

If I don't hear anything, I will check this in tomorrow (along with
a gcj.texi patch).
-- 
	--Per Bothner
per@bothner.com   http://www.bothner.com/per/
2002-02-22  Per Bothner  <per@bothner.com>

	Make --CLASSPATH by a synonym for --classpath and -classpath.
	Implement --bootclasspath.
	* jcf-path.c (classpath_u):  Rename static variable to classpath_user.
	(classpath_l):  Remove.
	(jcf_path_CLASSPATH_arg):  Remove.
	(jcf_path_bootclasspath_arg):  New function.
	(jcf_path_seal):  Simplify accordingly.

	* jcf.h (jcf_path_bootclasspath_arg):  New declarations.
	(jcf_path_CLASSPATH):  Remove declaration.
	* jvspec.c (jvgenmain_spec):  Also accept -fbootclasspath*.
	(lang_specific_driver):  Translate -bootclasspath.
	* lang-options.h:  Add --bootclasspath.  Update --CLASSPATH.
	* lang.c (decode_lang_options):  Do jcf_path_init first.
	Handle -fCLASSPATH same as -fclasspath.  Also process -fbootclasspath.
	* gjavah.c:  Also handle --bootclasspath.
	Handle --CLASSPATH as a synonum for --classpath.
	* jcf-dump.c: Likewise.

	"." is not part of system path, but is the default for --classpath.
	* jcf-path.c (jcf_path_init):  Don't add "." to sys_dirs.
	(jcf_path_seal):  Add "." if no CLASSPATH specified.

Index: gcc.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gcc.c,v
retrieving revision 1.295
diff -u -p -r1.295 gcc.c
--- gcc.c	2002/02/23 05:59:47	1.295
+++ gcc.c	2002/02/25 18:32:55
@@ -908,7 +908,8 @@ static const struct option_map option_ma
    {"--assemble", "-S", 0},
    {"--assert", "-A", "a"},
    {"--classpath", "-fclasspath=", "aj"},
-   {"--CLASSPATH", "-fCLASSPATH=", "aj"},
+   {"--bootclasspath", "-fbootclasspath=", "aj"},
+   {"--CLASSPATH", "-fclasspath=", "aj"},
    {"--comments", "-C", 0},
    {"--compile", "-c", 0},
    {"--debug", "-g", "oj"},
Index: java/gjavah.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/gjavah.c,v
retrieving revision 1.84
diff -u -p -r1.84 gjavah.c
--- gjavah.c	2002/02/20 23:12:24	1.84
+++ gjavah.c	2002/02/25 18:32:56
@@ -2102,7 +2102,8 @@ DEFUN(process_file, (jcf, out),
 #define LONG_OPT(Num)  ((Num) + 128)
 
 #define OPT_classpath     LONG_OPT (0)
-#define OPT_CLASSPATH     LONG_OPT (1)
+#define OPT_CLASSPATH     OPT_classpath
+#define OPT_bootclasspath LONG_OPT (1)
 #define OPT_HELP          LONG_OPT (2)
 #define OPT_TEMP          LONG_OPT (3)
 #define OPT_VERSION       LONG_OPT (4)
@@ -2119,7 +2120,8 @@ DEFUN(process_file, (jcf, out),
 static const struct option options[] =
 {
   { "classpath",     required_argument, NULL, OPT_classpath },
-  { "CLASSPATH",     required_argument, NULL, OPT_CLASSPATH },
+  { "bootclasspath", required_argument, NULL, OPT_bootclasspath },
+  { "CLASSPATH",     required_argument, NULL, OPT_CLASSPATH },
   { "help",          no_argument,       NULL, OPT_HELP },
   { "stubs",         no_argument,       &stubs, 1 },
   { "td",            required_argument, NULL, OPT_TEMP },
@@ -2158,10 +2160,9 @@ help ()
   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 ("  -IDIR                   Append directory to class path\n");
+  printf ("  --bootclasspath PATH    Override built-in class path\n");
   printf ("  -d DIRECTORY            Set output directory name\n");
   printf ("  -o FILE                 Set output file name\n");
   printf ("  -td DIRECTORY           Set temporary directory name\n");
@@ -2241,8 +2242,8 @@ DEFUN(main, (argc, argv),
 	  jcf_path_classpath_arg (optarg);
 	  break;
 
-	case OPT_CLASSPATH:
-	  jcf_path_CLASSPATH_arg (optarg);
+	case OPT_bootclasspath:
+	  jcf_path_bootclasspath_arg (optarg);
 	  break;
 
 	case OPT_HELP:
Index: java/jcf-dump.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/jcf-dump.c,v
retrieving revision 1.42
diff -u -p -r1.42 jcf-dump.c
--- jcf-dump.c	2002/02/20 23:12:24	1.42
+++ jcf-dump.c	2002/02/25 18:32:57
@@ -774,7 +774,8 @@ DEFUN(process_class, (jcf),
 #define LONG_OPT(Num)  ((Num) + 128)
 
 #define OPT_classpath     LONG_OPT (0)
-#define OPT_CLASSPATH     LONG_OPT (1)
+#define OPT_CLASSPATH     OPT_classpath
+#define OPT_bootclasspath LONG_OPT (1)
 #define OPT_HELP          LONG_OPT (2)
 #define OPT_VERSION       LONG_OPT (3)
 #define OPT_JAVAP         LONG_OPT (4)
@@ -782,6 +783,7 @@ DEFUN(process_class, (jcf),
 static const struct option options[] =
 {
   { "classpath",     required_argument, NULL, OPT_classpath },
+  { "bootclasspath", required_argument, NULL, OPT_bootclasspath },
   { "CLASSPATH",     required_argument, NULL, OPT_CLASSPATH },
   { "help",          no_argument,       NULL, OPT_HELP },
   { "verbose",       no_argument,       NULL, 'v' },
@@ -806,10 +808,9 @@ help ()
   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 ("  -IDIR                   Append directory to class path\n");
+  printf ("  --bootclasspath PATH    Override built-in class path\n");
   printf ("  -o FILE                 Set output file name\n");
   printf ("\n");
   printf ("  --help                  Print this help, then exit\n");
@@ -876,8 +877,8 @@ DEFUN(main, (argc, argv),
 	  jcf_path_classpath_arg (optarg);
 	  break;
 
-	case OPT_CLASSPATH:
-	  jcf_path_CLASSPATH_arg (optarg);
+	case OPT_bootclasspath:
+	  jcf_path_bootclasspath_arg (optarg);
 	  break;
 
 	case OPT_HELP:
Index: java/jcf-path.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/jcf-path.c,v
retrieving revision 1.18
diff -u -p -r1.18 jcf-path.c
--- jcf-path.c	2002/02/20 23:12:24	1.18
+++ jcf-path.c	2002/02/25 18:32:57
@@ -1,6 +1,6 @@
 /* Handle CLASSPATH, -classpath, and path searching.
 
-   Copyright (C) 1998, 1999, 2000, 2001  Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2000, 2001, 2002  Free Software Foundation, Inc.
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
@@ -72,7 +72,8 @@ static void add_path PARAMS ((struct ent
    built-in system directory (only libgcj.jar)
    CLASSPATH environment variable
    -classpath option overrides $CLASSPATH
-   -CLASSPATH option overrides $CLASSPATH, -classpath, and built-in
+   -CLASSPATH option is a synonym for -classpath (for compatibility)
+   -bootclasspath overrides built-in
    -I prepends path to list
 
    We implement this by keeping several path lists, and then simply
@@ -85,11 +86,8 @@ static struct entry *include_dirs;
 static struct entry *classpath_env;
 
 /* This holds the -classpath command-line option.  */
-static struct entry *classpath_u;
+static struct entry *classpath_user;
 
-/* This holds the -CLASSPATH command-line option.  */
-static struct entry *classpath_l;
-
 /* This holds the default directories.  Some of these will have the
    "system" flag set.  */
 static struct entry *sys_dirs;
@@ -222,6 +220,8 @@ add_path (entp, cp, is_system)
     }
 }
 
+static int init_done = 0;
+
 /* Initialize the path module.  */
 void
 jcf_path_init ()
@@ -231,7 +231,9 @@ jcf_path_init ()
   struct stat stat_b;
   int found = 0, len;
 
-  add_entry (&sys_dirs, ".", 0);
+  if (init_done)
+    return;
+  init_done = 1;
 
   sep[0] = DIR_SEPARATOR;
   sep[1] = '\0';
@@ -284,27 +286,25 @@ jcf_path_init ()
   add_path (&classpath_env, cp, 0);
 }
 
-/* Call this when -CLASSPATH is seen on the command line.
-   This is the override-all switch, even the built in classes
-   are overridden.
+/* 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_l);
-  add_path (&classpath_l, path, 0);
+  free_entry (&classpath_user);
+  add_path (&classpath_user, path, 0);
 }
 
-/* Call this when -classpath is seen on the command line.
-   This overrides only the $CLASSPATH environment variable.
+/* Call this when -bootclasspath is seen on the command line.
  */
 void
-jcf_path_classpath_arg (path)
+jcf_path_bootclasspath_arg (path)
      const char *path;
 {
-  free_entry (&classpath_u);
-  add_path (&classpath_u, path, 0);
+  free_entry (&sys_dirs);
+  add_path (&sys_dirs, path, 1);
 }
 
 /* Call this when -I is seen on the command line.  */
@@ -322,42 +322,32 @@ void
 jcf_path_seal (print)
      int print;
 {
-  int do_system = 1;
   struct entry *secondary;
 
   sealed = include_dirs;
   include_dirs = NULL;
 
-  if (classpath_l)
+  if (classpath_user)
     {
-      secondary = classpath_l;
-      classpath_l = NULL;
-      do_system = 0;
+      secondary = classpath_user;
+      classpath_user = NULL;
     }
-  else if (classpath_u)
-    {
-      secondary = classpath_u;
-      classpath_u = NULL;
-    }
   else
     {
+      if (! classpath_env)
+	add_entry (&classpath_env, ".", 0);
+
       secondary = classpath_env;
       classpath_env = NULL;
     }
+
 
-  free_entry (&classpath_l);
-  free_entry (&classpath_u);
+  free_entry (&classpath_user);
   free_entry (&classpath_env);
 
   append_entry (&sealed, secondary);
-
-  if (do_system)
-    {
-      append_entry (&sealed, sys_dirs);
-      sys_dirs = NULL;
-    }
-  else
-    free_entry (&sys_dirs);
+  append_entry (&sealed, sys_dirs);
+  sys_dirs = NULL;
 
   if (print)
     {
Index: java/jcf.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/jcf.h,v
retrieving revision 1.28
diff -u -p -r1.28 jcf.h
--- jcf.h	2002/02/20 23:12:24	1.28
+++ jcf.h	2002/02/25 18:32:57
@@ -271,8 +271,8 @@ extern void jcf_dependency_print_dummies
 
 /* 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_bootclasspath_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: java/jvspec.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/jvspec.c,v
retrieving revision 1.52
diff -u -p -r1.52 jvspec.c
--- jvspec.c	2002/02/23 00:42:13	1.52
+++ jvspec.c	2002/02/25 18:32:58
@@ -1,6 +1,6 @@
 /* Specific flags and argument handling of the front-end of the 
    GNU compiler for the Java(TM) language.
-   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
 
 This file is part of GNU CC.
 
@@ -65,8 +65,9 @@ static const char jvgenmain_spec[] =
                    %{<fcompile-resource*}\
 		   %{<femit-class-file} %{<femit-class-files} %{<fencoding*}\
 		   %{<fuse-boehm-gc} %{<fhash-synchronization} %{<fjni}\
-		   %{<findirect-dispatch} \
-		   %{<fclasspath*} %{<fCLASSPATH*} %{<foutput-class-dir}\
+		   %{<findirect-dispatch}\
+		   %{<fclasspath*} %{<fCLASSPATH*} %{<fbootclasspath*} \
+		   %{<foutput-class-dir}\
 		   %{<fuse-divide-subroutine} %{<fno-use-divide-subroutine}\
 		   %{<fcheck-references} %{<fno-check-references}\
 		   %{<ffilelist-file}\
@@ -328,6 +329,7 @@ lang_specific_driver (in_argc, in_argv, 
 	      quote = argv[i];
 	    }
 	  else if (strcmp(argv[i], "-classpath") == 0
+		   || strcmp(argv[i], "-bootclasspath") == 0
 		   || strcmp(argv[i], "-CLASSPATH") == 0)
 	    {
 	      quote = argv[i];
@@ -521,6 +523,7 @@ lang_specific_driver (in_argc, in_argv, 
 	}
 
       if (strcmp (argv[i], "-classpath") == 0
+	  || strcmp (argv[i], "-bootclasspath") == 0
 	  || strcmp (argv[i], "-CLASSPATH") == 0)
 	{
 	  arglist[j] = concat ("-f", argv[i]+1, "=", argv[i+1], NULL);
Index: java/lang-options.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/lang-options.h,v
retrieving revision 1.29
diff -u -p -r1.29 lang-options.h
--- lang-options.h	2002/02/20 23:12:24	1.29
+++ lang-options.h	2002/02/25 18:32:58
@@ -32,10 +32,12 @@ DEFINE_LANG_NAME ("Java")
     N_("Disable automatic array bounds checking") },
   { "-fjni",
     N_("Assume native functions are implemented using JNI") },
-  { "--CLASSPATH",
-    N_("Set class path and suppress system path") },
+  { "--bootclasspath",
+    N_("Replace system path") },
   { "--classpath",
     N_("Set class path") },
+  { "--CLASSPATH",
+    N_("Set class path (deprecated: use --classpath instead)") },
   { "--main",
     N_("Choose class whose main method should be used") },
   { "--encoding",
Index: java/lang.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/lang.c,v
retrieving revision 1.85
diff -u -p -r1.85 lang.c
--- lang.c	2002/02/20 23:12:24	1.85
+++ lang.c	2002/02/25 18:32:58
@@ -257,6 +257,8 @@ java_decode_option (argc, argv)
 {
   char *p = argv[0];
 
+  jcf_path_init ();
+
   if (strcmp (p, "-version") == 0)
     {
       version_flag = 1;
@@ -302,7 +304,7 @@ java_decode_option (argc, argv)
 #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
@@ -310,6 +312,13 @@ java_decode_option (argc, argv)
   if (strncmp (p, CLARG, sizeof (CLARG) - 1) == 0)
     {
       jcf_path_classpath_arg (p + sizeof (CLARG) - 1);
+      return 1;
+    }
+#undef CLARG
+#define CLARG "-fbootclasspath="
+  if (strncmp (p, CLARG, sizeof (CLARG) - 1) == 0)
+    {
+      jcf_path_bootclasspath_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]