![]() | Fun 0.41.5 The programming language that makes You have fun |
Helpers for manipulating C strings and bridging with Value arrays. More...


Go to the source code of this file.
Functions | |
| char * | string_substr (const char *s, int start, int len) |
| Create a newly allocated substring of s. | |
| int | string_find (const char *hay, const char *needle) |
| Find first occurrence of needle in hay. | |
| Value | string_split_to_array (const char *s, const char *sep) |
| Split a C string by separator into a Value array of strings. | |
| char * | array_join_with_sep (const Value *v, const char *sep) |
| Join the elements of a Value array into a single newly allocated C string. | |
Helpers for manipulating C strings and bridging with Value arrays.
Functions here return newly allocated C strings or construct Value arrays from strings. Callers own returned allocations and must free them using free()/free_value() as appropriate.
Definition in file str_utils.c.
| char * array_join_with_sep | ( | const Value * | v, |
| const char * | sep ) |
Join the elements of a Value array into a single newly allocated C string.
Each array element is converted to a string via value_to_string_alloc. NULL/invalid inputs yield an empty string. The caller owns the returned buffer and must free() it.
| v | Pointer to Value (expected VAL_ARRAY). |
| sep | Separator C string inserted between items (may be NULL). |
Definition at line 141 of file str_utils.c.


| int string_find | ( | const char * | hay, |
| const char * | needle ) |
Find first occurrence of needle in hay.
| hay | Haystack C string (may be NULL). |
| needle | Needle C string (may be NULL). |
Definition at line 56 of file str_utils.c.

| Value string_split_to_array | ( | const char * | s, |
| const char * | sep ) |
Split a C string by separator into a Value array of strings.
When sep is empty, splits into individual UTF-8 bytes (characters). Uses make_string/make_array_from_values; the returned Value owns internal memory per Value semantics. NULL inputs are treated as empty strings.
| s | Source C string (may be NULL). |
| sep | Separator C string (may be NULL). Empty means split into chars. |
Definition at line 74 of file str_utils.c.


| char * string_substr | ( | const char * | s, |
| int | start, | ||
| int | len ) |
Create a newly allocated substring of s.
Indices are clamped into valid range. If s is NULL, an empty string is returned. The caller owns the returned buffer and must free() it.
| s | Source C string (may be NULL). |
| start | Zero-based start index; clamped to [0, strlen(s)]. |
| len | Maximum number of characters to copy; negative treated as 0. |
Definition at line 35 of file str_utils.c.
