]> Repositorios git - scryer-prolog.git/commitdiff
properly handle character controls from ASCII to UTF-8, re: #48
authorMark Thom <[email protected]>
Mon, 3 Sep 2018 19:57:32 +0000 (13:57 -0600)
committerMark Thom <[email protected]>
Mon, 3 Sep 2018 19:57:32 +0000 (13:57 -0600)
src/prolog/heap_print.rs
src/prolog/parser

index 3b02a24585f6a45bb5761d499417ff6bdfe9809a..9b4689fb65672aaadffa8a75f25cf149d50dede4 100644 (file)
@@ -296,23 +296,16 @@ impl<'a, Formatter: HCValueFormatter, Outputter: HCValueOutputter>
     }
 
     fn print_char(&mut self, c: char) {
-        if c == '\n' {
-            self.outputter.append("\\n");
-        } else if c == '\r' {
-            self.outputter.append("\\r");
-        } else if c == '\t' {
-            self.outputter.append("\\t");
-        } else if c == '\u{0b}' { // UTF-8 vertical tab
-            self.outputter.append("\\v");
-        } else if c == '\u{0c}' { // UTF-8 form feed
-            self.outputter.append("\\f");            
-        } else if c == '\u{08}' { // UTF-8 backspace
-            self.outputter.append("\\b");
-        } else if c == '\u{07}' { // UTF-8 alert
-            self.outputter.append("\\a");
-        } else {
-            self.outputter.push_char(c);
-        }
+        match c {
+            '\n' => self.outputter.append("\\n"),
+            '\r' => self.outputter.append("\\r"),
+            '\t' => self.outputter.append("\\t"),
+            '\u{0b}' => self.outputter.append("\\v"), // UTF-8 vertical tab
+            '\u{0c}' => self.outputter.append("\\f"), // UTF-8 form feed
+            '\u{08}' => self.outputter.append("\\b"), // UTF-8 backspace
+            '\u{07}' => self.outputter.append("\\a"), // UTF-8 alert
+            _ => self.outputter.push_char(c)
+        };
     }
     
     fn print_constant(&mut self, c: Constant) {
index b23670b232d1f3a069c6a4a87378a399a69e8274..ba9962514adf528d973babe09c7ebdaeec3eb24c 160000 (submodule)
@@ -1 +1 @@
-Subproject commit b23670b232d1f3a069c6a4a87378a399a69e8274
+Subproject commit ba9962514adf528d973babe09c7ebdaeec3eb24c