Introduce argf_encoding function
This commit is contained in:
parent
040e0c8d67
commit
7bc63d6f43
Notes:
git
2022-12-01 16:30:21 +00:00
21
io.c
21
io.c
@ -13406,6 +13406,17 @@ global_argf_p(VALUE arg)
|
|||||||
return arg == argf;
|
return arg == argf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef VALUE (*argf_encoding_func)(VALUE io);
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
argf_encoding(VALUE argf, argf_encoding_func func)
|
||||||
|
{
|
||||||
|
if (!RTEST(ARGF.current_file)) {
|
||||||
|
return rb_enc_default_external();
|
||||||
|
}
|
||||||
|
return func(rb_io_check_io(ARGF.current_file));
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* ARGF.external_encoding -> encoding
|
* ARGF.external_encoding -> encoding
|
||||||
@ -13425,10 +13436,7 @@ global_argf_p(VALUE arg)
|
|||||||
static VALUE
|
static VALUE
|
||||||
argf_external_encoding(VALUE argf)
|
argf_external_encoding(VALUE argf)
|
||||||
{
|
{
|
||||||
if (!RTEST(ARGF.current_file)) {
|
return argf_encoding(argf, rb_io_external_encoding);
|
||||||
return rb_enc_from_encoding(rb_default_external_encoding());
|
|
||||||
}
|
|
||||||
return rb_io_external_encoding(rb_io_check_io(ARGF.current_file));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -13447,10 +13455,7 @@ argf_external_encoding(VALUE argf)
|
|||||||
static VALUE
|
static VALUE
|
||||||
argf_internal_encoding(VALUE argf)
|
argf_internal_encoding(VALUE argf)
|
||||||
{
|
{
|
||||||
if (!RTEST(ARGF.current_file)) {
|
return argf_encoding(argf, rb_io_internal_encoding);
|
||||||
return rb_enc_from_encoding(rb_default_external_encoding());
|
|
||||||
}
|
|
||||||
return rb_io_internal_encoding(rb_io_check_io(ARGF.current_file));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user