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/sys-utils/lscpu.c
static int lookup(char* line, char* pattern, char** value)
{
    char *p, *v;
    int len = strlen(pattern);

    /* don't re-fill already found tags, first one wins */
    if (!*line || *value)
        return 0;

    /* pattern */
    if (strncmp(line, pattern, len))
        return 0;

    /* white spaces */
    for (p = line + len; isspace(*p); p++)
        ;

    /* separator */
    if (*p != ':')
        return 0;

    /* white spaces */
    for (++p; isspace(*p); p++)
        ;

    /* value */
    if (!*p)
        return 0;
    v = p;

    /* end of value */
    len = strlen(line) - 1;
    for (p = line + len; isspace(*(p - 1)); p--)
        ;
    *p = '\0';

    *value = xstrdup(v);
    return 1;
}
/* Lookup a pattern and get the value from cpuinfo.
 * Format is:
 *
 *	"<pattern>   : <key>"
 */
Lookup a pattern and get the value from cpuinfo.
Format is.


Lookup a pattern and get the value from cpuinfo . Format is .
static int lookup(char* line, char* pattern, char** value)
{
    char *p, *v;
    int len = strlen(pattern);
    if (!*line || *value)
        return 0;
    if (strncmp(line, pattern, len))
        return 0;
    for (p = line + len; isspace(*p); p++)
        ;
    if (*p != ':')
        return 0;
    for (++p; isspace(*p); p++)
        ;
    if (!*p)
        return 0;
    v = p;
    len = strlen(line) - 1;
    for (p = line + len; isspace(*(p - 1)); p--)
        ;
    *p = '\0';
    *value = xstrdup(v);
    return 1;
}
static int lookup ( char * line , char * pattern , char * * value ) { char * p , * v ; int len = strlen ( pattern ) ; if ( ! * line || * value ) return 0 ; if ( strncmp ( line , pattern , len ) ) return 0 ; for ( p = line + len ; isspace ( * p ) ; p ++ ) ; if ( * p != ' ' ) return 0 ; for ( ++ p ; isspace ( * p ) ; p ++ ) ; if ( ! * p ) return 0 ; v = p ; len = strlen ( line ) - 1 ; for ( p = line + len ; isspace ( * ( p - 1 ) ) ; p -- ) ; * p = ' \0 ' ; * value = xstrdup ( v ) ; return 1 ; }
Lookup a pattern and get the value from cpuinfo.
Lookup a pattern and get the value from cpuinfo .
/* don't re-fill already found tags, first one wins */ /* pattern */ /* white spaces */ /* separator */ /* white spaces */ /* value */ /* end of value */