From 4582cc8579198b2319c9c4d14643f03dc32d6ab3 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Fri, 3 Jan 2025 09:27:43 +0900 Subject: [PATCH] string.c: rename type setting macro --- include/mruby/string.h | 3 ++- src/string.c | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/include/mruby/string.h b/include/mruby/string.h index 329f323b5..639f62248 100644 --- a/include/mruby/string.h +++ b/include/mruby/string.h @@ -38,7 +38,7 @@ struct RStringEmbed { char ary[RSTRING_EMBED_LEN_MAX+1]; }; -#define RSTR_SET_TYPE_FLAG(s, type) (RSTR_UNSET_TYPE_FLAG(s), (s)->flags |= MRB_STR_##type) +#define RSTR_SET_TYPE(s, type) (RSTR_UNSET_TYPE_FLAG(s), (s)->flags |= MRB_STR_##type) #define RSTR_UNSET_TYPE_FLAG(s) ((s)->flags &= ~(MRB_STR_TYPE_MASK|MRB_STR_EMBED_LEN_MASK)) #define RSTR_EMBED_P(s) ((s)->flags & MRB_STR_EMBED) @@ -107,6 +107,7 @@ struct RStringEmbed { #define RSTRING_END(s) (RSTRING_PTR(s) + RSTRING_LEN(s)) #define RSTRING_CSTR(mrb,s) mrb_string_cstr(mrb, s) +#define MRB_STR_NORMAL 0 #define MRB_STR_SHARED 1 #define MRB_STR_FSHARED 2 #define MRB_STR_NOFREE 4 diff --git a/src/string.c b/src/string.c index 8b8fcdfed..ae932aa37 100644 --- a/src/string.c +++ b/src/string.c @@ -61,7 +61,7 @@ str_init_normal_capa(mrb_state *mrb, struct RString *s, s->as.heap.ptr = dst; s->as.heap.len = len; s->as.heap.aux.capa = capa; - RSTR_UNSET_TYPE_FLAG(s); + RSTR_SET_TYPE(s, NORMAL); return s; } @@ -77,7 +77,7 @@ str_init_embed(struct RString *s, const char *p, mrb_int len) mrb_assert(len >= 0); if (p) memcpy(RSTR_EMBED_PTR(s), p, len); RSTR_EMBED_PTR(s)[len] = '\0'; - RSTR_SET_TYPE_FLAG(s, EMBED); + RSTR_SET_TYPE(s, EMBED); RSTR_SET_EMBED_LEN(s, len); return s; } @@ -88,7 +88,7 @@ str_init_nofree(struct RString *s, const char *p, mrb_int len) s->as.heap.ptr = (char*)p; s->as.heap.len = len; s->as.heap.aux.capa = 0; /* nofree */ - RSTR_SET_TYPE_FLAG(s, NOFREE); + RSTR_SET_TYPE(s, NOFREE); return s; } @@ -107,7 +107,7 @@ str_init_shared(mrb_state *mrb, const struct RString *orig, struct RString *s, m s->as.heap.ptr = orig->as.heap.ptr; s->as.heap.len = orig->as.heap.len; s->as.heap.aux.shared = shared; - RSTR_SET_TYPE_FLAG(s, SHARED); + RSTR_SET_TYPE(s, SHARED); return s; } @@ -117,7 +117,7 @@ str_init_fshared(const struct RString *orig, struct RString *s, struct RString * s->as.heap.ptr = orig->as.heap.ptr; s->as.heap.len = orig->as.heap.len; s->as.heap.aux.fshared = fshared; - RSTR_SET_TYPE_FLAG(s, FSHARED); + RSTR_SET_TYPE(s, FSHARED); return s; }