On 10/15/2012 12:30 PM, Michal Židek wrote:
> Added new parameter to split_on_separator that allows to skip
> empty values.
>
>
https://fedorahosted.org/sssd/ticket/1484
>
> Patch is in attachment.
>
> Michal
Nack. See below.
> --- a/src/util/util.c
> +++ b/src/util/util.c
> @@ -31,7 +31,8 @@
> * the separator is a string, and is case-sensitive.
> * optionally single values can be trimmed of of spaces and tabs */
> int split_on_separator(TALLOC_CTX *mem_ctx, const char *str,
> - const char sep, bool trim, char ***_list, int
> *size)
> + const char sep, bool trim, bool skip_empty,
> + char ***_list, int *size)
> {
> const char *t, *p, *n;
> size_t l, len;
> @@ -80,6 +81,11 @@ int split_on_separator(TALLOC_CTX *mem_ctx, const
> char *str,
> }
>
> if (len == 0) {
> + if (skip_empty) {
> + /* Move to next string and continue */
> + t = n;
> + continue;
> + }
Move this^ condition before talloc_realloc.
I did not like the function at all, it seemed to be written for
different purpose but slightly modified to fit our needs. I wrote a new
version in this patch and added test for it.
New patch attached.
Michal