Commit e54bee44 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

usp10: Properly check for numeric scripts.

parent ae1c02a2
...@@ -575,18 +575,18 @@ static const itemTest t74[4] = {{{0,0,0,0,0,0},0,0,0,0,1,latn_tag,FALSE}, ...@@ -575,18 +575,18 @@ static const itemTest t74[4] = {{{0,0,0,0,0,0},0,0,0,0,1,latn_tag,FALSE},
{{0,0,0,0,0,0}, 3,0,1,2,0,arab_tag,FALSE},{{0,1,0,1,0,0}, 6,0,1,2,0,arab_tag,FALSE}, {{0,0,0,0,0,0}, 3,0,1,2,0,arab_tag,FALSE},{{0,1,0,1,0,0}, 6,0,1,2,0,arab_tag,FALSE},
{{0,0,0,0,0,0}, 7,0,1,2,0,arab_tag,FALSE},{{0,1,0,1,0,0},10,0,1,2,0,arab_tag,FALSE}, {{0,0,0,0,0,0}, 7,0,1,2,0,arab_tag,FALSE},{{0,1,0,1,0,0},10,0,1,2,0,arab_tag,FALSE},
{{0,0,0,0,0,0},11,0,1,2,0,arab_tag,FALSE},{{0,0,0,0,0,0},13,0,0,0,0,-1,FALSE}}; {{0,0,0,0,0,0},11,0,1,2,0,arab_tag,FALSE},{{0,0,0,0,0,0},13,0,0,0,0,-1,FALSE}};
static const itemTest t572[] = {{{0,0,0,1,0,0}, 0,0,0,2,0,arab_tag,FALSE},{{0,0,1,0,0,0}, 2,0,1,2,0,arab_tag,FALSE}, static const itemTest t572[] = {{{0,0,0,0,0,0}, 0,0,0,2,0,arab_tag,FALSE},{{0,0,1,0,0,0}, 2,0,1,2,0,arab_tag,FALSE},
{{0,0,0,1,0,0}, 3,0,0,2,0,arab_tag,FALSE},{{0,0,1,0,0,0}, 6,0,1,2,0,arab_tag,FALSE}, {{0,0,0,0,0,0}, 3,0,0,2,0,arab_tag,FALSE},{{0,0,1,0,0,0}, 6,0,1,2,0,arab_tag,FALSE},
{{0,0,0,1,0,0}, 7,0,0,2,0,arab_tag,FALSE},{{0,0,1,0,0,0},10,0,1,2,0,arab_tag,FALSE}, {{0,0,0,0,0,0}, 7,0,0,2,0,arab_tag,FALSE},{{0,0,1,0,0,0},10,0,1,2,0,arab_tag,FALSE},
{{0,0,0,1,0,0},11,0,0,2,0,arab_tag,FALSE},{{0,0,0,0,0,0},13,0,0,0,0,-1,FALSE}}; {{0,0,0,0,0,0},11,0,0,2,0,arab_tag,FALSE},{{0,0,0,0,0,0},13,0,0,0,0,-1,FALSE}};
static const itemTest t573[] = {{{0,0,0,0,0,0}, 0,0,0,0,1,arab_tag,FALSE},{{0,0,0,0,0,0}, 2,0,0,0,1,arab_tag,FALSE}, static const itemTest t573[] = {{{0,0,0,0,0,0}, 0,0,0,0,1,arab_tag,FALSE},{{0,0,0,0,0,0}, 2,0,0,0,1,arab_tag,FALSE},
{{0,0,0,0,0,0}, 3,0,0,0,1,arab_tag,FALSE},{{0,0,0,0,0,0}, 6,0,0,0,1,arab_tag,FALSE}, {{0,0,0,0,0,0}, 3,0,0,0,1,arab_tag,FALSE},{{0,0,0,0,0,0}, 6,0,0,0,1,arab_tag,FALSE},
{{0,0,0,0,0,0}, 7,0,0,0,1,arab_tag,FALSE},{{0,0,0,0,0,0},10,0,0,0,1,arab_tag,FALSE}, {{0,0,0,0,0,0}, 7,0,0,0,1,arab_tag,FALSE},{{0,0,0,0,0,0},10,0,0,0,1,arab_tag,FALSE},
{{0,0,0,0,0,0},11,0,0,0,1,arab_tag,FALSE},{{0,0,0,0,0,0},13,0,0,0,0,-1,FALSE}}; {{0,0,0,0,0,0},11,0,0,0,1,arab_tag,FALSE},{{0,0,0,0,0,0},13,0,0,0,0,-1,FALSE}};
static const itemTest t574[] = {{{0,0,1,0,0,0}, 0,0,1,2,0,arab_tag,FALSE},{{0,0,1,0,0,0}, 2,0,1,2,0,arab_tag,FALSE}, static const itemTest t574[] = {{{0,0,0,0,0,0}, 0,0,1,2,0,arab_tag,FALSE},{{0,0,1,0,0,0}, 2,0,1,2,0,arab_tag,FALSE},
{{0,0,1,0,0,0}, 3,0,1,2,0,arab_tag,FALSE},{{0,0,1,0,0,0}, 6,0,1,2,0,arab_tag,FALSE}, {{0,0,0,0,0,0}, 3,0,1,2,0,arab_tag,FALSE},{{0,0,1,0,0,0}, 6,0,1,2,0,arab_tag,FALSE},
{{0,0,1,0,0,0}, 7,0,1,2,0,arab_tag,FALSE},{{0,0,1,0,0,0},10,0,1,2,0,arab_tag,FALSE}, {{0,0,0,0,0,0}, 7,0,1,2,0,arab_tag,FALSE},{{0,0,1,0,0,0},10,0,1,2,0,arab_tag,FALSE},
{{0,0,1,0,0,0},11,0,1,2,0,arab_tag,FALSE},{{0,0,0,0,0,0},13,0,0,0,0,-1,FALSE}}; {{0,0,0,0,0,0},11,0,1,2,0,arab_tag,FALSE},{{0,0,0,0,0,0},13,0,0,0,0,-1,FALSE}};
SCRIPT_ITEM items[15]; SCRIPT_ITEM items[15];
SCRIPT_CONTROL Control; SCRIPT_CONTROL Control;
......
...@@ -1253,6 +1253,10 @@ static inline WORD base_indic(WORD script) ...@@ -1253,6 +1253,10 @@ static inline WORD base_indic(WORD script)
}; };
} }
static BOOL script_is_numeric(WORD script)
{
return scriptInformation[script].props.fNumeric;
}
static HRESULT _ItemizeInternal(const WCHAR *pwcInChars, int cInChars, static HRESULT _ItemizeInternal(const WCHAR *pwcInChars, int cInChars,
int cMaxItems, const SCRIPT_CONTROL *psControl, int cMaxItems, const SCRIPT_CONTROL *psControl,
...@@ -1451,12 +1455,12 @@ static HRESULT _ItemizeInternal(const WCHAR *pwcInChars, int cInChars, ...@@ -1451,12 +1455,12 @@ static HRESULT _ItemizeInternal(const WCHAR *pwcInChars, int cInChars,
for (i = 0; i < cInChars; i++) for (i = 0; i < cInChars; i++)
{ {
if (i > 0 && i < cInChars-1 && if (i > 0 && i < cInChars-1 &&
scripts[i-1] == Script_Numeric && script_is_numeric(scripts[i-1]) &&
strchrW(math_punc, pwcInChars[i])) strchrW(math_punc, pwcInChars[i]))
{ {
if (scripts[i+1] == Script_Numeric) if (script_is_numeric(scripts[i+1]))
{ {
scripts[i] = Script_Numeric; scripts[i] = scripts[i+1];
levels[i] = levels[i-1]; levels[i] = levels[i-1];
strength[i] = strength[i-1]; strength[i] = strength[i-1];
i++; i++;
...@@ -1466,11 +1470,11 @@ static HRESULT _ItemizeInternal(const WCHAR *pwcInChars, int cInChars, ...@@ -1466,11 +1470,11 @@ static HRESULT _ItemizeInternal(const WCHAR *pwcInChars, int cInChars,
int j; int j;
for (j = i+1; j < cInChars; j++) for (j = i+1; j < cInChars; j++)
{ {
if (scripts[j] == Script_Numeric) if (script_is_numeric(scripts[j]))
{ {
for(;i<j; i++) for(;i<j; i++)
{ {
scripts[i] = Script_Numeric; scripts[i] = scripts[j];
levels[i] = levels[i-1]; levels[i] = levels[i-1];
strength[i] = strength[i-1]; strength[i] = strength[i-1];
} }
...@@ -1483,8 +1487,9 @@ static HRESULT _ItemizeInternal(const WCHAR *pwcInChars, int cInChars, ...@@ -1483,8 +1487,9 @@ static HRESULT _ItemizeInternal(const WCHAR *pwcInChars, int cInChars,
for (i = 0; i < cInChars; i++) for (i = 0; i < cInChars; i++)
{ {
/* Script_Numeric at level 0 get bumped to level 2 */ /* Numerics at level 0 get bumped to level 2 */
if (!overrides[i] && (levels[i] == 0 || (odd(psState->uBidiLevel) && levels[i] == psState->uBidiLevel+1)) && scripts[i] == Script_Numeric) if (!overrides[i] && (levels[i] == 0 || (odd(psState->uBidiLevel)
&& levels[i] == psState->uBidiLevel + 1)) && script_is_numeric(scripts[i]))
{ {
levels[i] = 2; levels[i] = 2;
} }
...@@ -1576,8 +1581,7 @@ static HRESULT _ItemizeInternal(const WCHAR *pwcInChars, int cInChars, ...@@ -1576,8 +1581,7 @@ static HRESULT _ItemizeInternal(const WCHAR *pwcInChars, int cInChars,
if (overrides) if (overrides)
pItems[index].a.s.fOverrideDirection = (overrides[cnt] != 0); pItems[index].a.s.fOverrideDirection = (overrides[cnt] != 0);
pItems[index].a.fRTL = odd(levels[cnt]); pItems[index].a.fRTL = odd(levels[cnt]);
if (pItems[index].a.eScript == Script_Numeric || if (script_is_numeric(pItems[index].a.eScript))
pItems[index].a.eScript == Script_Numeric2)
pItems[index].a.fLayoutRTL = layoutRTL; pItems[index].a.fLayoutRTL = layoutRTL;
else else
pItems[index].a.fLayoutRTL = pItems[index].a.fRTL; pItems[index].a.fLayoutRTL = pItems[index].a.fRTL;
...@@ -1590,8 +1594,7 @@ static HRESULT _ItemizeInternal(const WCHAR *pwcInChars, int cInChars, ...@@ -1590,8 +1594,7 @@ static HRESULT _ItemizeInternal(const WCHAR *pwcInChars, int cInChars,
layoutRTL = odd(baselayout); layoutRTL = odd(baselayout);
pItems[index].a.s.uBidiLevel = baselevel; pItems[index].a.s.uBidiLevel = baselevel;
pItems[index].a.fRTL = odd(baselevel); pItems[index].a.fRTL = odd(baselevel);
if (pItems[index].a.eScript == Script_Numeric || if (script_is_numeric(pItems[index].a.eScript))
pItems[index].a.eScript == Script_Numeric2)
pItems[index].a.fLayoutRTL = odd(baselayout); pItems[index].a.fLayoutRTL = odd(baselayout);
else else
pItems[index].a.fLayoutRTL = pItems[index].a.fRTL; pItems[index].a.fLayoutRTL = pItems[index].a.fRTL;
...@@ -1646,8 +1649,7 @@ static HRESULT _ItemizeInternal(const WCHAR *pwcInChars, int cInChars, ...@@ -1646,8 +1649,7 @@ static HRESULT _ItemizeInternal(const WCHAR *pwcInChars, int cInChars,
if (!new_run && strength && str == BIDI_STRONG) if (!new_run && strength && str == BIDI_STRONG)
{ {
layoutRTL = odd(layout_levels[cnt]); layoutRTL = odd(layout_levels[cnt]);
if (pItems[index].a.eScript == Script_Numeric || if (script_is_numeric(pItems[index].a.eScript))
pItems[index].a.eScript == Script_Numeric2)
pItems[index].a.fLayoutRTL = layoutRTL; pItems[index].a.fLayoutRTL = layoutRTL;
} }
...@@ -1677,8 +1679,7 @@ static HRESULT _ItemizeInternal(const WCHAR *pwcInChars, int cInChars, ...@@ -1677,8 +1679,7 @@ static HRESULT _ItemizeInternal(const WCHAR *pwcInChars, int cInChars,
else else
layoutRTL = (layoutRTL || odd(layout_levels[cnt])); layoutRTL = (layoutRTL || odd(layout_levels[cnt]));
pItems[index].a.fRTL = odd(levels[cnt]); pItems[index].a.fRTL = odd(levels[cnt]);
if (pItems[index].a.eScript == Script_Numeric || if (script_is_numeric(pItems[index].a.eScript))
pItems[index].a.eScript == Script_Numeric2)
pItems[index].a.fLayoutRTL = layoutRTL; pItems[index].a.fLayoutRTL = layoutRTL;
else else
pItems[index].a.fLayoutRTL = pItems[index].a.fRTL; pItems[index].a.fLayoutRTL = pItems[index].a.fRTL;
...@@ -1690,8 +1691,7 @@ static HRESULT _ItemizeInternal(const WCHAR *pwcInChars, int cInChars, ...@@ -1690,8 +1691,7 @@ static HRESULT _ItemizeInternal(const WCHAR *pwcInChars, int cInChars,
pItems[index].a.s.fOverrideDirection = TRUE; pItems[index].a.s.fOverrideDirection = TRUE;
pItems[index].a.s.uBidiLevel = baselevel; pItems[index].a.s.uBidiLevel = baselevel;
pItems[index].a.fRTL = odd(baselevel); pItems[index].a.fRTL = odd(baselevel);
if (pItems[index].a.eScript == Script_Numeric|| if (script_is_numeric(pItems[index].a.eScript))
pItems[index].a.eScript == Script_Numeric2)
pItems[index].a.fLayoutRTL = layoutRTL; pItems[index].a.fLayoutRTL = layoutRTL;
else else
pItems[index].a.fLayoutRTL = pItems[index].a.fRTL; pItems[index].a.fLayoutRTL = pItems[index].a.fRTL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment