Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
f369fc09
Commit
f369fc09
authored
May 27, 2011
by
Evan Shaw
Committed by
Robert Griesemer
May 27, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
go/scanner: don't allow "0x" and "0X" as integers
R=gri CC=golang-dev
https://golang.org/cl/4560047
parent
399a311e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
0 deletions
+6
-0
scanner.go
src/pkg/go/scanner/scanner.go
+4
-0
scanner_test.go
src/pkg/go/scanner/scanner_test.go
+2
-0
No files found.
src/pkg/go/scanner/scanner.go
View file @
f369fc09
...
...
@@ -297,6 +297,10 @@ func (S *Scanner) scanNumber(seenDecimalPoint bool) token.Token {
// hexadecimal int
S
.
next
()
S
.
scanMantissa
(
16
)
if
S
.
offset
-
offs
<=
2
{
// only scanned "0x" or "0X"
S
.
error
(
offs
,
"illegal hexadecimal number"
)
}
}
else
{
// octal int or float
seenDecimalDigit
:=
false
...
...
src/pkg/go/scanner/scanner_test.go
View file @
f369fc09
...
...
@@ -672,6 +672,8 @@ var errors = []struct {
{
"078e0"
,
token
.
FLOAT
,
0
,
""
},
{
"078"
,
token
.
INT
,
0
,
"illegal octal number"
},
{
"07800000009"
,
token
.
INT
,
0
,
"illegal octal number"
},
{
"0x"
,
token
.
INT
,
0
,
"illegal hexadecimal number"
},
{
"0X"
,
token
.
INT
,
0
,
"illegal hexadecimal number"
},
{
"
\"
abc
\x00
def
\"
"
,
token
.
STRING
,
4
,
"illegal character NUL"
},
{
"
\"
abc
\x80
def
\"
"
,
token
.
STRING
,
4
,
"illegal UTF-8 encoding"
},
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment