diff options
author | Olivier Hainque <hainque@adacore.com> | 2018-07-31 08:30:41 +0000 |
---|---|---|
committer | Olivier Hainque <hainque@gcc.gnu.org> | 2018-07-31 08:30:41 +0000 |
commit | 58691d4a04c2c8d81298441a7621e6e6df69b21a (patch) | |
tree | 2a59e72d1ad06f17e361ff67a641947ba95d60fb | |
parent | c89b64d7eb41cc750829db403f9e82549ce5e605 (diff) | |
download | gcc-58691d4a04c2c8d81298441a7621e6e6df69b21a.zip gcc-58691d4a04c2c8d81298441a7621e6e6df69b21a.tar.gz gcc-58691d4a04c2c8d81298441a7621e6e6df69b21a.tar.bz2 |
getenv_spec_function to prepend / to value for undef var
So the value can be used in places where an absolute path
is expected.
2018-07-31 Olivier Hainque <hainque@adacore.com>
* gcc.c (getenv_spec_function): Prepend '/' to value for
allowed undefined variables.
From-SVN: r263081
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/gcc.c | 15 |
2 files changed, 18 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0616687..e2eb1c6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2018-07-31 Olivier Hainque <hainque@adacore.com> + + * gcc.c (getenv_spec_function): Prepend '/' to value for allowed + undefined variables. + 2018-07-30 Segher Boessenkool <segher@kernel.crashing.org> PR target/86640 @@ -9244,7 +9244,11 @@ print_multilib_info (void) Returns the value of the environment variable given by its first argument, concatenated with the second argument. If the variable is not defined, a fatal error is issued unless such undefs are internally allowed, in which - case the variable name is used as the variable value. */ + case the variable name prefixed by a '/' is used as the variable value. + + The leading '/' allows using the result at a spot where a full path would + normally be expected and when the actual value doesn't really matter since + undef vars are allowed. */ static const char * getenv_spec_function (int argc, const char **argv) @@ -9262,8 +9266,15 @@ getenv_spec_function (int argc, const char **argv) varname = argv[0]; value = env.get (varname); + /* If the variable isn't defined and this is allowed, craft our expected + return value. Assume variable names used in specs strings don't contain + any active spec character so don't need escaping. */ if (!value && spec_undefvar_allowed) - value = varname; + { + result = XNEWVAR (char, strlen(varname) + 2); + sprintf (result, "/%s", varname); + return result; + } if (!value) fatal_error (input_location, |