-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
make Rbx API compatible #2
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,6 +73,9 @@ rb_sprintf(const char *format, ...) | |
} | ||
#endif | ||
|
||
#define rb_sys_fail_str(s) rb_iconv_sys_fail_str(s) | ||
#define rb_sys_fail(s) rb_iconv_sys_fail(s) | ||
|
||
/* | ||
* Document-class: Iconv | ||
* | ||
|
@@ -217,16 +220,27 @@ map_charset(VALUE *code) | |
VALUE val = StringValue(*code); | ||
|
||
if (RHASH_SIZE(charset_map)) { | ||
#ifdef RBX_CAPI_RUBY_H /* If Rubinius defined */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can always use rb_hash_aref; so remove ifdef and RHASH_TBL. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I fixed this at 3503301 |
||
VALUE data; | ||
VALUE key = rb_funcall2(val, rb_intern("downcase"), 0, 0); | ||
StringValuePtr(key); | ||
data = rb_hash_aref(charset_map, key); | ||
if(!NIL_P(data)) { | ||
*code = (VALUE)data; | ||
} | ||
#else | ||
st_data_t data; | ||
VALUE key = rb_funcall2(val, rb_intern("downcase"), 0, 0); | ||
StringValuePtr(key); | ||
if (st_lookup(RHASH_TBL(charset_map), key, &data)) { | ||
*code = (VALUE)data; | ||
} | ||
#endif | ||
} | ||
return StringValuePtr(*code); | ||
} | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove this empty line There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok. I will fix it. |
||
NORETURN(static void rb_iconv_sys_fail_str(VALUE msg)); | ||
static void | ||
rb_iconv_sys_fail_str(VALUE msg) | ||
|
@@ -237,7 +251,6 @@ rb_iconv_sys_fail_str(VALUE msg) | |
rb_sys_fail_str(msg); | ||
} | ||
|
||
#define rb_sys_fail_str(s) rb_iconv_sys_fail_str(s) | ||
|
||
NORETURN(static void rb_iconv_sys_fail(const char *s)); | ||
static void | ||
|
@@ -246,7 +259,6 @@ rb_iconv_sys_fail(const char *s) | |
rb_iconv_sys_fail_str(rb_str_new_cstr(s)); | ||
} | ||
|
||
#define rb_sys_fail(s) rb_iconv_sys_fail(s) | ||
|
||
static iconv_t | ||
iconv_create(VALUE to, VALUE from, struct rb_iconv_opt_t *opt, int *idx) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why you moved these?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The dynamic library loader didn't find the
rb_sys_fail_str
definition, because it was defined after the usage.I put the lines up and worked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will put it close from function calls.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rb_iconv_sys_fail_str uses rb_sys_fail_str, so this is incorrect.
This should check whether rb_sys_fail_str exists or not, and define it if not exist.