62#define ASSERT(x) do { if (!(x)) FIXME("assert failed: %s\n", #x); } while(0)
168 if (
c->fLegacyBidiClass && chartype[
i] ==
ES)
170 if (
string[
i] ==
'+' ||
string[
i] ==
'-') chartype[
i] =
NI;
179 return odd(
i) ?
i + 1 :
i + 2;
184 return odd(
i) ?
i + 2 :
i + 1;
217#define push_stack(l,o,i) \
219 stack[stack_top].level = l; \
220 stack[stack_top].override = o; \
221 stack[stack_top].isolate = i;} while(0)
223#define pop_stack() do { stack_top++; } while(0)
225#define valid_level(x) (x <= MAX_DEPTH && overflow_isolate_count == 0 && overflow_embedding_count == 0)
230 int overflow_isolate_count = 0;
231 int overflow_embedding_count = 0;
232 int valid_isolate_count = 0;
255 if (pclass[
i] ==
RLE)
261 else if (overflow_isolate_count == 0)
262 overflow_embedding_count++;
265 else if (pclass[
i] ==
LRE)
271 else if (overflow_isolate_count == 0)
272 overflow_embedding_count++;
275 else if (pclass[
i] ==
RLO)
281 else if (overflow_isolate_count == 0)
282 overflow_embedding_count++;
285 else if (pclass[
i] ==
LRO)
291 else if (overflow_isolate_count == 0)
292 overflow_embedding_count++;
295 else if (pclass[
i] ==
RLI)
301 valid_isolate_count++;
305 overflow_isolate_count++;
308 else if (pclass[
i] ==
LRI)
314 valid_isolate_count++;
318 overflow_isolate_count++;
321 else if (pclass[
i] ==
FSI)
329 if (pclass[
j] ==
LRI || pclass[
j] ==
RLI || pclass[
j] ==
FSI)
334 else if (pclass[
j] ==
PDI)
343 if (skipping)
continue;
350 else if (pclass[
j] ==
R || pclass[
j] ==
AL)
361 valid_isolate_count++;
365 overflow_isolate_count++;
372 valid_isolate_count++;
376 overflow_isolate_count++;
380 else if (pclass[
i] !=
B && pclass[
i] !=
BN && pclass[
i] !=
PDI && pclass[
i] !=
PDF)
387 else if (pclass[
i] ==
PDI)
389 if (overflow_isolate_count) overflow_isolate_count--;
390 else if (!valid_isolate_count) {}
393 overflow_embedding_count = 0;
396 valid_isolate_count --;
401 else if (pclass[
i] ==
PDF)
404 if (overflow_isolate_count) {}
405 else if (overflow_embedding_count) overflow_embedding_count--;
413 if (pclass[
i] ==
RLE || pclass[
i] ==
LRE || pclass[
i] ==
RLO || pclass[
i] ==
LRO || pclass[
i] ==
PDF)
469 if (
index <= 0)
return -1;
580 for (
j =
i-1 ;
j > -1;
j--)
629 if (iso_run->
sos ==
L &&
j == -1)
651 unsigned int pair_count = 0;
675 else if ((ubv >> 8) == 1)
686 if (
c != open_stack[
j])
690 ERR(
"Failed to grow output array.\n");
692 out[pair_count].start = stack_index[
j];
693 out[pair_count].end =
i;
696 out[pair_count].start = -1;
714#define N0_TYPE(a) ((a == AN || a == EN)?R:a)
761 while (
p->start >= 0)
767 TRACE(
"Bracket Pair [%i - %i]\n",
p->start,
p->end);
770 for (
j =
p->start+1; j < p->
end;
j++)
782 if (
j ==
p->end && flag_o)
784 for (
j =
p->start;
j >= 0;
j--)
896 for (
i = sos;
i <= eos;
i++)
904 if (
odd(plevel[
i]) && (pcls[
i] ==
L || pcls[
i] ==
EN || pcls [
i] ==
AN))
906 else if (!
odd(plevel[
i]) && pcls[
i] ==
R)
908 else if (!
odd(plevel[
i]) && (pcls[
i] ==
EN || pcls [
i] ==
AN))
918 for (
i = sos;
i <= eos;
i++)
920 if (pcls[
i] ==
B || pcls[
i] ==
S)
923 while (
i > sos &&
j >= sos &&
924 (pcls[
j] ==
WS || pcls[
j] ==
FSI || pcls[
j] ==
LRI || pcls[
j] ==
RLI ||
926 pcls[
j] ==
RLO || pcls[
j] ==
PDF || pcls[
j] ==
BN))
927 plevel[
j--] = baselevel;
928 plevel[
i] = baselevel;
930 else if (pcls[
i] ==
LRE || pcls[
i] ==
RLE || pcls[
i] ==
LRO || pcls[
i] ==
RLO ||
931 pcls[
i] ==
PDF || pcls[
i] ==
BN)
933 plevel[
i] =
i ? plevel[
i - 1] : baselevel;
936 (pcls[
i] ==
WS || pcls[
i] ==
FSI || pcls[
i] ==
LRI || pcls[
i] ==
RLI ||
938 pcls[
i] ==
RLO || pcls[
i] ==
PDF || pcls[
i] ==
BN ))
941 while (
j >= sos && (pcls[
j] ==
WS || pcls[
j] ==
FSI || pcls[
j] ==
LRI || pcls[
j] ==
RLI ||
943 pcls[
j] ==
RLO || pcls[
j] ==
PDF || pcls[
j] ==
BN))
944 plevel[
j--] = baselevel;
950 const WCHAR *
string,
unsigned int uCount,
struct list *
set)
952 int run_start, run_end,
i;
964 while (run_start < uCount)
967 while (run_end < uCount && pLevel[run_end] == pLevel[run_start]) run_end =
nextValidChar(pcls, run_end, uCount);
969 runs[run_count].
start = run_start;
970 runs[run_count].
end = run_end;
971 runs[run_count].
e = pLevel[run_start];
978 while (
i < run_count)
983 int type_fence, real_end;
989 run_start = runs[
k].
start;
990 current_isolated->
e = runs[
k].
e;
993 for (
j = 0;
j < current_isolated->
length;
j++)
996 current_isolated->
item[
j].
ch =
string[runs[
k].start +
j];
999 run_end = runs[
k].
end;
1001 TRACE(
"{ [%i -- %i]",run_start, run_end);
1003 if (pcls[run_end] ==
BN)
1006 while (run_end < uCount && (pcls[run_end] ==
RLI || pcls[run_end] ==
LRI || pcls[run_end] ==
FSI))
1010 while (
j < run_count && pcls[runs[
j].
start] !=
PDI)
j++;
1011 if (
j < run_count && runs[
i].
e != runs[
j].
e)
1020 int l = current_isolated->
length;
1023 for (
m = 0;
l < current_isolated->
length;
l++,
m++)
1026 current_isolated->
item[
l].
ch =
string[runs[
j].start +
m];
1031 run_end = runs[
j].
end;
1032 if (pcls[run_end] ==
BN)
1046 if (type_fence == -1)
1047 current_isolated->
sos = (baselevel > pLevel[run_start])?baselevel:pLevel[run_start];
1049 current_isolated->
sos = (pLevel[type_fence] > pLevel[run_start])?pLevel[type_fence]:pLevel[run_start];
1053 if (run_end == uCount)
1054 current_isolated->
eos = current_isolated->
sos;
1058 if ( pcls[run_end] ==
BN )
1061 if (real_end < run_start)
1062 real_end = run_start;
1068 if (type_fence == uCount)
1069 current_isolated->
eos = (baselevel > pLevel[real_end])?baselevel:pLevel[real_end];
1071 current_isolated->
eos = (pLevel[type_fence] > pLevel[real_end])?pLevel[type_fence]:pLevel[real_end];
1089 const WCHAR *lpString,
1090 unsigned int uCount,
1094 WORD *lpOutOverrides
1098 unsigned baselevel = 0;
1099 struct list IsolatingRuns;
1104 if (!(chartype =
heap_alloc(uCount *
sizeof(*chartype))))
1106 WARN(
"Out of memory\n");
1110 baselevel =
s->uBidiLevel;
1112 classify(lpString, chartype, uCount,
c);
1115 memset(lpOutOverrides, 0,
sizeof(
WORD) * uCount);
1118 resolveExplicit(baselevel, chartype, lpOutLevels, lpOutOverrides, uCount,
s->fOverrideDirection);
1145 classify(lpString, chartype, uCount,
c);
1157 for (; ich < --
cch; ich++)
1160 pidx[ich] = pidx[
cch];
1195 for (; ich <
cch; ich++)
1197 if (plevel[ich] <
level)
1201 else if (plevel[ich] >
level)
1204 cch - ich, fReverse) - 1;
1223 for (; ich <
cch; ich++)
1225 if (plevel[ich] <
level)
1227 else if (plevel[ich] >
level)
1238 for (; ich <
cch; ich++)
1239 if (plevel[ich] <
level)
1241 else if (plevel[ich] >
level)
1243 cch - ich, fReverse) - 1;
1256 switch (strength[
i])
ACPI_SIZE strlen(const char *String)
static void * heap_alloc(size_t len)
static BOOL heap_free(void *mem)
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
static void list_remove(struct list_entry *entry)
static void list_add_tail(struct list_entry *head, struct list_entry *entry)
static void list_init(struct list_entry *head)
const unsigned short DECLSPEC_HIDDEN bidi_bracket_table[768]
BOOL usp10_array_reserve(void **elements, SIZE_T *capacity, SIZE_T count, SIZE_T size)
static jsval_t stack_top(script_ctx_t *ctx)
GLuint GLuint GLsizei count
GLdouble GLdouble GLdouble r
GLboolean GLboolean GLboolean b
GLuint GLsizei GLsizei * length
GLboolean GLboolean GLboolean GLboolean a
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
static unsigned short get_table_entry(const unsigned short *table, WCHAR ch)
static void classify(LPCWSTR lpString, WORD *chartype, DWORD uCount)
const unsigned short bidi_direction_table[] DECLSPEC_HIDDEN
const unsigned short DECLSPEC_HIDDEN DECLSPEC_HIDDEN bidi_direction_table[4512]
static DWORD DWORD void LPSTR DWORD cch
static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK ULONG PVOID ULONG PVOID ULONG out_size
static short search(int val, const short *table, int size)
static unsigned __int64 next
static void * heap_calloc(SIZE_T count, SIZE_T size)
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
void __cdecl qsort(_Inout_updates_bytes_(_NumOfElements *_SizeOfElements) void *_Base, _In_ size_t _NumOfElements, _In_ size_t _SizeOfElements, _In_ int(__cdecl *_PtFuncCompare)(const void *, const void *))
#define FIELD_OFFSET(t, f)
static void reverse(int *pidx, int cch)
static BracketPair * computeBracketPairs(IsolatedRun *iso_run)
static WORD EmbeddingDirection(int level)
static void resolveImplicit(const WORD *pcls, WORD *plevel, int sos, int eos)
struct tagBracketPair BracketPair
int BIDI_ReorderL2vLevel(int level, int *pIndexs, const BYTE *plevel, int cch, BOOL fReverse)
static int iso_nextValidChar(IsolatedRun *iso_run, int index)
static int previousValidChar(const WORD *pcls, int index, int back_fence)
static WORD GreaterOdd(int i)
static int nextValidChar(const WORD *pcls, int index, int front_fence)
static void iso_dump_types(const char *header, IsolatedRun *iso_run)
static int iso_previousValidChar(IsolatedRun *iso_run, int index)
static void resolveWeak(IsolatedRun *iso_run)
static void computeIsolatingRunsSet(unsigned baselevel, WORD *pcls, const WORD *pLevel, const WCHAR *string, unsigned int uCount, struct list *set)
static void resolveResolved(unsigned baselevel, const WORD *pcls, WORD *plevel, int sos, int eos)
struct tagIsolatedRun IsolatedRun
static void dump_types(const char *header, WORD *types, int start, int end)
static const char debug_type[][4]
struct tagRunChar RunChar
static WORD GreaterEven(int i)
#define push_stack(l, o, i)
struct tagStackItem StackItem
BOOL BIDI_DetermineLevels(const WCHAR *lpString, unsigned int uCount, const SCRIPT_STATE *s, const SCRIPT_CONTROL *c, WORD *lpOutLevels, WORD *lpOutOverrides)
static void resolveExplicit(int level, WORD *pclass, WORD *poutLevel, WORD *poutOverrides, int count, BOOL initialOverride)
static int __cdecl compr(const void *a, const void *b)
BOOL BIDI_GetStrengths(const WCHAR *string, unsigned int count, const SCRIPT_CONTROL *c, WORD *strength)
int BIDI_ReorderV2lLevel(int level, int *pIndexs, const BYTE *plevel, int cch, BOOL fReverse)
static void resolveNeutrals(IsolatedRun *iso_run)