forked from github/server
fix an endless loop in unicode_utf8_to_cp437 for characters not in the table.
This commit is contained in:
parent
23b9774495
commit
8728fccaec
|
@ -506,10 +506,14 @@ size_t * length)
|
||||||
*cp_character = (char)xref[m].cp437;
|
*cp_character = (char)xref[m].cp437;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (xref[m].ucs4 < ucs4_character)
|
else if (xref[m].ucs4 < ucs4_character) {
|
||||||
l = m;
|
if (l == m) l = r;
|
||||||
else
|
else l = m;
|
||||||
r = m;
|
}
|
||||||
|
else {
|
||||||
|
if (r == m) r = l;
|
||||||
|
else r = m;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (l == r) {
|
if (l == r) {
|
||||||
*cp_character = '?';
|
*cp_character = '?';
|
||||||
|
|
|
@ -16,9 +16,20 @@ static void test_unicode_tolower(CuTest * tc)
|
||||||
CuAssertStrEquals(tc, "helloX", buffer);
|
CuAssertStrEquals(tc, "helloX", buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_unicode_utf8_to_cp437(CuTest *tc)
|
||||||
|
{
|
||||||
|
const char utf8_str[4] = { 0xc3, 0x98, 'l', 0 }; // Øl
|
||||||
|
char ch;
|
||||||
|
size_t sz;
|
||||||
|
CuAssertIntEquals(tc, 0, unicode_utf8_to_cp437(&ch, utf8_str, &sz));
|
||||||
|
CuAssertIntEquals(tc, 2, sz);
|
||||||
|
CuAssertIntEquals(tc, '?', ch);
|
||||||
|
}
|
||||||
|
|
||||||
CuSuite *get_unicode_suite(void)
|
CuSuite *get_unicode_suite(void)
|
||||||
{
|
{
|
||||||
CuSuite *suite = CuSuiteNew();
|
CuSuite *suite = CuSuiteNew();
|
||||||
SUITE_ADD_TEST(suite, test_unicode_tolower);
|
SUITE_ADD_TEST(suite, test_unicode_tolower);
|
||||||
|
SUITE_ADD_TEST(suite, test_unicode_utf8_to_cp437);
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue