/* * check if two wildcard paths are equal. Returns TRUE or FALSE. * They are equal if: * - both paths are NULL * - they have the same length * - char by char comparison is OK * - the only differences are in the counters behind a '**', so * '**\20' is equal to '**\24' */ static int ff_wc_equal(char_u *s1, char_u *s2) { int i; int prev1 = NUL; int prev2 = NUL; if (s1 == s2) return TRUE; if (s1 == NULL || s2 == NULL) return FALSE; if (STRLEN(s1) != STRLEN(s2)) return FAIL; for (i = 0; s1[i] != NUL && s2[i] != NUL; i += MB_PTR2LEN(s1 + i)) { int c1 = PTR2CHAR(s1 + i); int c2 = PTR2CHAR(s2 + i); if ((p_fic ? vim_tolower(c1) != vim_tolower(c2) : c1 != c2) && (prev1 != '*' || prev2 != '*')) return FAIL; prev2 = prev1; prev1 = c1; } return TRUE; }
// Check if two wildcard paths are equal. // They are equal if: // - both paths are NULL // - they have the same length // - char by char comparison is OK // - the only differences are in the counters behind a '**', so // '**\20' is equal to '**\24' static bool ff_wc_equal(char_u *s1, char_u *s2) { int i, j; int c1 = NUL; int c2 = NUL; int prev1 = NUL; int prev2 = NUL; if (s1 == s2) { return true; } if (s1 == NULL || s2 == NULL) { return false; } for (i = 0, j = 0; s1[i] != NUL && s2[j] != NUL;) { c1 = PTR2CHAR(s1 + i); c2 = PTR2CHAR(s2 + j); if ((p_fic ? vim_tolower(c1) != vim_tolower(c2) : c1 != c2) && (prev1 != '*' || prev2 != '*')) { return false; } prev2 = prev1; prev1 = c1; i += MB_PTR2LEN(s1 + i); j += MB_PTR2LEN(s2 + j); } return s1[i] == s2[j]; }