Ticket #56: rpm-tilde-support.diff

File rpm-tilde-support.diff, 1.7 kB (added by jengelh, 9 months ago)

4.7 rpm tilde patch for vercmp

  • a/lib/rpmvercmp.c

    old new  
    3333 
    3434    /* loop through each version segment of str1 and str2 and compare them */ 
    3535    while (*one && *two) { 
    36         while (*one && !risalnum(*one)) one++; 
    37         while (*two && !risalnum(*two)) two++; 
     36        while (*one && !risalnum(*one) && *one != '~') one++; 
     37        while (*two && !risalnum(*two) && *two != '~') two++; 
    3838 
    3939        /* If we ran to the end of either, we are finished with the loop */ 
    4040        if (!(*one && *two)) break; 
    4141 
     42        /* If exactly one side has a tilde, it is decided. */ 
     43        if ((*one == '~') ^ (*two == '~')) 
     44                break; 
     45 
    4246        str1 = one; 
    4347        str2 = two; 
    4448 
     
    103107    /* this catches the case where all numeric and alpha segments have */ 
    104108    /* compared identically but the segment sepparating characters were */ 
    105109    /* different */ 
     110    if (*two == '~') 
     111        return 1; 
     112    else if (*one == '~') 
     113        return -1; 
     114 
    106115    if ((!*one) && (!*two)) return 0; 
    107116 
    108117    /* whichever version still has characters left over wins */