{
assert(s1 != NULL && s2 != NULL);
- for (; n > 0 && *s1 != '\0' && *s2 != '\0'; n--, s1++, s2++) {
+ for (; *s1 != '\0' && *s2 != '\0' && n > 0; s1++, s2++, n--) {
if (tolower(*s1) != tolower(*s2))
break;
}
s1_mb = charalloc(MB_CUR_MAX);
s2_mb = charalloc(MB_CUR_MAX);
- while (n > 0 && *s1 != '\0' && *s2 != '\0') {
+ while (*s1 != '\0' && *s2 != '\0' && n > 0) {
bool bad_s1_mb = FALSE, bad_s2_mb = FALSE;
int s1_mb_len, s2_mb_len;
for (; *haystack != '\0'; haystack++) {
const char *r = haystack, *q = needle;
- for (; tolower(*r) == tolower(*q) && *q != '\0'; r++, q++)
+ for (; *q != '\0' && tolower(*r) == tolower(*q); r++, q++)
;
if (*q == '\0')
for (; rev_start >= haystack; rev_start--) {
const char *r, *q;
- for (r = rev_start, q = needle; *r == *q && *q != '\0'; r++, q++)
+ for (r = rev_start, q = needle; *q != '\0' && *r == *q; r++, q++)
;
if (*q == '\0')
for (; rev_start >= haystack; rev_start--) {
const char *r = rev_start, *q = needle;
- for (; tolower(*r) == tolower(*q) && *q != '\0'; r++, q++)
+ for (; *q != '\0' && tolower(*r) == tolower(*q); r++, q++)
;
if (*q == '\0')
assert(s != NULL);
- for (; maxlen > 0 && *s != '\0'; maxlen--, n++, s++)
+ for (; *s != '\0' && maxlen > 0; s++, maxlen--, n++)
;
return n;
if (maxlen == 0)
break;
- maxlen--;
s += s_mb_len;
+ maxlen--;
n++;
}