[PATCH v3 1/4] scripts: include: Add string_util.h for strsep_unescaped
Jonas Rebmann
jre at pengutronix.de
Tue Mar 17 04:16:48 PDT 2026
Hello,
On 2026-03-17 00:25, Marco Felsch wrote:
>> +// SPDX-SnippetBegin
>> +// SPDX-Snippet-Comment: Origin-URL: https://git.pengutronix.de/cgit/barebox/tree/lib/string.c?id=dfcf686f94a5a5387660f2afab79a714baab828a
>
> Do we really need this if we reference code within our own repo?
Yes, we want any code copied in verbatim to be referenced so we can have
an eye on diverging implementations.
>> +/**
>> + * strsep_unescaped - Split a string into tokens, while ignoring escaped delimiters
>> + * @s: The string to be searched
>> + * @ct: The delimiter characters to search for
>> + * @delim: optional pointer to store found delimiter into
>> + *
>> + * strsep_unescaped() behaves like strsep unless it meets an escaped delimiter.
>> + * In that case, it shifts the string back in memory to overwrite the escape's
>> + * backslash then continues the search until an unescaped delimiter is found.
>> + *
>> + * On end of string, this function returns NULL. As long as a non-NULL
>> + * value is returned and @delim is not NULL, the found delimiter will
>> + * be stored into *@delim.
>> + */
>> +static char *strsep_unescaped(char **s, const char *ct, char *delim)
>
> Is there a reason for defining this function within a .h instead of a .c
> file?
Yes, this is how it's done in scripts/include because those "scripts"
are single-source.
--
Pengutronix e.K. | Jonas Rebmann |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
More information about the barebox
mailing list