Rename `MRB_STR_NO_UTF` to 'MRB_STR_ASCII`; close #4550

In #4550, @shuuji proposed the name name `MRB_STR_NO_MULTI_BYTE` for
more precise description. Although I agree that the name name is
correct, but the flag means the string does not contain multi byte UTF-8
characters, i.e. all characters fit in the range of ASCII.
parent f4f3ced9
......@@ -87,7 +87,7 @@ MRB_API mrb_int mrb_str_strlen(mrb_state*, struct RString*);
#define MRB_STR_FSHARED 2
#define MRB_STR_NOFREE 4
#define MRB_STR_POOL 8
#define MRB_STR_NO_UTF 16
#define MRB_STR_ASCII 16
#define MRB_STR_EMBED 32
#define MRB_STR_EMBED_LEN_MASK 0x7c0
#define MRB_STR_EMBED_LEN_SHIFT 6
......
......@@ -260,12 +260,12 @@ utf8_strlen(mrb_value str)
{
mrb_int byte_len = RSTRING_LEN(str);
if (RSTRING(str)->flags & MRB_STR_NO_UTF) {
if (RSTRING(str)->flags & MRB_STR_ASCII) {
return byte_len;
}
else {
mrb_int utf8_len = mrb_utf8_len(RSTRING_PTR(str), byte_len);
if (byte_len == utf8_len) RSTRING(str)->flags |= MRB_STR_NO_UTF;
if (byte_len == utf8_len) RSTRING(str)->flags |= MRB_STR_ASCII;
return utf8_len;
}
}
......@@ -512,8 +512,8 @@ str_replace(mrb_state *mrb, struct RString *s1, struct RString *s2)
mrb_check_frozen(mrb, s1);
if (s1 == s2) return mrb_obj_value(s1);
s1->flags &= ~MRB_STR_NO_UTF;
s1->flags |= s2->flags&MRB_STR_NO_UTF;
s1->flags &= ~MRB_STR_ASCII;
s1->flags |= s2->flags&MRB_STR_ASCII;
len = RSTR_LEN(s2);
if (RSTR_SHARED_P(s1)) {
str_decref(mrb, s1->as.heap.aux.shared);
......@@ -651,7 +651,7 @@ MRB_API void
mrb_str_modify(mrb_state *mrb, struct RString *s)
{
mrb_check_frozen(mrb, s);
s->flags &= ~MRB_STR_NO_UTF;
s->flags &= ~MRB_STR_ASCII;
if (RSTR_SHARED_P(s)) {
mrb_shared_string *shared = s->as.heap.aux.shared;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment