Skip to content

Commit aedca01

Browse files
committed
pr: uniformly scan for form feed and newline chars
Fix the way form feed characters are interpreted by changing the way lines and pages are found. Before this commit, a file comprising two form feed characters (`/f/f`) would result in too few trailing newlines at the end of the second page. After this change, each page is produced with the correct number of lines. This commit changes the way files are read, replacing complex iterators with a loop-based approach, iteratively scanning for newline or form feed characters. The `memchr` library is used to efficiently scan for these two characters. One downside of this implementation is that it currently reads the entire input file into memory; this can be improved in subsequent merge requests.
1 parent f7f291d commit aedca01

File tree

4 files changed

+229
-215
lines changed

4 files changed

+229
-215
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/uu/pr/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ path = "src/pr.rs"
2121
clap = { workspace = true }
2222
uucore = { workspace = true, features = ["entries", "time"] }
2323
itertools = { workspace = true }
24+
memchr = { workspace = true }
2425
regex = { workspace = true }
2526
thiserror = { workspace = true }
2627
fluent = { workspace = true }

0 commit comments

Comments
 (0)