From 13032657858cd262cb140e7638cc1728ba2a3c24 Mon Sep 17 00:00:00 2001 From: lyken Date: Tue, 9 Jul 2024 21:02:20 +0800 Subject: [PATCH] core: build.rs rewrite regex to capture `= type` --- nac3core/build.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/nac3core/build.rs b/nac3core/build.rs index 197c357b..f92935c4 100644 --- a/nac3core/build.rs +++ b/nac3core/build.rs @@ -53,7 +53,11 @@ fn compile_irrt(irrt_dir: &Path, out_dir: &Path) { let output = std::str::from_utf8(&output.stdout).unwrap().replace("\r\n", "\n"); let mut filtered_output = String::with_capacity(output.len()); - let regex_filter = Regex::new(r"(?ms:^define.*?\}$)|(?m:^declare.*?$)").unwrap(); + // (?ms:^define.*?\}$) to capture `define` blocks + // (?m:^declare.*?$) to capture `declare` blocks + // (?m:^%.+?=\s*type\s*\{.+?\}$) to capture `type` declarations + let regex_filter = + Regex::new(r"(?ms:^define.*?\}$)|(?m:^declare.*?$)|(?m:^%.+?=\s*type\s*\{.+?\}$)").unwrap(); for f in regex_filter.captures_iter(&output) { assert_eq!(f.len(), 1); filtered_output.push_str(&f[0]);