cgo: fix a bug in number tokenization

Этот коммит содержится в:
Ayke van Laethem 2019-12-30 21:52:36 +01:00 коммит произвёл Ron Evans
родитель d735df6e16
коммит b424056721
2 изменённых файлов: 4 добавлений и 1 удалений

Просмотреть файл

@ -140,8 +140,10 @@ func (t *tokenizer) Next() {
if c == '.' { if c == '.' {
hasDot = true hasDot = true
} }
if (c >= '0' && c <= '9') || c == '.' || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') { if c >= '0' && c <= '9' || c == '.' || c == '_' || c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' {
tokenLen = i + 1 tokenLen = i + 1
} else {
break
} }
} }
t.value = t.buf[:tokenLen] t.value = t.buf[:tokenLen]

Просмотреть файл

@ -30,6 +30,7 @@ func TestParseConst(t *testing.T) {
{`'a'`, `'a'`}, {`'a'`, `'a'`},
{`0b10`, `0b10`}, {`0b10`, `0b10`},
{`0x1234_5678`, `0x1234_5678`}, {`0x1234_5678`, `0x1234_5678`},
{`5 5`, `error: 1:3: unexpected token INT`}, // test for a bugfix
} { } {
fset := token.NewFileSet() fset := token.NewFileSet()
startPos := fset.AddFile("", -1, 1000).Pos(0) startPos := fset.AddFile("", -1, 1000).Pos(0)