1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[ruby/stringio] Fix extracting encoding names in the fallback code

https://github.com/ruby/stringio/commit/0fe2e0c1e5
This commit is contained in:
Nobuyoshi Nakada 2022-05-30 14:16:03 +09:00 committed by git
parent d3e986d9ab
commit 7976142791

View file

@ -67,15 +67,20 @@ strio_extract_modeenc(VALUE *vmode_p, VALUE *vperm_p, VALUE opthash,
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;
}
convconfig_p->enc = rb_enc_find(n);
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->enc2 = rb_enc_find(e);
convconfig_p->enc = rb_enc_find(e);
}
}
}