Implement most commands#64
Conversation
Add test cases for output and zero-copy verification. While at it fix a bug that used a hardcoded stdout for the output. This required introducing RawFd, a stronger separation between the Unix and the fallback implementation, and the use of temporary output files for testing.
This was required to fix the Unix implementation.
This reverts commit 5545e82. Apparently there is no such thing. It doesn't work on Windows even with on the nightly build.
The preceding one, by bringing together input and output in the same structure, resulted in overlapping mutable borrowing. The current design separates the two and thus avoids this problem.
This is required for the b t and { commands, which point to others.
This demonstrates mutable patern space and starting a new cycle.
This avoids the duplication of implementation methods, which will be required for processing data.
Also fix the N command.
For the sake of consistency; we don't employ try in other methods with similar semantics.
|
@sylvestre Seeing that you hadn't started the review, I pushed recent work because it addresses some comments you might have. The PR is ready for review. My planned next task is to try to change the compiled command data structure to use bumpalo. I hope that this will simplify some hairy code while also improving performance by removing reference counters and allowing the safe and easy construction of the more complex structures required for blocks and branch commands. |
This will also make it easier to call compile_thread recursively.
The runtime stack would not handle jumps within blocks. Also, patched links are more efficient at runtime.
While at it fix the label population to avoid defining labels for the branch command targets.
|
@sylvestre Using I've completed most of the technically difficult and risky work. The few remaining commands and missing features should be easy to implement. As long as you don't start reviewing, I'll be pushing here complete batches that leave the code in a reviewable state (no half-baked stuff). |
|
Impressive! |
| /// the sub-chain, then splice its tail back to the original | ||
| /// “next” pointer of the *parent* (falling back to its own | ||
| /// parent_next if its own next was `None`). | ||
| fn patch_block_endings(head: Option<Rc<RefCell<Command>>>) { |
There was a problem hiding this comment.
would it make sense to write unit test for this function ?
There was a problem hiding this comment.
I have; search for "// patch_block_endings".
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #64 +/- ##
==========================
==========================
☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This PR implements the
s,y, and most single-letter commands. This allows the porting and implementation of integration tests and initial benchmarking. Thanks to zero-copy mmapped I/O, when few changes are made to the file, this implementation processes its input much faster than GNU sed.