diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2011-12-14 15:41:54 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2011-12-14 15:41:54 +0000 |
commit | d5363590597572228d4e0d0ae13f3469176ceb14 (patch) | |
tree | e3de46cbc89d82ca1f49843fe2e1e670db67795e /libgo/go/fmt/print.go | |
parent | ef0d4c4d9937276c8ff818ecb0b92925d322d3bd (diff) | |
download | gcc-d5363590597572228d4e0d0ae13f3469176ceb14.zip gcc-d5363590597572228d4e0d0ae13f3469176ceb14.tar.gz gcc-d5363590597572228d4e0d0ae13f3469176ceb14.tar.bz2 |
libgo: Update to weekly.2011-12-06.
From-SVN: r182338
Diffstat (limited to 'libgo/go/fmt/print.go')
-rw-r--r-- | libgo/go/fmt/print.go | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/libgo/go/fmt/print.go b/libgo/go/fmt/print.go index e5ca117..8b15a82 100644 --- a/libgo/go/fmt/print.go +++ b/libgo/go/fmt/print.go @@ -631,24 +631,30 @@ func (p *pp) handleMethods(verb rune, plus, goSyntax bool, depth int) (wasString return } } else { - // Is it an error or Stringer? - // The duplication in the bodies is necessary: - // setting wasString and handled and deferring catchPanic - // must happen before calling the method. - switch v := p.field.(type) { - case error: - wasString = false - handled = true - defer p.catchPanic(p.field, verb) - p.printField(v.Error(), verb, plus, false, depth) - return - - case Stringer: - wasString = false - handled = true - defer p.catchPanic(p.field, verb) - p.printField(v.String(), verb, plus, false, depth) - return + // If a string is acceptable according to the format, see if + // the value satisfies one of the string-valued interfaces. + // Println etc. set verb to %v, which is "stringable". + switch verb { + case 'v', 's', 'x', 'X', 'q': + // Is it an error or Stringer? + // The duplication in the bodies is necessary: + // setting wasString and handled, and deferring catchPanic, + // must happen before calling the method. + switch v := p.field.(type) { + case error: + wasString = false + handled = true + defer p.catchPanic(p.field, verb) + p.printField(v.Error(), verb, plus, false, depth) + return + + case Stringer: + wasString = false + handled = true + defer p.catchPanic(p.field, verb) + p.printField(v.String(), verb, plus, false, depth) + return + } } } handled = false |