diff options
Diffstat (limited to 'src/pkg/utf8/utf8.go')
| -rw-r--r-- | src/pkg/utf8/utf8.go | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/src/pkg/utf8/utf8.go b/src/pkg/utf8/utf8.go index 89cdc9956..1784a6db4 100644 --- a/src/pkg/utf8/utf8.go +++ b/src/pkg/utf8/utf8.go @@ -37,70 +37,70 @@ const ( func decodeRuneInternal(p []byte) (rune, size int, short bool) { n := len(p); if n < 1 { - return RuneError, 0, true; + return RuneError, 0, true } c0 := p[0]; // 1-byte, 7-bit sequence? if c0 < _Tx { - return int(c0), 1, false; + return int(c0), 1, false } // unexpected continuation byte? if c0 < _T2 { - return RuneError, 1, false; + return RuneError, 1, false } // need first continuation byte if n < 2 { - return RuneError, 1, true; + return RuneError, 1, true } c1 := p[1]; if c1 < _Tx || _T2 <= c1 { - return RuneError, 1, false; + return RuneError, 1, false } // 2-byte, 11-bit sequence? if c0 < _T3 { rune = int(c0&_Mask2)<<6 | int(c1&_Maskx); if rune <= _Rune1Max { - return RuneError, 1, false; + return RuneError, 1, false } return rune, 2, false; } // need second continuation byte if n < 3 { - return RuneError, 1, true; + return RuneError, 1, true } c2 := p[2]; if c2 < _Tx || _T2 <= c2 { - return RuneError, 1, false; + return RuneError, 1, false } // 3-byte, 16-bit sequence? if c0 < _T4 { rune = int(c0&_Mask3)<<12 | int(c1&_Maskx)<<6 | int(c2&_Maskx); if rune <= _Rune2Max { - return RuneError, 1, false; + return RuneError, 1, false } return rune, 3, false; } // need third continuation byte if n < 4 { - return RuneError, 1, true; + return RuneError, 1, true } c3 := p[3]; if c3 < _Tx || _T2 <= c3 { - return RuneError, 1, false; + return RuneError, 1, false } // 4-byte, 21-bit sequence? if c0 < _T5 { rune = int(c0&_Mask4)<<18 | int(c1&_Maskx)<<12 | int(c2&_Maskx)<<6 | int(c3&_Maskx); if rune <= _Rune3Max { - return RuneError, 1, false; + return RuneError, 1, false } return rune, 4, false; } @@ -112,70 +112,70 @@ func decodeRuneInternal(p []byte) (rune, size int, short bool) { func decodeRuneInStringInternal(s string) (rune, size int, short bool) { n := len(s); if n < 1 { - return RuneError, 0, true; + return RuneError, 0, true } c0 := s[0]; // 1-byte, 7-bit sequence? if c0 < _Tx { - return int(c0), 1, false; + return int(c0), 1, false } // unexpected continuation byte? if c0 < _T2 { - return RuneError, 1, false; + return RuneError, 1, false } // need first continuation byte if n < 2 { - return RuneError, 1, true; + return RuneError, 1, true } c1 := s[1]; if c1 < _Tx || _T2 <= c1 { - return RuneError, 1, false; + return RuneError, 1, false } // 2-byte, 11-bit sequence? if c0 < _T3 { rune = int(c0&_Mask2)<<6 | int(c1&_Maskx); if rune <= _Rune1Max { - return RuneError, 1, false; + return RuneError, 1, false } return rune, 2, false; } // need second continuation byte if n < 3 { - return RuneError, 1, true; + return RuneError, 1, true } c2 := s[2]; if c2 < _Tx || _T2 <= c2 { - return RuneError, 1, false; + return RuneError, 1, false } // 3-byte, 16-bit sequence? if c0 < _T4 { rune = int(c0&_Mask3)<<12 | int(c1&_Maskx)<<6 | int(c2&_Maskx); if rune <= _Rune2Max { - return RuneError, 1, false; + return RuneError, 1, false } return rune, 3, false; } // need third continuation byte if n < 4 { - return RuneError, 1, true; + return RuneError, 1, true } c3 := s[3]; if c3 < _Tx || _T2 <= c3 { - return RuneError, 1, false; + return RuneError, 1, false } // 4-byte, 21-bit sequence? if c0 < _T5 { rune = int(c0&_Mask4)<<18 | int(c1&_Maskx)<<12 | int(c2&_Maskx)<<6 | int(c3&_Maskx); if rune <= _Rune3Max { - return RuneError, 1, false; + return RuneError, 1, false } return rune, 4, false; } @@ -213,13 +213,13 @@ func DecodeRuneInString(s string) (rune, size int) { func RuneLen(rune int) int { switch { case rune <= _Rune1Max: - return 1; + return 1 case rune <= _Rune2Max: - return 2; + return 2 case rune <= _Rune3Max: - return 3; + return 3 case rune <= _Rune4Max: - return 4; + return 4 } return -1; } @@ -239,7 +239,7 @@ func EncodeRune(rune int, p []byte) int { } if rune > unicode.MaxRune { - rune = RuneError; + rune = RuneError } if rune <= _Rune3Max { @@ -263,7 +263,7 @@ func RuneCount(p []byte) int { var n int; for n = 0; i < len(p); n++ { if p[i] < RuneSelf { - i++; + i++ } else { _, size := DecodeRune(p[i:len(p)]); i += size; @@ -279,7 +279,7 @@ func RuneCountInString(s string) int { var n int; for n = 0; i < ei; n++ { if s[i] < RuneSelf { - i++; + i++ } else { _, size, _ := decodeRuneInStringInternal(s[i:ei]); i += size; |
