aboutsummaryrefslogtreecommitdiff
path: root/find.cc
diff options
context:
space:
mode:
authorDan Willemsen <dwillemsen@google.com>2017-07-26 02:02:58 -0700
committerdragonGR <alextsanisbadlorg@gmail.com>2017-07-27 12:26:38 +0000
commit629b087ed03b78286b80bb687c99a347662805bb (patch)
tree8330e18b778ec31d7583fe01dca0ec2193003031 /find.cc
parentbcb31defde3e3fc248a1f11049e7722233003b6f (diff)
Merge remote-tracking branch 'aosp/upstream' into masterHEADn7.1
* aosp/upstream: Fix (cd <symlink>; find .) Add some simple find unit tests Bug: 64041576 Test: Compare internal master build-aosp_arm.ninja before/after Change-Id: Ib29cf0dbb25a3f08c26520070cf53cdd912c0695
Diffstat (limited to 'find.cc')
-rw-r--r--find.cc22
1 files changed, 12 insertions, 10 deletions
diff --git a/find.cc b/find.cc
index 2af242b..c36c468 100644
--- a/find.cc
+++ b/find.cc
@@ -252,6 +252,8 @@ class DirentDirNode : public DirentNode {
return this;
size_t index = d.find('/');
const string& p = d.substr(0, index).as_string();
+ if (p.empty() || p == ".")
+ return FindDir(d.substr(index + 1));;
for (auto& child : children_) {
if (p == child.first) {
if (index == string::npos)
@@ -827,15 +829,17 @@ class FindEmulatorImpl : public FindEmulator {
}
}
+ const DirentNode* root = root_.get();
+
if (!fc.chdir.empty()) {
if (!CanHandle(fc.chdir)) {
LOG("FindEmulator: Cannot handle chdir (%.*s): %s",
SPF(fc.chdir), cmd.c_str());
return false;
}
- bool should_fallback = false;
- if (!FindDir(fc.chdir, &should_fallback)) {
- if (should_fallback)
+ root = root->FindDir(fc.chdir);
+ if (!root) {
+ if (Exists(fc.chdir))
return false;
if (!fc.redirect_to_devnull) {
FIND_WARN_LOC(loc, "FindEmulator: cd: %.*s: No such file or directory",
@@ -847,18 +851,16 @@ class FindEmulatorImpl : public FindEmulator {
vector<string> results;
for (const string& finddir : fc.finddirs) {
- const string dir = ConcatDir(fc.chdir, finddir);
-
- if (!CanHandle(dir)) {
+ if (!CanHandle(finddir)) {
LOG("FindEmulator: Cannot handle find dir (%s): %s",
- dir.c_str(), cmd.c_str());
+ finddir.c_str(), cmd.c_str());
return false;
}
- bool should_fallback = false;
- const DirentNode* base = FindDir(dir, &should_fallback);
+ const DirentNode* base;
+ base = root->FindDir(finddir);
if (!base) {
- if (should_fallback) {
+ if (Exists(finddir)) {
return false;
}
if (!fc.redirect_to_devnull) {