mirror of
https://github.com/golang/go
synced 2024-11-25 02:07:58 -07:00
fmt: rename internal interfaces
readRuner -> runeReader unreadRuner -> runeUnreader R=r, rsc CC=golang-dev https://golang.org/cl/4000054
This commit is contained in:
parent
b287d7cbe1
commit
c5fc3b6972
@ -16,18 +16,11 @@ import (
|
|||||||
"utf8"
|
"utf8"
|
||||||
)
|
)
|
||||||
|
|
||||||
// readRuner is the interface to something that can read runes. If
|
// runeUnreader is the interface to something that can unread runes.
|
||||||
// the object provided to Scan does not satisfy this interface, the
|
|
||||||
// object will be wrapped by a readRune object.
|
|
||||||
type readRuner interface {
|
|
||||||
ReadRune() (rune int, size int, err os.Error)
|
|
||||||
}
|
|
||||||
|
|
||||||
// unreadRuner is the interface to something that can unread runes.
|
|
||||||
// If the object provided to Scan does not satisfy this interface,
|
// If the object provided to Scan does not satisfy this interface,
|
||||||
// a local buffer will be used to back up the input, but its contents
|
// a local buffer will be used to back up the input, but its contents
|
||||||
// will be lost when Scan returns.
|
// will be lost when Scan returns.
|
||||||
type unreadRuner interface {
|
type runeUnreader interface {
|
||||||
UnreadRune() os.Error
|
UnreadRune() os.Error
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,15 +131,15 @@ const EOF = -1
|
|||||||
|
|
||||||
// ss is the internal implementation of ScanState.
|
// ss is the internal implementation of ScanState.
|
||||||
type ss struct {
|
type ss struct {
|
||||||
rr readRuner // where to read input
|
rr io.RuneReader // where to read input
|
||||||
buf bytes.Buffer // token accumulator
|
buf bytes.Buffer // token accumulator
|
||||||
nlIsSpace bool // whether newline counts as white space
|
nlIsSpace bool // whether newline counts as white space
|
||||||
peekRune int // one-rune lookahead
|
peekRune int // one-rune lookahead
|
||||||
prevRune int // last rune returned by GetRune
|
prevRune int // last rune returned by GetRune
|
||||||
atEOF bool // already read EOF
|
atEOF bool // already read EOF
|
||||||
maxWid int // max width of field, in runes
|
maxWid int // max width of field, in runes
|
||||||
widPresent bool // width was specified
|
widPresent bool // width was specified
|
||||||
wid int // width consumed so far; used in accept()
|
wid int // width consumed so far; used in accept()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ss) GetRune() (rune int, err os.Error) {
|
func (s *ss) GetRune() (rune int, err os.Error) {
|
||||||
@ -216,7 +209,7 @@ func (s *ss) mustGetRune() (rune int) {
|
|||||||
|
|
||||||
|
|
||||||
func (s *ss) UngetRune() {
|
func (s *ss) UngetRune() {
|
||||||
if u, ok := s.rr.(unreadRuner); ok {
|
if u, ok := s.rr.(runeUnreader); ok {
|
||||||
u.UnreadRune()
|
u.UnreadRune()
|
||||||
} else {
|
} else {
|
||||||
s.peekRune = s.prevRune
|
s.peekRune = s.prevRune
|
||||||
@ -247,7 +240,7 @@ func (s *ss) Token() (tok string, err os.Error) {
|
|||||||
|
|
||||||
// readRune is a structure to enable reading UTF-8 encoded code points
|
// readRune is a structure to enable reading UTF-8 encoded code points
|
||||||
// from an io.Reader. It is used if the Reader given to the scanner does
|
// from an io.Reader. It is used if the Reader given to the scanner does
|
||||||
// not already implement ReadRuner.
|
// not already implement io.RuneReader.
|
||||||
type readRune struct {
|
type readRune struct {
|
||||||
reader io.Reader
|
reader io.Reader
|
||||||
buf [utf8.UTFMax]byte // used only inside ReadRune
|
buf [utf8.UTFMax]byte // used only inside ReadRune
|
||||||
@ -309,7 +302,7 @@ var ssFree = newCache(func() interface{} { return new(ss) })
|
|||||||
// Allocate a new ss struct or grab a cached one.
|
// Allocate a new ss struct or grab a cached one.
|
||||||
func newScanState(r io.Reader, nlIsSpace bool) *ss {
|
func newScanState(r io.Reader, nlIsSpace bool) *ss {
|
||||||
s := ssFree.get().(*ss)
|
s := ssFree.get().(*ss)
|
||||||
if rr, ok := r.(readRuner); ok {
|
if rr, ok := r.(io.RuneReader); ok {
|
||||||
s.rr = rr
|
s.rr = rr
|
||||||
} else {
|
} else {
|
||||||
s.rr = &readRune{reader: r}
|
s.rr = &readRune{reader: r}
|
||||||
|
Loading…
Reference in New Issue
Block a user