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/libmount/src/optstr.c
static int mnt_optstr_parse_next(char** optstr, char** name, size_t* namesz,
                                 char** value, size_t* valsz)
{
    int open_quote = 0;
    char *start = NULL, *stop = NULL, *p, *sep = NULL;
    char* optstr0;

    assert(optstr);
    assert(*optstr);

    optstr0 = *optstr;

    if (name)
        *name = NULL;
    if (namesz)
        *namesz = 0;
    if (value)
        *value = NULL;
    if (valsz)
        *valsz = 0;

    /* trim leading commas as to not invalidate option
     * strings with multiple consecutive commas */
    while (optstr0 && *optstr0 == ',')
        optstr0++;

    for (p = optstr0; p && *p; p++)
    {
        if (!start)
            start = p; /* beginning of the option item */
        if (*p == '"')
            open_quote ^= 1; /* reverse the status */
        if (open_quote)
            continue; /* still in quoted block */
        if (!sep && p > start && *p == '=')
            sep = p; /* name and value separator */
        if (*p == ',')
            stop = p; /* terminate the option item */
        else if (*(p + 1) == '\0')
            stop = p + 1; /* end of optstr */
        if (!start || !stop)
            continue;
        if (stop <= start)
            goto error;

        if (name)
            *name = start;
        if (namesz)
            *namesz = sep ? sep - start : stop - start;
        *optstr = *stop ? stop + 1 : stop;

        if (sep)
        {
            if (value)
                *value = sep + 1;
            if (valsz)
                *valsz = stop - sep - 1;
        }
        return 0;
    }

    return 1; /* end of optstr */

error:
    DBG(OPTIONS, ul_debug("parse error: \"%s\"", optstr0));
    return -EINVAL;
}
/*
 * Parses the first option from @optstr. The @optstr pointer is set to the
 * beginning of the next option.
 *
 * Returns -EINVAL on parse error, 1 at the end of optstr and 0 on success.
 */
Parses the first option from @optstr. The @optstr pointer is set to the
beginning of the next option.

EINVAL on parse error, 1 at the end of optstr and 0 on success.
Parses the first option from @optstr . The @optstr pointer is set to the beginning of the next option . EINVAL on parse error 1 at the end of optstr and 0 on success .
static int mnt_optstr_parse_next(char** optstr, char** name, size_t* namesz,
                                 char** value, size_t* valsz)
{
    int open_quote = 0;
    char *start = NULL, *stop = NULL, *p, *sep = NULL;
    char* optstr0;
    assert(optstr);
    assert(*optstr);
    optstr0 = *optstr;
    if (name)
        *name = NULL;
    if (namesz)
        *namesz = 0;
    if (value)
        *value = NULL;
    if (valsz)
        *valsz = 0;
    while (optstr0 && *optstr0 == ',')
        optstr0++;
    for (p = optstr0; p && *p; p++)
    {
        if (!start)
            start = p; 
        if (*p == '"')
            open_quote ^= 1; 
        if (open_quote)
            continue; 
        if (!sep && p > start && *p == '=')
            sep = p; 
        if (*p == ',')
            stop = p; 
        else if (*(p + 1) == '\0')
            stop = p + 1; 
        if (!start || !stop)
            continue;
        if (stop <= start)
            goto error;
        if (name)
            *name = start;
        if (namesz)
            *namesz = sep ? sep - start : stop - start;
        *optstr = *stop ? stop + 1 : stop;
        if (sep)
        {
            if (value)
                *value = sep + 1;
            if (valsz)
                *valsz = stop - sep - 1;
        }
        return 0;
    }
    return 1; 
error:
    DBG(OPTIONS, ul_debug("parse error: \"%s\"", optstr0));
    return -EINVAL;
}
static int mnt_optstr_parse_next ( char * * optstr , char * * name , size_t * namesz , char * * value , size_t * valsz ) { int open_quote = 0 ; char * start = NULL , * stop = NULL , * p , * sep = NULL ; char * optstr0 ; assert ( optstr ) ; assert ( * optstr ) ; optstr0 = * optstr ; if ( name ) * name = NULL ; if ( namesz ) * namesz = 0 ; if ( value ) * value = NULL ; if ( valsz ) * valsz = 0 ; while ( optstr0 && * optstr0 == ' ' ) optstr0 ++ ; for ( p = optstr0 ; p && * p ; p ++ ) { if ( ! start ) start = p ; if ( * p == ' ' ) open_quote ^= 1 ; if ( open_quote ) continue ; if ( ! sep && p > start && * p == ' ' ) sep = p ; if ( * p == ' ' ) stop = p ; else if ( * ( p + 1 ) == ' \0 ' ) stop = p + 1 ; if ( ! start || ! stop ) continue ; if ( stop <= start ) goto error ; if ( name ) * name = start ; if ( namesz ) * namesz = sep ? sep - start : stop - start ; * optstr = * stop ? stop + 1 : stop ; if ( sep ) { if ( value ) * value = sep + 1 ; if ( valsz ) * valsz = stop - sep - 1 ; } return 0 ; } return 1 ; error : DBG ( OPTIONS , ul_debug ( " \" \" " , optstr0 ) ) ; return - EINVAL ; }
Parses the first option from @optstr.
Parses the first option from @optstr .
/* trim leading commas as to not invalidate option
     * strings with multiple consecutive commas */ /* beginning of the option item */ /* reverse the status */ /* still in quoted block */ /* name and value separator */ /* terminate the option item */ /* end of optstr */ /* end of optstr */