openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/util-linux/2.33.2-r0/util-linux-2.33.2/lib/strutils.c
int string_add_to_idarray(const char* list, int ary[], size_t arysz,
                          size_t* ary_pos, int(name2id)(const char*, size_t))
{
    const char* list_add;
    int r;

    if (!list || !*list || !ary_pos || *ary_pos > arysz)
        return -1;

    if (list[0] == '+')
        list_add = &list[1];
    else
    {
        list_add = list;
        *ary_pos = 0;
    }

    r = string_to_idarray(list_add, &ary[*ary_pos], arysz - *ary_pos, name2id);
    if (r > 0)
        *ary_pos += r;
    return r;
}
/*
 * Parses the array like string_to_idarray but if format is "+aaa,bbb"
 * it adds fields to array instead of replacing them.
 */
Parses the array like string_to_idarray but if format is "+aaa,bbb"
it adds fields to array instead of replacing them.
Parses the array like string_to_idarray but if format is " + aaa bbb " it adds fields to array instead of replacing them .
int string_add_to_idarray(const char* list, int ary[], size_t arysz,
                          size_t* ary_pos, int(name2id)(const char*, size_t))
{
    const char* list_add;
    int r;
    if (!list || !*list || !ary_pos || *ary_pos > arysz)
        return -1;
    if (list[0] == '+')
        list_add = &list[1];
    else
    {
        list_add = list;
        *ary_pos = 0;
    }
    r = string_to_idarray(list_add, &ary[*ary_pos], arysz - *ary_pos, name2id);
    if (r > 0)
        *ary_pos += r;
    return r;
}
int string_add_to_idarray ( const char * list , int ary [ ] , size_t arysz , size_t * ary_pos , int ( name2id ) ( const char * , size_t ) ) { const char * list_add ; int r ; if ( ! list || ! * list || ! ary_pos || * ary_pos > arysz ) return -1 ; if ( list [ 0 ] == ' ' ) list_add = & list [ 1 ] ; else { list_add = list ; * ary_pos = 0 ; } r = string_to_idarray ( list_add , & ary [ * ary_pos ] , arysz - * ary_pos , name2id ) ; if ( r > 0 ) * ary_pos += r ; return r ; }
Parses the array like string_to_idarray but if format is "+aaa,bbb"
 it adds fields to array instead of replacing them.
Parses the array like string_to_idarray but if format is " + aaa bbb " it adds fields to array instead of replacing them .