diff options
| author | Junio C Hamano <gitster@pobox.com> | 2025-08-01 15:04:20 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-08-02 22:34:32 -0700 |
| commit | 576454974165d51b7e39c0608cde1c84978f1a8a (patch) | |
| tree | 33b3ea4c05ae843ffeaa4a5f9bb2e66b6398a5e5 /string-list.h | |
| parent | 527535fcdd2d9dec56877435f609852d0f2bf163 (diff) | |
| download | git-576454974165d51b7e39c0608cde1c84978f1a8a.tar.gz | |
string-list: optionally trim string pieces split by string_list_split*()
Teach the unified split_string() to take an optional "flags" word,
and define the first flag STRING_LIST_SPLIT_TRIM to cause the split
pieces to be trimmed before they are placed in the string list.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'string-list.h')
| -rw-r--r-- | string-list.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/string-list.h b/string-list.h index 6c8650efde..40e148712d 100644 --- a/string-list.h +++ b/string-list.h @@ -281,4 +281,19 @@ int string_list_split(struct string_list *list, const char *string, */ int string_list_split_in_place(struct string_list *list, char *string, const char *delim, int maxsplit); + +/* Flag bits for split_f and split_in_place_f functions */ +enum { + /* + * trim whitespaces around resulting string piece before adding + * it to the list + */ + STRING_LIST_SPLIT_TRIM = (1 << 0), +}; + +int string_list_split_f(struct string_list *, const char *string, + const char *delim, int maxsplit, unsigned flags); + +int string_list_split_in_place_f(struct string_list *, char *string, + const char *delim, int maxsplit, unsigned flags); #endif /* STRING_LIST_H */ |
