Revert "error.c (mrb_sys_fail): errno argument removed from _sys_fail."

Intermediate function calls may update `errno`.
This reverts commit a099ca44f4.
This commit is contained in:
Yukihiro "Matz" Matsumoto
2022-11-16 18:26:35 +09:00
parent 80986804cc
commit 89a34e1b7e
2 changed files with 9 additions and 6 deletions
+5 -2
View File
@@ -4,6 +4,7 @@
** See Copyright Notice in mruby.h
*/
#include <errno.h>
#include <stdlib.h>
#include <mruby.h>
#include <mruby/array.h>
@@ -511,14 +512,16 @@ MRB_API mrb_noreturn void
mrb_sys_fail(mrb_state *mrb, const char *mesg)
{
struct RClass *sce;
mrb_int no;
no = (mrb_int)errno;
if (mrb_class_defined_id(mrb, MRB_SYM(SystemCallError))) {
sce = mrb_class_get_id(mrb, MRB_SYM(SystemCallError));
if (mesg != NULL) {
mrb_funcall_id(mrb, mrb_obj_value(sce), MRB_SYM(_sys_fail), 1, mrb_str_new_cstr(mrb, mesg));
mrb_funcall_id(mrb, mrb_obj_value(sce), MRB_SYM(_sys_fail), 2, mrb_fixnum_value(no), mrb_str_new_cstr(mrb, mesg));
}
else {
mrb_funcall_id(mrb, mrb_obj_value(sce), MRB_SYM(_sys_fail), 0);
mrb_funcall_id(mrb, mrb_obj_value(sce), MRB_SYM(_sys_fail), 1, mrb_fixnum_value(no));
}
}