[ruby/stringio] Drop support for ruby 2.6 or earlier
(https://github.com/ruby/stringio/pull/47) `rb_io_extract_modeenc` has been exported since ruby 2.7.
This commit is contained in:
parent
fb23fba082
commit
6987ec45b1
@ -1,4 +1,3 @@
|
|||||||
# frozen_string_literal: false
|
# frozen_string_literal: false
|
||||||
require 'mkmf'
|
require 'mkmf'
|
||||||
have_func("rb_io_extract_modeenc", "ruby/io.h")
|
|
||||||
create_makefile('stringio')
|
create_makefile('stringio')
|
||||||
|
@ -32,86 +32,6 @@
|
|||||||
# define rb_class_new_instance_kw(argc, argv, klass, kw_splat) rb_class_new_instance(argc, argv, klass)
|
# define rb_class_new_instance_kw(argc, argv, klass, kw_splat) rb_class_new_instance(argc, argv, klass)
|
||||||
#endif
|
#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 {
|
struct StringIO {
|
||||||
VALUE string;
|
VALUE string;
|
||||||
rb_encoding *enc;
|
rb_encoding *enc;
|
||||||
|
@ -14,7 +14,6 @@ Gem::Specification.new do |s|
|
|||||||
s.name = "stringio"
|
s.name = "stringio"
|
||||||
s.version = source_version
|
s.version = source_version
|
||||||
|
|
||||||
s.required_rubygems_version = Gem::Requirement.new(">= 2.6")
|
|
||||||
s.require_paths = ["lib"]
|
s.require_paths = ["lib"]
|
||||||
s.authors = ["Nobu Nakada", "Charles Oliver Nutter"]
|
s.authors = ["Nobu Nakada", "Charles Oliver Nutter"]
|
||||||
s.description = "Pseudo `IO` class from/to `String`."
|
s.description = "Pseudo `IO` class from/to `String`."
|
||||||
@ -30,7 +29,7 @@ Gem::Specification.new do |s|
|
|||||||
end
|
end
|
||||||
s.homepage = "https://github.com/ruby/stringio"
|
s.homepage = "https://github.com/ruby/stringio"
|
||||||
s.licenses = ["Ruby", "BSD-2-Clause"]
|
s.licenses = ["Ruby", "BSD-2-Clause"]
|
||||||
s.required_ruby_version = ">= 2.5"
|
s.required_ruby_version = ">= 2.7"
|
||||||
s.summary = "Pseudo IO on String"
|
s.summary = "Pseudo IO on String"
|
||||||
|
|
||||||
# s.cert_chain = %w[certs/nobu.pem]
|
# s.cert_chain = %w[certs/nobu.pem]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user