Go patch committed: Quote package paths with tabs

Submitted by Ian Taylor on June 14, 2012, 5:04 a.m.

Details

Message ID mcrk3za8oxk.fsf@dhcp-172-18-216-180.mtv.corp.google.com
State New
Headers show

Commit Message

Ian Taylor June 14, 2012, 5:04 a.m.
In my patch yesterday to quote package paths in reflection strings, I
managed to overlook the fact that quotes are already used for struct
field tags in reflection strings.  This patch changes the compiler and
the reflect package to quote using tabs instead, since tabs will never
appear in struct field tags.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian

Patch hide | download patch | download mbox

diff -r 2f9880d1acae go/types.cc
--- a/go/types.cc	Wed Jun 13 21:46:56 2012 -0700
+++ b/go/types.cc	Wed Jun 13 22:01:58 2012 -0700
@@ -8340,16 +8340,16 @@ 
       // -fgo-pkgpath was introduced.  When -fgo-pkgpath is specified,
       // we use it to make a unique reflection string, so that the
       // type canonicalization in the reflect package will work.  In
-      // order to be compatible with the gc compiler, we quote the
-      // package path, so that the reflect methods can discard it.
+      // order to be compatible with the gc compiler, we put tabs into
+      // the package path, so that the reflect methods can discard it.
       const Package* package = this->named_object_->package();
       if (gogo->pkgpath_from_option())
 	{
-	  ret->push_back('"');
+	  ret->push_back('\t');
 	  ret->append(package != NULL
 		      ? package->pkgpath_symbol()
 		      : gogo->pkgpath_symbol());
-	  ret->push_back('"');
+	  ret->push_back('\t');
 	}
       ret->append(package != NULL
 		  ? package->package_name()
diff -r 2f9880d1acae libgo/go/reflect/type.go
--- a/libgo/go/reflect/type.go	Wed Jun 13 21:46:56 2012 -0700
+++ b/libgo/go/reflect/type.go	Wed Jun 13 22:01:58 2012 -0700
@@ -444,7 +444,7 @@ 
 	r := make([]byte, len(s))
 	j := 0
 	for i := 0; i < len(s); i++ {
-		if s[i] == '"' {
+		if s[i] == '\t' {
 			q = !q
 		} else if !q {
 			r[j] = s[i]