Signed-off-by: Henri Verbeet hverbeet@codeweavers.com --- dlls/usp10/bidi.c | 71 +++++++++++++++++++++++++++---------------------------- 1 file changed, 35 insertions(+), 36 deletions(-)
diff --git a/dlls/usp10/bidi.c b/dlls/usp10/bidi.c index 2277190..b0df781 100644 --- a/dlls/usp10/bidi.c +++ b/dlls/usp10/bidi.c @@ -694,6 +694,7 @@ static BracketPair *computeBracketPairs(IsolatedRun *iso_run) int stack_top = iso_run->length; unsigned int pair_count = 0; BracketPair *out = NULL; + SIZE_T out_size = 0; int i;
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++) { unsigned short ubv = get_table_entry(bidi_bracket_table, iso_run->item[i].ch); - if (ubv) + + if (!ubv) + continue; + + if ((ubv >> 8) == 0) { - if (!out) - { - out = heap_alloc(sizeof(*out)); - out[0].start = -1; - } + --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;
- 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) + for (j = stack_top; j < iso_run->length; ++j) { - int j; - if (stack_top == iso_run->length) continue; - for (j = stack_top; j < iso_run->length; j++) - { - WCHAR c = iso_run->item[i].ch; - if (c == 0x232A) c = 0x3009; - if (c == open_stack[j]) - { - out[pair_count].start = stack_index[j]; - 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; - } - } + WCHAR c = iso_run->item[i].ch; + + if (c == 0x232a) + c = 0x3009; + + if (c != open_stack[j]) + continue; + + if (!(usp10_array_reserve((void **)&out, &out_size, pair_count + 2, sizeof(*out)))) + ERR("Failed to grow output array.\n"); + + out[pair_count].start = stack_index[j]; + out[pair_count].end = i; + ++pair_count; + + out[pair_count].start = -1; + stack_top = j + 1; + break; } } } @@ -746,10 +748,7 @@ static BracketPair *computeBracketPairs(IsolatedRun *iso_run) heap_free(stack_index);
if (!pair_count) - { - heap_free(out); return NULL; - }
qsort(out, pair_count, sizeof(*out), compr);
Signed-off-by: Aric Stewart aric@codeweavers.com
On 2/20/18 12:34 AM, Henri Verbeet wrote:
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
dlls/usp10/bidi.c | 71 +++++++++++++++++++++++++++---------------------------- 1 file changed, 35 insertions(+), 36 deletions(-)
diff --git a/dlls/usp10/bidi.c b/dlls/usp10/bidi.c index 2277190..b0df781 100644 --- a/dlls/usp10/bidi.c +++ b/dlls/usp10/bidi.c @@ -694,6 +694,7 @@ static BracketPair *computeBracketPairs(IsolatedRun *iso_run) int stack_top = iso_run->length; unsigned int pair_count = 0; BracketPair *out = NULL;
SIZE_T out_size = 0; int i;
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++) { unsigned short ubv = get_table_entry(bidi_bracket_table, iso_run->item[i].ch);
if (ubv)
if (!ubv)
continue;
if ((ubv >> 8) == 0) {
if (!out)
{
out = heap_alloc(sizeof(*out));
out[0].start = -1;
}
--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;
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)
for (j = stack_top; j < iso_run->length; ++j) {
int j;
if (stack_top == iso_run->length) continue;
for (j = stack_top; j < iso_run->length; j++)
{
WCHAR c = iso_run->item[i].ch;
if (c == 0x232A) c = 0x3009;
if (c == open_stack[j])
{
out[pair_count].start = stack_index[j];
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;
}
}
WCHAR c = iso_run->item[i].ch;
if (c == 0x232a)
c = 0x3009;
if (c != open_stack[j])
continue;
if (!(usp10_array_reserve((void **)&out, &out_size, pair_count + 2, sizeof(*out))))
ERR("Failed to grow output array.\n");
out[pair_count].start = stack_index[j];
out[pair_count].end = i;
++pair_count;
out[pair_count].start = -1;
stack_top = j + 1;
break; } } }
@@ -746,10 +748,7 @@ static BracketPair *computeBracketPairs(IsolatedRun *iso_run) heap_free(stack_index);
if (!pair_count)
{
heap_free(out); return NULL;
}
qsort(out, pair_count, sizeof(*out), compr);