aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/bytes/bytes.go
diff options
context:
space:
mode:
authorRob Pike <r@golang.org>2009-11-15 12:07:27 -0800
committerRob Pike <r@golang.org>2009-11-15 12:07:27 -0800
commit27779dd6cb20786b645dcf1a33169f9c51d26b6c (patch)
tree5eb1d990e3bd345c255af44850325fb4065daf57 /src/pkg/bytes/bytes.go
parent13ad5d40c49f10a760c907db6dd09425580310f4 (diff)
downloadgo-27779dd6cb20786b645dcf1a33169f9c51d26b6c.tar.xz
fix bug in bytes.Map and add test cases for Map in both strings and bytes packages.
thanks to ulrik.sverdrup for the test case. Fixes #191. R=rsc CC=golang-dev https://golang.org/cl/155056
Diffstat (limited to 'src/pkg/bytes/bytes.go')
-rw-r--r--src/pkg/bytes/bytes.go4
1 files changed, 1 insertions, 3 deletions
diff --git a/src/pkg/bytes/bytes.go b/src/pkg/bytes/bytes.go
index ccaa71a933..f6cae73537 100644
--- a/src/pkg/bytes/bytes.go
+++ b/src/pkg/bytes/bytes.go
@@ -220,9 +220,7 @@ func Map(mapping func(rune int) int, s []byte) []byte {
for i := 0; i < len(s); {
wid := 1;
rune := int(s[i]);
- if rune < utf8.RuneSelf {
- rune = mapping(rune)
- } else {
+ if rune >= utf8.RuneSelf {
rune, wid = utf8.DecodeRune(s[i:len(s)])
}
rune = mapping(rune);