usp10: Handle CR/LF in ScriptItemize.

This commit is contained in:
Hans Leidekker 2009-01-06 11:20:41 +01:00 committed by Alexandre Julliard
parent 020456f71b
commit 8a5eae2122
2 changed files with 57 additions and 4 deletions

View File

@ -1426,6 +1426,43 @@ static void test_ScriptBreak(void)
ok(!la.fReserved, "fReserved set\n");
}
static void test_newlines(void)
{
static const WCHAR test1[] = {'t','e','x','t','\r','t','e','x','t',0};
static const WCHAR test2[] = {'t','e','x','t','\n','t','e','x','t',0};
static const WCHAR test3[] = {'t','e','x','t','\r','\n','t','e','x','t',0};
static const WCHAR test4[] = {'t','e','x','t','\n','\r','t','e','x','t',0};
static const WCHAR test5[] = {'1','2','3','4','\n','\r','1','2','3','4',0};
SCRIPT_ITEM items[5];
HRESULT hr;
int count;
count = 0;
hr = ScriptItemize(test1, lstrlenW(test1), 5, NULL, NULL, items, &count);
ok(hr == S_OK, "ScriptItemize failed: 0x%08x\n", hr);
ok(count == 3, "got %d expected 3\n", count);
count = 0;
hr = ScriptItemize(test2, lstrlenW(test2), 5, NULL, NULL, items, &count);
ok(hr == S_OK, "ScriptItemize failed: 0x%08x\n", hr);
ok(count == 3, "got %d expected 3\n", count);
count = 0;
hr = ScriptItemize(test3, lstrlenW(test3), 5, NULL, NULL, items, &count);
ok(hr == S_OK, "ScriptItemize failed: 0x%08x\n", hr);
ok(count == 4, "got %d expected 4\n", count);
count = 0;
hr = ScriptItemize(test4, lstrlenW(test4), 5, NULL, NULL, items, &count);
ok(hr == S_OK, "ScriptItemize failed: 0x%08x\n", hr);
ok(count == 4, "got %d expected 4\n", count);
count = 0;
hr = ScriptItemize(test5, lstrlenW(test5), 5, NULL, NULL, items, &count);
ok(hr == S_OK, "ScriptItemize failed: 0x%08x\n", hr);
ok(count == 4, "got %d expected 4\n", count);
}
START_TEST(usp10)
{
HWND hwnd;
@ -1471,6 +1508,7 @@ START_TEST(usp10)
test_digit_substitution();
test_ScriptGetProperties();
test_ScriptBreak();
test_newlines();
ReleaseDC(hwnd, hdc);
DestroyWindow(hwnd);

View File

@ -519,6 +519,8 @@ HRESULT WINAPI ScriptItemize(const WCHAR *pwcInChars, int cInChars, int cMaxItem
#define Script_Arabic 6
#define Script_Latin 1
#define Script_Numeric 5
#define Script_CR 22
#define Script_LF 23
int cnt = 0, index = 0;
int New_Script = SCRIPT_UNDEFINED;
@ -532,6 +534,12 @@ HRESULT WINAPI ScriptItemize(const WCHAR *pwcInChars, int cInChars, int cMaxItem
pItems[index].iCharPos = 0;
memset(&pItems[index].a, 0, sizeof(SCRIPT_ANALYSIS));
if (pwcInChars[cnt] == '\r')
pItems[index].a.eScript = Script_CR;
else
if (pwcInChars[cnt] == '\n')
pItems[index].a.eScript = Script_LF;
else
if (pwcInChars[cnt] >= Numeric_start && pwcInChars[cnt] <= Numeric_stop)
pItems[index].a.eScript = Script_Numeric;
else
@ -546,10 +554,16 @@ HRESULT WINAPI ScriptItemize(const WCHAR *pwcInChars, int cInChars, int cMaxItem
TRACE("New_Script=%d, eScript=%d index=%d cnt=%d iCharPos=%d\n",
New_Script, pItems[index].a.eScript, index, cnt,
pItems[index].iCharPos = cnt);
pItems[index].iCharPos);
for (cnt=0; cnt < cInChars; cnt++)
for (cnt=1; cnt < cInChars; cnt++)
{
if (pwcInChars[cnt] == '\r')
New_Script = Script_CR;
else
if (pwcInChars[cnt] == '\n')
New_Script = Script_LF;
else
if ((pwcInChars[cnt] >= Numeric_start && pwcInChars[cnt] <= Numeric_stop)
|| (New_Script == Script_Numeric && pwcInChars[cnt] == Numeric_space))
New_Script = Script_Numeric;
@ -558,7 +572,8 @@ HRESULT WINAPI ScriptItemize(const WCHAR *pwcInChars, int cInChars, int cMaxItem
|| (New_Script == Script_Arabic && pwcInChars[cnt] == Numeric_space))
New_Script = Script_Arabic;
else
if ((WCHAR) pwcInChars[cnt] >= Latin_start && (WCHAR) pwcInChars[cnt] <= Latin_stop)
if ((pwcInChars[cnt] >= Latin_start && pwcInChars[cnt] <= Latin_stop)
|| (New_Script == Script_Latin && pwcInChars[cnt] == Numeric_space))
New_Script = Script_Latin;
else
New_Script = SCRIPT_UNDEFINED;
@ -580,7 +595,7 @@ HRESULT WINAPI ScriptItemize(const WCHAR *pwcInChars, int cInChars, int cMaxItem
if (New_Script == Script_Arabic)
pItems[index].a.s.uBidiLevel = 1;
TRACE("index=%d cnt=%d iCharPos=%d\n", index, cnt, pItems[index].iCharPos = cnt);
TRACE("index=%d cnt=%d iCharPos=%d\n", index, cnt, pItems[index].iCharPos);
}
}