Fix bad line printing for parse errors
The code that extracted lines from partially-parsed files was broken. Closes #1848
This commit is contained in:
parent
6627890f6b
commit
9ff5ba085d
3 changed files with 20 additions and 12 deletions
|
@ -68,6 +68,7 @@ export
|
|||
|
||||
// Searching
|
||||
index,
|
||||
byte_index,
|
||||
rindex,
|
||||
find,
|
||||
find_bytes,
|
||||
|
@ -852,6 +853,19 @@ fn index(ss: str, cc: char) -> option<uint> {
|
|||
ret option::none;
|
||||
}
|
||||
|
||||
// Function: byte_index
|
||||
//
|
||||
// Returns the index of the first matching byte
|
||||
// (as option some/none)
|
||||
fn byte_index(s: str, b: u8, start: uint) -> option<uint> {
|
||||
let i = start, l = len_bytes(s);
|
||||
while i < l {
|
||||
if s[i] == b { ret some(i); }
|
||||
i += 1u;
|
||||
}
|
||||
ret none;
|
||||
}
|
||||
|
||||
// Function: rindex
|
||||
//
|
||||
// Returns the index of the first matching char
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue