--- a/src/cx/string.h Sun Dec 21 11:09:46 2025 +0100 +++ b/src/cx/string.h Sun Dec 21 23:58:30 2025 +0100 @@ -639,23 +639,18 @@ CX_EXPORT cxmutstr cx_strrchr_m(cxmutstr string, int chr); /** - * Returns a substring starting at the location of the first occurrence of the - * specified string. + * Searches for a specific substring. * - * If @p haystack does not contain @p needle, an empty string is returned. - * - * If @p needle is an empty string, the complete @p haystack is - * returned. + * Internal function - do not use. * * @param haystack the string to be scanned - * @param needle string containing the sequence of characters to match - * @return a substring starting at the first occurrence of - * @p needle, or an empty string, if the sequence is not - * contained - * @see cx_strstr_m() + * @param needle string containing the sequence of characters to match + * @return a substring starting at the first occurrence of @p needle, + * or an empty string, if the sequence is not contained + * @see cx_strstr() */ cx_attr_nodiscard -CX_EXPORT cxstring cx_strstr(cxstring haystack, cxstring needle); +CX_EXPORT cxstring cx_strstr_(cxstring haystack, cxstring needle); /** * Returns a substring starting at the location of the first occurrence of the @@ -666,15 +661,44 @@ * If @p needle is an empty string, the complete @p haystack is * returned. * + * @param haystack (@c cxstring) the string to be scanned + * @param needle string containing the sequence of characters to match + * @return (@c cxstring) a substring starting at the first occurrence of + * @p needle, or an empty string, if the sequence is not contained + * @see cx_strstr_m() + */ +#define cx_strstr(haystack, needle) cx_strstr_(haystack, cx_strcast(needle)) + +/** + * Searches for a specific substring. + * + * Internal function - do not use. + * * @param haystack the string to be scanned - * @param needle string containing the sequence of characters to match - * @return a substring starting at the first occurrence of - * @p needle, or an empty string, if the sequence is not - * contained + * @param needle string containing the sequence of characters to match + * @return a substring starting at the first occurrence of @p needle, + * or an empty string, if the sequence is not contained + * @see cx_strstr_m() + */ +cx_attr_nodiscard +CX_EXPORT cxmutstr cx_strstr_m_(cxmutstr haystack, cxstring needle); + +/** + * Returns a substring starting at the location of the first occurrence of the + * specified string. + * + * If @p haystack does not contain @p needle, an empty string is returned. + * + * If @p needle is an empty string, the complete @p haystack is + * returned. + * + * @param haystack (@c cxmutstr) the string to be scanned + * @param needle string containing the sequence of characters to match + * @return (@c cxmutstr) a substring starting at the first occurrence of + * @p needle, or an empty string, if the sequence is not contained * @see cx_strstr() */ -cx_attr_nodiscard -CX_EXPORT cxmutstr cx_strstr_m(cxmutstr haystack, cxstring needle); +#define cx_strstr_m(haystack, needle) cx_strstr_m_(haystack, cx_strcast(needle)) /** * Splits a given string using a delimiter string.