Repository navigation
sed: implement \\U \\L \\u \\l \\E case-conversion escapes in s/// - #557
dedsec-terminal wants to merge 21 commits into
Conversation
|
GNU sed testsuite comparison: |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #557 +/- ##
==========================================
+ Coverage 95.45% 95.73% +0.28%
==========================================
Files 14 14
Lines 7762 8344 +582
Branches 469 490 +21
==========================================
+ Hits 7409 7988 +579
- Misses 352 355 +3
Partials 1 1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Merging this PR will degrade performance by 1.29%
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing |
|
Hi @dspinellis — friendly review request on this s/// case-conversion implementation (fixes #540; GNU suite +1, utf8-ru). Just pushed a perf follow-up (fast paths when no conversion directives; 265 tests green, fmt+clippy clean) to address the Codspeed delta. Let me know if you need anything else. Thanks! |
|
GNU sed testsuite comparison: |
|
Follow-up pushed (23b7709): patch coverage for the fast paths - unit tests for unmatched-group/single-literal fast paths, flag-sync contract panics, LowerFirst invalid-byte handling, compiler case-directive parsing + flag, and end-to-end substitution tests; plus removal of two dead None arms preempted by the all-None early return. Full suite green (lib + integration), fmt/clippy clean. Remaining reds are not from this change: Android jobs fail in sdkmanager setup, and CodSpeed shows -3.75% on number_fix only (genome/access_log improved; likely noise, happy to dig if you want). |
|
GNU sed testsuite comparison: |
|
GNU sed testsuite comparison: |
|
GNU sed testsuite comparison: |
|
Thanks for the review, @sylvestre. I simplified the replacement parser and fast paths, cleaned up the tests, and moved the case conversion docs to the GNU extensions section. |
|
GNU sed testsuite comparison: |
|
GNU sed testsuite comparison: |
There was a problem hiding this comment.
🔵 Needs a closer look
The broad replacement parsing/rendering changes across multiple encoding and locale-sensitive paths, together with the ICU addition, warrant human validation on supported targets and locales before approval.
No open issues 🎉
Review effort: Lite
|
GNU sed testsuite comparison: |
|
GNU sed testsuite comparison: |


Fixes #540.
Implements GNU
s///replacement case-conversion escapes:\Uuppercase until\L/\E,\Llowercase until\U/\E\u/\lone-shot next-character conversion\Eends persistent conversion and clears pending one-shotDetails:
ReplacementPart::{Upper,Lower,UpperFirst,LowerFirst,End}incommand.rs;compile_replacementparses them beforeparse_char_escapeso\u/\Uin replacements are case-conversion directives rather than\uXXXX/\UXXXXXXXXUnicode escapes (matches GNU sed behavior; README updated accordingly). Escaped delimiter still wins (e.g.sU...U\UU).append_with_caseapplies persistent + one-shot to literals,&,\1..\9. Empty matches leave one-shot pending (GNUs/(b?)-/\u\1x/gcarry), any produced char consumes it. Fresh state per substituted occurrence sogdoes not propagate.take_case(single, persistent)helper.Verified against GNU sed 4.9 including the issue table (
ABC DEF,ABc def) plus\U&\E,\U\1-\2, empty-groupgcases,\u\l/\l\ulast-wins,\U\l/\L\ucombos.Tests:
cargo test --lib385 passed,cargo test --test tests268 passed,cargo clippy --libclean,cargo fmt --checkclean.