Skip to content

Commit

Permalink
Fix utf8ncasecmp bug, not allowing for negative return. Add test case…
Browse files Browse the repository at this point in the history
…/example.
  • Loading branch information
lrpereira authored and sheredom committed Dec 20, 2023
1 parent e69ff90 commit 535001e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions test/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1210,6 +1210,10 @@ UTEST(utf8ncasecmp, basic_ascii) {
#endif
}

UTEST(utf8ncasecmp, latin_extended_a) {
ASSERT_EQ(96, utf8ncasecmp("Camón Romasan", "camu", 4));
}

UTEST(utf8codepoint, data) {
utf8_int32_t codepoint;
void *v;
Expand Down
6 changes: 3 additions & 3 deletions utf8.h
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ utf8_constexpr14_impl int utf8ncasecmp(const utf8_int8_t *src1,
const utf8_int32_t c1 = (0xe0 & *s1);
const utf8_int32_t c2 = (0xe0 & *s2);

if (c1 < c2) {
if (c1 != c2) {
return c1 - c2;
} else {
return 0;
Expand All @@ -579,7 +579,7 @@ utf8_constexpr14_impl int utf8ncasecmp(const utf8_int8_t *src1,
const utf8_int32_t c1 = (0xf0 & *s1);
const utf8_int32_t c2 = (0xf0 & *s2);

if (c1 < c2) {
if (c1 != c2) {
return c1 - c2;
} else {
return 0;
Expand All @@ -590,7 +590,7 @@ utf8_constexpr14_impl int utf8ncasecmp(const utf8_int8_t *src1,
const utf8_int32_t c1 = (0xf8 & *s1);
const utf8_int32_t c2 = (0xf8 & *s2);

if (c1 < c2) {
if (c1 != c2) {
return c1 - c2;
} else {
return 0;
Expand Down

0 comments on commit 535001e

Please sign in to comment.