1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225
|
Description: use older branch of crate nom
This essentially reverts upstream git commit 811b3dd.
Author: Jonas Smedegaard <dr@jones.dk>
Forwarded: not-needed
Last-Update: 2025-08-05
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -34,7 +34,7 @@
image = { version = "0.25", default-features = false, features = ["png"] }
iter_fixed = "0.4"
log = "0.4"
-nom = "8.0"
+nom = "7.1"
profiling = "1.0"
regex = "1.11"
thiserror = "2.0"
--- a/src/vobsub/img.rs
+++ b/src/vobsub/img.rs
@@ -8,8 +8,8 @@
bits::complete::{tag as tag_bits, take as take_bits},
branch::alt,
combinator::value,
- sequence::preceded,
- IResult, Parser as _,
+ sequence::{preceded, Tuple},
+ IResult,
};
use thiserror::Error;
@@ -136,7 +136,7 @@
let count2 = preceded(tag_bits(0, 2u8), take_bits(4u16));
// Count for 1-nibble RLE.
let count1 = take_bits(2u16);
- alt((end_of_line, count4, count3, count2, count1)).parse(input)
+ alt((end_of_line, count4, count3, count2, count1))(input)
}
/// Parse an `Rle`.
--- a/src/vobsub/mpeg2/clock.rs
+++ b/src/vobsub/mpeg2/clock.rs
@@ -1,6 +1,7 @@
use nom::{
bits::complete::{tag, take},
- IResult, Parser as _,
+ sequence::Tuple,
+ IResult,
};
use std::fmt;
--- a/src/vobsub/mpeg2/pes.rs
+++ b/src/vobsub/mpeg2/pes.rs
@@ -4,18 +4,16 @@
//! in a `*.sub` file.
use nom::{
- bits::{
- self, bits,
- complete::{tag as tag_bits, take},
- },
+ bits,
+ bits::complete::{tag as tag_bits, take},
branch::alt,
bytes::complete::tag as tag_bytes,
combinator::{map, rest, value},
multi::length_value,
number::complete::{be_u16, be_u8},
//do_parse, length_value, named, rest,
+ sequence::Tuple,
IResult,
- Parser as _,
};
use std::fmt;
@@ -45,8 +43,7 @@
value(PtsDtsFlags::None, tag_bits(0b00, 2u8)),
value(PtsDtsFlags::Pts, tag_bits(0b10, 2u8)),
value(PtsDtsFlags::PtsDts, tag_bits(0b11, 2u8)),
- ))
- .parse(input)
+ ))(input)
}
/// Presentation and Decode Time Stamps, if available.
@@ -106,7 +103,7 @@
/// Deserialize a single Boolean flag bit.
fn bool_flag(input: (&[u8], usize)) -> IResult<(&[u8], usize), bool> {
- map(|input| bits::complete::take(1u8)(input), |b: u8| b == 1).parse(input)
+ map(|input| bits::complete::take(1u8)(input), |b: u8| b == 1)(input)
}
/// Deserialize `HeaderDataFlags`
@@ -165,8 +162,7 @@
// call `header_data_fields` to do the actual parse. This ensures
// that if `header_data_fields` doesn't parse all the header data,
// we discard the rest before continuing.
- let (input, pts_dts) =
- length_value(be_u8, |input| pts_dts(input, flags.pts_dts_flags)).parse(input)?;
+ let (input, pts_dts) = length_value(be_u8, |input| pts_dts(input, flags.pts_dts_flags))(input)?;
Ok((input, HeaderData { flags, pts_dts }))
}
@@ -250,8 +246,7 @@
}
pub fn packet(input: &[u8]) -> IResult<&[u8], Packet<'_>> {
- const PACKET_TAG: &[u8] = &[0x00, 0x00, 0x01, 0xbd];
- let packet_tag = tag_bytes(PACKET_TAG);
+ let packet_tag = tag_bytes(&[0x00, 0x00, 0x01, 0xbd]);
let packet_data = length_value(be_u16, packet_helper);
let (input, (_, packet)) = (packet_tag, packet_data).parse(input)?;
--- a/src/vobsub/mpeg2/ps.rs
+++ b/src/vobsub/mpeg2/ps.rs
@@ -9,7 +9,8 @@
complete::{tag as tag_bits, take as take_bits},
},
bytes::complete::tag as tag_bytes,
- IResult, Parser as _,
+ sequence::Tuple,
+ IResult,
};
use std::fmt;
@@ -44,8 +45,7 @@
/// Parse a Program Stream header.
pub fn header(input: &[u8]) -> IResult<&[u8], Header> {
// Sync bytes.
- const PS_HEADER_TAG: &[u8] = &[0x00, 0x00, 0x01, 0xba];
- let tag1 = tag_bytes(PS_HEADER_TAG);
+ let tag1 = tag_bytes(&[0x00, 0x00, 0x01, 0xba]);
// 10-byte header.
let header_parse = bits(|input| {
--- a/src/vobsub/palette.rs
+++ b/src/vobsub/palette.rs
@@ -3,7 +3,8 @@
bytes::complete::{tag, take_while_m_n},
combinator::map_res,
multi::separated_list0,
- IResult, Parser as _,
+ sequence::tuple,
+ IResult,
};
use super::VobSubError;
@@ -38,13 +39,12 @@
map_res(
take_while_m_n(2, 2, |c: u8| c.is_ascii_hexdigit()),
from_hex,
- )
- .parse(input)
+ )(input)
}
/// Parse a 3-byte hexadecimal `RGB` color.
fn hex_rgb(input: &[u8]) -> IResult<&[u8], Rgb<u8>> {
- let (input, color) = (hex_primary, hex_primary, hex_primary).parse(input)?;
+ let (input, color) = tuple((hex_primary, hex_primary, hex_primary))(input)?;
Ok((input, Rgb(color.into())))
}
@@ -57,21 +57,16 @@
///
/// Will return `Err` if the input don't have 16 entries.
pub fn palette(input: &[u8]) -> IResult<&[u8], Palette> {
- const SEPARATOR_TAG: &[u8] = b", ";
- let res = map_res(
- separated_list0(tag(SEPARATOR_TAG), hex_rgb),
- |vec: Vec<Rgb<u8>>| {
- if vec.len() != 16 {
- return Err(VobSubError::PaletteInvalidEntriesNumbers(vec.len()));
- }
- // Coerce vector to known-size slice. Based on
- // http://stackoverflow.com/q/25428920/12089.
- let mut result = [Rgb([0, 0, 0]); 16];
- <[Rgb<u8>; 16] as AsMut<_>>::as_mut(&mut result).clone_from_slice(&vec[0..16]);
- Ok(result)
- },
- )
- .parse(input);
+ let res = map_res(separated_list0(tag(b", "), hex_rgb), |vec: Vec<Rgb<u8>>| {
+ if vec.len() != 16 {
+ return Err(VobSubError::PaletteInvalidEntriesNumbers(vec.len()));
+ }
+ // Coerce vector to known-size slice. Based on
+ // http://stackoverflow.com/q/25428920/12089.
+ let mut result = [Rgb([0, 0, 0]); 16];
+ <[Rgb<u8>; 16] as AsMut<_>>::as_mut(&mut result).clone_from_slice(&vec[0..16]);
+ Ok(result)
+ })(input);
res
}
--- a/src/vobsub/sub.rs
+++ b/src/vobsub/sub.rs
@@ -23,8 +23,8 @@
combinator::{map, value},
multi::{count, many_till},
number::complete::be_u16,
- sequence::preceded,
- IResult, Parser as _,
+ sequence::{preceded, Tuple},
+ IResult,
};
use std::{
cmp::Ordering, fmt::Debug, fs, iter::FusedIterator, marker::PhantomData, path::Path,
@@ -208,13 +208,12 @@
take_until(ControlCommandTag::End.as_slice()),
ControlCommand::Unsupported,
),
- ))
- .parse(input)
+ ))(input)
}
/// The end of a control sequence.
fn control_command_end(input: &[u8]) -> IResult<&[u8], &[u8]> {
- tag_bytes(ControlCommandTag::End.as_slice()).parse(input)
+ tag_bytes(ControlCommandTag::End.as_slice())(input)
}
/// The control packet for a subtitle.
|