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]

Interpolation of Env variables.


- gcc.c: The ability to interpolate an environment variable into
  specs is useful (e.g. CFLAGS), and in the case of the current
  Interix, necessary, as the path to the current root is
  installation-defined (also applicable to some other systems, e.g.
  windows).  This adds the ability to interpolate an environment
  variable in a spec.

  Note, I am aware of Zach Weinberg's proposal for a completely new
  specs syntax; it already has this feature, and would be fine if
  accepted.  (However, it would be very useful to apply this fix until
  such time as his proposal is done.)

  The syntax is %$ENV_VAR, which is terminated by the first
non-environment
  variable character (per the shells).

  (In a prior submission from Mumit Khan, this was bundled with a more
  specific-to-Interix feature that will be handled in another way.)

  See the Interix LIB_SPEC for an example use of this feature.

Donn
-- 

===================================================
Donn Terry                  mailto:donn@interix.com
Softway Systems, Inc.        http://www.interix.com
2850 McClelland Dr, Ste. 1800   Ft.Collins CO 80525
Tel: +1-970-204-9900           Fax: +1-970-204-9951
===================================================
- gcc.c: The ability to interpolate an environment variable into
  specs is useful (e.g. CFLAGS), and in the case of the current
  Interix, necessary, as the path to the current root is
  installation-defined (also applicable to some other systems, e.g.
  windows).  This adds the ability to interpolate an environment
  variable in a spec.

  Note, I am aware of Zach Weinberg's proposal for a completely new
  specs syntax; it already has this feature, and would be fine if
  accepted.  (However, it would be very useful to apply this fix until
  such time as his proposal is done.)

  The syntax is %$ENV_VAR, which is terminated by the first non-environment
  variable character (per the shells).

  (In a prior submission from Mumit Khan, this was bundled with a more
  specific-to-Interix feature that will be handled in another way.)

  See the Interix LIB_SPEC for an example use of this feature.

==========================================================================

Wed Mar 24 15:01:09 1999  Mumit Khan  <khan@xraylith.wisc.edu>
			  Donn Terry  <donn@interix.com>
	
	* gcc.c (main): Add specs handling for environment variables.

diff -urP egcs.source.old/gcc/gcc.c egcs.source/gcc/gcc.c
--- egcs.source.old/gcc/gcc.c	Tue Mar 23 09:24:22 1999
+++ egcs.source/gcc/gcc.c	Wed Mar 24 16:30:29 1999
@@ -352,6 +352,8 @@
 	  combined with ! and . as above binding stronger than the OR.
  %(Spec) processes a specification defined in a specs file as *Spec:
  %[Spec] as above, but put __ around -D arguments
+ %$     substitute env variable following $ (terminated by first
+	non-env character.)
 
 The conditional text X in a %{S:X} or %{!S:X} construct may contain
 other nested % constructs or spaces, or even newlines.  They are
@@ -4204,6 +4206,31 @@
 	    if (input_from_pipe)
 	      do_spec_1 ("-", 0, NULL_PTR);
 	    break;
+
+	  case '$':
+	    { 
+	      char *x;
+	      char *y;
+	      int t;
+
+	      t = strspn (p, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_");
+
+	      y = alloca (t+1);
+	      strncpy (y, p, t);
+	      y[t] = '\0';
+	      x = getenv (y);
+	      if (x != NULL) 
+		{
+		  obstack_grow (&obstack, x, strlen (x));
+		}
+	      else
+		{
+		  /* just copy the unexpanded variable */
+		  obstack_grow (&obstack, &p[-1], t+1);
+		}
+	      p += t;
+	  }
+	  break;
 
 	  default:
 	    abort ();

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