1
0
Fork 0

Vendor main dependencies.

This commit is contained in:
Timo Reimann 2017-02-07 22:33:23 +01:00
parent 49a09ab7dd
commit dd5e3fba01
2738 changed files with 1045689 additions and 0 deletions

35
vendor/github.com/donovanhide/eventsource/normalise.go generated vendored Normal file
View file

@ -0,0 +1,35 @@
package eventsource
import (
"io"
)
// A reader which normalises line endings
// "/r" and "/r/n" are converted to "/n"
type normaliser struct {
r io.Reader
lastChar byte
}
func newNormaliser(r io.Reader) *normaliser {
return &normaliser{r: r}
}
func (norm *normaliser) Read(p []byte) (n int, err error) {
n, err = norm.r.Read(p)
for i := 0; i < n; i++ {
switch {
case p[i] == '\n' && norm.lastChar == '\r':
copy(p[i:n], p[i+1:])
norm.lastChar = p[i]
n--
i--
case p[i] == '\r':
norm.lastChar = p[i]
p[i] = '\n'
default:
norm.lastChar = p[i]
}
}
return
}