Skip to content
This repository has been archived by the owner on Apr 9, 2023. It is now read-only.

nom v4 #15

Open
ignatenkobrain opened this issue Apr 28, 2019 · 4 comments · May be fixed by #20
Open

nom v4 #15

ignatenkobrain opened this issue Apr 28, 2019 · 4 comments · May be fixed by #20

Comments

@ignatenkobrain
Copy link

It would be very cool if you would update obsolete nom v2 to latest v4. I tried to do that update myself, but it turned out to be not trivial.

Thanks!

@ignatenkobrain
Copy link
Author

diff --git a/Cargo.toml b/Cargo.toml
index f5cc72a..7210b7b 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -11,7 +11,7 @@ license = "MIT"
 
 [dependencies]
 petgraph = "^0.4"
-nom = "^2"
+nom = "^4"
 lazy_static = "^0.2"
 fnv = "^1"
 parking_lot = "^0.4"
diff --git a/src/fdo_magic/mod.rs b/src/fdo_magic/mod.rs
index 3a1bee4..5325a5c 100644
--- a/src/fdo_magic/mod.rs
+++ b/src/fdo_magic/mod.rs
@@ -237,10 +237,10 @@ pub mod ruleset {
        }
     
     pub fn from_u8(b: &[u8]) -> Result<FnvHashMap<MIME, DiGraph<super::MagicRule, u32>>, String> {
-        let tuplevec = from_u8_to_tuple_vec(b).to_result().map_err(|e| e.to_string())?;;
+        let tuplevec = from_u8_to_tuple_vec(b).map_err(|e| e.to_string())?;
         let mut res = FnvHashMap::<MIME, DiGraph<super::MagicRule, u32>>::default();
         
-        for x in tuplevec {
+        for x in tuplevec.1 {
             res.insert(x.0, gen_graph(x.1));
         }
         

This is something I tried, but that broke all tests with:

test from_u8::application_tar ... thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `"application/octet-stream"`,
 right: `"application/x-tar"`', tests/from_u8.rs:70:9

It thinks that all files are octet-stream now.

@ignatenkobrain
Copy link
Author

@Geal, would you be able to help me with this, please? :)

mbrubeck referenced this issue in mbrubeck/tree_magic May 21, 2020
Fixes #15.

Adding an extra newline at the end of the builtin magic file fixed the
problem reported in issue #15.  There is probably a better way to do
this, but I haven't found it yet.
@mbrubeck mbrubeck linked a pull request Jun 6, 2020 that will close this issue
@mbrubeck
Copy link

I published a (temporary?) stripped-down fork that includes PR #20 (upgrade to nom 5):

https://crates.io/crates/tree_magic_mini

@pymongo
Copy link

pymongo commented Feb 22, 2023

tree_magic crate get warning at rustc 1.69.0-nightly (5243ea5c2 2023-02-20)

warning: the following packages contain code that will be rejected by a future version of Rust: nom v3.2.1
note: to see what the problems were, use the option --future-incompat-report

cargo tree -i -p nom@3.2.1
nom v3.2.1
└── tree_magic v0.2.3

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants