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


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

[RFA] Append / to -B


Hi Guys,

  I use the -B option to xgcc a lot, and I finally got fed up of it
  not coping with the fact that I occasionally forget to append a
  forward-slash to the end of the path.  Without the forward-slash the
  path is not valid and xgcc will, typically, complain about not being
  able to find cc1.

  The patch is careful to only append the forward-slash (actually a
  DIR_SEPARATOR) if one is missing and if doing so would create a
  valid path to a directory.  So -B can still be used to define a
  prefix to the names of executables.

  May I apply this patch ?

Cheers
        Nick

2001-06-29  Nick Clifton  <nickc@cambridge.redhat.com>

	* gcc.c (process_command): Append a DIR_SEPARATOR to a path
	specified by the -B switch, if doing so would create a valid
	directory name.

Index: gcc/gcc.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gcc.c,v
retrieving revision 1.233
diff -p -w -r1.233 gcc.c
*** gcc.c	2001/06/10 00:31:07	1.233
--- gcc.c	2001/06/29 15:37:00
*************** process_command (argc, argv)
*** 3366,3381 ****
  	    case 'B':
  	      {
  		const char *value;
  		if (p[1] == 0 && i + 1 == argc)
  		  fatal ("argument to `-B' is missing");
  		if (p[1] == 0)
  		  value = argv[++i];
  		else
  		  value = p + 1;
  		{
  		  /* As a kludge, if the arg is "[foo/]stageN/", just
  		     add "[foo/]include" to the include prefix.  */
- 		  int len = strlen (value);
  		  if ((len == 7
  		       || (len > 7
  			   && (IS_DIR_SEPARATOR (value[len - 8]))))
--- 3366,3399 ----
  	    case 'B':
  	      {
  		const char *value;
+ 		int len;
+ 
  		if (p[1] == 0 && i + 1 == argc)
  		  fatal ("argument to `-B' is missing");
  		if (p[1] == 0)
  		  value = argv[++i];
  		else
  		  value = p + 1;
+ 
+ 		len = strlen (value);
+ 
+ 		/* Catch the case where the user has forgotten to append a
+ 		   directory seperator to the path.  Note, they may be using
+ 		   -B to add an executable name prefix, eg "i386-elf-", in
+ 		   order to distinguish between multiple installations of
+ 		   GCC in the same directory.  Hence we must check to see
+ 		   if appending a directory separator actually makes a
+ 		   valid directory name.  */
+ 		if (! IS_DIR_SEPARATOR (value [len - 1])
+ 		    && is_directory (value, "", 0))
  		  {
+ 		    value = strcpy (xmalloc (len + 2), value);
+ 		    value[len] = DIR_SEPARATOR;
+ 		    value[++ len] = 0;
+ 		  }
+ 		
  		/* As a kludge, if the arg is "[foo/]stageN/", just
  		   add "[foo/]include" to the include prefix.  */
  		if ((len == 7
  		     || (len > 7
  			 && (IS_DIR_SEPARATOR (value[len - 8]))))
*************** process_command (argc, argv)
*** 3389,3401 ****
  		      else
  			{
  			  char *string = xmalloc (len + 1);
  			  strncpy (string, value, len-7);
  			  strcpy (string+len-7, "include");
  			  add_prefix (&include_prefixes, string, NULL,
  				      PREFIX_PRIORITY_B_OPT, 0, NULL);
  			}
- 		    }
  		}
  		add_prefix (&exec_prefixes, value, NULL,
  			    PREFIX_PRIORITY_B_OPT, 0, &warn_B);
  		add_prefix (&startfile_prefixes, value, NULL,
--- 3407,3420 ----
  		    else
  		      {
  			char * string = xmalloc (len + 1);
+ 
  			strncpy (string, value, len - 7);
  			strcpy (string + len - 7, "include");
  			add_prefix (&include_prefixes, string, NULL,
  				    PREFIX_PRIORITY_B_OPT, 0, NULL);
  		      }
  		  }
+ 
  		add_prefix (&exec_prefixes, value, NULL,
  			    PREFIX_PRIORITY_B_OPT, 0, &warn_B);
  		add_prefix (&startfile_prefixes, value, NULL,


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