zephyr/lib/libc/minimal/source/string/strncasecmp.c
Patrik Flykt 186fb94bcb lib: Add 'U' to unsigned variable assignments
Add 'U' to a value when assigning it to an unsigned variable.
MISRA-C rule 7.2

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2018-12-04 22:51:56 -05:00

29 lines
435 B
C

/*
* Copyright (c) 2018 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdlib.h>
#include <ctype.h>
int
strncasecmp(const char *s1, const char *s2, size_t n)
{
unsigned char c = 1U;
for (; c && n != 0; n--) {
unsigned char lower1, lower2;
c = *s1++;
lower1 = tolower(c);
lower2 = tolower(*s2++);
if (lower1 != lower2) {
return (lower1 > lower2) - (lower1 < lower2);
}
}
return 0;
}