Skip to content

Commit

Permalink
Change ASCII test logic to use DBCS functions.
Browse files Browse the repository at this point in the history
When using clang, using (if char > 0) may not work properly since char
may be either signed or unsigned.
  • Loading branch information
hungte committed Sep 4, 2015
1 parent 76afd31 commit b58900a
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions common/sys/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,17 +417,8 @@ DBCS_strcasestr(const char* pool, const char *ptr)
// compare szpool[i..szptr] with ptr
for (i2 = 0; i2 < szptr; i2++)
{
if (pool[i + i2] > 0)
if (IS_DBCSLEAD(pool[i + i2]))
{
// ascii
if (IS_DBCSLEAD(ptr[i2]) ||
tolower(ptr[i2]) != tolower(pool[i+i2]))
{
// printf("break on ascii (i=%d, i2=%d).\n", i, i2);
found = 0;
break;
}
} else {
// non-ascii
if (ptr[i2] != pool[i+i2] ||
ptr[i2+1] != pool[i+i2+1])
Expand All @@ -437,6 +428,15 @@ DBCS_strcasestr(const char* pool, const char *ptr)
break;
}
i2 ++;
} else {
// ascii
if (IS_DBCSLEAD(ptr[i2]) ||
tolower(ptr[i2]) != tolower(pool[i+i2]))
{
// printf("break on ascii (i=%d, i2=%d).\n", i, i2);
found = 0;
break;
}
}
}

Expand Down

0 comments on commit b58900a

Please sign in to comment.