This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [RFA/driver] Handle switches with arguments in self specs
- From: Richard Sandiford <rdsandiford at googlemail dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 29 Apr 2009 20:27:50 +0100
- Subject: Re: [RFA/driver] Handle switches with arguments in self specs
- References: <20090423152020.GC11799@caradoc.them.org>
Daniel Jacobowitz <drow@false.org> writes:
> +
> + /* Deal with option arguments in separate argv elements. */
> + if ((SWITCH_TAKES_ARG (c) > (p[1] != 0))
> + || WORD_SWITCH_TAKES_ARG (p))
> + {
> + int j = 0;
> + int n_args = WORD_SWITCH_TAKES_ARG (p);
> +
> + if (n_args == 0)
> + {
> + /* Count only the option arguments in separate argv elements. */
> + n_args = SWITCH_TAKES_ARG (c) - (p[1] != 0);
> + }
> + if (i + n_args >= argbuf_index)
> + fatal ("argument to '-%s' is missing", p);
> + switches[n_switches].args
> + = XNEWVEC (const char *, n_args + 1);
> + while (j < n_args)
> + switches[n_switches].args[j++] = argbuf[++i];
> + /* Null-terminate the vector. */
> + switches[n_switches].args[j] = 0;
> + }
> + n_switches++;
Sorry for sticking my oar in, but this looks like a cut-&-paste from
process_command. Maybe it would be worth splitting it out into a separate
function that can be shared by both.
Richard