From 64536b866b906fc853c955c8ff268fd56a35d503 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Fri, 7 Apr 2023 13:53:19 +0900 Subject: [PATCH] string.c (str_escape): simplify the logic --- src/string.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/string.c b/src/string.c index df83f2c05..de8a671ac 100644 --- a/src/string.c +++ b/src/string.c @@ -1249,19 +1249,16 @@ str_escape(mrb_state *mrb, mrb_value str, mrb_bool inspect) case 033: cc = 'e'; break; default: cc = 0; break; } + buf[0] = '\\'; if (cc) { - buf[0] = '\\'; buf[1] = (char)cc; mrb_str_cat(mrb, result, buf, 2); - continue; } else { - buf[0] = '\\'; buf[1] = 'x'; buf[3] = mrb_digitmap[c % 16]; c /= 16; buf[2] = mrb_digitmap[c % 16]; mrb_str_cat(mrb, result, buf, 4); - continue; } } mrb_str_cat_lit(mrb, result, "\"");