ruby-changes:72014
From: Nobuyoshi <ko1@a...>
Date: Mon, 30 May 2022 14:49:02 +0900 (JST)
Subject: [ruby-changes:72014] 7976142791 (master): [ruby/stringio] Fix extracting encoding names in the fallback code
https://git.ruby-lang.org/ruby.git/commit/?id=7976142791 From 79761427913e70344ace2d129183ee998bcc22ac Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Mon, 30 May 2022 14:16:03 +0900 Subject: [ruby/stringio] Fix extracting encoding names in the fallback code https://github.com/ruby/stringio/commit/0fe2e0c1e5 --- ext/stringio/stringio.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c index 13f9c28dd1..1b21c2e60f 100644 --- a/ext/stringio/stringio.c +++ b/ext/stringio/stringio.c @@ -67,15 +67,20 @@ strio_extract_modeenc(VALUE *vmode_p, VALUE *vperm_p, VALUE opthash, https://github.com/ruby/ruby/blob/trunk/ext/stringio/stringio.c#L67 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); } } } -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/