1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Using is_broken_string function

This commit is contained in:
S-H-GAMELINKS 2022-09-10 02:00:34 +09:00 committed by Nobuyoshi Nakada
parent 518301883e
commit 79f50b9d02
Notes: git 2022-09-10 09:33:12 +09:00
3 changed files with 4 additions and 4 deletions

4
file.c
View file

@ -4500,9 +4500,9 @@ rb_check_realpath_internal(VALUE basedir, VALUE path, rb_encoding *origenc, enum
rb_enc_associate(resolved, origenc);
}
if (rb_enc_str_coderange(resolved) == ENC_CODERANGE_BROKEN) {
if (is_broken_string(resolved)) {
rb_enc_associate(resolved, rb_filesystem_encoding());
if (rb_enc_str_coderange(resolved) == ENC_CODERANGE_BROKEN) {
if (is_broken_string(resolved)) {
rb_enc_associate(resolved, rb_ascii8bit_encoding());
}
}

View file

@ -1554,7 +1554,7 @@ r_symreal(struct load_arg *arg, int ivar)
}
if (idx > 0) {
rb_enc_associate_index(s, idx);
if (rb_enc_str_coderange(s) == ENC_CODERANGE_BROKEN) {
if (is_broken_string(s)) {
rb_raise(rb_eArgError, "invalid byte sequence in %s: %+"PRIsVALUE,
rb_enc_name(rb_enc_from_index(idx)), s);
}

View file

@ -2590,7 +2590,7 @@ rb_econv_prepare_options(VALUE opthash, VALUE *opts, int ecflags)
v = rb_hash_aref(opthash, sym_replace);
if (!NIL_P(v)) {
StringValue(v);
if (rb_enc_str_coderange(v) == ENC_CODERANGE_BROKEN) {
if (is_broken_string(v)) {
VALUE dumped = rb_str_dump(v);
rb_raise(rb_eArgError, "replacement string is broken: %s as %s",
StringValueCStr(dumped),