static inline void process_marked_switches (void);
static const char *process_brace_body (const char *, const char *, const char *, int, int);
static const struct spec_function *lookup_spec_function (const char *);
-static const char *eval_spec_function (const char *, const char *);
-static const char *handle_spec_function (const char *, bool *);
+static const char *eval_spec_function (const char *, const char *, const char *);
+static const char *handle_spec_function (const char *, bool *, const char *);
static char *save_string (const char *, int);
static void set_collect_gcc_options (void);
static int do_spec_1 (const char *, int, const char *);
-static int do_spec_2 (const char *);
+static int do_spec_2 (const char *, const char *);
static void do_option_spec (const char *, const char *);
static void do_self_spec (const char *);
static const char *find_file (const char *);
{
int value;
- value = do_spec_2 (spec);
+ value = do_spec_2 (spec, NULL);
/* Force out any unfinished command.
If -pipe, this forces out the last command if it ended in `|'. */
return value;
}
+/* Process the spec SPEC, with SOFT_MATCHED_PART designating the current value
+ of a matched * pattern which may be re-injected by way of %*. */
+
static int
-do_spec_2 (const char *spec)
+do_spec_2 (const char *spec, const char *soft_matched_part)
{
int result;
input_from_pipe = 0;
suffix_subst = NULL;
- result = do_spec_1 (spec, 0, NULL);
+ result = do_spec_1 (spec, 0, soft_matched_part);
end_going_arg ();
return result;
}
-
/* Process the given spec string and add any new options to the end
of the switches/n_switches array. */
{
int i;
- do_spec_2 (spec);
+ do_spec_2 (spec, NULL);
do_spec_1 (" ", 0, NULL);
/* Mark %<S switches processed by do_self_spec to be ignored permanently.
break;
case ':':
- p = handle_spec_function (p, NULL);
+ p = handle_spec_function (p, NULL, soft_matched_part);
if (p == 0)
return -1;
break;
/* Evaluate a spec function. */
static const char *
-eval_spec_function (const char *func, const char *args)
+eval_spec_function (const char *func, const char *args,
+ const char *soft_matched_part)
{
const struct spec_function *sf;
const char *funcval;
arguments. */
alloc_args ();
- if (do_spec_2 (args) < 0)
+ if (do_spec_2 (args, soft_matched_part) < 0)
fatal_error (input_location, "error in args to spec function %qs", func);
/* argbuf_index is an index for the next argument to be inserted, and
NULL if no processing is required.
If RETVAL_NONNULL is not NULL, then store a bool whether function
- returned non-NULL. */
+ returned non-NULL.
+
+ SOFT_MATCHED_PART holds the current value of a matched * pattern, which
+ may be re-expanded with a %* as part of the function arguments. */
static const char *
-handle_spec_function (const char *p, bool *retval_nonnull)
+handle_spec_function (const char *p, bool *retval_nonnull,
+ const char *soft_matched_part)
{
char *func, *args;
const char *endp, *funcval;
/* p now points to just past the end of the spec function expression. */
- funcval = eval_spec_function (func, args);
+ funcval = eval_spec_function (func, args, soft_matched_part);
if (funcval != NULL && do_spec_1 (funcval, 0, NULL) < 0)
p = NULL;
if (retval_nonnull)
{
atom = NULL;
end_atom = NULL;
- p = handle_spec_function (p + 2, &a_matched);
+ p = handle_spec_function (p + 2, &a_matched, NULL);
}
else
{
/* Process sysroot_suffix_spec. */
if (*sysroot_suffix_spec != 0
&& !no_sysroot_suffix
- && do_spec_2 (sysroot_suffix_spec) == 0)
+ && do_spec_2 (sysroot_suffix_spec, NULL) == 0)
{
if (argbuf.length () > 1)
error ("spec failure: more than one arg to SYSROOT_SUFFIX_SPEC");
/* Process sysroot_hdrs_suffix_spec. */
if (*sysroot_hdrs_suffix_spec != 0
&& !no_sysroot_suffix
- && do_spec_2 (sysroot_hdrs_suffix_spec) == 0)
+ && do_spec_2 (sysroot_hdrs_suffix_spec, NULL) == 0)
{
if (argbuf.length () > 1)
error ("spec failure: more than one arg to SYSROOT_HEADERS_SUFFIX_SPEC");
/* Look for startfiles in the standard places. */
if (*startfile_prefix_spec != 0
- && do_spec_2 (startfile_prefix_spec) == 0
+ && do_spec_2 (startfile_prefix_spec, NULL) == 0
&& do_spec_1 (" ", 0, NULL) == 0)
{
const char *arg;
fatal_error (input_location,
"too many arguments to %%:compare-debug-dump-opt");
- do_spec_2 ("%{fdump-final-insns=*:%*}");
+ do_spec_2 ("%{fdump-final-insns=*:%*}", NULL);
do_spec_1 (" ", 0, NULL);
if (argbuf.length () > 0
if (argbuf.length () > 0)
{
- do_spec_2 ("%{o*:%*}%{!o:%{!S:%b%O}%{S:%b.s}}");
+ do_spec_2 ("%{o*:%*}%{!o:%{!S:%b%O}%{S:%b.s}}", NULL);
ext = ".gkd";
}
else if (!compare_debug)
return NULL;
else
- do_spec_2 ("%g.gkd");
+ do_spec_2 ("%g.gkd", NULL);
do_spec_1 (" ", 0, NULL);
if (compare_debug >= 0)
return NULL;
- do_spec_2 ("%{c|S:%{o*:%*}}");
+ do_spec_2 ("%{c|S:%{o*:%*}}", NULL);
do_spec_1 (" ", 0, NULL);
if (argbuf.length () > 0)