diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2019-07-22 21:38:08 +0900 |
|---|---|---|
| committer | GitHub <[email protected]> | 2019-07-22 21:38:08 +0900 |
| commit | 477be4524417b4026dcfc98ad88a7b6d19fec60a (patch) | |
| tree | 478a50d7ad45906604319702f68f61a5f308e185 | |
| parent | d74355061bffe9762dabd2e303525002d3e6a585 (diff) | |
| parent | fe8b463c4ee84a89c116102a86181b2e7084e038 (diff) | |
| download | mruby-477be4524417b4026dcfc98ad88a7b6d19fec60a.tar.gz mruby-477be4524417b4026dcfc98ad88a7b6d19fec60a.zip | |
Merge pull request #4592 from shuujii/set-MRB_STR_ASCII-flag-in-String-inspect
Set `MRB_STR_ASCII` flag in `String#inspect`
| -rw-r--r-- | src/string.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/string.c b/src/string.c index de8a15ba9..ecbe21a22 100644 --- a/src/string.c +++ b/src/string.c @@ -2789,6 +2789,9 @@ mrb_str_inspect(mrb_state *mrb, mrb_value str) const char *p, *pend; char buf[CHAR_ESC_LEN + 1]; mrb_value result = mrb_str_new_lit(mrb, "\""); +#ifdef MRB_UTF8_STRING + uint32_t ascii_flag = MRB_STR_ASCII; +#endif p = RSTRING_PTR(str); pend = RSTRING_END(str); for (;p < pend; p++) { @@ -2805,6 +2808,7 @@ mrb_str_inspect(mrb_state *mrb, mrb_value str) } mrb_str_cat(mrb, result, buf, clen); p += clen-1; + ascii_flag = 0; continue; } #endif @@ -2846,7 +2850,10 @@ mrb_str_inspect(mrb_state *mrb, mrb_value str) } } mrb_str_cat_lit(mrb, result, "\""); - RSTR_COPY_ASCII_FLAG(mrb_str_ptr(result), mrb_str_ptr(str)); +#ifdef MRB_UTF8_STRING + mrb_str_ptr(str)->flags |= ascii_flag; + mrb_str_ptr(result)->flags |= ascii_flag; +#endif return result; } |
