mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27: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"
|
||||
checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766"
|
||||
dependencies = [
|
||||
"nom",
|
||||
"nom 7.1.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -861,7 +861,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys 0.52.0",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1276,7 +1276,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"windows-targets 0.48.5",
|
||||
"windows-targets 0.52.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1423,6 +1423,15 @@ dependencies = [
|
|||
"minimal-lexical",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nom"
|
||||
version = "8.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "df9761775871bdef83bee530e60050f7e54b1105350d6884eb0fb4f46c2f9405"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "notify"
|
||||
version = "8.0.0"
|
||||
|
@ -1620,7 +1629,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "ae130e79b384861c193d6016a46baa2733a6f8f17486eb36a5c098c577ce01e8"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"nom",
|
||||
"nom 7.1.3",
|
||||
"regex",
|
||||
]
|
||||
|
||||
|
@ -1996,7 +2005,7 @@ dependencies = [
|
|||
"errno",
|
||||
"libc",
|
||||
"linux-raw-sys 0.4.15",
|
||||
"windows-sys 0.52.0",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2241,7 +2250,7 @@ dependencies = [
|
|||
"getrandom",
|
||||
"once_cell",
|
||||
"rustix 0.38.43",
|
||||
"windows-sys 0.52.0",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -3325,7 +3334,7 @@ name = "uu_tr"
|
|||
version = "0.0.29"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"nom",
|
||||
"nom 8.0.0",
|
||||
"uucore",
|
||||
]
|
||||
|
||||
|
@ -3660,7 +3669,7 @@ version = "0.1.9"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
|
||||
dependencies = [
|
||||
"windows-sys 0.48.0",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
|
@ -308,7 +308,7 @@ lscolors = { version = "0.20.0", default-features = false, features = [
|
|||
memchr = "2.7.2"
|
||||
memmap2 = "0.9.4"
|
||||
nix = { version = "0.29", default-features = false }
|
||||
nom = "7.1.3"
|
||||
nom = "8.0.0"
|
||||
notify = { version = "=8.0.0", features = ["macos_kqueue"] }
|
||||
num-bigint = "0.4.4"
|
||||
num-prime = "0.4.4"
|
||||
|
|
|
@ -92,6 +92,8 @@ skip = [
|
|||
{ name = "itertools", version = "0.13.0" },
|
||||
# indexmap
|
||||
{ name = "hashbrown", version = "0.14.5" },
|
||||
# parse_datetime, cexpr (via bindgen)
|
||||
{ name = "nom", version = "7.1.3" },
|
||||
]
|
||||
# spell-checker: enable
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ use nom::{
|
|||
combinator::{map, map_opt, peek, recognize, value},
|
||||
multi::{many0, many_m_n},
|
||||
sequence::{delimited, preceded, separated_pair},
|
||||
IResult,
|
||||
IResult, Parser,
|
||||
};
|
||||
use std::{
|
||||
char,
|
||||
|
@ -298,7 +298,8 @@ impl Sequence {
|
|||
map(Self::parse_backslash_or_char_with_warning, |s| {
|
||||
Ok(Self::Char(s))
|
||||
}),
|
||||
)))(input)
|
||||
)))
|
||||
.parse(input)
|
||||
.map(|(_, r)| r)
|
||||
.unwrap()
|
||||
.into_iter()
|
||||
|
@ -308,7 +309,7 @@ impl Sequence {
|
|||
fn parse_octal(input: &[u8]) -> IResult<&[u8], u8> {
|
||||
// For `parse_char_range`, `parse_char_star`, `parse_char_repeat`, `parse_char_equal`.
|
||||
// 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> {
|
||||
|
@ -321,7 +322,8 @@ impl Sequence {
|
|||
// See test `test_multibyte_octal_sequence`
|
||||
Self::parse_octal_two_digits,
|
||||
)),
|
||||
)(input)
|
||||
)
|
||||
.parse(input)
|
||||
}
|
||||
|
||||
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();
|
||||
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> {
|
||||
|
@ -353,18 +356,21 @@ impl Sequence {
|
|||
}
|
||||
result
|
||||
},
|
||||
)(input)
|
||||
).parse(input)
|
||||
}
|
||||
|
||||
fn parse_octal_two_digits(input: &[u8]) -> IResult<&[u8], u8> {
|
||||
map_opt(
|
||||
recognize(many_m_n(2, 2, one_of("01234567"))),
|
||||
|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> {
|
||||
preceded(tag("\\"), Self::single_char)(input).map(|(l, a)| {
|
||||
preceded(tag("\\"), Self::single_char)
|
||||
.parse(input)
|
||||
.map(|(l, a)| {
|
||||
let c = match a {
|
||||
b'a' => unicode_table::BEL,
|
||||
b'b' => unicode_table::BS,
|
||||
|
@ -380,7 +386,7 @@ impl Sequence {
|
|||
}
|
||||
|
||||
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> {
|
||||
|
@ -388,7 +394,8 @@ impl Sequence {
|
|||
Self::parse_octal_with_warning,
|
||||
Self::parse_backslash,
|
||||
Self::single_char,
|
||||
))(input)
|
||||
))
|
||||
.parse(input)
|
||||
}
|
||||
|
||||
fn single_char(input: &[u8]) -> IResult<&[u8], u8> {
|
||||
|
@ -400,7 +407,8 @@ impl Sequence {
|
|||
Self::parse_backslash_or_char,
|
||||
tag("-"),
|
||||
Self::parse_backslash_or_char,
|
||||
)(input)
|
||||
)
|
||||
.parse(input)
|
||||
.map(|(l, (a, b))| {
|
||||
(l, {
|
||||
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>> {
|
||||
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))))
|
||||
}
|
||||
|
||||
|
@ -433,7 +442,8 @@ impl Sequence {
|
|||
take_till(|ue| matches!(ue, b']' | b'\\')),
|
||||
),
|
||||
tag("]"),
|
||||
)(input)
|
||||
)
|
||||
.parse(input)
|
||||
.map(|(l, (c, cnt_str))| {
|
||||
let s = String::from_utf8_lossy(cnt_str);
|
||||
let result = if cnt_str.starts_with(b"0") {
|
||||
|
@ -477,7 +487,8 @@ impl Sequence {
|
|||
value(Err(BadSequence::MissingCharClassName), tag("")),
|
||||
)),
|
||||
tag(":]"),
|
||||
)(input)
|
||||
)
|
||||
.parse(input)
|
||||
}
|
||||
|
||||
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))),
|
||||
)),
|
||||
tag("=]"),
|
||||
)(input)
|
||||
)
|
||||
.parse(input)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue