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
a16af59f
Commit
a16af59f
authored
Mar 10, 2011
by
Rob Pike
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fmt: heaven forfend we export EOF = -1
R=adg CC=golang-dev
https://golang.org/cl/4248076
parent
9e2fbe18
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
11 deletions
+11
-11
scan.go
src/pkg/fmt/scan.go
+11
-11
No files found.
src/pkg/fmt/scan.go
View file @
a16af59f
...
@@ -139,7 +139,7 @@ type scanError struct {
...
@@ -139,7 +139,7 @@ type scanError struct {
err
os
.
Error
err
os
.
Error
}
}
const
EOF
=
-
1
const
eof
=
-
1
// ss is the internal implementation of ScanState.
// ss is the internal implementation of ScanState.
type
ss
struct
{
type
ss
struct
{
...
@@ -207,7 +207,7 @@ func (s *ss) getRune() (rune int) {
...
@@ -207,7 +207,7 @@ func (s *ss) getRune() (rune int) {
rune
,
_
,
err
:=
s
.
ReadRune
()
rune
,
_
,
err
:=
s
.
ReadRune
()
if
err
!=
nil
{
if
err
!=
nil
{
if
err
==
os
.
EOF
{
if
err
==
os
.
EOF
{
return
EOF
return
eof
}
}
s
.
error
(
err
)
s
.
error
(
err
)
}
}
...
@@ -219,7 +219,7 @@ func (s *ss) getRune() (rune int) {
...
@@ -219,7 +219,7 @@ func (s *ss) getRune() (rune int) {
// syntax error.
// syntax error.
func
(
s
*
ss
)
mustReadRune
()
(
rune
int
)
{
func
(
s
*
ss
)
mustReadRune
()
(
rune
int
)
{
rune
=
s
.
getRune
()
rune
=
s
.
getRune
()
if
rune
==
EOF
{
if
rune
==
eof
{
s
.
error
(
io
.
ErrUnexpectedEOF
)
s
.
error
(
io
.
ErrUnexpectedEOF
)
}
}
return
return
...
@@ -378,7 +378,7 @@ func (s *ss) free(old ssave) {
...
@@ -378,7 +378,7 @@ func (s *ss) free(old ssave) {
func
(
s
*
ss
)
skipSpace
(
stopAtNewline
bool
)
{
func
(
s
*
ss
)
skipSpace
(
stopAtNewline
bool
)
{
for
{
for
{
rune
:=
s
.
getRune
()
rune
:=
s
.
getRune
()
if
rune
==
EOF
{
if
rune
==
eof
{
return
return
}
}
if
rune
==
'\n'
{
if
rune
==
'\n'
{
...
@@ -409,7 +409,7 @@ func (s *ss) token(skipSpace bool, f func(int) bool) []byte {
...
@@ -409,7 +409,7 @@ func (s *ss) token(skipSpace bool, f func(int) bool) []byte {
// read until white space or newline
// read until white space or newline
for
{
for
{
rune
:=
s
.
getRune
()
rune
:=
s
.
getRune
()
if
rune
==
EOF
{
if
rune
==
eof
{
break
break
}
}
if
!
f
(
rune
)
{
if
!
f
(
rune
)
{
...
@@ -433,7 +433,7 @@ var boolError = os.ErrorString("syntax error scanning boolean")
...
@@ -433,7 +433,7 @@ var boolError = os.ErrorString("syntax error scanning boolean")
// If accept is true, it puts the character into the input token.
// If accept is true, it puts the character into the input token.
func
(
s
*
ss
)
consume
(
ok
string
,
accept
bool
)
bool
{
func
(
s
*
ss
)
consume
(
ok
string
,
accept
bool
)
bool
{
rune
:=
s
.
getRune
()
rune
:=
s
.
getRune
()
if
rune
==
EOF
{
if
rune
==
eof
{
return
false
return
false
}
}
if
strings
.
IndexRune
(
ok
,
rune
)
>=
0
{
if
strings
.
IndexRune
(
ok
,
rune
)
>=
0
{
...
@@ -442,7 +442,7 @@ func (s *ss) consume(ok string, accept bool) bool {
...
@@ -442,7 +442,7 @@ func (s *ss) consume(ok string, accept bool) bool {
}
}
return
true
return
true
}
}
if
rune
!=
EOF
&&
accept
{
if
rune
!=
eof
&&
accept
{
s
.
UnreadRune
()
s
.
UnreadRune
()
}
}
return
false
return
false
...
@@ -451,7 +451,7 @@ func (s *ss) consume(ok string, accept bool) bool {
...
@@ -451,7 +451,7 @@ func (s *ss) consume(ok string, accept bool) bool {
// peek reports whether the next character is in the ok string, without consuming it.
// peek reports whether the next character is in the ok string, without consuming it.
func
(
s
*
ss
)
peek
(
ok
string
)
bool
{
func
(
s
*
ss
)
peek
(
ok
string
)
bool
{
rune
:=
s
.
getRune
()
rune
:=
s
.
getRune
()
if
rune
!=
EOF
{
if
rune
!=
eof
{
s
.
UnreadRune
()
s
.
UnreadRune
()
}
}
return
strings
.
IndexRune
(
ok
,
rune
)
>=
0
return
strings
.
IndexRune
(
ok
,
rune
)
>=
0
...
@@ -814,7 +814,7 @@ func (s *ss) hexDigit(digit int) int {
...
@@ -814,7 +814,7 @@ func (s *ss) hexDigit(digit int) int {
// There must be either two hexadecimal digits or a space character in the input.
// There must be either two hexadecimal digits or a space character in the input.
func
(
s
*
ss
)
hexByte
()
(
b
byte
,
ok
bool
)
{
func
(
s
*
ss
)
hexByte
()
(
b
byte
,
ok
bool
)
{
rune1
:=
s
.
getRune
()
rune1
:=
s
.
getRune
()
if
rune1
==
EOF
{
if
rune1
==
eof
{
return
return
}
}
if
unicode
.
IsSpace
(
rune1
)
{
if
unicode
.
IsSpace
(
rune1
)
{
...
@@ -970,7 +970,7 @@ func (s *ss) doScan(a []interface{}) (numProcessed int, err os.Error) {
...
@@ -970,7 +970,7 @@ func (s *ss) doScan(a []interface{}) (numProcessed int, err os.Error) {
if
!
s
.
nlIsSpace
{
if
!
s
.
nlIsSpace
{
for
{
for
{
rune
:=
s
.
getRune
()
rune
:=
s
.
getRune
()
if
rune
==
'\n'
||
rune
==
EOF
{
if
rune
==
'\n'
||
rune
==
eof
{
break
break
}
}
if
!
unicode
.
IsSpace
(
rune
)
{
if
!
unicode
.
IsSpace
(
rune
)
{
...
@@ -1010,7 +1010,7 @@ func (s *ss) advance(format string) (i int) {
...
@@ -1010,7 +1010,7 @@ func (s *ss) advance(format string) (i int) {
// There was space in the format, so there should be space (EOF)
// There was space in the format, so there should be space (EOF)
// in the input.
// in the input.
inputc
:=
s
.
getRune
()
inputc
:=
s
.
getRune
()
if
inputc
==
EOF
{
if
inputc
==
eof
{
return
return
}
}
if
!
unicode
.
IsSpace
(
inputc
)
{
if
!
unicode
.
IsSpace
(
inputc
)
{
...
...
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