From 49044d3ec361e88bbdbf97b9e4ad6be27cfd9d6a Mon Sep 17 00:00:00 2001 From: arty Date: Sat, 13 Jul 2024 14:14:02 -0700 Subject: [PATCH 1/2] Fix accidental parsing of processed inputs for dependency analysis and add a test --- resources/tests/bin-quote.bin | 1 + src/compiler/preprocessor/mod.rs | 5 ++++- src/tests/classic/run.rs | 15 +++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 resources/tests/bin-quote.bin diff --git a/resources/tests/bin-quote.bin b/resources/tests/bin-quote.bin new file mode 100644 index 00000000..0c26c19c --- /dev/null +++ b/resources/tests/bin-quote.bin @@ -0,0 +1 @@ +'test \ No newline at end of file diff --git a/src/compiler/preprocessor/mod.rs b/src/compiler/preprocessor/mod.rs index 97895375..6037b34d 100644 --- a/src/compiler/preprocessor/mod.rs +++ b/src/compiler/preprocessor/mod.rs @@ -199,10 +199,13 @@ impl Preprocessor { desc: IncludeDesc, ) -> Result<(), CompileErr> { let name_string = decode_string(&desc.name); - if KNOWN_DIALECTS.contains_key(&name_string) { + // Terminate early checking anything with a processed include type. + if KNOWN_DIALECTS.contains_key(&name_string) || desc.kind.is_some() { return Ok(()); } + if desc.kind.is_some() { + } let (full_name, content) = self.opts.read_new_file(self.opts.filename(), name_string)?; includes.push(IncludeDesc { name: full_name.as_bytes().to_vec(), diff --git a/src/tests/classic/run.rs b/src/tests/classic/run.rs index 702efd80..60d768a3 100644 --- a/src/tests/classic/run.rs +++ b/src/tests/classic/run.rs @@ -2495,3 +2495,18 @@ fn test_include_zero_bin_pre_fix() { ]); assert_eq!(program, "(2 (1 14 (1 . 1) 2) (4 (1 . 1) 1))"); } + +#[test] +fn test_include_bin_should_not_be_parsed() { + let program = do_basic_run(&vec![ + "run".to_string(), + "-i".to_string(), + "resources/tests".to_string(), + "(mod (X) (include *standard-cl-23.1*) (embed-file test bin bin-quote.bin) test)".to_string() + ]); + let result = do_basic_brun(&vec![ + "brun".to_string(), + program + ]); + assert_eq!(result.trim(), "\"'test\""); +} From aebb21e90e1512464a644ac9564248c3baf96d06 Mon Sep 17 00:00:00 2001 From: arty Date: Sat, 13 Jul 2024 14:15:00 -0700 Subject: [PATCH 2/2] Remove redundant --- src/compiler/preprocessor/mod.rs | 2 -- src/tests/classic/run.rs | 8 +++----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/compiler/preprocessor/mod.rs b/src/compiler/preprocessor/mod.rs index 6037b34d..9ba80e4a 100644 --- a/src/compiler/preprocessor/mod.rs +++ b/src/compiler/preprocessor/mod.rs @@ -204,8 +204,6 @@ impl Preprocessor { return Ok(()); } - if desc.kind.is_some() { - } let (full_name, content) = self.opts.read_new_file(self.opts.filename(), name_string)?; includes.push(IncludeDesc { name: full_name.as_bytes().to_vec(), diff --git a/src/tests/classic/run.rs b/src/tests/classic/run.rs index 60d768a3..7e573e13 100644 --- a/src/tests/classic/run.rs +++ b/src/tests/classic/run.rs @@ -2502,11 +2502,9 @@ fn test_include_bin_should_not_be_parsed() { "run".to_string(), "-i".to_string(), "resources/tests".to_string(), - "(mod (X) (include *standard-cl-23.1*) (embed-file test bin bin-quote.bin) test)".to_string() - ]); - let result = do_basic_brun(&vec![ - "brun".to_string(), - program + "(mod (X) (include *standard-cl-23.1*) (embed-file test bin bin-quote.bin) test)" + .to_string(), ]); + let result = do_basic_brun(&vec!["brun".to_string(), program]); assert_eq!(result.trim(), "\"'test\""); }