diff --git a/README.md b/README.md index de745209..49b2784b 100644 --- a/README.md +++ b/README.md @@ -5071,14 +5071,6 @@ Keep the right part of the string, after the index 'index'. Extract the medium string from offset 'index' and up to 'size' bytes. -##### void string\_subset (string\_t v, const string\_t org, size\_t index, size\_t size) - -Extract the medium string from offset 'index' and up to 'size' bytes of 'org' -and set it in 'v'. - -The subset string shall fully exist in the string org. -The string 'v' and 'org' shall be different. - ##### size\_t string\_replace\_str (string\_t v, const char str1[], const char str2[] [, size_t start]) ##### size\_t string\_replace (string\_t v, const string\_t str1, const string\_t str2 [ , size_t start]) diff --git a/m-string.h b/m-string.h index 267ac769..21976ebc 100644 --- a/m-string.h +++ b/m-string.h @@ -701,7 +701,9 @@ string_right(string_t v, size_t index) STRINGI_CONTRACT (v); } -/* Return the string from position index to size bytes */ +/* Return the string from position index to size bytes. + See also string_set_n + */ static inline void string_mid (string_t v, size_t index, size_t size) { @@ -709,18 +711,6 @@ string_mid (string_t v, size_t index, size_t size) string_left(v, size); } -/* Set the string 'v' to the substring of org from position index to size bytes */ -static inline void -string_subset (string_t v, const string_t org, size_t index, size_t size) -{ - // The substring shall fully exist within the string org - assert(index + size <= string_size(org) ); - assert(v != org); - - const char *str = string_get_cstr(org); - string_set_strn(v, &str[index], size); -} - /* Return in the string the C string str1 into the C string str2 from start By default, start is zero. */ diff --git a/tests/test-mstring.c b/tests/test-mstring.c index ec4761c8..1643b24f 100644 --- a/tests/test-mstring.c +++ b/tests/test-mstring.c @@ -201,7 +201,7 @@ static void test0(void) string_mid (s1, j, 2); assert (string_cmp_str (s1, ", ") == 0); - string_subset (s1, s2, j, 2); + string_set_n (s1, s2, j, 2); assert (string_cmp_str (s1, ", ") == 0); string_set (s1, s2);