Fix unicode handling and add tests
We now also return an incomplete triple to aid in debugging - non-nil error means that this is not usable except for manual examination.
This commit is contained in:
parent
59e3d620a5
commit
dc17ccae80
5 changed files with 79 additions and 10 deletions
|
|
@ -76,8 +76,12 @@
|
|||
|
||||
action Error {
|
||||
if p < len(data) {
|
||||
return graph.Triple{}, fmt.Errorf("%v: unexpected rune %q at %d", ErrInvalid, data[p], p)
|
||||
if r := data[p]; r < unicode.MaxASCII {
|
||||
return triple, fmt.Errorf("%v: unexpected rune %q at %d", ErrInvalid, data[p], p)
|
||||
} else {
|
||||
return triple, fmt.Errorf("%v: unexpected rune %q (\\u%04x) at %d", ErrInvalid, data[p], data[p], p)
|
||||
}
|
||||
}
|
||||
return graph.Triple{}, ErrIncomplete
|
||||
return triple, ErrIncomplete
|
||||
}
|
||||
}%%
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue