mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
csplit: only allow ASCII digits as offset
This commit is contained in:
parent
7439050d85
commit
d5b6af5216
2 changed files with 10 additions and 1 deletions
|
@ -106,7 +106,7 @@ pub fn get_patterns(args: &[String]) -> Result<Vec<Pattern>, CsplitError> {
|
|||
fn extract_patterns(args: &[String]) -> Result<Vec<Pattern>, CsplitError> {
|
||||
let mut patterns = Vec::with_capacity(args.len());
|
||||
let to_match_reg =
|
||||
Regex::new(r"^(/(?P<UPTO>.+)/|%(?P<SKIPTO>.+)%)(?P<OFFSET>[\+-]?\d+)?$").unwrap();
|
||||
Regex::new(r"^(/(?P<UPTO>.+)/|%(?P<SKIPTO>.+)%)(?P<OFFSET>[\+-]?[0-9]+)?$").unwrap();
|
||||
let execute_ntimes_reg = Regex::new(r"^\{(?P<TIMES>[0-9]+)|\*\}$").unwrap();
|
||||
let mut iter = args.iter().peekable();
|
||||
|
||||
|
|
|
@ -176,6 +176,15 @@ fn test_up_to_match_offset_repeat_twice() {
|
|||
assert_eq!(at.read("xx03"), generate(32, 51));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_up_to_match_non_ascii_offset() {
|
||||
// we use a different error message than GNU
|
||||
new_ucmd!()
|
||||
.args(&["numbers50.txt", "/9$/𝟚"])
|
||||
.fails()
|
||||
.stderr_contains("invalid pattern");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_up_to_match_negative_offset() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue