This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gccgo] Avoid producing // in an import file name


This patch changes import to avoid producing // when concatenating a
directory from the search path and the file name.  This implements the
same algorithm as append_file_to_dir in libcpp/files.c.  Committed to
gccgo branch.

Ian

diff -r 33c42b414546 go/import.cc
--- a/go/import.cc	Wed Nov 17 14:33:26 2010 -0800
+++ b/go/import.cc	Wed Nov 17 14:43:18 2010 -0800
@@ -67,8 +67,11 @@
 	   p != search_path.end();
 	   ++p)
 	{
-	  Stream* s = Import::try_package_in_directory(*p + '/' + filename,
-						       location);
+	  std::string indir = *p;
+	  if (!indir.empty() && indir[indir.size() - 1] != '/')
+	    indir += '/';
+	  indir += filename;
+	  Stream* s = Import::try_package_in_directory(indir, location);
 	  if (s != NULL)
 	    return s;
 	}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]