ReactOS 0.4.16-dev-91-g764881a
bidi.c File Reference
#include <stdarg.h>
#include <stdlib.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winnls.h"
#include "usp10.h"
#include "wine/debug.h"
#include "wine/heap.h"
#include "wine/list.h"
#include "usp10_internal.h"
Include dependency graph for bidi.c:

Go to the source code of this file.

Classes

struct  tagStackItem
 
struct  tagRun
 
struct  tagRunChar
 
struct  tagIsolatedRun
 
struct  tagBracketPair
 

Macros

#define ASSERT(x)   do { if (!(x)) FIXME("assert failed: %s\n", #x); } while(0)
 
#define MAX_DEPTH   125
 
#define push_stack(l, o, i)
 
#define pop_stack()   do { stack_top++; } while(0)
 
#define valid_level(x)   (x <= MAX_DEPTH && overflow_isolate_count == 0 && overflow_embedding_count == 0)
 
#define N0_TYPE(a)   ((a == AN || a == EN)?R:a)
 

Typedefs

typedef struct tagStackItem StackItem
 
typedef struct tagRun Run
 
typedef struct tagRunChar RunChar
 
typedef struct tagIsolatedRun IsolatedRun
 
typedef struct tagBracketPair BracketPair
 

Enumerations

enum  directions {
  ON = 0 , L , R , AN ,
  EN , AL , NSM , CS ,
  ES , ET , BN , S ,
  WS , B , RLO , RLE ,
  LRO , LRE , PDF , LRI ,
  RLI , FSI , PDI , NI = ON ,
  ON = 0 , L , R , AN ,
  EN , AL , NSM , CS ,
  ES , ET , BN , S ,
  WS , B , RLO , RLE ,
  LRO , LRE , PDF , LRI ,
  RLI , FSI , PDI , NI = ON
}
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (bidi)
 
static void dump_types (const char *header, WORD *types, int start, int end)
 
static void classify (const WCHAR *string, WORD *chartype, DWORD count, const SCRIPT_CONTROL *c)
 
static WORD GreaterEven (int i)
 
static WORD GreaterOdd (int i)
 
static WORD EmbeddingDirection (int level)
 
static void resolveExplicit (int level, WORD *pclass, WORD *poutLevel, WORD *poutOverrides, int count, BOOL initialOverride)
 
static int previousValidChar (const WORD *pcls, int index, int back_fence)
 
static int nextValidChar (const WORD *pcls, int index, int front_fence)
 
static int iso_nextValidChar (IsolatedRun *iso_run, int index)
 
static int iso_previousValidChar (IsolatedRun *iso_run, int index)
 
static void iso_dump_types (const char *header, IsolatedRun *iso_run)
 
static void resolveWeak (IsolatedRun *iso_run)
 
static int __cdecl compr (const void *a, const void *b)
 
static BracketPaircomputeBracketPairs (IsolatedRun *iso_run)
 
static void resolveNeutrals (IsolatedRun *iso_run)
 
static void resolveImplicit (const WORD *pcls, WORD *plevel, int sos, int eos)
 
static void resolveResolved (unsigned baselevel, const WORD *pcls, WORD *plevel, int sos, int eos)
 
static void computeIsolatingRunsSet (unsigned baselevel, WORD *pcls, const WORD *pLevel, const WCHAR *string, unsigned int uCount, struct list *set)
 
BOOL BIDI_DetermineLevels (const WCHAR *lpString, unsigned int uCount, const SCRIPT_STATE *s, const SCRIPT_CONTROL *c, WORD *lpOutLevels, WORD *lpOutOverrides)
 
static void reverse (int *pidx, int cch)
 
int BIDI_ReorderV2lLevel (int level, int *pIndexs, const BYTE *plevel, int cch, BOOL fReverse)
 
int BIDI_ReorderL2vLevel (int level, int *pIndexs, const BYTE *plevel, int cch, BOOL fReverse)
 
BOOL BIDI_GetStrengths (const WCHAR *string, unsigned int count, const SCRIPT_CONTROL *c, WORD *strength)
 

Variables

const unsigned short bidi_bracket_table[] DECLSPEC_HIDDEN
 
static const char debug_type [][4]
 

Macro Definition Documentation

◆ ASSERT

#define ASSERT (   x)    do { if (!(x)) FIXME("assert failed: %s\n", #x); } while(0)

Definition at line 62 of file bidi.c.

◆ MAX_DEPTH

#define MAX_DEPTH   125

Definition at line 63 of file bidi.c.

◆ N0_TYPE

#define N0_TYPE (   a)    ((a == AN || a == EN)?R:a)

Definition at line 714 of file bidi.c.

◆ pop_stack

#define pop_stack ( )    do { stack_top++; } while(0)

Definition at line 223 of file bidi.c.

◆ push_stack

#define push_stack (   l,
  o,
  i 
)
Value:
do { stack_top--; \
stack[stack_top].level = l; \
stack[stack_top].override = o; \
stack[stack_top].isolate = i;} while(0)
r l[0]
Definition: byte_order.h:168
static jsval_t stack_top(script_ctx_t *ctx)
Definition: engine.c:104
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
Definition: glfuncs.h:248
Definition: format.c:80

Definition at line 217 of file bidi.c.

◆ valid_level

#define valid_level (   x)    (x <= MAX_DEPTH && overflow_isolate_count == 0 && overflow_embedding_count == 0)

Definition at line 225 of file bidi.c.

Typedef Documentation

◆ BracketPair

◆ IsolatedRun

◆ Run

typedef struct tagRun Run

◆ RunChar

◆ StackItem

Enumeration Type Documentation

◆ directions

Enumerator
ON 
AN 
EN 
AL 
NSM 
CS 
ES 
ET 
BN 
WS 
RLO 
RLE 
LRO 
LRE 
PDF 
LRI 
RLI 
FSI 
PDI 
NI 
ON 
AN 
EN 
AL 
NSM 
CS 
ES 
ET 
BN 
WS 
RLO 
RLE 
LRO 
LRE 
PDF 
LRI 
RLI 
FSI 
PDI 
NI 

Definition at line 78 of file bidi.c.

79{
80 /* input types */
81 /* ON MUST be zero, code relies on ON = NI = 0 */
82 ON = 0, /* Other Neutral */
83 L, /* Left Letter */
84 R, /* Right Letter */
85 AN, /* Arabic Number */
86 EN, /* European Number */
87 AL, /* Arabic Letter (Right-to-left) */
88 NSM, /* Non-spacing Mark */
89 CS, /* Common Separator */
90 ES, /* European Separator */
91 ET, /* European Terminator (post/prefix e.g. $ and %) */
92
93 /* resolved types */
94 BN, /* Boundary neutral (type of RLE etc after explicit levels) */
95
96 /* input types, */
97 S, /* Segment Separator (TAB) // used only in L1 */
98 WS, /* White space // used only in L1 */
99 B, /* Paragraph Separator (aka as PS) */
100
101 /* types for explicit controls */
102 RLO, /* these are used only in X1-X9 */
103 RLE,
104 LRO,
105 LRE,
106 PDF,
107
108 LRI, /* Isolate formatting characters new with 6.3 */
109 RLI,
110 FSI,
111 PDI,
112
113 /* resolved types, also resolved directions */
114 NI = ON, /* alias, where ON, WS, S and Isolates are treated the same */
115};
@ FSI
Definition: bidi.c:98
@ LRO
Definition: bidi.c:92
@ WS
Definition: bidi.c:86
@ EN
Definition: bidi.c:74
@ PDI
Definition: bidi.c:99
@ R
Definition: bidi.c:72
@ LRE
Definition: bidi.c:93
@ NI
Definition: bidi.c:102
@ RLE
Definition: bidi.c:91
@ B
Definition: bidi.c:87
@ ET
Definition: bidi.c:79
@ AN
Definition: bidi.c:73
@ RLI
Definition: bidi.c:97
@ ES
Definition: bidi.c:78
@ PDF
Definition: bidi.c:94
@ RLO
Definition: bidi.c:90
@ CS
Definition: bidi.c:77
@ ON
Definition: bidi.c:70
@ AL
Definition: bidi.c:75
@ LRI
Definition: bidi.c:96
@ BN
Definition: bidi.c:82
@ NSM
Definition: bidi.c:76
@ L
Definition: bidi.c:71
@ S
Definition: bidi.c:85

Function Documentation

◆ BIDI_DetermineLevels()

BOOL BIDI_DetermineLevels ( const WCHAR lpString,
unsigned int  uCount,
const SCRIPT_STATE s,
const SCRIPT_CONTROL c,
WORD lpOutLevels,
WORD lpOutOverrides 
)

Definition at line 1088 of file bidi.c.

1096{
1097 WORD *chartype;
1098 unsigned baselevel = 0;
1099 struct list IsolatingRuns;
1100 IsolatedRun *iso_run, *next;
1101
1102 TRACE("%s, %d\n", debugstr_wn(lpString, uCount), uCount);
1103
1104 if (!(chartype = heap_alloc(uCount * sizeof(*chartype))))
1105 {
1106 WARN("Out of memory\n");
1107 return FALSE;
1108 }
1109
1110 baselevel = s->uBidiLevel;
1111
1112 classify(lpString, chartype, uCount, c);
1113 if (TRACE_ON(bidi)) dump_types("Start ", chartype, 0, uCount);
1114
1115 memset(lpOutOverrides, 0, sizeof(WORD) * uCount);
1116
1117 /* resolve explicit */
1118 resolveExplicit(baselevel, chartype, lpOutLevels, lpOutOverrides, uCount, s->fOverrideDirection);
1119 if (TRACE_ON(bidi)) dump_types("After Explicit", chartype, 0, uCount);
1120
1121 /* X10/BD13: Computer Isolating runs */
1122 computeIsolatingRunsSet(baselevel, chartype, lpOutLevels, lpString, uCount, &IsolatingRuns);
1123
1124 LIST_FOR_EACH_ENTRY_SAFE(iso_run, next, &IsolatingRuns, IsolatedRun, entry)
1125 {
1126 if (TRACE_ON(bidi)) iso_dump_types("Run", iso_run);
1127
1128 /* resolve weak */
1129 resolveWeak(iso_run);
1130 if (TRACE_ON(bidi)) iso_dump_types("After Weak", iso_run);
1131
1132 /* resolve neutrals */
1133 resolveNeutrals(iso_run);
1134 if (TRACE_ON(bidi)) iso_dump_types("After Neutrals", iso_run);
1135
1136 list_remove(&iso_run->entry);
1137 heap_free(iso_run);
1138 }
1139
1140 if (TRACE_ON(bidi)) dump_types("Before Implicit", chartype, 0, uCount);
1141 /* resolveImplicit */
1142 resolveImplicit(chartype, lpOutLevels, 0, uCount-1);
1143
1144 /* resolveResolvedLevels*/
1145 classify(lpString, chartype, uCount, c);
1146 resolveResolved(baselevel, chartype, lpOutLevels, 0, uCount-1);
1147
1148 heap_free(chartype);
1149 return TRUE;
1150}
static void * heap_alloc(size_t len)
Definition: appwiz.h:66
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
static void list_remove(struct list_entry *entry)
Definition: list.h:90
#define WARN(fmt,...)
Definition: precomp.h:61
Definition: list.h:37
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define TRACE_ON(x)
Definition: compat.h:75
unsigned short WORD
Definition: ntddk_ex.h:93
GLdouble s
Definition: gl.h:2039
const GLubyte * c
Definition: glext.h:8905
uint32_t entry
Definition: isohybrid.c:63
#define debugstr_wn
Definition: kernel32.h:33
static void classify(LPCWSTR lpString, WORD *chartype, DWORD uCount)
Definition: bidi.c:113
static unsigned __int64 next
Definition: rand_nt.c:6
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204
#define memset(x, y, z)
Definition: compat.h:39
#define TRACE(s)
Definition: solgame.cpp:4
static void resolveImplicit(const WORD *pcls, WORD *plevel, int sos, int eos)
Definition: bidi.c:891
static void iso_dump_types(const char *header, IsolatedRun *iso_run)
Definition: bidi.c:475
static void resolveWeak(IsolatedRun *iso_run)
Definition: bidi.c:506
static void computeIsolatingRunsSet(unsigned baselevel, WORD *pcls, const WORD *pLevel, const WCHAR *string, unsigned int uCount, struct list *set)
Definition: bidi.c:949
static void resolveResolved(unsigned baselevel, const WORD *pcls, WORD *plevel, int sos, int eos)
Definition: bidi.c:913
static void dump_types(const char *header, WORD *types, int start, int end)
Definition: bidi.c:146
static void resolveExplicit(int level, WORD *pclass, WORD *poutLevel, WORD *poutOverrides, int count, BOOL initialOverride)
Definition: bidi.c:227
static void resolveNeutrals(IsolatedRun *iso_run)
Definition: bidi.c:734

Referenced by _ItemizeInternal().

◆ BIDI_GetStrengths()

BOOL BIDI_GetStrengths ( const WCHAR string,
unsigned int  count,
const SCRIPT_CONTROL c,
WORD strength 
)

Definition at line 1249 of file bidi.c.

1250{
1251 unsigned int i;
1252
1253 classify(string, strength, count, c);
1254 for (i = 0; i < count; i++)
1255 {
1256 switch (strength[i])
1257 {
1258 case L:
1259 case LRE:
1260 case LRO:
1261 case R:
1262 case AL:
1263 case RLE:
1264 case RLO:
1265 strength[i] = BIDI_STRONG;
1266 break;
1267 case PDF:
1268 case EN:
1269 case ES:
1270 case ET:
1271 case AN:
1272 case CS:
1273 case BN:
1274 strength[i] = BIDI_WEAK;
1275 break;
1276 case B:
1277 case S:
1278 case WS:
1279 case ON:
1280 default: /* Neutrals and NSM */
1281 strength[i] = BIDI_NEUTRAL;
1282 }
1283 }
1284 return TRUE;
1285}
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define BIDI_NEUTRAL
#define BIDI_STRONG
#define BIDI_WEAK

Referenced by _ItemizeInternal().

◆ BIDI_ReorderL2vLevel()

int BIDI_ReorderL2vLevel ( int  level,
int pIndexs,
const BYTE plevel,
int  cch,
BOOL  fReverse 
)

Definition at line 1215 of file bidi.c.

1216{
1217 int ich = 0;
1218 int newlevel = -1;
1219
1220 /* true as soon as first odd level encountered */
1221 fReverse = fReverse || odd(level);
1222
1223 for (; ich < cch; ich++)
1224 {
1225 if (plevel[ich] < level)
1226 break;
1227 else if (plevel[ich] > level)
1228 newlevel = ich;
1229 }
1230 if (fReverse)
1231 {
1232 reverse(pIndexs, ich);
1233 }
1234
1235 if (newlevel >= 0)
1236 {
1237 ich = 0;
1238 for (; ich < cch; ich++)
1239 if (plevel[ich] < level)
1240 break;
1241 else if (plevel[ich] > level)
1242 ich += BIDI_ReorderL2vLevel(level + 1, pIndexs + ich, plevel + ich,
1243 cch - ich, fReverse) - 1;
1244 }
1245
1246 return ich;
1247}
GLint level
Definition: gl.h:1546
#define odd(x)
Definition: bidi.c:51
static DWORD DWORD void LPSTR DWORD cch
Definition: str.c:202
static void reverse(int *pidx, int cch)
Definition: bidi.c:1153
int BIDI_ReorderL2vLevel(int level, int *pIndexs, const BYTE *plevel, int cch, BOOL fReverse)
Definition: bidi.c:1215

Referenced by BIDI_ReorderL2vLevel(), and ScriptLayout().

◆ BIDI_ReorderV2lLevel()

int BIDI_ReorderV2lLevel ( int  level,
int pIndexs,
const BYTE plevel,
int  cch,
BOOL  fReverse 
)

Definition at line 1188 of file bidi.c.

1189{
1190 int ich = 0;
1191
1192 /* true as soon as first odd level encountered */
1193 fReverse = fReverse || odd(level);
1194
1195 for (; ich < cch; ich++)
1196 {
1197 if (plevel[ich] < level)
1198 {
1199 break;
1200 }
1201 else if (plevel[ich] > level)
1202 {
1203 ich += BIDI_ReorderV2lLevel(level + 1, pIndexs + ich, plevel + ich,
1204 cch - ich, fReverse) - 1;
1205 }
1206 }
1207 if (fReverse)
1208 {
1209 reverse(pIndexs, ich);
1210 }
1211 return ich;
1212}
int BIDI_ReorderV2lLevel(int level, int *pIndexs, const BYTE *plevel, int cch, BOOL fReverse)
Definition: bidi.c:1188

Referenced by BIDI_ReorderV2lLevel(), and ScriptLayout().

◆ classify()

static void classify ( const WCHAR string,
WORD chartype,
DWORD  count,
const SCRIPT_CONTROL c 
)
static

Definition at line 161 of file bidi.c.

162{
163 unsigned i;
164
165 for (i = 0; i < count; ++i)
166 {
167 chartype[i] = get_table_entry( bidi_direction_table, string[i] );
168 if (c->fLegacyBidiClass && chartype[i] == ES)
169 {
170 if (string[i] == '+' || string[i] == '-') chartype[i] = NI;
171 }
172 }
173}
static unsigned short get_table_entry(const unsigned short *table, WCHAR ch)
Definition: bidi.c:107
const unsigned short DECLSPEC_HIDDEN DECLSPEC_HIDDEN bidi_direction_table[4512]
Definition: direction.c:6

◆ compr()

static int __cdecl compr ( const void a,
const void b 
)
static

Definition at line 641 of file bidi.c.

642{
643 return ((BracketPair*)a)->start - ((BracketPair*)b)->start;
644}
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

Referenced by BITMAP_LoadImageW(), computeBracketPairs(), create_alpha_bitmap(), CURSORICON_GetCursorDataFromBMI(), DIB_GetBitmapInfo(), GreGetDIBitsInternal(), pcf_get_metric(), and test_dib_formats().

◆ computeBracketPairs()

static BracketPair * computeBracketPairs ( IsolatedRun iso_run)
static

Definition at line 646 of file bidi.c.

647{
648 WCHAR *open_stack;
649 int *stack_index;
650 int stack_top = iso_run->length;
651 unsigned int pair_count = 0;
653 SIZE_T out_size = 0;
654 int i;
655
656 open_stack = heap_alloc(iso_run->length * sizeof(*open_stack));
657 stack_index = heap_alloc(iso_run->length * sizeof(*stack_index));
658
659 for (i = 0; i < iso_run->length; i++)
660 {
661 unsigned short ubv = get_table_entry(bidi_bracket_table, iso_run->item[i].ch);
662
663 if (!ubv)
664 continue;
665
666 if ((ubv >> 8) == 0)
667 {
668 --stack_top;
669 open_stack[stack_top] = iso_run->item[i].ch + (signed char)(ubv & 0xff);
670 /* Deal with canonical equivalent U+2329/232A and U+3008/3009. */
671 if (open_stack[stack_top] == 0x232a)
672 open_stack[stack_top] = 0x3009;
673 stack_index[stack_top] = i;
674 }
675 else if ((ubv >> 8) == 1)
676 {
677 unsigned int j;
678
679 for (j = stack_top; j < iso_run->length; ++j)
680 {
681 WCHAR c = iso_run->item[i].ch;
682
683 if (c == 0x232a)
684 c = 0x3009;
685
686 if (c != open_stack[j])
687 continue;
688
689 if (!(usp10_array_reserve((void **)&out, &out_size, pair_count + 2, sizeof(*out))))
690 ERR("Failed to grow output array.\n");
691
692 out[pair_count].start = stack_index[j];
693 out[pair_count].end = i;
694 ++pair_count;
695
696 out[pair_count].start = -1;
697 stack_top = j + 1;
698 break;
699 }
700 }
701 }
702
703 heap_free(open_stack);
704 heap_free(stack_index);
705
706 if (!pair_count)
707 return NULL;
708
709 qsort(out, pair_count, sizeof(*out), compr);
710
711 return out;
712}
#define ERR(fmt,...)
Definition: precomp.h:57
const unsigned short DECLSPEC_HIDDEN bidi_bracket_table[768]
Definition: bracket.c:7
#define NULL
Definition: types.h:112
BOOL usp10_array_reserve(void **elements, SIZE_T *capacity, SIZE_T count, SIZE_T size)
Definition: usp10.c:730
unsigned char
Definition: typeof.h:29
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
Definition: glfuncs.h:250
static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK ULONG PVOID ULONG PVOID ULONG out_size
Definition: file.c:100
static FILE * out
Definition: regtests2xml.c:44
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 *))
RunChar item[1]
Definition: bidi.c:454
int length
Definition: bidi.c:449
WCHAR ch
Definition: bidi.c:442
ULONG_PTR SIZE_T
Definition: typedefs.h:80
static int __cdecl compr(const void *a, const void *b)
Definition: bidi.c:641
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by resolveNeutrals().

◆ computeIsolatingRunsSet()

static void computeIsolatingRunsSet ( unsigned  baselevel,
WORD pcls,
const WORD pLevel,
const WCHAR string,
unsigned int  uCount,
struct list set 
)
static

Definition at line 949 of file bidi.c.

951{
952 int run_start, run_end, i;
953 int run_count = 0;
954 Run *runs;
955 IsolatedRun *current_isolated;
956
957 if (!(runs = heap_calloc(uCount, sizeof(*runs))))
958 return;
959
960 list_init(set);
961
962 /* Build Runs */
963 run_start = 0;
964 while (run_start < uCount)
965 {
966 run_end = nextValidChar(pcls, run_start, uCount);
967 while (run_end < uCount && pLevel[run_end] == pLevel[run_start]) run_end = nextValidChar(pcls, run_end, uCount);
968 run_end --;
969 runs[run_count].start = run_start;
970 runs[run_count].end = run_end;
971 runs[run_count].e = pLevel[run_start];
972 run_start = nextValidChar(pcls, run_end, uCount);
973 run_count++;
974 }
975
976 /* Build Isolating Runs */
977 i = 0;
978 while (i < run_count)
979 {
980 int k = i;
981 if (runs[k].start >= 0)
982 {
983 int type_fence, real_end;
984 int j;
985
986 if (!(current_isolated = heap_alloc(FIELD_OFFSET(IsolatedRun, item[uCount]))))
987 break;
988
989 run_start = runs[k].start;
990 current_isolated->e = runs[k].e;
991 current_isolated->length = (runs[k].end - runs[k].start)+1;
992
993 for (j = 0; j < current_isolated->length; j++)
994 {
995 current_isolated->item[j].pcls = &pcls[runs[k].start+j];
996 current_isolated->item[j].ch = string[runs[k].start + j];
997 }
998
999 run_end = runs[k].end;
1000
1001 TRACE("{ [%i -- %i]",run_start, run_end);
1002
1003 if (pcls[run_end] == BN)
1004 run_end = previousValidChar(pcls, run_end, runs[k].start);
1005
1006 while (run_end < uCount && (pcls[run_end] == RLI || pcls[run_end] == LRI || pcls[run_end] == FSI))
1007 {
1008 j = k+1;
1009search:
1010 while (j < run_count && pcls[runs[j].start] != PDI) j++;
1011 if (j < run_count && runs[i].e != runs[j].e)
1012 {
1013 j++;
1014 goto search;
1015 }
1016
1017 if (j != run_count)
1018 {
1019 int m;
1020 int l = current_isolated->length;
1021
1022 current_isolated->length += (runs[j].end - runs[j].start)+1;
1023 for (m = 0; l < current_isolated->length; l++, m++)
1024 {
1025 current_isolated->item[l].pcls = &pcls[runs[j].start+m];
1026 current_isolated->item[l].ch = string[runs[j].start + m];
1027 }
1028
1029 TRACE("[%i -- %i]",runs[j].start, runs[j].end);
1030
1031 run_end = runs[j].end;
1032 if (pcls[run_end] == BN)
1033 run_end = previousValidChar(pcls, run_end, runs[i].start);
1034 runs[j].start = -1;
1035 k = j;
1036 }
1037 else
1038 {
1039 run_end = uCount;
1040 break;
1041 }
1042 }
1043
1044 type_fence = previousValidChar(pcls, run_start, -1);
1045
1046 if (type_fence == -1)
1047 current_isolated->sos = (baselevel > pLevel[run_start])?baselevel:pLevel[run_start];
1048 else
1049 current_isolated->sos = (pLevel[type_fence] > pLevel[run_start])?pLevel[type_fence]:pLevel[run_start];
1050
1051 current_isolated->sos = EmbeddingDirection(current_isolated->sos);
1052
1053 if (run_end == uCount)
1054 current_isolated->eos = current_isolated->sos;
1055 else
1056 {
1057 /* eos could be an BN */
1058 if ( pcls[run_end] == BN )
1059 {
1060 real_end = previousValidChar(pcls, run_end, run_start-1);
1061 if (real_end < run_start)
1062 real_end = run_start;
1063 }
1064 else
1065 real_end = run_end;
1066
1067 type_fence = nextValidChar(pcls, run_end, uCount);
1068 if (type_fence == uCount)
1069 current_isolated->eos = (baselevel > pLevel[real_end])?baselevel:pLevel[real_end];
1070 else
1071 current_isolated->eos = (pLevel[type_fence] > pLevel[real_end])?pLevel[type_fence]:pLevel[real_end];
1072
1073 current_isolated->eos = EmbeddingDirection(current_isolated->eos);
1074 }
1075
1076 list_add_tail(set, &current_isolated->entry);
1077 TRACE(" } level %i {%s <--> %s}\n",current_isolated->e, debug_type[current_isolated->sos], debug_type[current_isolated->eos]);
1078 }
1079 i++;
1080 }
1081
1082 heap_free(runs);
1083}
static void list_add_tail(struct list_entry *head, struct list_entry *entry)
Definition: list.h:83
static void list_init(struct list_entry *head)
Definition: list.h:51
Definition: _set.h:50
GLuint start
Definition: gl.h:1545
GLuint GLuint end
Definition: gl.h:1545
const GLfloat * m
Definition: glext.h:10848
#define e
Definition: ke_i.h:82
static ATOM item
Definition: dde.c:856
int k
Definition: mpi.c:3369
static short search(int val, const short *table, int size)
Definition: msg711.c:255
static void * heap_calloc(SIZE_T count, SIZE_T size)
Definition: heap.h:49
WORD eos
Definition: bidi.c:451
WORD sos
Definition: bidi.c:450
struct list entry
Definition: bidi.c:448
WORD e
Definition: bidi.c:452
WORD * pcls
Definition: bidi.c:443
Definition: bidi.c:434
int start
Definition: bidi.c:435
int end
Definition: bidi.c:436
WORD e
Definition: bidi.c:437
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
static WORD EmbeddingDirection(int level)
Definition: bidi.c:187
static int previousValidChar(const WORD *pcls, int index, int back_fence)
Definition: bidi.c:417
static int nextValidChar(const WORD *pcls, int index, int front_fence)
Definition: bidi.c:425
static const char debug_type[][4]
Definition: bidi.c:117

Referenced by BIDI_DetermineLevels().

◆ dump_types()

static void dump_types ( const char header,
WORD types,
int  start,
int  end 
)
inlinestatic

Definition at line 146 of file bidi.c.

147{
148 int i, len = 0;
149 TRACE("%s:",header);
150 for (i = start; i < end && len < 200; i++)
151 {
152 TRACE(" %s",debug_type[types[i]]);
153 len += strlen(debug_type[types[i]])+1;
154 }
155 if (i != end)
156 TRACE("...");
157 TRACE("\n");
158}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLenum GLsizei len
Definition: glext.h:6722
Definition: cmds.c:130

Referenced by BIDI_DetermineLevels().

◆ EmbeddingDirection()

static WORD EmbeddingDirection ( int  level)
static

Definition at line 187 of file bidi.c.

188{
189 return odd(level) ? R : L;
190}

Referenced by computeIsolatingRunsSet(), and resolveNeutrals().

◆ GreaterEven()

static WORD GreaterEven ( int  i)
static

Definition at line 177 of file bidi.c.

178{
179 return odd(i) ? i + 1 : i + 2;
180}

Referenced by resolveExplicit().

◆ GreaterOdd()

static WORD GreaterOdd ( int  i)
static

Definition at line 182 of file bidi.c.

183{
184 return odd(i) ? i + 2 : i + 1;
185}

Referenced by resolveExplicit().

◆ iso_dump_types()

static void iso_dump_types ( const char header,
IsolatedRun iso_run 
)
inlinestatic

Definition at line 475 of file bidi.c.

476{
477 int i, len = 0;
478 TRACE("%s:",header);
479 TRACE("[ ");
480 for (i = 0; i < iso_run->length && len < 200; i++)
481 {
482 TRACE(" %s",debug_type[*iso_run->item[i].pcls]);
483 len += strlen(debug_type[*iso_run->item[i].pcls])+1;
484 }
485 if (i != iso_run->length)
486 TRACE("...");
487 TRACE(" ]\n");
488}

Referenced by BIDI_DetermineLevels().

◆ iso_nextValidChar()

static int iso_nextValidChar ( IsolatedRun iso_run,
int  index 
)
inlinestatic

Definition at line 457 of file bidi.c.

458{
459 if (index >= (iso_run->length-1)) return -1;
460 index ++;
461 while (index < iso_run->length && *iso_run->item[index].pcls == BN) index++;
462 if (index == iso_run->length) return -1;
463 return index;
464}
#define index(s, c)
Definition: various.h:29
GLuint index
Definition: glext.h:6031
GLuint GLsizei GLsizei * length
Definition: glext.h:6040

Referenced by resolveNeutrals(), and resolveWeak().

◆ iso_previousValidChar()

static int iso_previousValidChar ( IsolatedRun iso_run,
int  index 
)
inlinestatic

Definition at line 466 of file bidi.c.

467{
468
469 if (index <= 0) return -1;
470 index --;
471 while (index > -1 && *iso_run->item[index].pcls == BN) index--;
472 return index;
473}

Referenced by resolveNeutrals(), and resolveWeak().

◆ nextValidChar()

static int nextValidChar ( const WORD pcls,
int  index,
int  front_fence 
)
inlinestatic

Definition at line 425 of file bidi.c.

426{
427 if (index == front_fence) return index;
428 index ++;
429 while (index < front_fence && pcls[index] == BN) index ++;
430 return index;
431}

Referenced by computeIsolatingRunsSet().

◆ previousValidChar()

static int previousValidChar ( const WORD pcls,
int  index,
int  back_fence 
)
inlinestatic

Definition at line 417 of file bidi.c.

418{
419 if (index == -1 || index == back_fence) return index;
420 index --;
421 while (index > back_fence && pcls[index] == BN) index --;
422 return index;
423}

Referenced by computeIsolatingRunsSet().

◆ resolveExplicit()

static void resolveExplicit ( int  level,
WORD pclass,
WORD poutLevel,
WORD poutOverrides,
int  count,
BOOL  initialOverride 
)
static

Definition at line 227 of file bidi.c.

228{
229 /* X1 */
230 int overflow_isolate_count = 0;
231 int overflow_embedding_count = 0;
232 int valid_isolate_count = 0;
233 int i;
234
236 int stack_top = MAX_DEPTH+1;
237
238 stack[stack_top].level = level;
239 stack[stack_top].override = NI;
240 stack[stack_top].isolate = FALSE;
241
242 if (initialOverride)
243 {
244 if (odd(level))
246 else
248 }
249
250 for (i = 0; i < count; i++)
251 {
252 poutOverrides[i] = stack[stack_top].override;
253
254 /* X2 */
255 if (pclass[i] == RLE)
256 {
257 int least_odd = GreaterOdd(stack[stack_top].level);
258 poutLevel[i] = stack[stack_top].level;
259 if (valid_level(least_odd))
260 push_stack(least_odd, NI, FALSE);
261 else if (overflow_isolate_count == 0)
262 overflow_embedding_count++;
263 }
264 /* X3 */
265 else if (pclass[i] == LRE)
266 {
267 int least_even = GreaterEven(stack[stack_top].level);
268 poutLevel[i] = stack[stack_top].level;
269 if (valid_level(least_even))
270 push_stack(least_even, NI, FALSE);
271 else if (overflow_isolate_count == 0)
272 overflow_embedding_count++;
273 }
274 /* X4 */
275 else if (pclass[i] == RLO)
276 {
277 int least_odd = GreaterOdd(stack[stack_top].level);
278 poutLevel[i] = stack[stack_top].level;
279 if (valid_level(least_odd))
280 push_stack(least_odd, R, FALSE);
281 else if (overflow_isolate_count == 0)
282 overflow_embedding_count++;
283 }
284 /* X5 */
285 else if (pclass[i] == LRO)
286 {
287 int least_even = GreaterEven(stack[stack_top].level);
288 poutLevel[i] = stack[stack_top].level;
289 if (valid_level(least_even))
290 push_stack(least_even, L, FALSE);
291 else if (overflow_isolate_count == 0)
292 overflow_embedding_count++;
293 }
294 /* X5a */
295 else if (pclass[i] == RLI)
296 {
297 int least_odd = GreaterOdd(stack[stack_top].level);
298 poutLevel[i] = stack[stack_top].level;
299 if (valid_level(least_odd))
300 {
301 valid_isolate_count++;
302 push_stack(least_odd, NI, TRUE);
303 }
304 else
305 overflow_isolate_count++;
306 }
307 /* X5b */
308 else if (pclass[i] == LRI)
309 {
310 int least_even = GreaterEven(stack[stack_top].level);
311 poutLevel[i] = stack[stack_top].level;
312 if (valid_level(least_even))
313 {
314 valid_isolate_count++;
315 push_stack(least_even, NI, TRUE);
316 }
317 else
318 overflow_isolate_count++;
319 }
320 /* X5c */
321 else if (pclass[i] == FSI)
322 {
323 int j;
324 int new_level = 0;
325 int skipping = 0;
326 poutLevel[i] = stack[stack_top].level;
327 for (j = i+1; j < count; j++)
328 {
329 if (pclass[j] == LRI || pclass[j] == RLI || pclass[j] == FSI)
330 {
331 skipping++;
332 continue;
333 }
334 else if (pclass[j] == PDI)
335 {
336 if (skipping)
337 skipping --;
338 else
339 break;
340 continue;
341 }
342
343 if (skipping) continue;
344
345 if (pclass[j] == L)
346 {
347 new_level = 0;
348 break;
349 }
350 else if (pclass[j] == R || pclass[j] == AL)
351 {
352 new_level = 1;
353 break;
354 }
355 }
356 if (odd(new_level))
357 {
358 int least_odd = GreaterOdd(stack[stack_top].level);
359 if (valid_level(least_odd))
360 {
361 valid_isolate_count++;
362 push_stack(least_odd, NI, TRUE);
363 }
364 else
365 overflow_isolate_count++;
366 }
367 else
368 {
369 int least_even = GreaterEven(stack[stack_top].level);
370 if (valid_level(least_even))
371 {
372 valid_isolate_count++;
373 push_stack(least_even, NI, TRUE);
374 }
375 else
376 overflow_isolate_count++;
377 }
378 }
379 /* X6 */
380 else if (pclass[i] != B && pclass[i] != BN && pclass[i] != PDI && pclass[i] != PDF)
381 {
382 poutLevel[i] = stack[stack_top].level;
383 if (stack[stack_top].override != NI)
384 pclass[i] = stack[stack_top].override;
385 }
386 /* X6a */
387 else if (pclass[i] == PDI)
388 {
389 if (overflow_isolate_count) overflow_isolate_count--;
390 else if (!valid_isolate_count) {/* do nothing */}
391 else
392 {
393 overflow_embedding_count = 0;
394 while (!stack[stack_top].isolate) pop_stack();
395 pop_stack();
396 valid_isolate_count --;
397 }
398 poutLevel[i] = stack[stack_top].level;
399 }
400 /* X7 */
401 else if (pclass[i] == PDF)
402 {
403 poutLevel[i] = stack[stack_top].level;
404 if (overflow_isolate_count) {/* do nothing */}
405 else if (overflow_embedding_count) overflow_embedding_count--;
406 else if (!stack[stack_top].isolate && stack_top < (MAX_DEPTH+1))
407 pop_stack();
408 }
409 /* X8: Nothing */
410 }
411 /* X9: Based on 5.2 Retaining Explicit Formatting Characters */
412 for (i = 0; i < count ; i++)
413 if (pclass[i] == RLE || pclass[i] == LRE || pclass[i] == RLO || pclass[i] == LRO || pclass[i] == PDF)
414 pclass[i] = BN;
415}
Definition: ehthrow.cxx:54
static WORD GreaterOdd(int i)
Definition: bidi.c:182
#define MAX_DEPTH
Definition: bidi.c:63
#define valid_level(x)
Definition: bidi.c:225
static WORD GreaterEven(int i)
Definition: bidi.c:177
#define push_stack(l, o, i)
Definition: bidi.c:217
#define pop_stack()
Definition: bidi.c:223

Referenced by BIDI_DetermineLevels().

◆ resolveImplicit()

static void resolveImplicit ( const WORD pcls,
WORD plevel,
int  sos,
int  eos 
)
static

Definition at line 891 of file bidi.c.

892{
893 int i;
894
895 /* I1/2 */
896 for (i = sos; i <= eos; i++)
897 {
898 if (pcls[i] == BN)
899 continue;
900
901 ASSERT(pcls[i] > 0); /* "No Neutrals allowed to survive here." */
902 ASSERT(pcls[i] < 5); /* "Out of range." */
903
904 if (odd(plevel[i]) && (pcls[i] == L || pcls[i] == EN || pcls [i] == AN))
905 plevel[i]++;
906 else if (!odd(plevel[i]) && pcls[i] == R)
907 plevel[i]++;
908 else if (!odd(plevel[i]) && (pcls[i] == EN || pcls [i] == AN))
909 plevel[i]+=2;
910 }
911}
#define ASSERT(x)
Definition: bidi.c:62

Referenced by BIDI_DetermineLevels().

◆ resolveNeutrals()

static void resolveNeutrals ( IsolatedRun iso_run)
static

Definition at line 734 of file bidi.c.

735{
736 int i;
737 BracketPair *pairs = NULL;
738
739 /* Translate isolates into NI */
740 for (i = 0; i < iso_run->length; i++)
741 {
742 if (*iso_run->item[i].pcls >= LRI)
743 *iso_run->item[i].pcls = NI;
744
745 switch(*iso_run->item[i].pcls)
746 {
747 case B:
748 case S:
749 case WS: *iso_run->item[i].pcls = NI;
750 }
751
752 ASSERT(*iso_run->item[i].pcls < 5 || *iso_run->item[i].pcls == BN); /* "Only NI, L, R, AN, EN and BN are allowed" */
753 }
754
755 /* N0: Skipping bracketed pairs for now */
756 pairs = computeBracketPairs(iso_run);
757 if (pairs)
758 {
759 BracketPair *p = &pairs[0];
760 int i = 0;
761 while (p->start >= 0)
762 {
763 int j;
764 int e = EmbeddingDirection(iso_run->e);
765 int o = EmbeddingDirection(iso_run->e+1);
766 BOOL flag_o = FALSE;
767 TRACE("Bracket Pair [%i - %i]\n",p->start, p->end);
768
769 /* N0.b */
770 for (j = p->start+1; j < p->end; j++)
771 {
772 if (N0_TYPE(*iso_run->item[j].pcls) == e)
773 {
774 *iso_run->item[p->start].pcls = e;
775 *iso_run->item[p->end].pcls = e;
776 break;
777 }
778 else if (N0_TYPE(*iso_run->item[j].pcls) == o)
779 flag_o = TRUE;
780 }
781 /* N0.c */
782 if (j == p->end && flag_o)
783 {
784 for (j = p->start; j >= 0; j--)
785 {
786 if (N0_TYPE(*iso_run->item[j].pcls) == o)
787 {
788 *iso_run->item[p->start].pcls = o;
789 *iso_run->item[p->end].pcls = o;
790 break;
791 }
792 else if (N0_TYPE(*iso_run->item[j].pcls) == e)
793 {
794 *iso_run->item[p->start].pcls = e;
795 *iso_run->item[p->end].pcls = e;
796 break;
797 }
798 }
799 if ( j < 0 )
800 {
801 *iso_run->item[p->start].pcls = iso_run->sos;
802 *iso_run->item[p->end].pcls = iso_run->sos;
803 }
804 }
805
806 i++;
807 p = &pairs[i];
808 }
809 heap_free(pairs);
810 }
811
812 /* N1 */
813 for (i = 0; i < iso_run->length; i++)
814 {
815 WORD l,r;
816
817 if (*iso_run->item[i].pcls == NI)
818 {
819 int j;
820 int b = iso_previousValidChar(iso_run, i);
821
822 if (b == -1)
823 {
824 l = iso_run->sos;
825 b = 0;
826 }
827 else
828 {
829 if (*iso_run->item[b].pcls == R || *iso_run->item[b].pcls == AN || *iso_run->item[b].pcls == EN)
830 l = R;
831 else if (*iso_run->item[b].pcls == L)
832 l = L;
833 else /* No string type */
834 continue;
835 }
836 j = iso_nextValidChar(iso_run, i);
837 while (j > -1 && *iso_run->item[j].pcls == NI) j = iso_nextValidChar(iso_run, j);
838
839 if (j == -1)
840 {
841 r = iso_run->eos;
842 j = iso_run->length;
843 }
844 else if (*iso_run->item[j].pcls == R || *iso_run->item[j].pcls == AN || *iso_run->item[j].pcls == EN)
845 r = R;
846 else if (*iso_run->item[j].pcls == L)
847 r = L;
848 else /* No string type */
849 continue;
850
851 if (r == l)
852 {
853 for (b = i; b < j && b < iso_run->length; b++)
854 *iso_run->item[b].pcls = r;
855 }
856 }
857 }
858
859 /* N2 */
860 for (i = 0; i < iso_run->length; i++)
861 {
862 if (*iso_run->item[i].pcls == NI)
863 {
864 int b = i-1;
865 int f = i+1;
866 *iso_run->item[i].pcls = EmbeddingDirection(iso_run->e);
867 if (b > -1 && *iso_run->item[b].pcls == BN)
868 *iso_run->item[b].pcls = EmbeddingDirection(iso_run->e);
869 if (f < iso_run->length && *iso_run->item[f].pcls == BN)
870 *iso_run->item[f].pcls = EmbeddingDirection(iso_run->e);
871 }
872 }
873}
unsigned int BOOL
Definition: ntddk_ex.h:94
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLfloat f
Definition: glext.h:7540
GLfloat GLfloat p
Definition: glext.h:8902
#define f
Definition: ke_i.h:83
#define b
Definition: ke_i.h:79
static BracketPair * computeBracketPairs(IsolatedRun *iso_run)
Definition: bidi.c:646
static int iso_nextValidChar(IsolatedRun *iso_run, int index)
Definition: bidi.c:457
static int iso_previousValidChar(IsolatedRun *iso_run, int index)
Definition: bidi.c:466
#define N0_TYPE(a)
Definition: bidi.c:714

Referenced by BIDI_DetermineLevels().

◆ resolveResolved()

static void resolveResolved ( unsigned  baselevel,
const WORD pcls,
WORD plevel,
int  sos,
int  eos 
)
static

Definition at line 913 of file bidi.c.

914{
915 int i;
916
917 /* L1 */
918 for (i = sos; i <= eos; i++)
919 {
920 if (pcls[i] == B || pcls[i] == S)
921 {
922 int j = i -1;
923 while (i > sos && j >= sos &&
924 (pcls[j] == WS || pcls[j] == FSI || pcls[j] == LRI || pcls[j] == RLI ||
925 pcls[j] == PDI || pcls[j] == LRE || pcls[j] == RLE || pcls[j] == LRO ||
926 pcls[j] == RLO || pcls[j] == PDF || pcls[j] == BN))
927 plevel[j--] = baselevel;
928 plevel[i] = baselevel;
929 }
930 else if (pcls[i] == LRE || pcls[i] == RLE || pcls[i] == LRO || pcls[i] == RLO ||
931 pcls[i] == PDF || pcls[i] == BN)
932 {
933 plevel[i] = i ? plevel[i - 1] : baselevel;
934 }
935 if (i == eos &&
936 (pcls[i] == WS || pcls[i] == FSI || pcls[i] == LRI || pcls[i] == RLI ||
937 pcls[i] == PDI || pcls[i] == LRE || pcls[i] == RLE || pcls[i] == LRO ||
938 pcls[i] == RLO || pcls[i] == PDF || pcls[i] == BN ))
939 {
940 int j = i;
941 while (j >= sos && (pcls[j] == WS || pcls[j] == FSI || pcls[j] == LRI || pcls[j] == RLI ||
942 pcls[j] == PDI || pcls[j] == LRE || pcls[j] == RLE || pcls[j] == LRO ||
943 pcls[j] == RLO || pcls[j] == PDF || pcls[j] == BN))
944 plevel[j--] = baselevel;
945 }
946 }
947}
Definition: movable.cpp:9

Referenced by BIDI_DetermineLevels().

◆ resolveWeak()

static void resolveWeak ( IsolatedRun iso_run)
static

Definition at line 506 of file bidi.c.

507{
508 int i;
509
510 /* W1 */
511 for (i=0; i < iso_run->length; i++)
512 {
513 if (*iso_run->item[i].pcls == NSM)
514 {
515 int j = iso_previousValidChar(iso_run, i);
516 if (j == -1)
517 *iso_run->item[i].pcls = iso_run->sos;
518 else if (*iso_run->item[j].pcls >= LRI)
519 *iso_run->item[i].pcls = ON;
520 else
521 *iso_run->item[i].pcls = *iso_run->item[j].pcls;
522 }
523 }
524
525 /* W2 */
526 for (i = 0; i < iso_run->length; i++)
527 {
528 if (*iso_run->item[i].pcls == EN)
529 {
530 int j = iso_previousValidChar(iso_run, i);
531 while (j > -1)
532 {
533 if (*iso_run->item[j].pcls == R || *iso_run->item[j].pcls == L || *iso_run->item[j].pcls == AL)
534 {
535 if (*iso_run->item[j].pcls == AL)
536 *iso_run->item[i].pcls = AN;
537 break;
538 }
539 j = iso_previousValidChar(iso_run, j);
540 }
541 }
542 }
543
544 /* W3 */
545 for (i = 0; i < iso_run->length; i++)
546 {
547 if (*iso_run->item[i].pcls == AL)
548 *iso_run->item[i].pcls = R;
549 }
550
551 /* W4 */
552 for (i = 0; i < iso_run->length; i++)
553 {
554 if (*iso_run->item[i].pcls == ES)
555 {
556 int b = iso_previousValidChar(iso_run, i);
557 int f = iso_nextValidChar(iso_run, i);
558
559 if (b > -1 && f > -1 && *iso_run->item[b].pcls == EN && *iso_run->item[f].pcls == EN)
560 *iso_run->item[i].pcls = EN;
561 }
562 else if (*iso_run->item[i].pcls == CS)
563 {
564 int b = iso_previousValidChar(iso_run, i);
565 int f = iso_nextValidChar(iso_run, i);
566
567 if (b > -1 && f > -1 && *iso_run->item[b].pcls == EN && *iso_run->item[f].pcls == EN)
568 *iso_run->item[i].pcls = EN;
569 else if (b > -1 && f > -1 && *iso_run->item[b].pcls == AN && *iso_run->item[f].pcls == AN)
570 *iso_run->item[i].pcls = AN;
571 }
572 }
573
574 /* W5 */
575 for (i = 0; i < iso_run->length; i++)
576 {
577 if (*iso_run->item[i].pcls == ET)
578 {
579 int j;
580 for (j = i-1 ; j > -1; j--)
581 {
582 if (*iso_run->item[j].pcls == BN) continue;
583 if (*iso_run->item[j].pcls == ET) continue;
584 else if (*iso_run->item[j].pcls == EN) *iso_run->item[i].pcls = EN;
585 else break;
586 }
587 if (*iso_run->item[i].pcls == ET)
588 {
589 for (j = i+1; j < iso_run->length; j++)
590 {
591 if (*iso_run->item[j].pcls == BN) continue;
592 if (*iso_run->item[j].pcls == ET) continue;
593 else if (*iso_run->item[j].pcls == EN) *iso_run->item[i].pcls = EN;
594 else break;
595 }
596 }
597 }
598 }
599
600 /* W6 */
601 for (i = 0; i < iso_run->length; i++)
602 {
603 if (*iso_run->item[i].pcls == ET || *iso_run->item[i].pcls == ES || *iso_run->item[i].pcls == CS || *iso_run->item[i].pcls == ON)
604 {
605 int b = i-1;
606 int f = i+1;
607 if (b > -1 && *iso_run->item[b].pcls == BN)
608 *iso_run->item[b].pcls = ON;
609 if (f < iso_run->length && *iso_run->item[f].pcls == BN)
610 *iso_run->item[f].pcls = ON;
611
612 *iso_run->item[i].pcls = ON;
613 }
614 }
615
616 /* W7 */
617 for (i = 0; i < iso_run->length; i++)
618 {
619 if (*iso_run->item[i].pcls == EN)
620 {
621 int j;
622 for (j = iso_previousValidChar(iso_run, i); j > -1; j = iso_previousValidChar(iso_run, j))
623 if (*iso_run->item[j].pcls == R || *iso_run->item[j].pcls == L)
624 {
625 if (*iso_run->item[j].pcls == L)
626 *iso_run->item[i].pcls = L;
627 break;
628 }
629 if (iso_run->sos == L && j == -1)
630 *iso_run->item[i].pcls = L;
631 }
632 }
633}

Referenced by BIDI_DetermineLevels().

◆ reverse()

static void reverse ( int pidx,
int  cch 
)
static

Definition at line 1153 of file bidi.c.

1154{
1155 int temp;
1156 int ich = 0;
1157 for (; ich < --cch; ich++)
1158 {
1159 temp = pidx[ich];
1160 pidx[ich] = pidx[cch];
1161 pidx[cch] = temp;
1162 }
1163}
static calc_node_t temp
Definition: rpn_ieee.c:38

Referenced by __next_permutation(), __prev_permutation(), BIDI_ReorderL2vLevel(), BIDI_ReorderV2lLevel(), cert_name_to_str_with_indent(), CertNameToStrA(), ft_stroke_border_close(), RmCpTest::reverse1(), and test_WinHttpAddHeaders().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( bidi  )

Variable Documentation

◆ debug_type

const char debug_type[][4]
static
Initial value:
=
{
"ON",
"L",
"R",
"AN",
"EN",
"AL",
"NSM",
"CS",
"ES",
"ET",
"BN",
"S",
"WS",
"B",
"RLO",
"RLE",
"LRO",
"LRE",
"PDF",
"LRI",
"RLI",
"FSI",
"PDI",
}

Definition at line 117 of file bidi.c.

Referenced by computeIsolatingRunsSet(), dump_types(), and iso_dump_types().

◆ DECLSPEC_HIDDEN

const unsigned short bidi_direction_table [] DECLSPEC_HIDDEN
extern

Definition at line 58 of file bidi.c.