Backport from xs.

This commit is contained in:
default 2023-01-10 08:57:31 +01:00
parent 061291cabf
commit d2eae2b369
2 changed files with 14 additions and 1 deletions

13
xs.h
View file

@ -64,6 +64,7 @@ d_char *xs_crop(d_char *str, int start, int end);
d_char *xs_strip_chars(d_char *str, const char *chars); d_char *xs_strip_chars(d_char *str, const char *chars);
#define xs_strip(str) xs_strip_chars(str, " \r\n\t\v\f") #define xs_strip(str) xs_strip_chars(str, " \r\n\t\v\f")
d_char *xs_tolower(d_char *str); d_char *xs_tolower(d_char *str);
d_char *xs_str_prepend(d_char *str, const char *prefix);
d_char *xs_list_new(void); d_char *xs_list_new(void);
d_char *xs_list_append_m(d_char *list, const char *mem, int dsz); d_char *xs_list_append_m(d_char *list, const char *mem, int dsz);
#define xs_list_append(list, data) xs_list_append_m(list, data, xs_size(data)) #define xs_list_append(list, data) xs_list_append_m(list, data, xs_size(data))
@ -489,6 +490,18 @@ d_char *xs_tolower(d_char *str)
} }
d_char *xs_str_prepend(d_char *str, const char *prefix)
/* prepends prefix into string */
{
int sz = strlen(prefix);
str = xs_expand(str, 0, sz);
memcpy(str, prefix, sz);
return str;
}
/** lists **/ /** lists **/
d_char *xs_list_new(void) d_char *xs_list_new(void)

View file

@ -1 +1 @@
/* e8f087f6b185939256227ea21b69f5f16f25a2dd */ /* 38b055a19829fb788f1bb6917f76cc4830388e35 */