Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
3a700c1
Add fast I/O code (WIP)
dspinellis May 3, 2025
0388dc4
Improve naming and documentation
dspinellis May 4, 2025
1eec451
Implement write_str convenience method
dspinellis May 4, 2025
f941e26
Improve testing and fix output bug
dspinellis May 4, 2025
f266e88
Ensure regular output flushing
dspinellis May 4, 2025
7b874a4
Fix non-Unix compilation
dspinellis May 4, 2025
e4f7336
Add tests for non-newline terminated files
dspinellis May 4, 2025
814e370
Handle missing newlines
dspinellis May 4, 2025
8d48bee
Remove unneeded generic parameter
dspinellis May 4, 2025
9f4fb9e
Remove unneeded generic argument
dspinellis May 6, 2025
e480d51
Implement skeleton processor
dspinellis May 6, 2025
6ad0985
Improve name for processing options
dspinellis May 6, 2025
5545e82
Use portable as_raw_fd
dspinellis May 6, 2025
7d17727
Revert "Use portable as_raw_fd"
dspinellis May 6, 2025
48cd61e
Fix Unix AsRawFd handling
dspinellis May 6, 2025
8da4755
Implement new in-place editing design
dspinellis May 6, 2025
5972713
Implement unbuffered output
dspinellis May 6, 2025
bf35c99
Move file processing into separate function
dspinellis May 6, 2025
6d2c4dd
Iterate over all commands
dspinellis May 6, 2025
9810765
Add is_last_line() method
dspinellis May 7, 2025
2082d0a
Support partial equality missing on Windows
dspinellis May 7, 2025
6cca6f2
Track input line number
dspinellis May 7, 2025
2e49096
Add command codes
dspinellis May 7, 2025
a8db13a
Allow command pointers to be shared
dspinellis May 7, 2025
55f09fd
Add command switching examples
dspinellis May 7, 2025
c5ef0fc
Implement the 'd' command
dspinellis May 7, 2025
9d23255
Remove unneeded type alias
dspinellis May 7, 2025
3366d7e
Create a single portable OutputChunk
dspinellis May 8, 2025
b90bf03
Test the delete command
dspinellis May 8, 2025
f628fe0
Add applies function to filter commands (WIP)
dspinellis May 8, 2025
f6d0702
Remove needless String-bytes-string conversion
dspinellis May 8, 2025
0acd866
Have Reader::get_line also return is_last_line
dspinellis May 8, 2025
7740263
Implement and pass address range tests
dspinellis May 9, 2025
d3b0cc4
Clarify extensions and incompatibilities
dspinellis May 9, 2025
d2f59fa
Add tests for --separate
dspinellis May 10, 2025
c21a9f2
Move input files to separate directory
dspinellis May 10, 2025
4226827
Add torture scripts
dspinellis May 10, 2025
4be5600
Add tests for multiple commands
dspinellis May 10, 2025
b98a9d4
Add regular expression replacement template
dspinellis May 10, 2025
fa7a906
Implement compilation for the s command
dspinellis May 10, 2025
cc4b378
Abstract code into compile_empty_command()
dspinellis May 10, 2025
2aaa6be
Add link to original implementation
dspinellis May 10, 2025
878de49
Add negated address tests
dspinellis May 10, 2025
1024eaa
Implement the 's' command processing
dspinellis May 10, 2025
e1e5bb1
Fix handling of & in replacement string
dspinellis May 10, 2025
fb41cf3
Improve implementation of output files
dspinellis May 10, 2025
0c22c02
Add and fix integration tests for the s command
dspinellis May 11, 2025
ca5a7da
Add test for empty RE reuse
dspinellis May 11, 2025
a90bfe6
Test extended regular expression use
dspinellis May 11, 2025
e37ac8f
Improve I/O file access error reporting
dspinellis May 11, 2025
9e589d1
Move saved regex into processing context
dspinellis May 11, 2025
13d067d
Improve substitution default handling
dspinellis May 11, 2025
5c2579c
Verify capture group references at compile time
dspinellis May 11, 2025
10a48ac
Add missing type annotation
dspinellis May 11, 2025
ab97623
Fix and make portable the subst_write_file test
dspinellis May 11, 2025
8b4b43a
Addsubst_ tests
dspinellis May 11, 2025
17bde5f
Merge remote-tracking branch 'upstream' into process
dspinellis May 11, 2025
9c5b956
Update format to current formatter
dspinellis May 11, 2025
305aa47
Remove unsafe warning
dspinellis May 11, 2025
a799a97
Partially address \r on Windows (WIP)
dspinellis May 11, 2025
39c9fcc
Revert "Partially address \r on Windows (WIP)"
dspinellis May 11, 2025
d732052
Ensure no auto-crlf on Windows
dspinellis May 11, 2025
abd5406
See and fix CR files before testing
dspinellis May 11, 2025
fa853c0
Implement the transliteration command
dspinellis May 13, 2025
50b7091
Fix handling of files ending without a newline
dspinellis May 14, 2025
8f1e6e1
Add ensure_owned and as_mut_string methods
dspinellis May 14, 2025
063ac98
Implement the N and P commands
dspinellis May 14, 2025
95abc50
Implement the D command
dspinellis May 15, 2025
3759c2c
Refactor duplicated command ending parsing
dspinellis May 15, 2025
edd215b
Optimize D implementation
dspinellis May 15, 2025
bb864d4
Implement g G h H n N q x single-letter commands
dspinellis May 16, 2025
0c06e66
Clean up defined structures
dspinellis May 16, 2025
3de177b
Rename try_as_str method into as_str
dspinellis May 16, 2025
9d060ff
Remove useless elements
dspinellis May 16, 2025
635444f
Ensure no CRs on Windows code coverage
dspinellis May 16, 2025
7b3883d
Simplify LF setting
dspinellis May 16, 2025
e4267bc
Simplify command thread construction
dspinellis May 16, 2025
f8221a8
Simplify line and char processing
dspinellis May 16, 2025
3b88ac6
Implement command blocks
dspinellis May 17, 2025
0281a12
Replace runtime block stack with static links
dspinellis May 17, 2025
dce3d5d
Improve function name
dspinellis May 17, 2025
4c2ef5f
Compile labels
dspinellis May 17, 2025
a404366
Create map from labels to commands
dspinellis May 17, 2025
1e190f3
Resolve branch targets to commands
dspinellis May 17, 2025
fa5910d
Report error on duplicate labels
dspinellis May 17, 2025
039d629
Implement processing of branch (b and t) commands
dspinellis May 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ jobs:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
steps:
- name: Set Git to use LF, even on Windows
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo test --all
Expand All @@ -39,6 +43,10 @@ jobs:
- { os: macos-latest , features: macos }
- { os: windows-latest , features: windows }
steps:
- name: Set Git to use LF, even on Windows
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- uses: actions/checkout@v4
- name: Initialize workflow variables
id: vars
Expand Down
33 changes: 33 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ feat_common_core = [
]

[workspace.dependencies]
atty = "0.2"
bytesize = "2.0.0"
chrono = { version = "0.4.37", default-features = false, features = [
"clock",
Expand All @@ -37,6 +38,7 @@ clap = { version = "4.4", features = ["wrap_help", "cargo"] }
clap_complete = "4.5"
clap_mangen = "0.2"
libc = "0.2.153"
memmap2 = "0.5"
once_cell = "1.21"
phf = "0.11.2"
phf_codegen = "0.11.2"
Expand All @@ -48,17 +50,19 @@ textwrap = { version = "0.16.1", features = ["terminal_size"] }
uucore = "0.0.30"
xattr = "1.3.1"


[dependencies]
atty = { workspace = true }
clap = { workspace = true }
clap_complete = { workspace = true }
clap_mangen = { workspace = true }
ctor = "0.4.1"
memmap2.workspace = true
phf = { workspace = true }
sed = { optional = true, version = "0.0.1", package = "uu_sed", path = "src/uu/sed" }
sysinfo = { workspace = true }
textwrap = { workspace = true }
uucore = { workspace = true }

ctor = "0.4.1"
sed = { optional = true, version = "0.0.1", package = "uu_sed", path = "src/uu/sed" }
uutests = "0.0.30"

[dev-dependencies]
Expand Down
31 changes: 27 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,41 @@ cd sed
cargo build --release
cargo run --release
```
## Extensions
### GNU
## Extensions and incompatibilities
### Spported GNU extensions
* Command-line arguments can be specified in long (`--`) form.
* Spaces can precede a regular expression modifier.
* `I` can be used in as a synonym for the `i` (case insensitive) substitution
flag.
* In addition to `\n`, other escape sequences (octal, hex, C) are supported
in the strings of the `y` command.
Under POSIX these yield undefined behavior.

### BSD and GNU
### Supported BSD and GNU extensions
* The second address in a range can be specified as a relative address with +N.

### Other
### New extensions
* Unicode characters can be specified in regular expression pattern, replacement
and transliteration sequences using `\uXXXX` or `\UXXXXXXXX` sequences.

### Incompatibilities
* The input is assumed to be valid UTF-8 (this includes 7-bit ASCII).
If the input is in another code page, consider converting it through UTF-8
in order to avoid errors on invalid UTF-8 sequences and for the correct
handling of regular expressions.
This _sed_ program can also handle arbitrary byte sequences if no part of the
input is treated as string.
* The command will report an error and fail if duplicate labels are found
in the script.
This matches the BSD behavior. The GNU version accepts duplicate labels.
* The last line (`$`) address is interpreted as the last non-empty line of
the last file. If files specified in subsequent arguments until the last
one are empty, then the last line condition will never be triggered.
This behavior is consistent with the
[original implementation](https://github.com/dspinellis/unix-history-repo/blob/Research-V7/usr/src/cmd/sed/sed1.c#L665).
* Labels are parsed for alphanumeric characters. The BSD version parses them
until the end of the line, preventing ; to be used as a separator.

## License

sed is licensed under the MIT License - see the `LICENSE` file for details
2 changes: 2 additions & 0 deletions src/uu/sed/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ categories = ["command-line-utilities"]


[dependencies]
atty = { workspace = true }
clap = { workspace = true }
once_cell = { workspace = true }
regex = { workspace = true }
tempfile = { workspace = true }
memmap2 = { workspace = true }
uucore = { workspace = true }

[lib]
Expand Down
Loading
Loading