/* intuitively: shiro_str = c_string */ int ss_set_cstring(struct sstr* sstrp, const char* cstring) { int len = strlen(cstring); while (sstrp->size < len + 1) { if (!ss_grow(sstrp)) { return 0; } } strcpy(sstrp->textp, cstring); sstrp->len = len; return 1; }
/* intuitively: shiro_str = shiro_str */ int ss_set(struct sstr* sstrp_dest, const struct sstr* sstrp_source) { int len = ss_strlen(sstrp_source); while (sstrp_dest->size < len + 1) { if (!ss_grow(sstrp_dest)) { return 0; } } strcpy(sstrp_dest->textp, sstrp_source->textp); sstrp_dest->len = len; return 1; }
/* BEHAVIOR: aliasing is supported, e.g. append(&a, a) */ static ss_t *ss_cat_cn_raw(ss_t **s, const char *src, const size_t src_off, const size_t src_size, const size_t src_usize) { ASSERT_RETURN_IF(!s, ss_void); if (src && src_size > 0) { const size_t off = *s ? sd_get_size(*s) : 0; if (ss_grow(s, src_size)) { memmove(get_str(*s) + off, src + src_off, src_size); inc_size(*s, src_size); if (is_unicode_size_cached(*s)) { if (src_usize > 0) inc_unicode_size(*s, src_usize); else set_unicode_size_cached(*s, S_FALSE); } } } return ss_check(s); }