From fe2760549731f63ba2fb01558f20d192844ea99b Mon Sep 17 00:00:00 2001 From: Markus Triska Date: Sat, 1 Apr 2023 20:29:02 +0200 Subject: [PATCH] FIXED: number_chars(N, "0' "), addressing #1580. There may be a more elegant way to solve this. --- src/machine/system_calls.rs | 45 +++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/src/machine/system_calls.rs b/src/machine/system_calls.rs index a84b78c7..70dd649f 100644 --- a/src/machine/system_calls.rs +++ b/src/machine/system_calls.rs @@ -834,19 +834,40 @@ impl MachineState { ) -> CallResult { let nx = self.store(self.deref(self.registers[2])); - if let Some(c) = string.chars().last() { - if layout_char!(c) { - let (line_num, col_num) = string.chars().fold((0, 0), |(line_num, col_num), c| { - if new_line_char!(c) { - (1 + line_num, 0) - } else { - (line_num, col_num + 1) - } - }); - let err = ParserError::UnexpectedChar(c, line_num, col_num); - let err = self.syntax_error(err); + let mut charcode_space = false; + let mut cs = string.chars(); - return Err(self.error_form(err, stub_gen())); + loop { + let c = cs.next(); + + if c == None { + break; + } + + if c == Some('0') + && cs.next() == Some('\'') + && cs.next() == Some(' ') + && cs.next() == None { + charcode_space = true; + break; + } + } + + if !charcode_space { + if let Some(c) = string.chars().last() { + if layout_char!(c) { + let (line_num, col_num) = string.chars().fold((0, 0), |(line_num, col_num), c| { + if new_line_char!(c) { + (1 + line_num, 0) + } else { + (line_num, col_num + 1) + } + }); + let err = ParserError::UnexpectedChar(c, line_num, col_num); + let err = self.syntax_error(err); + + return Err(self.error_form(err, stub_gen())); + } } } -- 2.54.0