! \brief compare str to str */
| 417 | |
| 418 | /*! \brief compare str to str */ |
| 419 | inline static int comp_s2s(int op, str *s1, str *s2) |
| 420 | { |
| 421 | #define make_nt_copy(_sd,_so) \ |
| 422 | do { \ |
| 423 | if (pkg_str_extend(_sd, (_so)->len+1)<0) \ |
| 424 | return -1; \ |
| 425 | memcpy((_sd)->s, (_so)->s, (_so)->len);\ |
| 426 | (_sd)->s[(_so)->len] = '\0'; \ |
| 427 | } while(0) |
| 428 | static str cp1 = {NULL,0}; |
| 429 | static str cp2 = {NULL,0}; |
| 430 | int rt; |
| 431 | int ret; |
| 432 | regex_t* re; |
| 433 | |
| 434 | ret = -1; |
| 435 | /* check the input values : |
| 436 | * s1 - must be a non-empty string |
| 437 | * s2 - must be a non-empty string or a regexp* for [NOT]MATCH_OP */ |
| 438 | if ( s1->s==NULL ) |
| 439 | return 0; |
| 440 | |
| 441 | switch(op) { |
| 442 | case EQUAL_OP: |
| 443 | if ( s2->s==NULL) return 0; |
| 444 | ret = str_casematch(s1, s2); |
| 445 | break; |
| 446 | case DIFF_OP: |
| 447 | if ( s2->s==NULL ) return 0; |
| 448 | ret = !str_casematch(s1, s2); |
| 449 | break; |
| 450 | case GT_OP: |
| 451 | if ( s2->s==NULL ) return 0; |
| 452 | rt = str_strcasecmp(s1, s2); |
| 453 | if (rt>0) |
| 454 | ret = 1; |
| 455 | else if(rt==0 && s1->len>s2->len) |
| 456 | ret = 1; |
| 457 | else ret = 0; |
| 458 | break; |
| 459 | case GTE_OP: |
| 460 | if ( s2->s==NULL ) return 0; |
| 461 | rt = str_strcasecmp(s1, s2); |
| 462 | if (rt>0) |
| 463 | ret = 1; |
| 464 | else if(rt==0 && s1->len>=s2->len) |
| 465 | ret = 1; |
| 466 | else ret = 0; |
| 467 | break; |
| 468 | case LT_OP: |
| 469 | if ( s2->s==NULL ) return 0; |
| 470 | rt = str_strcasecmp(s1, s2); |
| 471 | if (rt<0) |
| 472 | ret = 1; |
| 473 | else if(rt==0 && s1->len<s2->len) |
| 474 | ret = 1; |
| 475 | else ret = 0; |
| 476 | break; |
no test coverage detected