Module: wine
Branch: master
Commit: a7fc0c65c1dcf4a1d40476f99713524e1bbb00c0
URL: http://source.winehq.org/git/wine.git/?a=commit;h=a7fc0c65c1dcf4a1d40476f99…
Author: Jeff Latimer <lats(a)yless4u.com.au>
Date: Tue Apr 27 22:43:43 2010 +1000
usp10/tests: Remove some redundant tests and fully test bidi flag setting.
---
dlls/usp10/tests/usp10.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/dlls/usp10/tests/usp10.c b/dlls/usp10/tests/usp10.c
index 5ba4315..002748a 100644
--- a/dlls/usp10/tests/usp10.c
+++ b/dlls/usp10/tests/usp10.c
@@ -806,8 +806,6 @@ static void test_ScriptItemIzeShapePlace(HDC hdc, unsigned short pwOutGlyphs[256
"Start pos [2] not = 11 (%d) or end [3] pos not = 14 (%d), cInChars = %d\n",
pItem[2].iCharPos, pItem[3].iCharPos, cInChars);
}
- hr = ScriptFreeCache( &psc);
- ok (!psc, "psc is not null after ScriptFreeCache\n");
}
/* This is a valid test that will cause parsing to take place and create 5 script_items */
@@ -823,21 +821,27 @@ static void test_ScriptItemIzeShapePlace(HDC hdc, unsigned short pwOutGlyphs[256
ok (pItem[0].iCharPos == 0 && pItem[1].iCharPos == 6,
"Start pos [0] not = 0 (%d) or end pos [1] not = %d\n",
pItem[0].iCharPos, pItem[1].iCharPos);
+ ok (pItem[0].a.s.uBidiLevel == 0, "Should have been bidi=0 not %d\n",
+ pItem[0].a.s.uBidiLevel);
ok (pItem[1].iCharPos == 6 && pItem[2].iCharPos == 11,
"Start pos [1] not = 6 (%d) or end pos [2] not = 11 (%d)\n",
pItem[1].iCharPos, pItem[2].iCharPos);
+ ok (pItem[1].a.s.uBidiLevel == 1, "Should have been bidi=1 not %d\n",
+ pItem[1].a.s.uBidiLevel);
ok (pItem[2].iCharPos == 11 && pItem[3].iCharPos == 12,
"Start pos [2] not = 11 (%d) or end [3] pos not = 12 (%d)\n",
pItem[2].iCharPos, pItem[3].iCharPos);
+ ok (pItem[2].a.s.uBidiLevel == 0, "Should have been bidi=0 not %d\n",
+ pItem[2].a.s.uBidiLevel);
ok (pItem[3].iCharPos == 12 && pItem[4].iCharPos == 13,
"Start pos [3] not = 12 (%d) or end [4] pos not = 13 (%d)\n",
pItem[3].iCharPos, pItem[4].iCharPos);
+ ok (pItem[3].a.s.uBidiLevel == 0, "Should have been bidi=0 not %d\n",
+ pItem[3].a.s.uBidiLevel);
ok (pItem[4].iCharPos == 13 && pItem[5].iCharPos == cInChars,
"Start pos [4] not = 13 (%d) or end [5] pos not = 16 (%d), cInChars = %d\n",
pItem[4].iCharPos, pItem[5].iCharPos, cInChars);
}
- hr = ScriptFreeCache( &psc);
- ok (!psc, "psc is not null after ScriptFreeCache\n");
}
/*
Module: wine
Branch: master
Commit: b367e902c9cafb1dfa5f35e52bf89377dd608ac6
URL: http://source.winehq.org/git/wine.git/?a=commit;h=b367e902c9cafb1dfa5f35e52…
Author: Jeff Latimer <lats(a)yless4u.com.au>
Date: Tue Apr 27 22:43:34 2010 +1000
usp10: Check that there are sufficient script_items before setting the last pointer.
---
dlls/usp10/tests/usp10.c | 10 ++++++++++
dlls/usp10/usp10.c | 11 ++++++-----
2 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/dlls/usp10/tests/usp10.c b/dlls/usp10/tests/usp10.c
index 124526b..5ba4315 100644
--- a/dlls/usp10/tests/usp10.c
+++ b/dlls/usp10/tests/usp10.c
@@ -673,6 +673,7 @@ static void test_ScriptItemIzeShapePlace(HDC hdc, unsigned short pwOutGlyphs[256
WCHAR TestItem3[] = {'T', 'e', 's', 't', 'c',' ','1','2','3',' ',' ','e','n','d',0};
WCHAR TestItem4[] = {'T', 'e', 's', 't', 'd',' ',0x0684,0x0694,0x06a4,' ',' ','\r','\n','e','n','d',0};
WCHAR TestItem5[] = {0x0684,'T','e','s','t','e',' ',0x0684,0x0694,0x06a4,' ',' ','e','n','d',0};
+ WCHAR TestItem6[] = {'T', 'e', 's', 't', 'f',' ',' ',' ','\r','\n','e','n','d',0};
SCRIPT_CACHE psc;
int cChars;
@@ -848,6 +849,15 @@ static void test_ScriptItemIzeShapePlace(HDC hdc, unsigned short pwOutGlyphs[256
ok (pcItems == 4, "There should have been 4 items, found %d\n", pcItems);
ok (pItem[0].a.s.uBidiLevel == 1, "The first character should have been bidi=1 not %d\n",
pItem[0].a.s.uBidiLevel);
+
+ /* This test checks to make sure that the test to see if there are sufficient buffers to store *
+ * the pointer to the last char works. Note that windows often needs a greater number of *
+ * SCRIPT_ITEMS to process a string than is returned in pcItems. */
+ cInChars = (sizeof(TestItem6)/2)-1;
+ cMaxItems = 4;
+ hr = ScriptItemize(TestItem6, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems);
+ ok (hr == E_OUTOFMEMORY, "ScriptItemize should return E_OUTOFMEMORY, returned %08x\n", hr);
+
}
static void test_ScriptGetCMap(HDC hdc, unsigned short pwOutGlyphs[256])
diff --git a/dlls/usp10/usp10.c b/dlls/usp10/usp10.c
index 201a74a..eebc8ab 100644
--- a/dlls/usp10/usp10.c
+++ b/dlls/usp10/usp10.c
@@ -669,16 +669,17 @@ HRESULT WINAPI ScriptItemize(const WCHAR *pwcInChars, int cInChars, int cMaxItem
/* While not strictly necessary according to the spec, make sure the n+1
* item is set up to prevent random behaviour if the caller erroneously
* checks the n+1 structure */
- memset(&pItems[index+1].a, 0, sizeof(SCRIPT_ANALYSIS));
+ index++;
+ memset(&pItems[index].a, 0, sizeof(SCRIPT_ANALYSIS));
- TRACE("index=%d cnt=%d iCharPos=%d\n", index+1, cnt, pItems[index+1].iCharPos);
+ TRACE("index=%d cnt=%d iCharPos=%d\n", index, cnt, pItems[index].iCharPos);
/* Set one SCRIPT_STATE item being returned */
- if (pcItems) *pcItems = index + 1;
+ if (index + 1 > cMaxItems) return E_OUTOFMEMORY;
+ if (pcItems) *pcItems = index;
/* Set SCRIPT_ITEM */
- pItems[index+1].iCharPos = cnt; /* the last + 1 item
- contains the ptr to the lastchar */
+ pItems[index].iCharPos = cnt; /* the last item contains the ptr to the lastchar */
heap_free(levels);
return S_OK;
}