Add macro string_sets (like string_cats)
This commit is contained in:
1 parent
5f05c1e169
commit
8a9d5f6a00
3 files changed
+11
No files matched your search
@@ -5020,6 +5020,11 @@ NOTE: v2 can also be a 'const char *' in C11.
|
||||
Append all the strings 'v2' ... to the string 'v'.
|
||||
NOTE: v2 can also be a 'const char *' in C11.
|
||||
|
||||
##### void string\_sets(string\_t v, const string\_t v2[, ...] )
|
||||
|
||||
Set the string 'v' to the concatenation of all the strings 'v2'
|
||||
NOTE: v2 can also be a 'const char *' in C11.
|
||||
|
||||
##### int string\_cmp\_str(const string\_t v1, const char str[])
|
||||
##### int string\_cmp(const string\_t v1, const string\_t str)
|
||||
|
||||
|
||||
@@ -1859,6 +1859,10 @@ namespace m_lib {
|
||||
#define string_cats(a, ...) \
|
||||
M_MAP2_C(string_cat, a, __VA_ARGS__)
|
||||
|
||||
/* Set a string to a set strings (or const char * if C1)) */
|
||||
#define string_sets(a, ...) \
|
||||
(string_clean(a), M_MAP2_C(string_cat, a, __VA_ARGS__) )
|
||||
|
||||
/* Macro encapsulation for C11 */
|
||||
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
|
||||
|
||||
|
||||
@@ -302,6 +302,8 @@ static void test0(void)
|
||||
string_set_str(s3, " world");
|
||||
string_cats(s1, s2, s3);
|
||||
assert (string_cmp_str (s1, "Hello world") == 0);
|
||||
string_sets(s1, s2, s3);
|
||||
assert (string_cmp_str (s1, "o world") == 0);
|
||||
}
|
||||
|
||||
string_clear (s1);
|
||||
|
||||
Reference in new issue
Block a user