{
FriBidiCharType ppp_type = RL_TYPE (ppp);
- if (ppp_type == _FRIBIDI_TYPE_SENTINEL)
+ if (ppp_type == FRIBIDI_TYPE_SENTINEL)
break;
/* Note that when sweeping forward we continue one run
* define macros for push and pop the status in to / out of the stack
*-------------------------------------------------------------------------*/
-/* There are a few little points in pushing into and poping from the status
+/* There are a few little points in pushing into and popping from the status
stack:
1. when the embedding level is not valid (more than
FRIBIDI_BIDI_MAX_EXPLICIT_LEVEL=125), you must reject it, and not to push
FriBidiLevel *embedding_levels
)
{
- FriBidiLevel base_level_per_iso_level[FRIBIDI_BIDI_MAX_EXPLICIT_LEVEL];
FriBidiLevel base_level, max_level = 0;
FriBidiParType base_dir;
FriBidiRun *main_run_list = NULL, *explicits_list = NULL, *pp;
DBG2 (" base level : %c", fribidi_char_from_level (base_level));
DBG2 (" base dir : %s", fribidi_get_bidi_type_name (base_dir));
- base_level_per_iso_level[0] = base_level;
-
# if DEBUG
if UNLIKELY
(fribidi_debug_status ())
} status_stack[FRIBIDI_BIDI_MAX_RESOLVED_LEVELS];
FriBidiRun temp_link;
FriBidiRun *run_per_isolate_level[FRIBIDI_BIDI_MAX_RESOLVED_LEVELS];
+ int prev_isolate_level = 0; /* When running over the isolate levels, remember the previous level */
memset(run_per_isolate_level, 0, sizeof(run_per_isolate_level[0])
* FRIBIDI_BIDI_MAX_RESOLVED_LEVELS);
}
RL_LEVEL (pp) = level;
- RL_ISOLATE_LEVEL (pp) = isolate_level++;
- base_level_per_iso_level[isolate_level] = new_level;
+ RL_ISOLATE_LEVEL (pp) = isolate_level;
+ if (isolate_level < FRIBIDI_BIDI_MAX_EXPLICIT_LEVEL-1)
+ isolate_level++;
if (!FRIBIDI_IS_NEUTRAL (override))
RL_TYPE (pp) = override;
}
/* Build the isolate_level connections */
+ prev_isolate_level = 0;
for_run_list (pp, main_run_list)
{
int isolate_level = RL_ISOLATE_LEVEL (pp);
+ int i;
+
+ /* When going from an upper to a lower level, zero out all higher levels
+ in order not erroneous connections! */
+ if (isolate_level<prev_isolate_level)
+ for (i=isolate_level+1; i<=prev_isolate_level; i++)
+ run_per_isolate_level[i]=0;
+ prev_isolate_level = isolate_level;
+
if (run_per_isolate_level[isolate_level])
{
run_per_isolate_level[isolate_level]->next_isolate = pp;
/* 4. Resolving weak types. Also calculate the maximum isolate level */
max_iso_level = 0;
- DBG ("resolving weak types");
+ DBG ("4a. resolving weak types");
{
int last_strong_stack[FRIBIDI_BIDI_MAX_RESOLVED_LEVELS];
FriBidiCharType prev_type_orig;
}
}
+# if DEBUG
+ if UNLIKELY
+ (fribidi_debug_status ())
+ {
+ print_resolved_levels (main_run_list);
+ print_resolved_types (main_run_list);
+ }
+# endif /* DEBUG */
+ /* The last iso level is used to invalidate the the last strong values when going from
+ a higher to a lower iso level. When this occur, all "last_strong" values are
+ set to the base_dir. */
last_strong_stack[0] = base_dir;
+ DBG ("4b. resolving weak types. W4 and W5");
+
/* Resolving dependency of loops for rules W4 and W5, W5 may
want to prevent W4 to take effect in the next turn, do this
through "w4". */
/* 5. Resolving Neutral Types */
- DBG ("resolving neutral types - N0");
+ DBG ("5. resolving neutral types - N0");
{
/* BD16 - Build list of all pairs*/
int num_iso_levels = max_iso_level + 1;
FriBidiPairingNode *ppairs = pairing_nodes;
while (ppairs)
{
- int iso_level = ppairs->open->isolate_level;
- int embedding_level = base_level_per_iso_level[iso_level];
+ int embedding_level = ppairs->open->level;
/* Find matching strong. */
fribidi_boolean found = false;
compare with the preceding strong to establish whether
to apply N0c1 (opposite) or N0c2 embedding */
RL_TYPE(ppairs->open) = RL_TYPE(ppairs->close) = prec_strong_level % 2 ? FRIBIDI_TYPE_RTL : FRIBIDI_TYPE_LTR;
- RL_LEVEL(ppairs->open) = RL_LEVEL(ppairs->close) = prec_strong_level;
found = true;
break;
}