aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/kevinburke/ssh_config/lexer.go
diff options
context:
space:
mode:
authorAntoine GIRARD <sapk@users.noreply.github.com>2019-07-31 18:45:42 +0200
committertechknowlogick <techknowlogick@gitea.io>2019-07-31 12:45:42 -0400
commita9b4c8171f3b62a951079cdca67e4cf703eb4cc1 (patch)
treeb52f51ec06fb0b91958708b958f7c15c1623e9d1 /vendor/github.com/kevinburke/ssh_config/lexer.go
parentbb875e98a1ee4a30c67a3b879f924e88789baf67 (diff)
downloadgitea-a9b4c8171f3b62a951079cdca67e4cf703eb4cc1.tar.gz
gitea-a9b4c8171f3b62a951079cdca67e4cf703eb4cc1.zip
Update src-d/go-git to v4.13.0 (#7688)
* update gopkg.in/src-d/go-git.v4 v4.13.0 * mod tidy * vendor
Diffstat (limited to 'vendor/github.com/kevinburke/ssh_config/lexer.go')
-rw-r--r--vendor/github.com/kevinburke/ssh_config/lexer.go47
1 files changed, 23 insertions, 24 deletions
diff --git a/vendor/github.com/kevinburke/ssh_config/lexer.go b/vendor/github.com/kevinburke/ssh_config/lexer.go
index b0c6a8650c..11680b4c74 100644
--- a/vendor/github.com/kevinburke/ssh_config/lexer.go
+++ b/vendor/github.com/kevinburke/ssh_config/lexer.go
@@ -1,22 +1,22 @@
package ssh_config
import (
- "io"
-
- buffruneio "github.com/pelletier/go-buffruneio"
+ "bytes"
)
// Define state functions
type sshLexStateFn func() sshLexStateFn
type sshLexer struct {
- input *buffruneio.Reader // Textual source
- buffer []rune // Runes composing the current token
+ inputIdx int
+ input []rune // Textual source
+
+ buffer []rune // Runes composing the current token
tokens chan token
- line uint32
- col uint16
- endbufferLine uint32
- endbufferCol uint16
+ line int
+ col int
+ endbufferLine int
+ endbufferCol int
}
func (s *sshLexer) lexComment(previousState sshLexStateFn) sshLexStateFn {
@@ -114,16 +114,14 @@ func (s *sshLexer) lexRvalue() sshLexStateFn {
}
func (s *sshLexer) read() rune {
- r, _, err := s.input.ReadRune()
- if err != nil {
- panic(err)
- }
+ r := s.peek()
if r == '\n' {
s.endbufferLine++
s.endbufferCol = 1
} else {
s.endbufferCol++
}
+ s.inputIdx++
return r
}
@@ -197,21 +195,22 @@ func (s *sshLexer) emitWithValue(t tokenType, value string) {
}
func (s *sshLexer) peek() rune {
- r, _, err := s.input.ReadRune()
- if err != nil {
- panic(err)
+ if s.inputIdx >= len(s.input) {
+ return eof
}
- s.input.UnreadRune()
+
+ r := s.input[s.inputIdx]
return r
}
func (s *sshLexer) follow(next string) bool {
+ inputIdx := s.inputIdx
for _, expectedRune := range next {
- r, _, err := s.input.ReadRune()
- defer s.input.UnreadRune()
- if err != nil {
- panic(err)
+ if inputIdx >= len(s.input) {
+ return false
}
+ r := s.input[inputIdx]
+ inputIdx++
if expectedRune != r {
return false
}
@@ -226,10 +225,10 @@ func (s *sshLexer) run() {
close(s.tokens)
}
-func lexSSH(input io.Reader) chan token {
- bufferedInput := buffruneio.NewReader(input)
+func lexSSH(input []byte) chan token {
+ runes := bytes.Runes(input)
l := &sshLexer{
- input: bufferedInput,
+ input: runes,
tokens: make(chan token),
line: 1,
col: 1,