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>
This commit is contained in:
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user