aboutsummaryrefslogtreecommitdiff
path: root/exec.cc
diff options
context:
space:
mode:
authorShinichiro Hamaji <shinichiro.hamaji@gmail.com>2015-06-25 21:48:23 +0900
committerShinichiro Hamaji <shinichiro.hamaji@gmail.com>2015-06-25 21:48:23 +0900
commit1c448b1590119c77d0711b8cb4c09a53dfe4b695 (patch)
tree8f910fee628db10122ada5f6d32897d03bcbc8a6 /exec.cc
parent14bb279334c9db568f6cb8b8854f4309b3bfbc5e (diff)
downloadkati-1c448b1590119c77d0711b8cb4c09a53dfe4b695.tar.gz
[C++] Fix silient_multiline.mk
Diffstat (limited to 'exec.cc')
-rw-r--r--exec.cc35
1 files changed, 22 insertions, 13 deletions
diff --git a/exec.cc b/exec.cc
index 051a593..40ea6c0 100644
--- a/exec.cc
+++ b/exec.cc
@@ -175,12 +175,30 @@ class Executor {
}
}
+ void ParseCommandPrefixes(StringPiece* s, bool* echo, bool* ignore_error) {
+ *s = TrimLeftSpace(*s);
+ while (true) {
+ char c = s->get(0);
+ if (c == '@') {
+ *echo = false;
+ } else if (c == '-') {
+ *ignore_error = true;
+ } else {
+ break;
+ }
+ *s = TrimLeftSpace(s->substr(1));
+ }
+ }
+
void CreateRunners(DepNode* n, vector<Runner*>* runners) {
ev_->set_current_scope(n->rule_vars);
current_dep_node_ = n;
for (Value* v : n->cmds) {
shared_ptr<string> cmds_buf = v->Eval(ev_);
- StringPiece cmds = TrimLeftSpace(*cmds_buf);
+ StringPiece cmds = *cmds_buf;
+ bool global_echo = true;
+ bool global_ignore_error = false;
+ ParseCommandPrefixes(&cmds, &global_echo, &global_ignore_error);
if (cmds == "")
continue;
while (true) {
@@ -191,18 +209,9 @@ class Executor {
StringPiece cmd = TrimLeftSpace(cmds.substr(0, index));
cmds = cmds.substr(index + 1);
- bool echo = true;
- bool ignore_error = false;
- while (true) {
- char c = cmd.get(0);
- if (c == '@')
- echo = false;
- else if (c == '-')
- ignore_error = true;
- else
- break;
- cmd = TrimLeftSpace(cmd.substr(1));
- }
+ bool echo = global_echo;
+ bool ignore_error = global_ignore_error;
+ ParseCommandPrefixes(&cmd, &echo, &ignore_error);
if (!cmd.empty()) {
Runner* runner = new Runner;