~ubuntu-branches/ubuntu/quantal/ruby1.9.1/quantal

« back to all changes in this revision

Viewing changes to ext/iconv/iconv.c

  • Committer: Bazaar Package Importer
  • Author(s): Lucas Nussbaum
  • Date: 2011-09-24 19:16:17 UTC
  • mfrom: (1.1.8 upstream) (13.1.7 experimental)
  • Revision ID: james.westby@ubuntu.com-20110924191617-o1qz4rcmqjot8zuy
Tags: 1.9.3~rc1-1
* New upstream release: 1.9.3 RC1.
  + Includes load.c fixes. Closes: #639959.
* Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
164
164
    VALUE val = StringValue(*code);
165
165
 
166
166
    if (RHASH_SIZE(charset_map)) {
 
167
        st_data_t data;
167
168
        VALUE key = rb_funcall2(val, rb_intern("downcase"), 0, 0);
168
169
        StringValuePtr(key);
169
 
        if (st_lookup(RHASH_TBL(charset_map), key, &val)) {
170
 
            *code = val;
 
170
        if (st_lookup(RHASH_TBL(charset_map), key, &data)) {
 
171
            *code = (VALUE)data;
171
172
        }
172
173
    }
173
174
    return StringValuePtr(*code);
1178
1179
 * * returns an error without setting errno properly
1179
1180
 */
1180
1181
 
 
1182
static void
 
1183
warn_deprecated(void)
 
1184
{
 
1185
    static const char message[] =
 
1186
        ": iconv will be deprecated in the future, use String#encode instead.\n";
 
1187
    VALUE msg = Qnil, caller = rb_make_backtrace();
 
1188
    long i;
 
1189
 
 
1190
    for (i = 1; i < RARRAY_LEN(caller); ++i) {
 
1191
        VALUE s = RARRAY_PTR(caller)[i];
 
1192
        if (strncmp(RSTRING_PTR(s), "<internal:", 10) != 0) {
 
1193
            msg = s;
 
1194
            break;
 
1195
        }
 
1196
    }
 
1197
    if (NIL_P(msg)) {
 
1198
        msg = rb_str_new_cstr(message + 2);
 
1199
    }
 
1200
    else {
 
1201
        rb_str_cat(msg, message, sizeof(message) - 1);
 
1202
    }
 
1203
    rb_io_puts(1, &msg, rb_stderr);
 
1204
}
 
1205
 
1181
1206
void
1182
1207
Init_iconv(void)
1183
1208
{
1184
1209
    VALUE rb_cIconv = rb_define_class("Iconv", rb_cData);
1185
1210
 
 
1211
    if (!NIL_P(ruby_verbose)) {
 
1212
        warn_deprecated();
 
1213
    }
1186
1214
    rb_define_alloc_func(rb_cIconv, iconv_s_allocate);
1187
1215
    rb_define_singleton_method(rb_cIconv, "open", iconv_s_open, -1);
1188
1216
    rb_define_singleton_method(rb_cIconv, "iconv", iconv_s_iconv, -1);