public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Go patch committed: Don't use import path for ./ or ../ imports
@ 2012-01-17 19:51 Ian Lance Taylor
  0 siblings, 0 replies; only message in thread
From: Ian Lance Taylor @ 2012-01-17 19:51 UTC (permalink / raw)
  To: gcc-patches, gofrontend-dev

[-- Attachment #1: Type: text/plain, Size: 296 bytes --]

When importing a path which starts with ./ or ../, we should not use the
import path.  This patch implements that.  This makes gccgo compatible
with the other Go compiler in how such paths are handled.  Bootstrapped
and ran Go testsuite on x86_64-unknown-linux-gnu.  Committed to
mainline.

Ian


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 1227 bytes --]

diff -r 90c1cf927434 go/import.cc
--- a/go/import.cc	Tue Jan 17 06:18:15 2012 -0800
+++ b/go/import.cc	Tue Jan 17 11:42:44 2012 -0800
@@ -42,8 +42,8 @@
 // returns a pointer to a Stream object to read the data that it
 // exports.  If the file is not found, it returns NULL.
 
-// When FILENAME is not an absolute path, we use the search path
-// provided by -I and -L options.
+// When FILENAME is not an absolute path and does not start with ./ or
+// ../, we use the search path provided by -I and -L options.
 
 // When FILENAME does not exist, we try modifying FILENAME to find the
 // file.  We use the first of these which exists:
@@ -61,7 +61,18 @@
 Import::Stream*
 Import::open_package(const std::string& filename, Location location)
 {
-  if (!IS_ABSOLUTE_PATH(filename))
+  bool is_local;
+  if (IS_ABSOLUTE_PATH(filename))
+    is_local = true;
+  else if (filename[0] == '.' && IS_DIR_SEPARATOR(filename[1]))
+    is_local = true;
+  else if (filename[0] == '.'
+	   && filename[1] == '.'
+	   && IS_DIR_SEPARATOR(filename[2]))
+    is_local = true;
+  else
+    is_local = false;
+  if (!is_local)
     {
       for (std::vector<std::string>::const_iterator p = search_path.begin();
 	   p != search_path.end();

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-01-17 19:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-17 19:51 Go patch committed: Don't use import path for ./ or ../ imports Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).