diff options
author | default <nobody@localhost> | 2023-07-05 09:51:41 +0200 |
---|---|---|
committer | default <nobody@localhost> | 2023-07-05 09:51:41 +0200 |
commit | c47df7634e693736c31a446bb432fc036ead0513 (patch) | |
tree | 7cf13583b0e301cf1be27c99f5ca98e56298b58b /xs.h | |
parent | 5b3c7d45bbaa4bb0fee61b89f4ecc5df4c4ffcd8 (diff) |
Backport from xs.
Diffstat (limited to 'xs.h')
-rw-r--r-- | xs.h | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -96,6 +96,7 @@ int xs_list_in(const xs_list *list, const xs_val *val); xs_str *xs_join(const xs_list *list, const char *sep); xs_list *xs_split_n(const char *str, const char *sep, int times); #define xs_split(str, sep) xs_split_n(str, sep, XS_ALL) +xs_list *xs_list_cat(xs_list *l1, const xs_list *l2); xs_dict *xs_dict_new(void); xs_dict *xs_dict_append_m(xs_dict *dict, const xs_str *key, const xs_val *mem, int dsz); @@ -858,6 +859,17 @@ xs_list *xs_split_n(const char *str, const char *sep, int times) } +xs_list *xs_list_cat(xs_list *l1, const xs_list *l2) +/* concatenates list l2 to l1 */ +{ + XS_ASSERT_TYPE(l1, XSTYPE_LIST); + XS_ASSERT_TYPE(l2, XSTYPE_LIST); + + /* inserts at the end of l1 the content of l2 (skipping header and footer) */ + return xs_insert_m(l1, xs_size(l1) - 1, l2 + 4, xs_size(l2) - 5); +} + + /** dicts **/ xs_dict *xs_dict_new(void) |