From 79f50b9d02b228aba2d8887422f00767046051a6 Mon Sep 17 00:00:00 2001 From: S-H-GAMELINKS Date: Sat, 10 Sep 2022 02:00:34 +0900 Subject: [PATCH] Using is_broken_string function --- file.c | 4 ++-- marshal.c | 2 +- transcode.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/file.c b/file.c index eb5851de7d..de7ed5e33b 100644 --- a/file.c +++ b/file.c @@ -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()); } } diff --git a/marshal.c b/marshal.c index 9e2f1c4381..e4b40c0607 100644 --- a/marshal.c +++ b/marshal.c @@ -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); } diff --git a/transcode.c b/transcode.c index 535e436b03..e315a8f1ab 100644 --- a/transcode.c +++ b/transcode.c @@ -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),