ruby-changes:71075
From: S.H <ko1@a...>
Date: Wed, 2 Feb 2022 22:53:07 +0900 (JST)
Subject: [ruby-changes:71075] af10771045 (master): Add `econv_get_encoding` function
https://git.ruby-lang.org/ruby.git/commit/?id=af10771045 From af107710457b4bd148c6e5ee7a336ed4961f5423 Mon Sep 17 00:00:00 2001 From: "S.H" <gamelinks007@g...> Date: Wed, 2 Feb 2022 22:52:55 +0900 Subject: Add `econv_get_encoding` function --- transcode.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/transcode.c b/transcode.c index d7011443f8..9cc4d00f28 100644 --- a/transcode.c +++ b/transcode.c @@ -3499,6 +3499,14 @@ check_econv(VALUE self) https://github.com/ruby/ruby/blob/trunk/transcode.c#L3499 return ec; } +static VALUE +econv_get_encoding(rb_encoding *encoding) +{ + if (!encoding) + return Qnil; + return rb_enc_from_encoding(encoding); +} + /* * call-seq: * ec.source_encoding -> encoding @@ -3509,9 +3517,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/transcode.c#L3517 econv_source_encoding(VALUE self) { rb_econv_t *ec = check_econv(self); - if (!ec->source_encoding) - return Qnil; - return rb_enc_from_encoding(ec->source_encoding); + return econv_get_encoding(ec->source_encoding); } /* @@ -3524,9 +3530,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/transcode.c#L3530 econv_destination_encoding(VALUE self) { rb_econv_t *ec = check_econv(self); - if (!ec->destination_encoding) - return Qnil; - return rb_enc_from_encoding(ec->destination_encoding); + return econv_get_encoding(ec->destination_encoding); } /* -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/