The original Rust implementation assummed a UTF-8 environment, as is
common in modern systems. This commit improves GNU sed compatibility
by changing most processing to run on bytes rather than Rust's Unicode
characters and strings. This change also improves the handling of binary
files. The commit adds a simple POSIX-compatible locale configuration
to support UTF-8 processing when specified. While at it, also fix
script-specified file handling to take place through OsString and
add a few missing unit tests.
The change fixes two failing GNU test suite cases.
The multiline matching resulted in a large performance regression due to
the indiscriminate use of the dotall (?s) flag. Change the regex
selection process to use only the flag when probably needed.
The previous harness tried to extract sed commands from GNU test scripts
via regex pattern matching, which produced false negatives (comparing
against empty expected output) and false positives. This led to inflated
test counts and unreliable pass/fail signals.
The new approach:
- Provides a lightweight shim for the gnulib test framework (init.sh)
with implementations of compare_, returns_, skip_, framework_failure_,
and all require_* functions
- Executes each .sh test script from the GNU testsuite directly,
injecting our Rust sed binary via PATH
- Uses a clean srcdir with symlinks to real test data files
- Adds per-test timeout (10s) to catch infinite loops, with SIGTERM
isolation so timeout signals don't kill the parent script
- Properly propagates exit codes (0=pass, 77=skip, 99=framework failure)
Results are now consistent with CI tracking (~12% pass rate) with
clear PASS/FAIL/SKIP/timeout categorization.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>