Skip to content

Commit

Permalink
Define rb_sys_fail_str if not exist in ruby
Browse files Browse the repository at this point in the history
For non CRuby, it should check the function itself.
https://github.com/nurse/iconv/pull/2/files#r7012116
  • Loading branch information
nurse committed Oct 16, 2013
1 parent 951e750 commit 3503301
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions ext/iconv/extconf.rb
Expand Up @@ -8,6 +8,7 @@
unless have_func("rb_enc_get", "ruby/encoding.h") || have_func("vasprintf", "stdio.h")
raise "vasprintf is required for Ruby 1.8"
end
have_func("rb_sys_fail_str", "ruby.h")
if have_func("iconv", "iconv.h") or
have_library("iconv", "iconv", "iconv.h")
check_signedness("size_t") rescue nil
Expand Down
14 changes: 8 additions & 6 deletions ext/iconv/iconv.c
Expand Up @@ -27,12 +27,6 @@
# define rb_f_notimplement rb_notimplement
# define rb_str_subseq(a, b, c) rb_str_substr(a, b, c)
# define rb_str_new_cstr(a) rb_str_new2(a)
NORETURN(static void rb_sys_fail_str(VALUE msg));
static void
rb_sys_fail_str(VALUE msg)
{
rb_sys_fail(RSTRING_PTR(msg));
}
static VALUE
rb_str_equal(str1, str2)
VALUE str1, str2;
Expand Down Expand Up @@ -72,6 +66,14 @@ rb_sprintf(const char *format, ...)
return rb_str_new(ret, len);
}
#endif
#ifndef HAVE_RB_SYS_FAIL_STR
NORETURN(static void rb_sys_fail_str(VALUE msg));
static void
rb_sys_fail_str(VALUE msg)
{
rb_sys_fail(RSTRING_PTR(msg));
}
#endif

/*
* Document-class: Iconv
Expand Down

0 comments on commit 3503301

Please sign in to comment.