changeset 755:fc937d93a57c

Bump nom to version 6, and image to 0.23.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Mon, 04 Jan 2021 21:14:02 +0100
parents a6875f90c141
children 4d91790cf8ab
files Cargo.toml src/th06/anm0.rs src/th06/ecl.rs src/th06/std.rs
diffstat 4 files changed, 15 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -10,9 +10,9 @@ license = "GPL-3.0-or-later"
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
 [dependencies]
-nom = "5"
+nom = { version = "6", default-features = false, features = ["alloc"] }
 encoding_rs = "0.8"
-image = { version = "0.22", default-features = false, features = ["png_codec", "jpeg"] }
+image = { version = "0.23", default-features = false, features = ["png", "jpeg"] }
 bitflags = "1"
 luminance = "0.39"
 luminance-glfw = { version = "0.12", default-features = false, features = ["log-errors"] }
--- a/src/th06/anm0.rs
+++ b/src/th06/anm0.rs
@@ -88,7 +88,7 @@ fn parse_name(i: &[u8]) -> IResult<&[u8]
     let string = match String::from_utf8(slice.to_vec()) {
         Ok(string) => string,
         // XXX: use a more specific error instead.
-        Err(_) => return Err(nom::Err::Failure((i, nom::error::ErrorKind::Eof)))
+        Err(_) => return Err(nom::Err::Failure(nom::error::Error::new(i, nom::error::ErrorKind::Eof)))
     };
     Ok((i, string))
 }
@@ -127,7 +127,7 @@ macro_rules! declare_anm_instructions {
                     }
                 )*
                 // XXX: use a more specific error instead.
-                _ => return Err(nom::Err::Failure((i, nom::error::ErrorKind::Eof)))
+                _ => return Err(nom::Err::Failure(nom::error::Error::new(i, nom::error::ErrorKind::Eof)))
             };
             Ok((i, instr))
         }
@@ -185,7 +185,7 @@ fn parse_anm0(input: &[u8]) -> IResult<&
 
     let png_filename = if first_name_offset > 0 {
         if input.len() < first_name_offset as usize {
-            return Err(nom::Err::Failure((input, nom::error::ErrorKind::Eof)));
+            return Err(nom::Err::Failure(nom::error::Error::new(input, nom::error::ErrorKind::Eof)));
         }
         let i = &input[first_name_offset as usize..];
         let (_, name) = parse_name(i)?;
@@ -196,7 +196,7 @@ fn parse_anm0(input: &[u8]) -> IResult<&
 
     let alpha_filename = if second_name_offset > 0 {
         if input.len() < second_name_offset as usize {
-            return Err(nom::Err::Failure((input, nom::error::ErrorKind::Eof)));
+            return Err(nom::Err::Failure(nom::error::Error::new(input, nom::error::ErrorKind::Eof)));
         }
         let i = &input[second_name_offset as usize..];
         let (_, name) = parse_name(i)?;
@@ -209,7 +209,7 @@ fn parse_anm0(input: &[u8]) -> IResult<&
     let mut i = &input[..];
     for offset in sprite_offsets.into_iter().map(|x| x as usize) {
         if input.len() < offset {
-            return Err(nom::Err::Failure((input, nom::error::ErrorKind::Eof)));
+            return Err(nom::Err::Failure(nom::error::Error::new(input, nom::error::ErrorKind::Eof)));
         }
         i = &input[offset..];
         let (_, sprite) = parse_sprite(i)?;
@@ -219,7 +219,7 @@ fn parse_anm0(input: &[u8]) -> IResult<&
     let mut scripts = HashMap::new();
     for (index, offset) in script_offsets.into_iter().map(|(index, offset)| (index as u8, offset as usize)) {
         if input.len() < offset {
-            return Err(nom::Err::Failure((input, nom::error::ErrorKind::Eof)));
+            return Err(nom::Err::Failure(nom::error::Error::new(input, nom::error::ErrorKind::Eof)));
         }
         i = &input[offset..];
         let mut instruction_offsets = vec![];
@@ -247,7 +247,7 @@ fn parse_anm0(input: &[u8]) -> IResult<&
                         Ok(ptr) => *offset = ptr as u32,
                         Err(ptr) => {
                             // XXX: use a more specific error instead.
-                            return Err(nom::Err::Failure((input, nom::error::ErrorKind::Eof)));
+                            return Err(nom::Err::Failure(nom::error::Error::new(input, nom::error::ErrorKind::Eof)));
                             //println!("Instruction offset not found for pointer: {}", ptr);
                         }
                     }
--- a/src/th06/ecl.rs
+++ b/src/th06/ecl.rs
@@ -331,7 +331,7 @@ fn parse_sub_instruction(input: &[u8]) -
     let i = &input[..];
     let (i, (time, opcode)) = tuple((le_i32, le_u16))(i)?;
     if time == -1 || opcode == 0xffff {
-        return Err(Err::Error((i, ErrorKind::Eof)));
+        return Err(Err::Error(nom::error::Error::new(i, ErrorKind::Eof)));
     }
 
     let (i, (size, rank_mask, param_mask)) = tuple((le_u16, le_u16, le_u16))(i)?;
@@ -352,7 +352,7 @@ fn parse_main_instruction(input: &[u8]) 
     let i = &input[..];
     let (i, (time, sub)) = tuple((le_u16, le_u16))(i)?;
     if time == 0xffff && sub == 4 {
-        return Err(Err::Error((i, ErrorKind::Eof)));
+        return Err(Err::Error(nom::error::Error::new(i, ErrorKind::Eof)));
     }
 
     let (i, (opcode, size)) = tuple((le_u16, le_u16))(i)?;
@@ -377,7 +377,7 @@ fn parse_ecl(input: &[u8]) -> IResult<&[
 
     if main_count != 0 {
         // TODO: use a better error.
-        return Err(Err::Error((i, ErrorKind::Eof)));
+        return Err(Err::Error(nom::error::Error::new(i, ErrorKind::Eof)));
     }
 
     let (_, (main_offsets, sub_offsets)) = tuple((
--- a/src/th06/std.rs
+++ b/src/th06/std.rs
@@ -166,7 +166,7 @@ declare_stage_instructions!{
 fn parse_quad(i: &[u8]) -> IResult<&[u8], Quad> {
     let (i, (unk1, size)) = tuple((le_u16, le_u16))(i)?;
     if unk1 == 0xffff {
-        return Err(Err::Error((i, ErrorKind::Eof)));
+        return Err(Err::Error(nom::error::Error::new(i, ErrorKind::Eof)));
     }
     // TODO: replace this assert with a custom error.
     assert_eq!(size, 0x1c);
@@ -193,7 +193,7 @@ fn parse_model(i: &[u8]) -> IResult<&[u8
 fn parse_instance(i: &[u8]) -> IResult<&[u8], Instance> {
     let (i, (id, unknown, x, y, z)) = tuple((le_u16, le_u16, le_f32, le_f32, le_f32))(i)?;
     if id == 0xffff && unknown == 0xffff {
-        return Err(Err::Error((i, ErrorKind::Eof)));
+        return Err(Err::Error(nom::error::Error::new(i, ErrorKind::Eof)));
     }
     // TODO: replace this assert with a custom error.
     assert_eq!(unknown, 0x100);
@@ -207,7 +207,7 @@ fn parse_instance(i: &[u8]) -> IResult<&
 fn parse_instruction(i: &[u8]) -> IResult<&[u8], Call> {
     let (i, (time, opcode, size)) = tuple((le_u32, le_u16, le_u16))(i)?;
     if time == 0xffffffff && opcode == 0xffff && size == 0xffff {
-        return Err(Err::Error((i, ErrorKind::Eof)));
+        return Err(Err::Error(nom::error::Error::new(i, ErrorKind::Eof)));
     }
     // TODO: replace this assert with a custom error.
     assert_eq!(size, 12);