mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
Merge pull request #7227 from cakebaker/bump_nom
Bump `nom` and adapt `tr` to API changes
This commit is contained in:
commit
7747351cb1
4 changed files with 59 additions and 36 deletions
25
Cargo.lock
generated
25
Cargo.lock
generated
|
@ -276,7 +276,7 @@ version = "0.6.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766"
|
checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"nom",
|
"nom 7.1.3",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -861,7 +861,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d"
|
checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"windows-sys 0.52.0",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1276,7 +1276,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34"
|
checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"windows-targets 0.48.5",
|
"windows-targets 0.52.6",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1423,6 +1423,15 @@ dependencies = [
|
||||||
"minimal-lexical",
|
"minimal-lexical",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "nom"
|
||||||
|
version = "8.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "df9761775871bdef83bee530e60050f7e54b1105350d6884eb0fb4f46c2f9405"
|
||||||
|
dependencies = [
|
||||||
|
"memchr",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "notify"
|
name = "notify"
|
||||||
version = "8.0.0"
|
version = "8.0.0"
|
||||||
|
@ -1620,7 +1629,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ae130e79b384861c193d6016a46baa2733a6f8f17486eb36a5c098c577ce01e8"
|
checksum = "ae130e79b384861c193d6016a46baa2733a6f8f17486eb36a5c098c577ce01e8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"nom",
|
"nom 7.1.3",
|
||||||
"regex",
|
"regex",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1996,7 +2005,7 @@ dependencies = [
|
||||||
"errno",
|
"errno",
|
||||||
"libc",
|
"libc",
|
||||||
"linux-raw-sys 0.4.15",
|
"linux-raw-sys 0.4.15",
|
||||||
"windows-sys 0.52.0",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2241,7 +2250,7 @@ dependencies = [
|
||||||
"getrandom",
|
"getrandom",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"rustix 0.38.43",
|
"rustix 0.38.43",
|
||||||
"windows-sys 0.52.0",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -3325,7 +3334,7 @@ name = "uu_tr"
|
||||||
version = "0.0.29"
|
version = "0.0.29"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
"nom",
|
"nom 8.0.0",
|
||||||
"uucore",
|
"uucore",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -3660,7 +3669,7 @@ version = "0.1.9"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
|
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-sys 0.48.0",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
@ -308,7 +308,7 @@ lscolors = { version = "0.20.0", default-features = false, features = [
|
||||||
memchr = "2.7.2"
|
memchr = "2.7.2"
|
||||||
memmap2 = "0.9.4"
|
memmap2 = "0.9.4"
|
||||||
nix = { version = "0.29", default-features = false }
|
nix = { version = "0.29", default-features = false }
|
||||||
nom = "7.1.3"
|
nom = "8.0.0"
|
||||||
notify = { version = "=8.0.0", features = ["macos_kqueue"] }
|
notify = { version = "=8.0.0", features = ["macos_kqueue"] }
|
||||||
num-bigint = "0.4.4"
|
num-bigint = "0.4.4"
|
||||||
num-prime = "0.4.4"
|
num-prime = "0.4.4"
|
||||||
|
|
|
@ -92,6 +92,8 @@ skip = [
|
||||||
{ name = "itertools", version = "0.13.0" },
|
{ name = "itertools", version = "0.13.0" },
|
||||||
# indexmap
|
# indexmap
|
||||||
{ name = "hashbrown", version = "0.14.5" },
|
{ name = "hashbrown", version = "0.14.5" },
|
||||||
|
# parse_datetime, cexpr (via bindgen)
|
||||||
|
{ name = "nom", version = "7.1.3" },
|
||||||
]
|
]
|
||||||
# spell-checker: enable
|
# spell-checker: enable
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ use nom::{
|
||||||
combinator::{map, map_opt, peek, recognize, value},
|
combinator::{map, map_opt, peek, recognize, value},
|
||||||
multi::{many0, many_m_n},
|
multi::{many0, many_m_n},
|
||||||
sequence::{delimited, preceded, separated_pair},
|
sequence::{delimited, preceded, separated_pair},
|
||||||
IResult,
|
IResult, Parser,
|
||||||
};
|
};
|
||||||
use std::{
|
use std::{
|
||||||
char,
|
char,
|
||||||
|
@ -298,7 +298,8 @@ impl Sequence {
|
||||||
map(Self::parse_backslash_or_char_with_warning, |s| {
|
map(Self::parse_backslash_or_char_with_warning, |s| {
|
||||||
Ok(Self::Char(s))
|
Ok(Self::Char(s))
|
||||||
}),
|
}),
|
||||||
)))(input)
|
)))
|
||||||
|
.parse(input)
|
||||||
.map(|(_, r)| r)
|
.map(|(_, r)| r)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
@ -308,7 +309,7 @@ impl Sequence {
|
||||||
fn parse_octal(input: &[u8]) -> IResult<&[u8], u8> {
|
fn parse_octal(input: &[u8]) -> IResult<&[u8], u8> {
|
||||||
// For `parse_char_range`, `parse_char_star`, `parse_char_repeat`, `parse_char_equal`.
|
// For `parse_char_range`, `parse_char_star`, `parse_char_repeat`, `parse_char_equal`.
|
||||||
// Because in these patterns, there's no ambiguous cases.
|
// Because in these patterns, there's no ambiguous cases.
|
||||||
preceded(tag("\\"), Self::parse_octal_up_to_three_digits)(input)
|
preceded(tag("\\"), Self::parse_octal_up_to_three_digits).parse(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_octal_with_warning(input: &[u8]) -> IResult<&[u8], u8> {
|
fn parse_octal_with_warning(input: &[u8]) -> IResult<&[u8], u8> {
|
||||||
|
@ -321,7 +322,8 @@ impl Sequence {
|
||||||
// See test `test_multibyte_octal_sequence`
|
// See test `test_multibyte_octal_sequence`
|
||||||
Self::parse_octal_two_digits,
|
Self::parse_octal_two_digits,
|
||||||
)),
|
)),
|
||||||
)(input)
|
)
|
||||||
|
.parse(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_octal_up_to_three_digits(input: &[u8]) -> IResult<&[u8], u8> {
|
fn parse_octal_up_to_three_digits(input: &[u8]) -> IResult<&[u8], u8> {
|
||||||
|
@ -331,7 +333,8 @@ impl Sequence {
|
||||||
let str_to_parse = std::str::from_utf8(out).unwrap();
|
let str_to_parse = std::str::from_utf8(out).unwrap();
|
||||||
u8::from_str_radix(str_to_parse, 8).ok()
|
u8::from_str_radix(str_to_parse, 8).ok()
|
||||||
},
|
},
|
||||||
)(input)
|
)
|
||||||
|
.parse(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_octal_up_to_three_digits_with_warning(input: &[u8]) -> IResult<&[u8], u8> {
|
fn parse_octal_up_to_three_digits_with_warning(input: &[u8]) -> IResult<&[u8], u8> {
|
||||||
|
@ -353,18 +356,21 @@ impl Sequence {
|
||||||
}
|
}
|
||||||
result
|
result
|
||||||
},
|
},
|
||||||
)(input)
|
).parse(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_octal_two_digits(input: &[u8]) -> IResult<&[u8], u8> {
|
fn parse_octal_two_digits(input: &[u8]) -> IResult<&[u8], u8> {
|
||||||
map_opt(
|
map_opt(
|
||||||
recognize(many_m_n(2, 2, one_of("01234567"))),
|
recognize(many_m_n(2, 2, one_of("01234567"))),
|
||||||
|out: &[u8]| u8::from_str_radix(std::str::from_utf8(out).unwrap(), 8).ok(),
|
|out: &[u8]| u8::from_str_radix(std::str::from_utf8(out).unwrap(), 8).ok(),
|
||||||
)(input)
|
)
|
||||||
|
.parse(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_backslash(input: &[u8]) -> IResult<&[u8], u8> {
|
fn parse_backslash(input: &[u8]) -> IResult<&[u8], u8> {
|
||||||
preceded(tag("\\"), Self::single_char)(input).map(|(l, a)| {
|
preceded(tag("\\"), Self::single_char)
|
||||||
|
.parse(input)
|
||||||
|
.map(|(l, a)| {
|
||||||
let c = match a {
|
let c = match a {
|
||||||
b'a' => unicode_table::BEL,
|
b'a' => unicode_table::BEL,
|
||||||
b'b' => unicode_table::BS,
|
b'b' => unicode_table::BS,
|
||||||
|
@ -380,7 +386,7 @@ impl Sequence {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_backslash_or_char(input: &[u8]) -> IResult<&[u8], u8> {
|
fn parse_backslash_or_char(input: &[u8]) -> IResult<&[u8], u8> {
|
||||||
alt((Self::parse_octal, Self::parse_backslash, Self::single_char))(input)
|
alt((Self::parse_octal, Self::parse_backslash, Self::single_char)).parse(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_backslash_or_char_with_warning(input: &[u8]) -> IResult<&[u8], u8> {
|
fn parse_backslash_or_char_with_warning(input: &[u8]) -> IResult<&[u8], u8> {
|
||||||
|
@ -388,7 +394,8 @@ impl Sequence {
|
||||||
Self::parse_octal_with_warning,
|
Self::parse_octal_with_warning,
|
||||||
Self::parse_backslash,
|
Self::parse_backslash,
|
||||||
Self::single_char,
|
Self::single_char,
|
||||||
))(input)
|
))
|
||||||
|
.parse(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn single_char(input: &[u8]) -> IResult<&[u8], u8> {
|
fn single_char(input: &[u8]) -> IResult<&[u8], u8> {
|
||||||
|
@ -400,7 +407,8 @@ impl Sequence {
|
||||||
Self::parse_backslash_or_char,
|
Self::parse_backslash_or_char,
|
||||||
tag("-"),
|
tag("-"),
|
||||||
Self::parse_backslash_or_char,
|
Self::parse_backslash_or_char,
|
||||||
)(input)
|
)
|
||||||
|
.parse(input)
|
||||||
.map(|(l, (a, b))| {
|
.map(|(l, (a, b))| {
|
||||||
(l, {
|
(l, {
|
||||||
let (start, end) = (u32::from(a), u32::from(b));
|
let (start, end) = (u32::from(a), u32::from(b));
|
||||||
|
@ -417,7 +425,8 @@ impl Sequence {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_char_star(input: &[u8]) -> IResult<&[u8], Result<Self, BadSequence>> {
|
fn parse_char_star(input: &[u8]) -> IResult<&[u8], Result<Self, BadSequence>> {
|
||||||
delimited(tag("["), Self::parse_backslash_or_char, tag("*]"))(input)
|
delimited(tag("["), Self::parse_backslash_or_char, tag("*]"))
|
||||||
|
.parse(input)
|
||||||
.map(|(l, a)| (l, Ok(Self::CharStar(a))))
|
.map(|(l, a)| (l, Ok(Self::CharStar(a))))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -433,7 +442,8 @@ impl Sequence {
|
||||||
take_till(|ue| matches!(ue, b']' | b'\\')),
|
take_till(|ue| matches!(ue, b']' | b'\\')),
|
||||||
),
|
),
|
||||||
tag("]"),
|
tag("]"),
|
||||||
)(input)
|
)
|
||||||
|
.parse(input)
|
||||||
.map(|(l, (c, cnt_str))| {
|
.map(|(l, (c, cnt_str))| {
|
||||||
let s = String::from_utf8_lossy(cnt_str);
|
let s = String::from_utf8_lossy(cnt_str);
|
||||||
let result = if cnt_str.starts_with(b"0") {
|
let result = if cnt_str.starts_with(b"0") {
|
||||||
|
@ -477,7 +487,8 @@ impl Sequence {
|
||||||
value(Err(BadSequence::MissingCharClassName), tag("")),
|
value(Err(BadSequence::MissingCharClassName), tag("")),
|
||||||
)),
|
)),
|
||||||
tag(":]"),
|
tag(":]"),
|
||||||
)(input)
|
)
|
||||||
|
.parse(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_char_equal(input: &[u8]) -> IResult<&[u8], Result<Self, BadSequence>> {
|
fn parse_char_equal(input: &[u8]) -> IResult<&[u8], Result<Self, BadSequence>> {
|
||||||
|
@ -491,7 +502,8 @@ impl Sequence {
|
||||||
map(Self::parse_backslash_or_char, |c| Ok(Self::Char(c))),
|
map(Self::parse_backslash_or_char, |c| Ok(Self::Char(c))),
|
||||||
)),
|
)),
|
||||||
tag("=]"),
|
tag("=]"),
|
||||||
)(input)
|
)
|
||||||
|
.parse(input)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue