string.c (str_escape): simplify the logic

This commit is contained in:
Yukihiro "Matz" Matsumoto
2023-04-07 13:53:19 +09:00
parent d0653ca908
commit 64536b866b
+1 -4
View File
@@ -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, "\"");