mirror of
https://github.com/yanyiwu/cppjieba.git
synced 2025-07-18 00:00:12 +08:00
使用 uint8_t 通过 UBSAN 测试
This commit is contained in:
parent
61f2031e4b
commit
2b522b20ff
@ -204,7 +204,7 @@ namespace Limonp
|
|||||||
vec.push_back(str[i]);
|
vec.push_back(str[i]);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
else if ((unsigned char)str[i] <= 0xdf && i + 1 < len) // 110xxxxxx
|
else if ((uint8_t)str[i] <= 0xdf && i + 1 < len) // 110xxxxxx
|
||||||
{
|
{
|
||||||
ch1 = (str[i] >> 2) & 0x07;
|
ch1 = (str[i] >> 2) & 0x07;
|
||||||
ch2 = (str[i+1] & 0x3f) | ((str[i] & 0x03) << 6 );
|
ch2 = (str[i+1] & 0x3f) | ((str[i] & 0x03) << 6 );
|
||||||
@ -212,10 +212,10 @@ namespace Limonp
|
|||||||
vec.push_back(tmp);
|
vec.push_back(tmp);
|
||||||
i += 2;
|
i += 2;
|
||||||
}
|
}
|
||||||
else if((unsigned char)str[i] <= 0xef && i + 2 < len)
|
else if((uint8_t)str[i] <= 0xef && i + 2 < len)
|
||||||
{
|
{
|
||||||
ch1 = (str[i] << 4) | ((str[i+1] >> 2) & 0x0f );
|
ch1 = ((uint8_t)str[i] << 4) | ((str[i+1] >> 2) & 0x0f );
|
||||||
ch2 = ((str[i+1]<<6) & 0xc0) | (str[i+2] & 0x3f);
|
ch2 = (((uint8_t)str[i+1]<<6) & 0xc0) | (str[i+2] & 0x3f);
|
||||||
tmp = (((uint16_t(ch1) & 0x00ff ) << 8) | (uint16_t(ch2) & 0x00ff));
|
tmp = (((uint16_t(ch1) & 0x00ff ) << 8) | (uint16_t(ch2) & 0x00ff));
|
||||||
vec.push_back(tmp);
|
vec.push_back(tmp);
|
||||||
i += 3;
|
i += 3;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user