From 9a59d81f7254cd6e4b99822e2f0cf997ae80e9f7 Mon Sep 17 00:00:00 2001 From: Aric Stewart Date: Thu, 14 Feb 2013 12:10:31 -0600 Subject: [PATCH] usp10: Correct error with ScriptLayout log2vis. Issue found and test written by Huw Davies. --- dlls/usp10/bidi.c | 6 ++++-- dlls/usp10/tests/usp10.c | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/dlls/usp10/bidi.c b/dlls/usp10/bidi.c index a2edfa6c73..3b1823f0f2 100644 --- a/dlls/usp10/bidi.c +++ b/dlls/usp10/bidi.c @@ -872,11 +872,13 @@ int BIDI_ReorderL2vLevel(int level, int *pIndexs, const BYTE* plevel, int cch, B reverse(pIndexs, ich); } - if (newlevel > 1) + if (newlevel >= 0) { ich = 0; for (; ich < cch; ich++) - if (plevel[ich] > level) + if (plevel[ich] < level) + break; + else if (plevel[ich] > level) ich += BIDI_ReorderL2vLevel(level + 1, pIndexs + ich, plevel + ich, cch - ich, fReverse) - 1; } diff --git a/dlls/usp10/tests/usp10.c b/dlls/usp10/tests/usp10.c index 7752f2c023..354bc23482 100644 --- a/dlls/usp10/tests/usp10.c +++ b/dlls/usp10/tests/usp10.c @@ -2786,6 +2786,11 @@ static void test_ScriptLayout(void) { 0, 0, 1, 1, 2, 2, 1, 1, 0, 1 }, { 1, 0, 1, 2, 2, 1, 2, 1, 0, 1 }, + + { 1, 2, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 2, 2, 2, 0, 0, 0, 0, 0, 0, 0 }, + { 2, 2, 2, 4, 4, 4, 1, 1, 0, 0 }, + { 1, 2, 3, 0, 3, 2, 1, 0, 0, 0 } }; static const int expect_l2v[][10] = { @@ -2802,6 +2807,11 @@ static void test_ScriptLayout(void) { 0, 1, 7, 6, 4, 5, 3 ,2 ,8, 9}, /**/ { 0, 1, 7, 5, 6, 4, 3 ,2 ,8, 9}, + + { 1, 0, 2, 3, 4, 5, 6, 7, 8, 9}, + { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, + { 2, 3, 4, 5, 6, 7, 1, 0, 8, 9}, + { 2, 0, 1, 3, 5, 6, 4, 7, 8, 9} }; static const int expect_v2l[][10] = { @@ -2818,6 +2828,11 @@ static void test_ScriptLayout(void) { 0, 1, 7, 6, 4, 5, 3 ,2 ,8, 9}, { 0, 1, 7, 6, 5, 3, 4 ,2 ,8, 9}, + + { 1, 0, 2, 3, 4, 5, 6, 7, 8, 9}, + { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, + { 7, 6, 0, 1, 2, 3, 4, 5, 8, 9}, + { 1, 2, 0, 3, 6, 4, 5, 7, 8, 9} }; int i, j, vistolog[sizeof(levels[0])], logtovis[sizeof(levels[0])];