Skip to content

Commit

Permalink
Refactor rb_syserr_fail and rb_syserr_fail_str to call rb_syserr_fail…
Browse files Browse the repository at this point in the history
… Ruby method with nil instead of "" when custom message is NULL or Qnil
  • Loading branch information
andrykonchin committed Dec 5, 2024
1 parent 7d8b161 commit a19a172
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/cext/ABI_check.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4
5
7 changes: 2 additions & 5 deletions src/main/c/cext/exception.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,12 @@ VALUE rb_errinfo(void) {
}

void rb_syserr_fail(int eno, const char *message) {
polyglot_invoke(RUBY_CEXT, "rb_syserr_fail", eno, rb_tr_unwrap(rb_str_new_cstr(message == NULL ? "" : message)));
VALUE messageValue = (message == NULL) ? Qnil : rb_str_new_cstr(message);
polyglot_invoke(RUBY_CEXT, "rb_syserr_fail", eno, rb_tr_unwrap(messageValue));
UNREACHABLE;
}

void rb_syserr_fail_str(int eno, VALUE message) {
if (message == Qnil) {
message = rb_str_new_cstr("");
}

polyglot_invoke(RUBY_CEXT, "rb_syserr_fail", eno, rb_tr_unwrap(message));
UNREACHABLE;
}
Expand Down

0 comments on commit a19a172

Please sign in to comment.