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 parse_range(const char* str, int* lower, int* upper, int def)
{
    char* end = NULL;

    if (!str)
        return 0;

    *upper = *lower = def;
    errno = 0;

    if (*str == ':')
    { /* <:N> */
        str++;
        *upper = strtol(str, &end, 10);
        if (errno || !end || *end || end == str)
            return -1;
    }
    else
    {
        *upper = *lower = strtol(str, &end, 10);
        if (errno || !end || end == str)
            return -1;

        if (*end == ':' && !*(end + 1)) /* <M:> */
            *upper = def;
        else if (*end == '-' || *end == ':')
        { /* <M:N> <M-N> */
            str = end + 1;
            end = NULL;
            errno = 0;
            *upper = strtol(str, &end, 10);

            if (errno || !end || *end || end == str)
                return -1;
        }
    }
    return 0;
}
/*
 * Parse the lower and higher values in a string containing
 * "lower:higher" or "lower-higher" format. Note that either
 * the lower or the higher values may be missing, and the def
 * value will be assigned to it by default.
 *
 * Returns: 0 on success, <0 on error.
 */
Parse the lower and higher values in a string containing
"lower:higher" or "lower-higher" format. Note that either
the lower or the higher values may be missing, and the def
value will be assigned to it by default.

0 on success, <0 on error.
Parse the lower and higher values in a string containing " lower : higher " or " lower - higher " format . Note that either the lower or the higher values may be missing and the def value will be assigned to it by default . 0 on success <0 on error .
int parse_range(const char* str, int* lower, int* upper, int def)
{
    char* end = NULL;
    if (!str)
        return 0;
    *upper = *lower = def;
    errno = 0;
    if (*str == ':')
    { 
        str++;
        *upper = strtol(str, &end, 10);
        if (errno || !end || *end || end == str)
            return -1;
    }
    else
    {
        *upper = *lower = strtol(str, &end, 10);
        if (errno || !end || end == str)
            return -1;
        if (*end == ':' && !*(end + 1)) 
            *upper = def;
        else if (*end == '-' || *end == ':')
        { 
            str = end + 1;
            end = NULL;
            errno = 0;
            *upper = strtol(str, &end, 10);
            if (errno || !end || *end || end == str)
                return -1;
        }
    }
    return 0;
}
int parse_range ( const char * str , int * lower , int * upper , int def ) { char * end = NULL ; if ( ! str ) return 0 ; * upper = * lower = def ; errno = 0 ; if ( * str == ' ' ) { str ++ ; * upper = strtol ( str , & end , 10 ) ; if ( errno || ! end || * end || end == str ) return -1 ; } else { * upper = * lower = strtol ( str , & end , 10 ) ; if ( errno || ! end || end == str ) return -1 ; if ( * end == ' ' && ! * ( end + 1 ) ) * upper = def ; else if ( * end == ' ' || * end == ' ' ) { str = end + 1 ; end = NULL ; errno = 0 ; * upper = strtol ( str , & end , 10 ) ; if ( errno || ! end || * end || end == str ) return -1 ; } } return 0 ; }
Parse the lower and higher values in a string containing
 "lower:higher" or "lower-higher" format.
Parse the lower and higher values in a string containing " lower : higher " or " lower - higher " format .
/* <:N> */ /* <M:> */ /* <M:N> <M-N> */