Skip to content

Commit

Permalink
Count lines in all cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
toots committed Jun 26, 2023
1 parent fa49875 commit 9bf3c6a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
- Use `Sedlexing.{Utf8,Utf16}.from_gen` to initialize UTF8 (resp. UTF16) lexing buffers from
string.
- Delay raising Malformed until actually reading the malformed part of the imput. (#140)
- Count lines in all cases (#130). Previously, certain functions for initiating the
lexical buffer would disable lines counting.

# 3.1:
- Fix directly nested sedlex matches (@smuenzel, PR #117, fixes: #12)
Expand Down
5 changes: 2 additions & 3 deletions src/lib/sedlexing.ml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ let empty_lexbuf =
offset = 0;
pos = 0;
curr_bol = 0;
curr_line = 0;
curr_line = 1;
start_pos = 0;
start_bol = 0;
start_line = 0;
Expand All @@ -75,7 +75,6 @@ let create refill =
empty_lexbuf with
refill;
buf = Array.make chunk_size dummy_uchar;
curr_line = 1;
}

let set_position lexbuf position =
Expand Down Expand Up @@ -139,7 +138,7 @@ let refill lexbuf =
if n = 0 then lexbuf.finished <- true else lexbuf.len <- lexbuf.len + n

let new_line lexbuf =
if lexbuf.curr_line != 0 then lexbuf.curr_line <- lexbuf.curr_line + 1;
lexbuf.curr_line <- lexbuf.curr_line + 1;
lexbuf.curr_bol <- lexbuf.pos + lexbuf.offset

let[@inline always] next_aux some none lexbuf =
Expand Down

0 comments on commit 9bf3c6a

Please sign in to comment.