]> Cypherpunks repositories - gostls13.git/commit
fmt: reuse buffer and add range checks for %c and %q
authorMartin Möhrmann <martisch@uos.de>
Tue, 8 Mar 2016 19:13:58 +0000 (20:13 +0100)
committerRob Pike <r@golang.org>
Wed, 16 Mar 2016 05:13:29 +0000 (05:13 +0000)
commit42cd69f5d1a222a2e794d19e0b287dde2ee9a112
tree891802f25a23b97d2fcc13f6128434ede89c7b78
parentb8ddcc0a03415786bb6278849530c88bfa5b97e6
fmt: reuse buffer and add range checks for %c and %q

Use The fmt internal buffer for character formatting instead of
the pp Printer rune decoding buffer.

Uses an uint64 instead of int64 argument to fmt_c and fmt_qc for easier
range checks since no valid runes are represented by negative numbers or
are above 0x10ffff.

Add range checks to fmt_c and fmt_qc to guarantee that a RuneError
character is returned by the functions for any invalid code point
in range uint64. For invalid code points in range utf8.MaxRune
the used utf8 and strconv functions already return a RuneError.

Change-Id: I9772f804dfcd79c3826fa7f6c5ebfbf4b5304a51
Reviewed-on: https://go-review.googlesource.com/20373
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
src/fmt/fmt_test.go
src/fmt/format.go
src/fmt/print.go