usp10: Use usp10_array_reserve() in computeBracketPairs().
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Aric Stewart <aric@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
24f64acc35
commit
d48dd7efbf
|
@ -694,6 +694,7 @@ static BracketPair *computeBracketPairs(IsolatedRun *iso_run)
|
||||||
int stack_top = iso_run->length;
|
int stack_top = iso_run->length;
|
||||||
unsigned int pair_count = 0;
|
unsigned int pair_count = 0;
|
||||||
BracketPair *out = NULL;
|
BracketPair *out = NULL;
|
||||||
|
SIZE_T out_size = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
open_stack = heap_alloc(iso_run->length * sizeof(*open_stack));
|
open_stack = heap_alloc(iso_run->length * sizeof(*open_stack));
|
||||||
|
@ -702,42 +703,43 @@ static BracketPair *computeBracketPairs(IsolatedRun *iso_run)
|
||||||
for (i = 0; i < iso_run->length; i++)
|
for (i = 0; i < iso_run->length; i++)
|
||||||
{
|
{
|
||||||
unsigned short ubv = get_table_entry(bidi_bracket_table, iso_run->item[i].ch);
|
unsigned short ubv = get_table_entry(bidi_bracket_table, iso_run->item[i].ch);
|
||||||
if (ubv)
|
|
||||||
{
|
|
||||||
if (!out)
|
|
||||||
{
|
|
||||||
out = heap_alloc(sizeof(*out));
|
|
||||||
out[0].start = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((ubv >> 8) == 0)
|
if (!ubv)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if ((ubv >> 8) == 0)
|
||||||
|
{
|
||||||
|
--stack_top;
|
||||||
|
open_stack[stack_top] = iso_run->item[i].ch + (signed char)(ubv & 0xff);
|
||||||
|
/* Deal with canonical equivalent U+2329/232A and U+3008/3009. */
|
||||||
|
if (open_stack[stack_top] == 0x232a)
|
||||||
|
open_stack[stack_top] = 0x3009;
|
||||||
|
stack_index[stack_top] = i;
|
||||||
|
}
|
||||||
|
else if ((ubv >> 8) == 1)
|
||||||
|
{
|
||||||
|
unsigned int j;
|
||||||
|
|
||||||
|
for (j = stack_top; j < iso_run->length; ++j)
|
||||||
{
|
{
|
||||||
stack_top --;
|
WCHAR c = iso_run->item[i].ch;
|
||||||
open_stack[stack_top] = iso_run->item[i].ch + (signed char)(ubv & 0xff);
|
|
||||||
/* deal with canonical equivalent U+2329/232A and U+3008/3009 */
|
if (c == 0x232a)
|
||||||
if (open_stack[stack_top] == 0x232A)
|
c = 0x3009;
|
||||||
open_stack[stack_top] = 0x3009;
|
|
||||||
stack_index[stack_top] = i;
|
if (c != open_stack[j])
|
||||||
}
|
continue;
|
||||||
else if ((ubv >> 8) == 1)
|
|
||||||
{
|
if (!(usp10_array_reserve((void **)&out, &out_size, pair_count + 2, sizeof(*out))))
|
||||||
int j;
|
ERR("Failed to grow output array.\n");
|
||||||
if (stack_top == iso_run->length) continue;
|
|
||||||
for (j = stack_top; j < iso_run->length; j++)
|
out[pair_count].start = stack_index[j];
|
||||||
{
|
out[pair_count].end = i;
|
||||||
WCHAR c = iso_run->item[i].ch;
|
++pair_count;
|
||||||
if (c == 0x232A) c = 0x3009;
|
|
||||||
if (c == open_stack[j])
|
out[pair_count].start = -1;
|
||||||
{
|
stack_top = j + 1;
|
||||||
out[pair_count].start = stack_index[j];
|
break;
|
||||||
out[pair_count].end = i;
|
|
||||||
pair_count++;
|
|
||||||
out = HeapReAlloc(GetProcessHeap(), 0, out, sizeof(BracketPair) * (pair_count+1));
|
|
||||||
out[pair_count].start = -1;
|
|
||||||
stack_top = j+1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -746,10 +748,7 @@ static BracketPair *computeBracketPairs(IsolatedRun *iso_run)
|
||||||
heap_free(stack_index);
|
heap_free(stack_index);
|
||||||
|
|
||||||
if (!pair_count)
|
if (!pair_count)
|
||||||
{
|
|
||||||
heap_free(out);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
qsort(out, pair_count, sizeof(*out), compr);
|
qsort(out, pair_count, sizeof(*out), compr);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue