aboutsummaryrefslogtreecommitdiff
path: root/libcpp/mkdeps.c
diff options
context:
space:
mode:
Diffstat (limited to 'libcpp/mkdeps.c')
-rw-r--r--libcpp/mkdeps.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/libcpp/mkdeps.c b/libcpp/mkdeps.c
index 96cc49b..676ae12 100644
--- a/libcpp/mkdeps.c
+++ b/libcpp/mkdeps.c
@@ -59,6 +59,10 @@ public:
{
return ary[ix];
}
+ T &operator[] (unsigned ix)
+ {
+ return ary[ix];
+ }
void push (const T &elt)
{
if (num == alloc)
@@ -235,14 +239,22 @@ deps_free (struct mkdeps *d)
void
deps_add_target (struct mkdeps *d, const char *t, int quote)
{
- t = apply_vpath (d, t);
+ t = xstrdup (apply_vpath (d, t));
+
if (!quote)
{
- gcc_assert (d->quote_lwm == d->targets.size ());
+ /* Sometimes unquoted items are added after quoted ones.
+ Swap out the lowest quoted. */
+ if (d->quote_lwm != d->targets.size ())
+ {
+ const char *lowest = d->targets[d->quote_lwm];
+ d->targets[d->quote_lwm] = t;
+ t = lowest;
+ }
d->quote_lwm++;
}
- d->targets.push (xstrdup (t));
+ d->targets.push (t);
}
/* Sets the default target if none has been given already. An empty