-
Notifications
You must be signed in to change notification settings - Fork 32
Updates #427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request refactors regex handling across the codebase by introducing a centralized plib::regex module that provides a safe Rust wrapper around POSIX regcomp/regexec functions. This improves code maintainability and consistency while handling platform-specific quirks (like macOS's empty pattern behavior) in one place.
Key changes:
- Introduces
plib::regexmodule withRegex,RegexFlags, andMatchtypes for POSIX BRE/ERE support - Migrates text utilities (sed, grep, csplit, comm, asa), shell pattern matching, pax, display/more, and awk to use the new regex API
- Updates tests to handle platform-specific regex error messages using custom checker functions
- Fixes several bugs: csplit now rejects line number 0, corrects BRE pattern escaping (e.g.,
main(notmain\(), fixes csplit output formatting, and simplifies comm.rs logic
Reviewed changes
Copilot reviewed 25 out of 28 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| plib/src/regex.rs | New POSIX regex wrapper with BRE/ERE support, thread-safe design, and comprehensive test coverage |
| plib/src/lib.rs | Exports the new regex module |
| text/sed.rs | Migrates to plib::regex, updates match_pattern logic, removes direct libc calls |
| text/grep.rs | Replaces libc regex with plib::regex, simplifies pattern compilation |
| text/csplit.rs | Migrates to plib::regex, adds line number 0 validation, fixes BRE patterns, adds prefix length validation |
| text/comm.rs | Migrates to use plib::io::input_reader for stdin support, simplifies conditional logic |
| text/asa.rs | Updates to use "-" for stdin consistently, fixes UTF-8 multi-byte character handling |
| text/join.rs | Simplifies nested else-if logic |
| sh/pattern/regex.rs | Migrates shell pattern matching to plib::regex |
| pax/subst.rs | Migrates substitution patterns to plib::regex, removes custom POSIX wrapper |
| display/more.rs | Migrates search functionality to plib::regex |
| awk/regex.rs | Migrates AWK regex to plib::regex |
| text/tests/sed/mod.rs | Adds regex error test helper, updates test expectations for fixed bugs |
| text/tests/grep/mod.rs | Adds regex error test helper to handle platform-specific messages |
| text/tests/csplit/mod.rs | Fixes expected output formatting, adds new tests for error cases and BRE patterns |
| text/tests/comm/mod.rs | Adds comprehensive tests for column suppression, empty files, stdin, and error handling |
| text/tests/asa/mod.rs | Adds UTF-8 multi-byte content and control character tests |
| text/tests/comm/. | New test fixture files for comm utility |
| sh/Cargo.toml | Adds plib dependency |
| display/Cargo.toml | Adds plib dependency |
| awk/Cargo.toml | Adds plib dependency |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
No description provided.