aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2017-06-14 13:37:48 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2017-06-14 13:37:48 +0000
commit6916d6104ff448f07130597473356334c3d73501 (patch)
tree284721011965de05fde468a68fead07b9739d32e /gcc
parent26fda5f59aa242dcf11cf4dd7ef837c635c02673 (diff)
downloadgcc-6916d6104ff448f07130597473356334c3d73501.zip
gcc-6916d6104ff448f07130597473356334c3d73501.tar.gz
gcc-6916d6104ff448f07130597473356334c3d73501.tar.bz2
compiler: remove "DIR/../" when joining relative import path
Otherwise if DIR does not exist, the path does not work. This matches what the gc cmd/compile tool does, because it calls path.Join. The test for this is the cmd/go tests, to be added in a follow-up CL. Reviewed-on: https://go-review.googlesource.com/45691 From-SVN: r249194
Diffstat (limited to 'gcc')
-rw-r--r--gcc/go/gofrontend/MERGE2
-rw-r--r--gcc/go/gofrontend/import.cc19
2 files changed, 20 insertions, 1 deletions
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index 2d9adaf..4365d6e 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-be5fa26b2b1b5d0755bc1c7ce25f3aa26bea9d9c
+c0840d5826abb713487b2d8a04ab249764b21010
The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.
diff --git a/gcc/go/gofrontend/import.cc b/gcc/go/gofrontend/import.cc
index f6b4e0c..20b077f 100644
--- a/gcc/go/gofrontend/import.cc
+++ b/gcc/go/gofrontend/import.cc
@@ -82,6 +82,25 @@ Import::open_package(const std::string& filename, Location location,
// A special case.
fn = relative_import_path;
}
+ else if (fn[0] == '.' && fn[1] == '.'
+ && (fn[2] == '\0' || IS_DIR_SEPARATOR(fn[2])))
+ {
+ // We are going to join relative_import_path and fn, and it
+ // will look like DIR/../PATH. But DIR does not necessarily
+ // exist in this case, and if it doesn't the use of .. will
+ // fail although it shouldn't. The gc compiler uses
+ // path.Join here, which cleans up the .., so we need to do
+ // the same.
+ size_t index;
+ for (index = relative_import_path.length() - 1;
+ index > 0 && !IS_DIR_SEPARATOR(relative_import_path[index]);
+ index--)
+ ;
+ if (index > 0)
+ fn = relative_import_path.substr(0, index) + fn.substr(2);
+ else
+ fn = relative_import_path + '/' + fn;
+ }
else
fn = relative_import_path + '/' + fn;
is_local = false;