"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "vendor/golang.org/x/text/transform/transform.go" between
etcd-3.4.12.tar.gz and etcd-3.4.13.tar.gz

About: etcd is a distributed reliable key-value store for the most critical data of a distributed system (written in "Go").

transform.go  (etcd-3.4.12):transform.go  (etcd-3.4.13)
skipping to change at line 81 skipping to change at line 81
// Span returns a position in src such that transforming src[:n] results in // Span returns a position in src such that transforming src[:n] results in
// identical output src[:n] for these bytes. It does not necessarily retu rn // identical output src[:n] for these bytes. It does not necessarily retu rn
// the largest such n. The atEOF argument tells whether src represents th e // the largest such n. The atEOF argument tells whether src represents th e
// last bytes of the input. // last bytes of the input.
// //
// Callers should always account for the n bytes consumed before // Callers should always account for the n bytes consumed before
// considering the error err. // considering the error err.
// //
// A nil error means that all input bytes are known to be identical to th e // A nil error means that all input bytes are known to be identical to th e
// output produced by the Transformer. A nil error can be be returned // output produced by the Transformer. A nil error can be returned
// regardless of whether atEOF is true. If err is nil, then then n must // regardless of whether atEOF is true. If err is nil, then n must
// equal len(src); the converse is not necessarily true. // equal len(src); the converse is not necessarily true.
// //
// ErrEndOfSpan means that the Transformer output may differ from the // ErrEndOfSpan means that the Transformer output may differ from the
// input after n bytes. Note that n may be len(src), meaning that the out put // input after n bytes. Note that n may be len(src), meaning that the out put
// would contain additional bytes after otherwise identical output. // would contain additional bytes after otherwise identical output.
// ErrShortSrc means that src had insufficient data to determine whether the // ErrShortSrc means that src had insufficient data to determine whether the
// remaining bytes would change. Other than the error conditions listed // remaining bytes would change. Other than the error conditions listed
// here, implementations are free to report other errors that arise. // here, implementations are free to report other errors that arise.
// //
// Calling Span can modify the Transformer state as a side effect. In // Calling Span can modify the Transformer state as a side effect. In
skipping to change at line 496 skipping to change at line 496
// downstream, as Transform would have bailed while handling ErrShortDst. // downstream, as Transform would have bailed while handling ErrShortDst.
if c.errStart > 0 { if c.errStart > 0 {
for i := 1; i < c.errStart; i++ { for i := 1; i < c.errStart; i++ {
c.link[i].p, c.link[i].n = 0, 0 c.link[i].p, c.link[i].n = 0, 0
} }
err, c.errStart, c.err = c.err, 0, nil err, c.errStart, c.err = c.err, 0, nil
} }
return dstL.n, srcL.p, err return dstL.n, srcL.p, err
} }
// Deprecated: use runes.Remove instead. // Deprecated: Use runes.Remove instead.
func RemoveFunc(f func(r rune) bool) Transformer { func RemoveFunc(f func(r rune) bool) Transformer {
return removeF(f) return removeF(f)
} }
type removeF func(r rune) bool type removeF func(r rune) bool
func (removeF) Reset() {} func (removeF) Reset() {}
// Transform implements the Transformer interface. // Transform implements the Transformer interface.
func (t removeF) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err err or) { func (t removeF) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err err or) {
skipping to change at line 651 skipping to change at line 651
// Prevent duplicate Transform calls with atEOF being true at the end of // Prevent duplicate Transform calls with atEOF being true at the end of
// the input. Also return if we have an unrecoverable error. // the input. Also return if we have an unrecoverable error.
if (err == nil && pSrc == len(s)) || if (err == nil && pSrc == len(s)) ||
(err != nil && err != ErrShortDst && err != ErrShortSrc) { (err != nil && err != ErrShortDst && err != ErrShortSrc) {
return string(dst[:pDst]), pSrc, err return string(dst[:pDst]), pSrc, err
} }
// Transform the remaining input, growing dst and src buffers as necessar y. // Transform the remaining input, growing dst and src buffers as necessar y.
for { for {
n := copy(src, s[pSrc:]) n := copy(src, s[pSrc:])
nDst, nSrc, err := t.Transform(dst[pDst:], src[:n], pSrc+n == len atEOF := pSrc+n == len(s)
(s)) nDst, nSrc, err := t.Transform(dst[pDst:], src[:n], atEOF)
pDst += nDst pDst += nDst
pSrc += nSrc pSrc += nSrc
// If we got ErrShortDst or ErrShortSrc, do not grow as long as w e can // If we got ErrShortDst or ErrShortSrc, do not grow as long as w e can
// make progress. This may avoid excessive allocations. // make progress. This may avoid excessive allocations.
if err == ErrShortDst { if err == ErrShortDst {
if nDst == 0 { if nDst == 0 {
dst = grow(dst, pDst) dst = grow(dst, pDst)
} }
} else if err == ErrShortSrc { } else if err == ErrShortSrc {
if atEOF {
return string(dst[:pDst]), pSrc, err
}
if nSrc == 0 { if nSrc == 0 {
src = grow(src, 0) src = grow(src, 0)
} }
} else if err != nil || pSrc == len(s) { } else if err != nil || pSrc == len(s) {
return string(dst[:pDst]), pSrc, err return string(dst[:pDst]), pSrc, err
} }
} }
} }
// Bytes returns a new byte slice with the result of converting b[:n] using t, // Bytes returns a new byte slice with the result of converting b[:n] using t,
 End of changes. 4 change blocks. 
5 lines changed or deleted 8 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)