From 39970310a89b06bc59c5d35e82bbb3c12109ed31 Mon Sep 17 00:00:00 2001 From: Shinichiro Hamaji Date: Fri, 31 Jul 2015 16:10:34 +0900 Subject: [C++] Better find command detection --- find.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'find.cc') diff --git a/find.cc b/find.cc index f7e7508..bc83b5f 100644 --- a/find.cc +++ b/find.cc @@ -539,6 +539,8 @@ class FindCommandParser { if (!GetNextToken(&tok) || !tok.empty()) return false; return true; + } else { + return false; } } } @@ -676,8 +678,10 @@ FindCommand::FindCommand() bool FindCommand::Parse(const string& cmd) { FindCommandParser fcp(cmd, this); - if (cmd.find("find ") == string::npos) + size_t found = cmd.find("find "); + if (found == string::npos || (found != 0 && !isspace(cmd[found-1]))) { return false; + } if (!fcp.Parse()) return false; -- cgit v1.2.3