Skip to content

Commit f648cfb

Browse files
committed
all: use ints instead of uints
Files are small and these are cheap enough that we should be more worried about overflow errors than the space cost.
1 parent 81db2a7 commit f648cfb

4 files changed

Lines changed: 14 additions & 13 deletions

File tree

config.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ import (
4545

4646
const version = "0.5"
4747

48+
var _ = version
49+
4850
type configFinder func() string
4951

5052
// UserSettings checks ~/.ssh and /etc/ssh for configuration files. The config
@@ -367,7 +369,7 @@ type Host struct {
367369
// EOLComment is the comment (if any) terminating the Host line.
368370
EOLComment string
369371
hasEquals bool
370-
leadingSpace uint16 // TODO: handle spaces vs tabs here.
372+
leadingSpace int // TODO: handle spaces vs tabs here.
371373
// The file starts with an implicit "Host *" declaration.
372374
implicit bool
373375
}
@@ -438,7 +440,7 @@ type KV struct {
438440
Value string
439441
Comment string
440442
hasEquals bool
441-
leadingSpace uint16 // Space before the key. TODO handle spaces vs tabs.
443+
leadingSpace int // Space before the key. TODO handle spaces vs tabs.
442444
position Position
443445
}
444446

@@ -467,7 +469,7 @@ func (k *KV) String() string {
467469
// Empty is a line in the config file that contains only whitespace or comments.
468470
type Empty struct {
469471
Comment string
470-
leadingSpace uint16 // TODO handle spaces vs tabs.
472+
leadingSpace int // TODO handle spaces vs tabs.
471473
position Position
472474
}
473475

@@ -494,7 +496,6 @@ type Include struct {
494496
// Comment is the contents of any comment at the end of the Include
495497
// statement.
496498
Comment string
497-
parsed bool
498499
// an include directive can include several different files, and wildcards
499500
directives []string
500501

@@ -504,7 +505,7 @@ type Include struct {
504505
matches []string
505506
// actual filenames are listed here
506507
files map[string]*Config
507-
leadingSpace uint16
508+
leadingSpace int
508509
position Position
509510
depth uint8
510511
hasEquals bool
@@ -544,7 +545,7 @@ func NewInclude(directives []string, hasEquals bool, pos Position, comment strin
544545
directives: directives,
545546
files: make(map[string]*Config),
546547
position: pos,
547-
leadingSpace: uint16(pos.Col) - 1,
548+
leadingSpace: pos.Col - 1,
548549
depth: depth,
549550
hasEquals: hasEquals,
550551
}

lexer.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ type sshLexer struct {
1313
input *buffruneio.Reader // Textual source
1414
buffer []rune // Runes composing the current token
1515
tokens chan token
16-
line uint32
17-
col uint16
18-
endbufferLine uint32
19-
endbufferCol uint16
16+
line int
17+
col int
18+
endbufferLine int
19+
endbufferCol int
2020
}
2121

2222
func (s *sshLexer) lexComment(previousState sshLexStateFn) sshLexStateFn {

parser.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ func (p *sshParser) parseKV() sshParserStateFn {
149149
Value: val.val,
150150
Comment: comment,
151151
hasEquals: hasEquals,
152-
leadingSpace: uint16(key.Position.Col) - 1,
152+
leadingSpace: key.Position.Col - 1,
153153
position: key.Position,
154154
}
155155
lastHost.Nodes = append(lastHost.Nodes, kv)

position.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import "fmt"
88
// column number, respectively. Values of zero or less will cause Invalid(),
99
// to return true.
1010
type Position struct {
11-
Line uint32 // line within the document
12-
Col uint16 // column within the line
11+
Line int // line within the document
12+
Col int // column within the line
1313
}
1414

1515
// String representation of the position.

0 commit comments

Comments
 (0)