Skip to content

Commit

Permalink
Using is_broken_string function
Browse files Browse the repository at this point in the history
  • Loading branch information
S-H-GAMELINKS authored and nobu committed Sep 10, 2022
1 parent 5183018 commit 79f50b9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions file.c
Expand Up @@ -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());
}
}
Expand Down
2 changes: 1 addition & 1 deletion marshal.c
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion transcode.c
Expand Up @@ -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),
Expand Down

0 comments on commit 79f50b9

Please sign in to comment.