1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-07-04 08:40:21 +02:00

Name the field for string backing store

* libguile/strings.h (chars): Name the field.
* libguile/strings.c (string_stringbuf, string_aliased_string)
(make_string, scm_i_string_ensure_mutable_x, scm_i_substring_shared)
(scm_i_try_narrow_string, scm_i_string_set_x): Adapt.
This commit is contained in:
Andy Wingo 2025-06-30 14:50:18 +02:00
parent 38c22e77a0
commit 8e6a06ca29
2 changed files with 8 additions and 8 deletions

View file

@ -305,7 +305,7 @@ string_stringbuf (struct scm_string *str)
{ {
if (string_is_shared (str)) if (string_is_shared (str))
abort (); abort ();
return str->stringbuf; return str->chars.stringbuf;
} }
static inline struct scm_string * static inline struct scm_string *
@ -313,7 +313,7 @@ string_aliased_string (struct scm_string *str)
{ {
if (!string_is_shared (str)) if (!string_is_shared (str))
abort (); abort ();
return str->string; return str->chars.string;
} }
static inline size_t static inline size_t
@ -337,7 +337,7 @@ make_string (struct scm_stringbuf *buf, int read_only_p,
struct scm_string *str = scm_allocate_tagged (SCM_I_CURRENT_THREAD, struct scm_string *str = scm_allocate_tagged (SCM_I_CURRENT_THREAD,
sizeof (*str)); sizeof (*str));
str->tag_and_flags = read_only_p ? scm_tc7_ro_string : scm_tc7_string; str->tag_and_flags = read_only_p ? scm_tc7_ro_string : scm_tc7_string;
str->stringbuf = buf; str->chars.stringbuf = buf;
str->start = start; str->start = start;
str->length = length; str->length = length;
return str; return str;
@ -524,7 +524,7 @@ scm_i_string_ensure_mutable_x (struct scm_string *str)
} }
stringbuf_set_mutable (buf); stringbuf_set_mutable (buf);
str->stringbuf = buf; str->chars.stringbuf = buf;
} }
} }
@ -551,7 +551,7 @@ scm_i_substring_shared (SCM str, size_t start, size_t end)
struct scm_string *ret = scm_allocate_tagged (SCM_I_CURRENT_THREAD, struct scm_string *ret = scm_allocate_tagged (SCM_I_CURRENT_THREAD,
sizeof (struct scm_string)); sizeof (struct scm_string));
ret->tag_and_flags = mutation_sharing_string_tag; ret->tag_and_flags = mutation_sharing_string_tag;
ret->string = s; ret->chars.string = s;
ret->start = start; ret->start = start;
ret->length = len; ret->length = len;
return scm_from_string (ret); return scm_from_string (ret);
@ -635,7 +635,7 @@ scm_i_try_narrow_string (SCM str)
try_narrow_stringbuf (as_wide_stringbuf (buf), 0, buf->length); try_narrow_stringbuf (as_wide_stringbuf (buf), 0, buf->length);
if (narrowed) if (narrowed)
{ {
s->stringbuf = &narrowed->header; s->chars.stringbuf = &narrowed->header;
return 1; return 1;
} }
@ -815,7 +815,7 @@ scm_i_string_set_x (SCM str, size_t p, scm_t_wchar chr)
{ {
struct scm_wide_stringbuf *wide = struct scm_wide_stringbuf *wide =
widen_stringbuf (as_narrow_stringbuf (buf)); widen_stringbuf (as_narrow_stringbuf (buf));
s->stringbuf = &wide->header; s->chars.stringbuf = &wide->header;
wide_stringbuf_chars (wide)[idx] = chr; wide_stringbuf_chars (wide)[idx] = chr;
} }
else else

View file

@ -202,7 +202,7 @@ struct scm_string
struct scm_stringbuf *stringbuf; struct scm_stringbuf *stringbuf;
/* Sometimes though it aliases another string. */ /* Sometimes though it aliases another string. */
struct scm_string *string; struct scm_string *string;
}; } chars;
size_t start; size_t start;
size_t length; size_t length;
}; };