Skip to content

Conversation

@jgarzik
Copy link
Contributor

@jgarzik jgarzik commented Nov 30, 2025

No description provided.

@jgarzik jgarzik requested a review from Copilot November 30, 2025 14:50
@jgarzik jgarzik self-assigned this Nov 30, 2025
@jgarzik jgarzik added bug Something isn't working enhancement New feature or request cleanup labels Nov 30, 2025
Copy link

Copilot AI left a 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::regex module with Regex, RegexFlags, and Match types 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( not main\(), 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.

@jgarzik jgarzik merged commit 3b05152 into main Nov 30, 2025
5 of 6 checks passed
@jgarzik jgarzik deleted the updates branch November 30, 2025 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working cleanup enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants