From b3bf83dfc580aa97a4aa68fdab3e8da516d55be4 Mon Sep 17 00:00:00 2001 From: q66 Date: Fri, 20 Nov 2015 16:49:23 +0000 Subject: [PATCH] improve the duprule command --- main.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/main.cc b/main.cc index 0e6ee5e..073a61b 100644 --- a/main.cc +++ b/main.cc @@ -339,8 +339,7 @@ struct ObState { r.target = tgt; r.action = oldr->action; r.func = oldr->func; - r.deps = dep ? cscript::util::list_explode(dep) - : ostd::Vector(); + r.deps = dep ? cscript::util::list_explode(dep) : oldr->deps; } }; @@ -442,9 +441,10 @@ int main(int argc, char **argv) { ((ObState &)cs).rule_add(file, deps, nullptr); }); - os.cs.add_command("duprule", "sss", [](CsState &cs, const char *tgt, - const char *ptgt, const char *dep) { - ((ObState &)cs).rule_dup(tgt, ptgt, dep); + os.cs.add_command("duprule", "sssN", [](CsState &cs, const char *tgt, + const char *ptgt, const char *dep, + int *numargs) { + ((ObState &)cs).rule_dup(tgt, ptgt, (*numargs > 2) ? dep : nullptr); }); os.cs.add_commandn("getenv", "ss", [](CsState &cs, TvalRange args) {