mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-23 22:27:38 -05:00
6fde3632ef
The vendor/ folder was created with the help of @FiloSottile's gvt and vendorcheck. Any dependencies of Caddy plugins outside this repo are not vendored. We do not remove any unused, vendored packages because vendorcheck -u only checks using the current build configuration; i.e. packages that may be imported by files toggled by build tags of other systems. CI tests have been updated to ignore the vendor/ folder. When Go 1.9 is released, a few of the go commands should be revised to again use ./... as it will ignore the vendor folder by default.
43 lines
808 B
Go
43 lines
808 B
Go
package dns
|
|
|
|
// Implement a simple scanner, return a byte stream from an io reader.
|
|
|
|
import (
|
|
"bufio"
|
|
"io"
|
|
"text/scanner"
|
|
)
|
|
|
|
type scan struct {
|
|
src *bufio.Reader
|
|
position scanner.Position
|
|
eof bool // Have we just seen a eof
|
|
}
|
|
|
|
func scanInit(r io.Reader) *scan {
|
|
s := new(scan)
|
|
s.src = bufio.NewReader(r)
|
|
s.position.Line = 1
|
|
return s
|
|
}
|
|
|
|
// tokenText returns the next byte from the input
|
|
func (s *scan) tokenText() (byte, error) {
|
|
c, err := s.src.ReadByte()
|
|
if err != nil {
|
|
return c, err
|
|
}
|
|
// delay the newline handling until the next token is delivered,
|
|
// fixes off-by-one errors when reporting a parse error.
|
|
if s.eof == true {
|
|
s.position.Line++
|
|
s.position.Column = 0
|
|
s.eof = false
|
|
}
|
|
if c == '\n' {
|
|
s.eof = true
|
|
return c, nil
|
|
}
|
|
s.position.Column++
|
|
return c, nil
|
|
}
|