Handle zero-length strings in bencode data.
Improve error reporting slightly.
This commit is contained in:
parent
bd0555a835
commit
2532a37945
1 changed files with 3 additions and 2 deletions
5
parse.go
5
parse.go
|
@ -10,6 +10,7 @@ package bencode
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -110,7 +111,7 @@ Switch:
|
||||||
goto exit
|
goto exit
|
||||||
}
|
}
|
||||||
switch {
|
switch {
|
||||||
case c >= '1' && c <= '9':
|
case c >= '0' && c <= '9':
|
||||||
// String
|
// String
|
||||||
err = r.UnreadByte()
|
err = r.UnreadByte()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -193,7 +194,7 @@ Switch:
|
||||||
n++
|
n++
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
err = os.NewError("Unexpected character")
|
err = os.NewError(fmt.Sprintf("Unexpected character: '%v'", c))
|
||||||
}
|
}
|
||||||
exit:
|
exit:
|
||||||
build.Flush()
|
build.Flush()
|
||||||
|
|
Loading…
Reference in a new issue