diff --git a/CMakeLists.txt b/CMakeLists.txt index 4e4424ff9c21015a7e5926f22e77fd2bfc36d1b6..75ba3bf532534fae123727e1b7984593301699cc 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 diff --git a/re2/Cargo.toml b/re2/Cargo.toml index dcd72cf2dfe3dfba4e1fb1c113822b42c88f6110..e3e4b131bde6d47d6952c16e3ad578f908de87f2 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/include/rure.h b/regex-capi/include/rure.h index 597344b0194678926c88938a4578eada19d1037a..1817e25869e22d7907f5b62663f2618f2058ec11 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 411f024a029f72601026f6599ff3984eab7508d4..53cc5f969d408f24969239689c801440fa4f93a5 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)); } } } @@ -679,10 +680,6 @@ ffi_fn! { } } -/* - * Simple way to use regex - */ - /* * Simple way to use regex */ @@ -695,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) { @@ -725,21 +720,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