Skip to content

Commit a251e3d

Browse files
author
梶塚太智
committed
Update main.rs
1 parent 968f02f commit a251e3d

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

src/main.rs

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -287,12 +287,12 @@ impl Executor {
287287
_ => {
288288
if parentheses == 0 && brackets == 0 && !hash {
289289
if escape {
290-
buffer.push(match c {
291-
'n' => '\n',
292-
't' => '\t',
293-
'r' => '\r',
294-
_ => c,
295-
})
290+
match c {
291+
'n' => buffer.push_str("\\n"),
292+
't' => buffer.push_str("\\t"),
293+
'r' => buffer.push_str("\\r"),
294+
_ => buffer.push(c),
295+
}
296296
} else {
297297
buffer.push(c);
298298
}
@@ -374,12 +374,12 @@ impl Executor {
374374
_ => {
375375
if parentheses == 0 && brackets == 0 && !hash {
376376
if escape {
377-
buffer.push(match c {
378-
'n' => '\n',
379-
't' => '\t',
380-
'r' => '\r',
381-
_ => c,
382-
})
377+
match c {
378+
'n' => buffer.push_str("\\n"),
379+
't' => buffer.push_str("\\t"),
380+
'r' => buffer.push_str("\\r"),
381+
_ => buffer.push(c),
382+
}
383383
} else {
384384
buffer.push(c);
385385
}
@@ -700,6 +700,11 @@ impl Executor {
700700
// Standard output
701701
"print" => {
702702
let a = self.pop_stack().get_string();
703+
704+
let a = a.replace("\\n", "\n");
705+
let a = a.replace("\\t", "\t");
706+
let a = a.replace("\\r", "\r");
707+
703708
if let Mode::Debug = self.mode {
704709
println!("[Output]: {a}");
705710
} else {

0 commit comments

Comments
 (0)