61#define ASSERT(x) do { if (!(x)) FIXME("assert failed: %s\n", #x); } while(0)
167 if (
c->fLegacyBidiClass && chartype[
i] ==
ES)
169 if (
string[
i] ==
'+' ||
string[
i] ==
'-') chartype[
i] =
NI;
178 return odd(
i) ?
i + 1 :
i + 2;
183 return odd(
i) ?
i + 2 :
i + 1;
216#define push_stack(l,o,i) \
218 stack[stack_top].level = l; \
219 stack[stack_top].override = o; \
220 stack[stack_top].isolate = i;} while(0)
222#define pop_stack() do { stack_top++; } while(0)
224#define valid_level(x) (x <= MAX_DEPTH && overflow_isolate_count == 0 && overflow_embedding_count == 0)
229 int overflow_isolate_count = 0;
230 int overflow_embedding_count = 0;
231 int valid_isolate_count = 0;
254 if (pclass[
i] ==
RLE)
260 else if (overflow_isolate_count == 0)
261 overflow_embedding_count++;
264 else if (pclass[
i] ==
LRE)
270 else if (overflow_isolate_count == 0)
271 overflow_embedding_count++;
274 else if (pclass[
i] ==
RLO)
280 else if (overflow_isolate_count == 0)
281 overflow_embedding_count++;
284 else if (pclass[
i] ==
LRO)
290 else if (overflow_isolate_count == 0)
291 overflow_embedding_count++;
294 else if (pclass[
i] ==
RLI)
300 valid_isolate_count++;
304 overflow_isolate_count++;
307 else if (pclass[
i] ==
LRI)
313 valid_isolate_count++;
317 overflow_isolate_count++;
320 else if (pclass[
i] ==
FSI)
328 if (pclass[
j] ==
LRI || pclass[
j] ==
RLI || pclass[
j] ==
FSI)
333 else if (pclass[
j] ==
PDI)
342 if (skipping)
continue;
349 else if (pclass[
j] ==
R || pclass[
j] ==
AL)
360 valid_isolate_count++;
364 overflow_isolate_count++;
371 valid_isolate_count++;
375 overflow_isolate_count++;
379 else if (pclass[
i] !=
B && pclass[
i] !=
BN && pclass[
i] !=
PDI && pclass[
i] !=
PDF)
386 else if (pclass[
i] ==
PDI)
388 if (overflow_isolate_count) overflow_isolate_count--;
389 else if (!valid_isolate_count) {}
392 overflow_embedding_count = 0;
395 valid_isolate_count --;
400 else if (pclass[
i] ==
PDF)
403 if (overflow_isolate_count) {}
404 else if (overflow_embedding_count) overflow_embedding_count--;
412 if (pclass[
i] ==
RLE || pclass[
i] ==
LRE || pclass[
i] ==
RLO || pclass[
i] ==
LRO || pclass[
i] ==
PDF)
468 if (
index <= 0)
return -1;
579 for (
j =
i-1 ;
j > -1;
j--)
628 if (iso_run->
sos ==
L &&
j == -1)
650 unsigned int pair_count = 0;
655 open_stack =
malloc(iso_run->
length *
sizeof(*open_stack));
656 stack_index =
malloc(iso_run->
length *
sizeof(*stack_index));
674 else if ((ubv >> 8) == 1)
685 if (
c != open_stack[
j])
689 ERR(
"Failed to grow output array.\n");
691 out[pair_count].start = stack_index[
j];
692 out[pair_count].end =
i;
695 out[pair_count].start = -1;
713#define N0_TYPE(a) ((a == AN || a == EN)?R:a)
760 while (
p->start >= 0)
766 TRACE(
"Bracket Pair [%i - %i]\n",
p->start,
p->end);
769 for (
j =
p->start+1; j < p->
end;
j++)
781 if (
j ==
p->end && flag_o)
783 for (
j =
p->start;
j >= 0;
j--)
895 for (
i = sos;
i <= eos;
i++)
903 if (
odd(plevel[
i]) && (pcls[
i] ==
L || pcls[
i] ==
EN || pcls [
i] ==
AN))
905 else if (!
odd(plevel[
i]) && pcls[
i] ==
R)
907 else if (!
odd(plevel[
i]) && (pcls[
i] ==
EN || pcls [
i] ==
AN))
917 for (
i = sos;
i <= eos;
i++)
919 if (pcls[
i] ==
B || pcls[
i] ==
S)
922 while (
i > sos &&
j >= sos &&
923 (pcls[
j] ==
WS || pcls[
j] ==
FSI || pcls[
j] ==
LRI || pcls[
j] ==
RLI ||
925 pcls[
j] ==
RLO || pcls[
j] ==
PDF || pcls[
j] ==
BN))
926 plevel[
j--] = baselevel;
927 plevel[
i] = baselevel;
929 else if (pcls[
i] ==
LRE || pcls[
i] ==
RLE || pcls[
i] ==
LRO || pcls[
i] ==
RLO ||
930 pcls[
i] ==
PDF || pcls[
i] ==
BN)
932 plevel[
i] =
i ? plevel[
i - 1] : baselevel;
935 (pcls[
i] ==
WS || pcls[
i] ==
FSI || pcls[
i] ==
LRI || pcls[
i] ==
RLI ||
937 pcls[
i] ==
RLO || pcls[
i] ==
PDF || pcls[
i] ==
BN ))
940 while (
j >= sos && (pcls[
j] ==
WS || pcls[
j] ==
FSI || pcls[
j] ==
LRI || pcls[
j] ==
RLI ||
942 pcls[
j] ==
RLO || pcls[
j] ==
PDF || pcls[
j] ==
BN))
943 plevel[
j--] = baselevel;
949 const WCHAR *
string,
unsigned int uCount,
struct list *
set)
951 int run_start, run_end,
i;
956 if (!(runs =
calloc(uCount,
sizeof(*runs))))
963 while (run_start < uCount)
966 while (run_end < uCount && pLevel[run_end] == pLevel[run_start]) run_end =
nextValidChar(pcls, run_end, uCount);
968 runs[run_count].
start = run_start;
969 runs[run_count].
end = run_end;
970 runs[run_count].
e = pLevel[run_start];
977 while (
i < run_count)
982 int type_fence, real_end;
988 run_start = runs[
k].
start;
989 current_isolated->
e = runs[
k].
e;
992 for (
j = 0;
j < current_isolated->
length;
j++)
995 current_isolated->
item[
j].
ch =
string[runs[
k].start +
j];
998 run_end = runs[
k].
end;
1000 TRACE(
"{ [%i -- %i]",run_start, run_end);
1002 if (pcls[run_end] ==
BN)
1005 while (run_end < uCount && (pcls[run_end] ==
RLI || pcls[run_end] ==
LRI || pcls[run_end] ==
FSI))
1009 while (
j < run_count && pcls[runs[
j].
start] !=
PDI)
j++;
1010 if (
j < run_count && runs[
i].
e != runs[
j].
e)
1019 int l = current_isolated->
length;
1022 for (
m = 0;
l < current_isolated->
length;
l++,
m++)
1025 current_isolated->
item[
l].
ch =
string[runs[
j].start +
m];
1030 run_end = runs[
j].
end;
1031 if (pcls[run_end] ==
BN)
1045 if (type_fence == -1)
1046 current_isolated->
sos = (baselevel > pLevel[run_start])?baselevel:pLevel[run_start];
1048 current_isolated->
sos = (pLevel[type_fence] > pLevel[run_start])?pLevel[type_fence]:pLevel[run_start];
1052 if (run_end == uCount)
1053 current_isolated->
eos = current_isolated->
sos;
1057 if ( pcls[run_end] ==
BN )
1060 if (real_end < run_start)
1061 real_end = run_start;
1067 if (type_fence == uCount)
1068 current_isolated->
eos = (baselevel > pLevel[real_end])?baselevel:pLevel[real_end];
1070 current_isolated->
eos = (pLevel[type_fence] > pLevel[real_end])?pLevel[type_fence]:pLevel[real_end];
1088 const WCHAR *lpString,
1089 unsigned int uCount,
1093 WORD *lpOutOverrides
1097 unsigned baselevel = 0;
1098 struct list IsolatingRuns;
1103 if (!(chartype =
malloc(uCount *
sizeof(*chartype))))
1105 WARN(
"Out of memory\n");
1109 baselevel =
s->uBidiLevel;
1111 classify(lpString, chartype, uCount,
c);
1114 memset(lpOutOverrides, 0,
sizeof(
WORD) * uCount);
1117 resolveExplicit(baselevel, chartype, lpOutLevels, lpOutOverrides, uCount,
s->fOverrideDirection);
1144 classify(lpString, chartype, uCount,
c);
1156 for (; ich < --
cch; ich++)
1159 pidx[ich] = pidx[
cch];
1194 for (; ich <
cch; ich++)
1196 if (plevel[ich] <
level)
1200 else if (plevel[ich] >
level)
1203 cch - ich, fReverse) - 1;
1222 for (; ich <
cch; ich++)
1224 if (plevel[ich] <
level)
1226 else if (plevel[ich] >
level)
1237 for (; ich <
cch; ich++)
1238 if (plevel[ich] <
level)
1240 else if (plevel[ich] >
level)
1242 cch - ich, fReverse) - 1;
1255 switch (strength[
i])
#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)
struct tagBracketPair BracketPair
const unsigned short bidi_direction_table[]
static void iso_dump_types(const char *header, IsolatedRun *run)
struct tagIsolatedRun IsolatedRun
static const char debug_type[][4]
struct tagRunChar RunChar
#define push_stack(l, o, i)
struct tagStackItem StackItem
const unsigned short bidi_bracket_table[]
_ACRTIMP void __cdecl qsort(void *, size_t, size_t, int(__cdecl *)(const void *, const void *))
_ACRTIMP size_t __cdecl strlen(const char *)
BOOL usp10_array_reserve(void **elements, SIZE_T *capacity, SIZE_T count, SIZE_T size)
static const uint32_t k[]
static unsigned short get_table_entry_16(const unsigned short *table, WCHAR ch)
static unsigned short get_table_entry_32(const unsigned short *table, UINT ch)
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 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)
#define offsetof(TYPE, MEMBER)
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
PSYMCRYPT_PARALLEL_HASH_OPERATION next
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
static void classify(LPCWSTR lpString, WORD *chartype, DWORD uCount)
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)
int BIDI_ReorderL2vLevel(int level, int *pIndices, const BYTE *plevel, int cch, BOOL fReverse)
int BIDI_ReorderV2lLevel(int level, int *pIndices, 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 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)
static void dump_types(const char *header, WORD *types, int start, int end)
static WORD GreaterEven(int i)
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)
static void resolveNeutrals(IsolatedRun *iso_run)