static void die(const char *fmt, ...)
{
va_list ap;
- va_start(ap,fmt);
-
+ va_start(ap,fmt);
+
vfprintf(stderr, fmt, ap);
exit(-1);
}
+static
FriBidiChar parse_uni_char(const char *start, int len)
{
return strtoul(start, NULL, 16);
}
+static
void parse_test_line (char *line,
int line_no,
FriBidiChar **code_points, /* Field 0 */
char *end;
int level;
-
+
code_points_array = g_array_new (FALSE, FALSE, sizeof (FriBidiChar));
levels_array = g_array_new (FALSE, FALSE, sizeof (FriBidiLevel));
line = end;
}
-
+
*code_points_len = code_points_array->len;
*code_points = (FriBidiChar *) g_array_free (code_points_array, FALSE);
line++;
else
die("Oops! Didn't find expected ;\n");
-
+
/* Field 2. resolved paragraph_dir */
end = line;
while (isdigit (*end))
for(; errno = 0, level = strtol (line, &end, 10), line != end && errno != EINVAL; line = end) {
g_array_append_val (visual_ordering_array, level);
}
-
+
*visual_ordering_len = visual_ordering_array->len;
*visual_ordering = (int*)g_array_free (visual_ordering_array, FALSE);
}
}
die("Unknown option %s!\n", arg);
}
-
+
filename = argv[next_arg++];
error = NULL;
types_len,
&base_dir,
levels))
- ;
+ {}
for (i = 0; i < types_len; i++)
ltor[i] = i;
levels,
NULL,
ltor))
- ;
+ {}
j = 0;
for (i = 0; i < types_len; i++)
types_len,
&base_dir,
levels))
- ;
+ {}
fribidi_set_debug (0);
}
* Copyright (C) 2004 Sharif FarsiWeb, Inc
* Copyright (C) 2001,2002 Behdad Esfahbod
* Copyright (C) 1999,2000,2017 Dov Grobgeld
- *
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public License
* along with this library, in a file named COPYING; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA
- *
+ *
* For licensing issues, contact <fribidi.license@gmail.com>.
*/
/* Some convenience macros */
#define RL_TYPE(list) ((list)->type)
#define RL_LEN(list) ((list)->len)
-#define RL_POS(list) ((list)->pos)
#define RL_LEVEL(list) ((list)->level)
/* "Within this scope, bidirectional types EN and AN are treated as R" */
while (ppp)
{
FriBidiCharType ppp_type = RL_TYPE (ppp);
-
+
if (ppp_type == _FRIBIDI_TYPE_SENTINEL)
break;
static void sort_pairing_nodes(FriBidiPairingNode **nodes)
{
+ FriBidiPairingNode *front, *back;
+
/* 0 or 1 node case */
if (!*nodes || !(*nodes)->next)
return;
- FriBidiPairingNode *front, *back;
pairing_nodes_front_back_split(*nodes, &front, &back);
sort_pairing_nodes(&front);
sort_pairing_nodes(&back);
FriBidiParType base_dir;
FriBidiRun *main_run_list = NULL, *explicits_list = NULL, *pp;
fribidi_boolean status = false;
+ int max_iso_level = 0;
if UNLIKELY
(!len)
isolate_overflow--;
RL_LEVEL (pp) = level;
}
-
+
else if (valid_isolate_count > 0)
{
/* Pop away all LRE,RLE,LRO, RLO levels
else
new_level = level + 2 - (level%2);
}
-
+
RL_LEVEL (pp) = level;
RL_ISOLATE_LEVEL (pp) = isolate_level++;
base_level_per_iso_level[isolate_level] = new_level;
# endif /* DEBUG */
/* 4. Resolving weak types. Also calculate the maximum isolate level */
- int max_iso_level = 0;
+ max_iso_level = 0;
DBG ("resolving weak types");
{
int *last_strong_stack;
pp = merge_with_prev (pp);
}
else
- RL_TYPE (pp) = prev_type;
+ RL_TYPE (pp) = prev_type;
if (prev_type == next_type && RL_LEVEL (pp) == RL_LEVEL (pp->next))
{
last_strong_stack[iso_level] = prev_type;
/* W2 ??? */
-
+
/* W3: Change ALs to R. */
if (this_type == FRIBIDI_TYPE_AL)
{
FriBidiPairingNode *pairing_nodes = NULL;
FriBidiRun ***bracket_stack = fribidi_malloc(sizeof(bracket_stack[0])
* num_iso_levels);
-
- memset(bracket_stack, 0, sizeof(bracket_stack[0])*num_iso_levels);
-
int *bracket_stack_size = fribidi_malloc(sizeof(bracket_stack_size[0])
* num_iso_levels);
+ int last_level = RL_LEVEL(main_run_list);
+ int last_iso_level = 0;
+
+ memset(bracket_stack, 0, sizeof(bracket_stack[0])*num_iso_levels);
memset(bracket_stack_size, 0, sizeof(bracket_stack_size[0])*num_iso_levels);
/* Build the bd16 pair stack. */
- int last_level = RL_LEVEL(main_run_list);
- int last_iso_level = 0;
for_run_list (pp, main_run_list)
{
int level = RL_LEVEL(pp);
int iso_level = RL_ISOLATE_LEVEL(pp);
+ FriBidiBracketType brack_prop = RL_BRACKET_TYPE(pp);
/* Interpret the isolating run sequence as such that they
end at a change in the level, unless the iso_level has been
raised. */
if (level != last_level && last_iso_level == iso_level)
bracket_stack_size[last_iso_level] = 0;
-
+
if (!bracket_stack[iso_level])
bracket_stack[iso_level] = fribidi_malloc (sizeof (bracket_stack[0])
* FRIBIDI_BIDI_MAX_NESTED_BRACKET_PAIRS);
- FriBidiBracketType brack_prop = RL_BRACKET_TYPE(pp);
if (brack_prop!= FRIBIDI_NO_BRACKET)
{
if (FRIBIDI_IS_BRACKET_OPEN(brack_prop))
{
if (bracket_stack_size[iso_level]==FRIBIDI_BIDI_MAX_NESTED_BRACKET_PAIRS)
break;
-
+
/* push onto the pair stack */
bracket_stack[iso_level][bracket_stack_size[iso_level]++] = pp;
}
if (FRIBIDI_BRACKET_ID(se_brack_prop) == FRIBIDI_BRACKET_ID(brack_prop))
{
bracket_stack_size[iso_level] = stack_idx;
-
+
pairing_nodes = pairing_nodes_push(pairing_nodes,
bracket_stack[iso_level][stack_idx],
pp);
while (ppairs)
{
int iso_level = ppairs->open->isolate_level;
- int embedding_level = base_level_per_iso_level[iso_level];
-
+ int embedding_level = base_level_per_iso_level[iso_level];
+
/* Find matching strong. */
fribidi_boolean found = false;
FriBidiRun *ppn;
for (ppn = ppairs->open; ppn!= ppairs->close; ppn = ppn->next)
{
FriBidiCharType this_type = RL_TYPE_AN_EN_AS_RTL(ppn);
-
+
/* Calculate level like in resolve implicit levels below to prevent
embedded levels not to match the base_level */
int this_level = RL_LEVEL (ppn) +
(FRIBIDI_LEVEL_IS_RTL (RL_LEVEL(ppn)) ^ FRIBIDI_DIR_TO_LEVEL (this_type));
-
+
/* N0b */
if (FRIBIDI_IS_STRONG (this_type) && this_level == embedding_level)
{
break;
}
}
-
+
/* N0c */
/* Search for any strong type preceding and within the bracket pair */
if (!found)
{
prec_strong_level = RL_LEVEL (ppn) +
(FRIBIDI_LEVEL_IS_RTL (RL_LEVEL(ppn)) ^ FRIBIDI_DIR_TO_LEVEL (this_type));
-
+
break;
}
}
-
+
for (ppn = ppairs->open; ppn!= ppairs->close; ppn = ppn->next)
{
FriBidiCharType this_type = RL_TYPE_AN_EN_AS_RTL(ppn);
}
}
}
-
+
ppairs = ppairs->next;
}
-
+
free_pairing_nodes(pairing_nodes);
{
int i;
}
fribidi_free(bracket_stack);
fribidi_free(bracket_stack_size);
-
+
/* Remove the bracket property and re-compact */
- const FriBidiBracketType NoBracket = FRIBIDI_NO_BRACKET;
- for_run_list (pp, main_run_list)
- pp->bracket_type = NoBracket;
- compact_list (main_run_list);
+ {
+ const FriBidiBracketType NoBracket = FRIBIDI_NO_BRACKET;
+ for_run_list (pp, main_run_list)
+ pp->bracket_type = NoBracket;
+ compact_list (main_run_list);
+ }
}
# if DEBUG