int raw_equal(const char *first, const char *second) { while(*first && *second) { if(raw_toupper(*first) != raw_toupper(*second)) /* get out of the loop as soon as they don't match */ break; first++; second++; } /* we do the comparison here (possibly again), just to make sure that if the loop above is skipped because one of the strings reached zero, we must not return this as a successful match */ return (raw_toupper(*first) == raw_toupper(*second)); }
int strncasecompare(const char *first, const char *second, size_t max) { while(*first && *second && max) { if(raw_toupper(*first) != raw_toupper(*second)) { break; } max--; first++; second++; } if(0 == max) return 1; /* they are equal this far */ return raw_toupper(*first) == raw_toupper(*second); }
int _alpm_raw_ncmp(const char *first, const char *second, size_t max) { while(*first && *second && max) { if(raw_toupper(*first) != raw_toupper(*second)) { break; } max--; first++; second++; } if(0 == max) { /* they are equal this far */ return 0; } return (raw_toupper(*first) - raw_toupper(*second)); }