diff options
Diffstat (limited to 'ext/stringio/stringio.c')
-rw-r--r-- | ext/stringio/stringio.c | 80 |
1 files changed, 0 insertions, 80 deletions
diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c index 99a19ead0d..e69afc31f1 100644 --- a/ext/stringio/stringio.c +++ b/ext/stringio/stringio.c @@ -32,86 +32,6 @@ # define rb_class_new_instance_kw(argc, argv, klass, kw_splat) rb_class_new_instance(argc, argv, klass) #endif -#ifndef HAVE_RB_IO_EXTRACT_MODEENC -#define rb_io_extract_modeenc strio_extract_modeenc -static void -strio_extract_modeenc(VALUE *vmode_p, VALUE *vperm_p, VALUE opthash, - int *oflags_p, int *fmode_p, struct rb_io_enc_t *convconfig_p) -{ - VALUE mode = *vmode_p; - VALUE intmode; - int fmode; - int has_enc = 0, has_vmode = 0; - - convconfig_p->enc = convconfig_p->enc2 = 0; - - vmode_handle: - if (NIL_P(mode)) { - fmode = FMODE_READABLE; - } - else if (!NIL_P(intmode = rb_check_to_integer(mode, "to_int"))) { - int flags = NUM2INT(intmode); - fmode = rb_io_oflags_fmode(flags); - } - else { - const char *m = StringValueCStr(mode), *n, *e; - fmode = rb_io_modestr_fmode(m); - n = strchr(m, ':'); - if (n) { - long len; - char encname[ENCODING_MAXNAMELEN+1]; - has_enc = 1; - if (fmode & FMODE_SETENC_BY_BOM) { - n = strchr(n, '|'); - } - e = strchr(++n, ':'); - len = e ? e - n : (long)strlen(n); - if (len > 0 && len <= ENCODING_MAXNAMELEN) { - rb_encoding *enc; - if (e) { - memcpy(encname, n, len); - encname[len] = '\0'; - n = encname; - } - enc = rb_enc_find(n); - if (e) - convconfig_p->enc2 = enc; - else - convconfig_p->enc = enc; - } - if (e && (len = strlen(++e)) > 0 && len <= ENCODING_MAXNAMELEN) { - convconfig_p->enc = rb_enc_find(e); - } - } - } - - if (!NIL_P(opthash)) { - rb_encoding *extenc = 0, *intenc = 0; - VALUE v; - if (!has_vmode) { - ID id_mode; - CONST_ID(id_mode, "mode"); - v = rb_hash_aref(opthash, ID2SYM(id_mode)); - if (!NIL_P(v)) { - if (!NIL_P(mode)) { - rb_raise(rb_eArgError, "mode specified twice"); - } - has_vmode = 1; - mode = v; - goto vmode_handle; - } - } - - if (rb_io_extract_encoding_option(opthash, &extenc, &intenc, &fmode)) { - if (has_enc) { - rb_raise(rb_eArgError, "encoding specified twice"); - } - } - } - *fmode_p = fmode; -} -#endif - struct StringIO { VALUE string; rb_encoding *enc; |