From 6da53232244f888750bb8aa6c3d70eb4a3072516 Mon Sep 17 00:00:00 2001 From: Jason Perkins Date: Wed, 20 Oct 2010 19:52:32 -0400 Subject: [PATCH] Bug 3016050: {"../Dir/file1.c","../../Dir/file2.c"} breaks Xcode (Stephane) --- CHANGES.txt | 1 + src/base/tree.lua | 7 +++++-- tests/base/test_tree.lua | 10 ++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index e90d5935..d5901f0a 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -24,6 +24,7 @@ * Bug 3035545: The pattern { "./folder/*.c" } matches no files * Bug 3034222: StaticLib projects ignore linkoptions * Bug 3020382: GCC PCH not working +* Bug 3016050: {"../Dir/file1.c","../../Dir/file2.c"} breaks Xcode (Stephane) ------- diff --git a/src/base/tree.lua b/src/base/tree.lua index 028f655c..9a16ef51 100644 --- a/src/base/tree.lua +++ b/src/base/tree.lua @@ -51,9 +51,12 @@ return parentnode end - -- Create the child if necessary + -- Create the child if necessary. If two children with the same name appear + -- at the same level, make sure they have the same path to prevent conflicts + -- i.e. ../Common and ../../Common can both appear at the top of the tree + -- yet they have different paths (Bug #3016050) local childnode = parentnode.children[childname] - if not childnode then + if not childnode or childnode.path ~= p then childnode = tree.insert(parentnode, tree.new(childname)) childnode.path = p end diff --git a/tests/base/test_tree.lua b/tests/base/test_tree.lua index da13b862..bbc4add9 100644 --- a/tests/base/test_tree.lua +++ b/tests/base/test_tree.lua @@ -68,6 +68,16 @@ tree.add(tr, "MyProject/../hello") test.isequal("MyProject>hello", getresult()) end + + function suite.AddsNodes_OnDifferentParentLevel() + tree.add(tr, "../Common") + tree.add(tr, "../../Common") + test.isequal(2, #tr.children) + test.isequal("Common", tr.children[1].name) + test.isequal("Common", tr.children[2].name) + test.isequal("../Common", tr.children[1].path) + test.isequal("../../Common", tr.children[2].path) + end --