summaryrefslogtreecommitdiff
path: root/libgo/go/runtime/error.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/runtime/error.go')
-rw-r--r--libgo/go/runtime/error.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/libgo/go/runtime/error.go b/libgo/go/runtime/error.go
index d3913ec27b8e..f7f81e95d3e7 100644
--- a/libgo/go/runtime/error.go
+++ b/libgo/go/runtime/error.go
@@ -57,9 +57,41 @@ func NewTypeAssertionError(ps1, ps2, ps3 *string, pmeth *string, ret *interface{
if pmeth != nil {
meth = *pmeth
}
+
+ // For gccgo, strip out quoted strings.
+ s1 = unquote(s1)
+ s2 = unquote(s2)
+ s3 = unquote(s3)
+
*ret = &TypeAssertionError{s1, s2, s3, meth}
}
+// Remove quoted strings from gccgo reflection strings.
+func unquote(s string) string {
+ ls := len(s)
+ var i int
+ for i = 0; i < ls; i++ {
+ if s[i] == '\t' {
+ break
+ }
+ }
+ if i == ls {
+ return s
+ }
+ var q bool
+ r := make([]byte, len(s))
+ j := 0
+ for i = 0; i < ls; i++ {
+ if s[i] == '\t' {
+ q = !q
+ } else if !q {
+ r[j] = s[i]
+ j++
+ }
+ }
+ return string(r[:j])
+}
+
// An errorString represents a runtime error described by a single string.
type errorString string