From: Pierre Chifflier Date: Wed, 19 Jan 2022 13:26:57 +0000 (+0100) Subject: rust/conf: convert parser to nom7 X-Git-Tag: suricata-7.0.0-beta1~163 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d98b386f368127abe1b1661b4f97777e4c0f93ac;p=thirdparty%2Fsuricata.git rust/conf: convert parser to nom7 --- diff --git a/rust/src/conf.rs b/rust/src/conf.rs index b3f996945c..94a868566d 100644 --- a/rust/src/conf.rs +++ b/rust/src/conf.rs @@ -21,11 +21,12 @@ use std::os::raw::c_int; use std::ffi::{CString, CStr}; use std::ptr; use std::str; -use nom::{ +use nom7::{ character::complete::{multispace0, not_line_ending}, sequence::{preceded, tuple}, number::complete::double, combinator::verify, + IResult, }; extern { @@ -86,9 +87,7 @@ pub struct ConfNode { impl ConfNode { pub fn wrap(conf: *const c_void) -> Self { - return Self { - conf: conf, - } + return Self { conf } } pub fn get_child_value(&self, key: &str) -> Option<&str> { @@ -170,9 +169,9 @@ pub fn get_memval(arg: &str) -> Result { let arg = arg.trim(); let val: f64; let mut unit: &str; - let parser = tuple((preceded(multispace0, double), + let mut parser = tuple((preceded(multispace0, double), preceded(multispace0, verify(not_line_ending, |c: &str| c.len() < 3)))); - let r: nom::IResult<&str, (f64, &str)> = parser(arg); + let r: IResult<&str, (f64, &str)> = parser(arg); if let Ok(r) = r { val = (r.1).0; unit = (r.1).1;