errno.c: use `MRB_SYM()` instead of `mrb_intern_lit()`.
MODIFY
mrbgems/mruby-errno/src/errno.c
mrbgems/mruby-errno/src/errno.c
#include <errno.h>
#include <stdio.h>
#include <string.h>
+#include <mruby/presym.h>
#if MRUBY_RELEASE_NO < 10000
static struct RClass *
@@ -35,13 +36,13 @@ mrb_sce_init(mrb_state *mrb, mrb_value self)
}
}
if (!no_errno) {
- e2c = mrb_const_get(mrb, mrb_obj_value(mrb_module_get(mrb, "Errno")), mrb_intern_lit(mrb, "Errno2class"));
+ e2c = mrb_const_get(mrb, mrb_obj_value(mrb_module_get(mrb, "Errno")), MRB_SYM(Errno2class));
c = mrb_hash_fetch(mrb, e2c, mrb_fixnum_value(n), mrb_nil_value());
if (!mrb_nil_p(c)) {
mrb_basic_ptr(self)->c = mrb_class_ptr(c);
str = mrb_str_new_cstr(mrb, strerror(n));
} else {
- mrb_iv_set(mrb, self, mrb_intern_lit(mrb, "errno"), mrb_fixnum_value(n));
+ mrb_iv_set(mrb, self, MRB_SYM(errno), mrb_fixnum_value(n));
str = mrb_str_new_cstr(mrb, "Unknown error: ");
snprintf(buf, sizeof(buf), "%d", (int)n);
mrb_str_cat2(mrb, str, buf);
@@ -53,7 +54,7 @@ mrb_sce_init(mrb_state *mrb, mrb_value self)
mrb_str_cat2(mrb, str, " - ");
mrb_str_append(mrb, str, m);
}
- mrb_iv_set(mrb, self, mrb_intern_lit(mrb, "mesg"), str);
+ mrb_iv_set(mrb, self, MRB_SYM(mesg), str);
return self;
}
@@ -64,7 +65,7 @@ mrb_sce_errno(mrb_state *mrb, mrb_value self)
mrb_sym sym;
c = mrb_class(mrb, self);
- sym = mrb_intern_lit(mrb, "Errno");
+ sym = MRB_SYM(Errno);
#if MRUBY_RELEASE_NO < 10000
if (mrb_const_defined_at(mrb, c, sym)) {
#else
@@ -72,7 +73,7 @@ mrb_sce_errno(mrb_state *mrb, mrb_value self)
#endif
return mrb_const_get(mrb, mrb_obj_value(c), sym);
} else {
- sym = mrb_intern_lit(mrb, "errno");
+ sym = MRB_SYM(errno);
return mrb_attr_get(mrb, self, sym);
}
}
@@ -80,7 +81,7 @@ mrb_sce_errno(mrb_state *mrb, mrb_value self)
static mrb_value
mrb_sce_to_s(mrb_state *mrb, mrb_value self)
{
- return mrb_attr_get(mrb, self, mrb_intern_lit(mrb, "mesg"));
+ return mrb_attr_get(mrb, self, MRB_SYM(mesg));
}
static mrb_value
@@ -115,7 +116,7 @@ mrb_exxx_init(mrb_state *mrb, mrb_value self)
{
mrb_value m, no, str;
- no = mrb_const_get(mrb, mrb_obj_value(mrb_class(mrb, self)), mrb_intern_lit(mrb, "Errno"));
+ no = mrb_const_get(mrb, mrb_obj_value(mrb_class(mrb, self)), MRB_SYM(Errno));
str = mrb_str_new_cstr(mrb, strerror(mrb_fixnum(no)));
m = mrb_nil_value();
@@ -124,7 +125,7 @@ mrb_exxx_init(mrb_state *mrb, mrb_value self)
mrb_str_cat2(mrb, str, " - ");
mrb_str_append(mrb, str, m);
}
- mrb_iv_set(mrb, self, mrb_intern_lit(mrb, "mesg"), str);
+ mrb_iv_set(mrb, self, MRB_SYM(mesg), str);
return self;
}

errno.c: use `MRB_SYM()` instead of `mrb_intern_lit()`.