]> Repositorios git - scryer-prolog.git/commitdiff
FIXED: number_chars(N, "0' "), addressing #1580.
authorMarkus Triska <[email protected]>
Sat, 1 Apr 2023 18:29:02 +0000 (20:29 +0200)
committerMarkus Triska <[email protected]>
Sun, 2 Apr 2023 08:04:52 +0000 (10:04 +0200)
There may be a more elegant way to solve this.

src/machine/system_calls.rs

index a84b78c719e28d5359752ceff48580c145f2a429..70dd649fc8e8f54b05fc5c03d67d6eea3f1ee47d 100644 (file)
@@ -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()));
+                }
             }
         }