From f74b71c1091164d5bf011ace48390ce5354a3902 Mon Sep 17 00:00:00 2001 From: mengning997 Date: Wed, 7 Sep 2022 15:22:31 +0800 Subject: [PATCH 1/3] fixed cmake bug --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4e4424f..75ba3bf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -145,6 +145,10 @@ set(RE2_HEADERS re2/stringpiece.h ) +install(FILES regex-capi/include/rure.h + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +install(FILES target/release/librure.so + DESTINATION ${CMAKE_INSTALL_LIBDIR}) install(FILES ${RE2_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/re2) install(TARGETS re2 EXPORT re2Config -- Gitee From d94af31cd007fc46adddfa66a5951c6aec139189 Mon Sep 17 00:00:00 2001 From: mengning997 Date: Wed, 7 Sep 2022 15:33:35 +0800 Subject: [PATCH 2/3] remove rubbish comments --- regex-capi/include/rure.h | 4 +--- regex-capi/src/rure.rs | 22 +--------------------- 2 files changed, 2 insertions(+), 24 deletions(-) diff --git a/regex-capi/include/rure.h b/regex-capi/include/rure.h index 597344b..1817e25 100644 --- a/regex-capi/include/rure.h +++ b/regex-capi/include/rure.h @@ -607,9 +607,7 @@ const char *rure_replace_all(rure *re, const uint8_t *haystack, size_t len_h, /* * Simple way to use regex */ -// rure *rure_compile(const uint8_t *pattern, size_t length, -// uint32_t flags, rure_options *options, -// rure_error *error); + rure *rure_new(const uint8_t *pattern, size_t length); bool rure_consume(rure *re, const uint8_t *haystack, size_t length, rure_match *match); diff --git a/regex-capi/src/rure.rs b/regex-capi/src/rure.rs index 411f024..5cc4b50 100644 --- a/regex-capi/src/rure.rs +++ b/regex-capi/src/rure.rs @@ -679,10 +679,6 @@ ffi_fn! { } } -/* - * Simple way to use regex - */ - /* * Simple way to use regex */ @@ -725,21 +721,5 @@ ffi_fn! { } }).is_some() } - // fn rure_consume( - // raw_exp: *mut Regex, - // p: *const u8, - // len: size_t, - // match_info: *mut rure_match, - // ) -> bool { - // let exp = unsafe { Box::from_raw(raw_exp) }; - // let s = unsafe { slice::from_raw_parts(p, len as usize) }; - // let m = exp.find(s).unwrap(); - // unsafe { - // if !match_info.is_null() { - // (*match_info).start = m.start(); - // (*match_info).end = m.end(); - // } - // } - // true - // } + } \ No newline at end of file -- Gitee From e686de1b0c11238c8547581fd7c2c2f3d19a3a16 Mon Sep 17 00:00:00 2001 From: mengning997 Date: Wed, 7 Sep 2022 15:58:58 +0800 Subject: [PATCH 3/3] fixed warnnings --- re2/Cargo.toml | 12 ------------ regex-capi/src/rure.rs | 11 +++++------ 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/re2/Cargo.toml b/re2/Cargo.toml index dcd72cf..e3e4b13 100644 --- a/re2/Cargo.toml +++ b/re2/Cargo.toml @@ -10,15 +10,3 @@ edition = "2018" crate-type = ["lib"] path = "re2.rs" name = "re2" - -toml = "0.5.8" -serde_derive = "1.0.130" -serde = "1.0.130" -log = "0.4" -log4rs = "1.0" -thiserror = "1.0" -anyhow = "1.0" -http = "0.2.6" -procfs = "0.12.0" -nix = "0.23.0" -pathdiff = "0.2.1" diff --git a/regex-capi/src/rure.rs b/regex-capi/src/rure.rs index 5cc4b50..53cc5f9 100644 --- a/regex-capi/src/rure.rs +++ b/regex-capi/src/rure.rs @@ -258,7 +258,8 @@ ffi_fn! { unsafe { let it = &mut *it; while let Some(ptr) = it.name_ptrs.pop(){ - CString::from_raw(ptr); + // CString::from_raw(ptr); + drop(CString::from_raw(ptr)) } Box::from_raw(it); } @@ -624,7 +625,7 @@ fn rure_escape( ffi_fn! { fn rure_cstring_free(s: *mut c_char) { - unsafe { CString::from_raw(s); } + unsafe { drop(CString::from_raw(s)); } } } @@ -691,10 +692,8 @@ ffi_fn! { let pat = unsafe { slice::from_raw_parts(pattern, length) }; let pat = match str::from_utf8(pat) { Ok(pat) => pat, - Err(err) => { - unsafe { - return ptr::null(); - } + Err(_err) => { + return ptr::null(); } }; let exp = match bytes::Regex::new(pat) { -- Gitee