From d2eae2b369b7ef444ac8a8d92e7dde6e8383a1b3 Mon Sep 17 00:00:00 2001 From: default Date: Tue, 10 Jan 2023 08:57:31 +0100 Subject: [PATCH] Backport from xs. --- xs.h | 13 +++++++++++++ xs_version.h | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/xs.h b/xs.h index 68236a1..e3126fd 100644 --- a/xs.h +++ b/xs.h @@ -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); #define xs_strip(str) xs_strip_chars(str, " \r\n\t\v\f") 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_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)) @@ -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 **/ d_char *xs_list_new(void) diff --git a/xs_version.h b/xs_version.h index 2691aed..0e03cfb 100644 --- a/xs_version.h +++ b/xs_version.h @@ -1 +1 @@ -/* e8f087f6b185939256227ea21b69f5f16f25a2dd */ +/* 38b055a19829fb788f1bb6917f76cc4830388e35 */