summaryrefslogtreecommitdiffstats
path: root/newlib/libc/string/wcsncasecmp.c
diff options
context:
space:
mode:
Diffstat (limited to 'newlib/libc/string/wcsncasecmp.c')
-rw-r--r--newlib/libc/string/wcsncasecmp.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/newlib/libc/string/wcsncasecmp.c b/newlib/libc/string/wcsncasecmp.c
index 1634ca195..c6fc08ef6 100644
--- a/newlib/libc/string/wcsncasecmp.c
+++ b/newlib/libc/string/wcsncasecmp.c
@@ -49,16 +49,13 @@ _DEFUN (wcsncasecmp, (s1, s2, n),
_CONST wchar_t *s2 _AND
size_t n)
{
- if (n == 0)
- return 0;
-
- while (n-- != 0 && towlower(*s1) == towlower(*s2))
+ int d = 0;
+ for ( ; n != 0; n--)
{
- if (n == 0 || *s1 == '\0' || *s2 == '\0')
- break;
- s1++;
- s2++;
+ const int c1 = towlower (*s1++);
+ const int c2 = towlower (*s2++);
+ if (((d = c1 - c2) != 0) || (c2 == '\0'))
+ break;
}
-
- return towlower(*s1) - towlower(*s2);
+ return d;
}