src/util/show_help.c
/*
 * Returns PRTE_SUCCESS if the strings match; PRTE_ERROR otherwise.
 */
Returns PRTE_SUCCESS if the strings match; PRTE_ERROR otherwise.
Returns PRTE_SUCCESS if the strings match ; PRTE_ERROR otherwise .
static int match(const char *a, const char *b)
{
    int rc = PRTE_ERROR;
    char *p1, *p2, *tmp1 = NULL, *tmp2 = NULL;
    size_t min;
    if (0 == strcmp(a, b))
        return PRTE_SUCCESS;
    if (NULL != strchr(a, '*') || NULL != strchr(b, '*')) {
        tmp1 = strdup(a);
        if (NULL == tmp1) {
            return PRTE_ERR_OUT_OF_RESOURCE;
        }
        tmp2 = strdup(b);
        if (NULL == tmp2) {
            free(tmp1);
            return PRTE_ERR_OUT_OF_RESOURCE;
        }
        p1 = strchr(tmp1, '*');
        p2 = strchr(tmp2, '*');
        if (NULL != p1) {
            *p1 = '\0';
        }
        if (NULL != p2) {
            *p2 = '\0';
        }
        min = strlen(tmp1);
        if (strlen(tmp2) < min) {
            min = strlen(tmp2);
        }
        if (0 == min || 0 == strncmp(tmp1, tmp2, min)) {
            rc = PRTE_SUCCESS;
        }
        free(tmp1);
        free(tmp2);
        return rc;
    }
    return PRTE_ERROR;
}
static int match ( const char * a , const char * b ) { int rc = PRTE_ERROR ; char * p1 , * p2 , * tmp1 = NULL , * tmp2 = NULL ; size_t min ; if ( 0 == strcmp ( a , b ) ) return PRTE_SUCCESS ; if ( NULL != strchr ( a , ' ' ) || NULL != strchr ( b , ' ' ) ) { tmp1 = strdup ( a ) ; if ( NULL == tmp1 ) { return PRTE_ERR_OUT_OF_RESOURCE ; } tmp2 = strdup ( b ) ; if ( NULL == tmp2 ) { free ( tmp1 ) ; return PRTE_ERR_OUT_OF_RESOURCE ; } p1 = strchr ( tmp1 , ' ' ) ; p2 = strchr ( tmp2 , ' ' ) ; if ( NULL != p1 ) { * p1 = ' \0 ' ; } if ( NULL != p2 ) { * p2 = ' \0 ' ; } min = strlen ( tmp1 ) ; if ( strlen ( tmp2 ) < min ) { min = strlen ( tmp2 ) ; } if ( 0 == min || 0 == strncmp ( tmp1 , tmp2 , min ) ) { rc = PRTE_SUCCESS ; } free ( tmp1 ) ; free ( tmp2 ) ; return rc ; } return PRTE_ERROR ; }
Returns PRTE_SUCCESS if the strings match; PRTE_ERROR otherwise.
Returns PRTE_SUCCESS if the strings match ; PRTE_ERROR otherwise .
/* Check straight string match first */ /* No match */