mruby-io/file.c: reduce the scope of local variables

This commit is contained in:
Yukihiro "Matz" Matsumoto
2024-01-06 08:30:56 +09:00
parent e1b6501183
commit b06fdb4bfa
+2 -4
View File
@@ -120,15 +120,13 @@ mrb_file_s_unlink(mrb_state *mrb, mrb_value obj)
{
const mrb_value *argv;
mrb_int argc, i;
char *path;
mrb_get_args(mrb, "*", &argv, &argc);
for (i = 0; i < argc; i++) {
const char *utf8_path;
mrb_value pathv = argv[i];
mrb_ensure_string_type(mrb, pathv);
utf8_path = RSTRING_CSTR(mrb, pathv);
path = mrb_locale_from_utf8(utf8_path, -1);
const char *utf8_path = RSTRING_CSTR(mrb, pathv);
char *path = mrb_locale_from_utf8(utf8_path, -1);
if (UNLINK(path) < 0) {
mrb_locale_free(path);
mrb_sys_fail(mrb, utf8_path);