[ruby/stringio] An empty string should be converted to empty in any encoding

ef03f9368d
This commit is contained in:
Nobuyoshi Nakada 2024-10-26 22:13:18 +09:00 committed by git
parent f513863c81
commit 484ea00d2e

View file

@ -961,6 +961,7 @@ strio_ungetc(VALUE self, VALUE c)
} }
else { else {
StringValue(c); StringValue(c);
if (RSTRING_LEN(c) == 0) return Qnil;
enc = rb_enc_get(ptr->string); enc = rb_enc_get(ptr->string);
enc2 = rb_enc_get(c); enc2 = rb_enc_get(c);
if (enc != enc2 && enc != rb_ascii8bit_encoding()) { if (enc != enc2 && enc != rb_ascii8bit_encoding()) {