summaryrefslogtreecommitdiff
path: root/pango/mini-fribidi
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2001-04-16 22:42:34 +0000
committerOwen Taylor <otaylor@src.gnome.org>2001-04-16 22:42:34 +0000
commit09ff7235f2481c569e91bf114be126fd92ce7a64 (patch)
treebc8305fd22df25918a27fe5e567c1aef193f9b12 /pango/mini-fribidi
parent8794423e39341d2ebeec77fbce39ced5c18d8d2b (diff)
downloadpango-09ff7235f2481c569e91bf114be126fd92ce7a64.tar.gz
Small updates
Mon Apr 16 18:12:06 2001 Owen Taylor <otaylor@redhat.com> * README: Small updates * examples/HELLO.utf8: Insert a RLM on the Yiddish line to correct for fixes to the bidi algorithm. * pango/mini-fribidi/*: Update to CVS fribidi which has various bug fixes.
Diffstat (limited to 'pango/mini-fribidi')
-rw-r--r--pango/mini-fribidi/Makefile.am2
-rw-r--r--pango/mini-fribidi/README18
-rw-r--r--pango/mini-fribidi/fribidi.c325
-rw-r--r--pango/mini-fribidi/fribidi.patch (renamed from pango/mini-fribidi/fribidi-0.9.0.patch)328
-rw-r--r--pango/mini-fribidi/fribidi_get_type.c20
-rw-r--r--pango/mini-fribidi/fribidi_tables.i10
-rw-r--r--pango/mini-fribidi/fribidi_types.h6
7 files changed, 377 insertions, 332 deletions
diff --git a/pango/mini-fribidi/Makefile.am b/pango/mini-fribidi/Makefile.am
index 1afd6635..53263f14 100644
--- a/pango/mini-fribidi/Makefile.am
+++ b/pango/mini-fribidi/Makefile.am
@@ -23,4 +23,4 @@ EXTRA_DIST = \
README \
makefile.mingw \
fribidi_tables.i \
- fribidi-0.9.0.patch
+ fribidi.patch
diff --git a/pango/mini-fribidi/README b/pango/mini-fribidi/README
index a3a81bdd..5bad0741 100644
--- a/pango/mini-fribidi/README
+++ b/pango/mini-fribidi/README
@@ -40,5 +40,23 @@ The latest version of FriBidi may be found at:
http://imagic.weizmann.ac.il/~dov/freesw/FriBidi
+Notes
+=====
+- shell fragment to generate fribidi.patch:
+ echo -n "" > fribidi.patch
+ for i in fribidi.c fribidi_get_type.c fribidi_tables.i fribidi_types.h ; do
+ diff -u ~/cvs/fribidi/$i $i >> fribidi.patch
+ done
+
+- Shell fragment to update from fribidi
+
+ for i in fribidi.c fribidi_get_type.c fribidi_tables.i fribidi_types.h ; do
+ cp ~/cvs/fribidi/$i .
+ done
+ patch < fribidi.patch
+
+ (And fix rejects)
+
+- Current fribidi.patch is against fribidi CVS with -D "15 Apr 2001"
diff --git a/pango/mini-fribidi/fribidi.c b/pango/mini-fribidi/fribidi.c
index 902cde31..6b5fdf72 100644
--- a/pango/mini-fribidi/fribidi.c
+++ b/pango/mini-fribidi/fribidi.c
@@ -25,28 +25,33 @@
#include "pango/pango-utils.h"
#include "fribidi_types.h"
-#undef DEBUG
-
#ifdef DEBUG
#include <stdio.h>
#endif
+#ifndef FRIBIDI_CHUNK_SIZE
+#define FRIBIDI_CHUNK_SIZE 128
+#endif
+
#ifdef DEBUG
#define DBG(s) if (fribidi_debug) { fprintf(stderr, s); }
+#define DBG2(s, t) if (fribidi_debug) { fprintf(stderr, s, t); }
#else
#define DBG(s)
+#define DBG2(s, t)
#endif
#ifdef DEBUG
-// for easier test with the reference code only.
+/* for easier test with the reference code only */
#define MAX_LEVEL 15
#else
-// default value.
+/* default value */
#define MAX_LEVEL 61
#endif
+
/*======================================================================
-// Typedef for the run-length list.
-//----------------------------------------------------------------------*/
+ * Typedef for the run-length list.
+ *----------------------------------------------------------------------*/
typedef struct _TypeLink TypeLink;
struct _TypeLink
@@ -66,23 +71,17 @@ struct _TypeLink
typedef struct
{
- FriBidiChar key;
- FriBidiChar value;
-}
-key_value_t;
-
-typedef struct
-{
FriBidiCharType override; /* only L, R and N are valid */
gint level;
}
-level_info;
+LevelInfo;
#ifdef DEBUG
static gboolean fribidi_debug = FALSE;
#endif
-gboolean fribidi_set_debug (gboolean debug)
+gboolean
+fribidi_set_debug (gboolean debug)
{
#ifdef DEBUG
return fribidi_debug = debug;
@@ -91,19 +90,6 @@ gboolean fribidi_set_debug (gboolean debug)
#endif
}
-#ifdef DEBUG
-static gint
-bidi_string_strlen (FriBidiChar * str)
-{
- gint len = 0;
-
- while (*str++)
- len++;
-
- return len;
-}
-#endif
-
#ifndef USE_SIMPLE_MALLOC
static TypeLink *free_type_links = NULL;
#endif
@@ -115,7 +101,7 @@ new_type_link (void)
#ifdef USE_SIMPLE_MALLOC
link = g_malloc (sizeof (TypeLink));
-#else
+#else /* !USE_SIMPLE_MALLOC */
if (free_type_links)
{
link = free_type_links;
@@ -126,13 +112,12 @@ new_type_link (void)
static GMemChunk *mem_chunk = NULL;
if (!mem_chunk)
- mem_chunk = g_mem_chunk_new ("TypeLinkList",
- sizeof (TypeLink),
- sizeof (TypeLink) * 128, G_ALLOC_ONLY);
+ mem_chunk =
+ g_mem_chunk_create (TypeLink, FRIBIDI_CHUNK_SIZE, G_ALLOC_ONLY);
link = g_chunk_new (TypeLink, mem_chunk);
}
-#endif
+#endif /* !USE_SIMPLE_MALLOC */
link->len = 0;
link->pos = 0;
@@ -143,7 +128,7 @@ new_type_link (void)
}
static void
-free_type_link (TypeLink * link)
+free_type_link (TypeLink *link)
{
#ifdef USE_SIMPLE_MALLOC
g_free (link);
@@ -154,13 +139,12 @@ free_type_link (TypeLink * link)
}
static TypeLink *
-run_length_encode_types (FriBidiCharType * char_type, gint type_len)
+run_length_encode_types (FriBidiCharType *char_type, gint type_len)
{
- TypeLink *list = NULL, *last, *link;
+ TypeLink *list, *last, *link;
TypeLink current;
- FriBidiCharType type;
- gint len, pos, i;
+ gint i;
/* Add the starting link */
list = new_type_link ();
@@ -214,9 +198,9 @@ run_length_encode_types (FriBidiCharType * char_type, gint type_len)
the override_list.
*/
static void
-init_list (TypeLink ** start, TypeLink ** end)
+init_list (TypeLink **start, TypeLink **end)
{
- TypeLink *list = NULL;
+ TypeLink *list;
TypeLink *link;
/* Add the starting link */
@@ -244,8 +228,8 @@ init_list (TypeLink ** start, TypeLink ** end)
assuming that p have both prev and next or none of them, also update
the list that p is currently in, if any.
*/
-void
-move_element_before (TypeLink * p, TypeLink * list)
+static void
+move_element_before (TypeLink *p, TypeLink *list)
{
if (p->prev)
{
@@ -272,8 +256,8 @@ move_element_before (TypeLink * p, TypeLink * list)
TBD: use some explanatory names instead of p, q, ...
*/
-void
-override_list (TypeLink * base, TypeLink * over)
+static void
+override_list (TypeLink *base, TypeLink *over)
{
TypeLink *p = base, *q, *r, *s, *t;
gint pos = 0, pos2;
@@ -375,7 +359,7 @@ override_list (TypeLink * base, TypeLink * over)
#define RL_LEVEL(list) (list)->level
static void
-compact_list (TypeLink * list)
+compact_list (TypeLink *list)
{
if (list->next)
{
@@ -399,7 +383,7 @@ compact_list (TypeLink * list)
}
static void
-compact_neutrals (TypeLink * list)
+compact_neutrals (TypeLink *list)
{
if (list->next)
{
@@ -410,8 +394,8 @@ compact_neutrals (TypeLink * list)
&&
((RL_TYPE
(list->prev) == RL_TYPE (list)
- || FRIBIDI_IS_NEUTRAL (RL_TYPE (list->prev))
- && FRIBIDI_IS_NEUTRAL (RL_TYPE (list)))))
+ || (FRIBIDI_IS_NEUTRAL (RL_TYPE (list->prev))
+ && FRIBIDI_IS_NEUTRAL (RL_TYPE (list))))))
{
TypeLink *next = list->next;
list->prev->next = list->next;
@@ -427,8 +411,8 @@ compact_neutrals (TypeLink * list)
}
/*=======================================================
-// define macros for push and pop the status in to / out of the stack
-//-------------------------------------------------------*/
+ * define macros for push and pop the status in to / out of the stack
+ *-------------------------------------------------------*/
/* There's some little points in pushing and poping into the status stack:
1. when the embedding level is not valid (more than MAX_LEVEL=61),
@@ -460,9 +444,8 @@ compact_neutrals (TypeLink * list)
{ \
if (level == MAX_LEVEL - 1) \
first_interval = over_pushed; \
- status_stack->level = level; \
- status_stack->override = override; \
- status_stack++; \
+ status_stack[stack_size].level = level; \
+ status_stack[stack_size].override = override; \
stack_size++; \
level = new_level; \
override = new_override; \
@@ -483,33 +466,36 @@ compact_neutrals (TypeLink * list)
{ \
if (over_pushed == first_interval) \
first_interval = 0; \
- status_stack--; \
stack_size--; \
- level = status_stack->level; \
- override = status_stack->override; \
+ level = status_stack[stack_size].level; \
+ override = status_stack[stack_size].override; \
} \
} \
}
/*==========================================================================
-// There was no support for sor and eor in the absence of Explicit Embedding
-// Levels, so define macros, to support them, with as less change as needed.
-//--------------------------------------------------------------------------*/
+ * There was no support for sor and eor in the absence of Explicit Embedding
+ * Levels, so define macros, to support them, with as less change as needed.
+ *--------------------------------------------------------------------------*/
/* Return the type of previous char or the sor, if already at the start of
a run level. */
#define PREV_TYPE_OR_SOR(pp) \
- (RL_LEVEL(pp->prev)==RL_LEVEL(pp) ? RL_TYPE(pp->prev) : FRIBIDI_LEVEL_TO_DIR( \
- (RL_LEVEL(pp->prev)>RL_LEVEL(pp) ? RL_LEVEL(pp->prev) : RL_LEVEL(pp)) \
- ))
+ (RL_LEVEL(pp->prev) == RL_LEVEL(pp) ? \
+ RL_TYPE(pp->prev) : \
+ FRIBIDI_LEVEL_TO_DIR(MAX(RL_LEVEL(pp->prev), RL_LEVEL(pp))) \
+ )
/* Return the type of next char or the eor, if already at the end of
a run level. */
#define NEXT_TYPE_OR_EOR(pp) \
- (!pp->next ? FRIBIDI_LEVEL_TO_DIR(RL_LEVEL(pp)) : \
- (RL_LEVEL(pp->next)==RL_LEVEL(pp) ? RL_TYPE(pp->next) : FRIBIDI_LEVEL_TO_DIR( \
- (RL_LEVEL(pp->next)>RL_LEVEL(pp) ? RL_LEVEL(pp->next) : RL_LEVEL(pp)) \
- )))
+ (!pp->next ? \
+ FRIBIDI_LEVEL_TO_DIR(RL_LEVEL(pp)) : \
+ (RL_LEVEL(pp->next) == RL_LEVEL(pp) ? \
+ RL_TYPE(pp->next) : \
+ FRIBIDI_LEVEL_TO_DIR(MAX(RL_LEVEL(pp->next), RL_LEVEL(pp))) \
+ ) \
+ )
/* Return the embedding direction of a link. */
@@ -518,11 +504,11 @@ compact_neutrals (TypeLink * list)
#ifdef DEBUG
/*======================================================================
-// For debugging, define some functions for printing the types and the
-// levels.
-//----------------------------------------------------------------------*/
+ * For debugging, define some functions for printing the types and the
+ * levels.
+ *----------------------------------------------------------------------*/
-static guchar char_from_level_array[] = {
+static gchar char_from_level_array[] = {
'e', /* FRIBIDI_LEVEL_REMOVED, internal error, this level shouldn't be viewed. */
'_', /* FRIBIDI_LEVEL_START or _END, indicating start of string and end of string. */
/* 0-9,A-F are the only valid levels in debug mode and before resolving
@@ -536,9 +522,9 @@ static guchar char_from_level_array[] = {
#define fribidi_char_from_level(level) char_from_level_array[(level) + 2]
static void
-print_types_re (TypeLink * pp)
+print_types_re (TypeLink *pp)
{
- fprintf (stderr, "Run types : ");
+ fprintf (stderr, " Run types : ");
while (pp)
{
fprintf (stderr, "%d:l%d(%s)[%d] ",
@@ -549,9 +535,9 @@ print_types_re (TypeLink * pp)
}
static void
-print_resolved_levels (TypeLink * pp)
+print_resolved_levels (TypeLink *pp)
{
- fprintf (stderr, "Res. levels: ");
+ fprintf (stderr, " Res. levels: ");
while (pp)
{
gint i;
@@ -563,9 +549,9 @@ print_resolved_levels (TypeLink * pp)
}
static void
-print_resolved_types (TypeLink * pp)
+print_resolved_types (TypeLink *pp)
{
- fprintf (stderr, "Res. types : ");
+ fprintf (stderr, " Res. types : ");
while (pp)
{
gint i;
@@ -576,12 +562,14 @@ print_resolved_types (TypeLink * pp)
fprintf (stderr, "\n");
}
+/* Here, only for test porpuses, we have assumed that a fribidi_string
+ ends with a 0 character */
static void
-print_bidi_string (FriBidiChar * str)
+print_bidi_string (FriBidiChar *str)
{
gint i;
- fprintf (stderr, "Org. types : ");
- for (i = 0; i < bidi_string_strlen (str); i++)
+ fprintf (stderr, " Org. types : ");
+ for (i = 0; str[i]; i++)
fprintf (stderr, "%c",
fribidi_char_from_type (_pango_fribidi_get_type (str[i])));
fprintf (stderr, "\n");
@@ -589,34 +577,38 @@ print_bidi_string (FriBidiChar * str)
#endif
/*======================================================================
-// This function should follow the Unicode specification closely!
-//----------------------------------------------------------------------*/
+ * This function should follow the Unicode specification closely!
+ *----------------------------------------------------------------------*/
static void
fribidi_analyse_string ( /* input */
- FriBidiChar * str,
- gint len, FriBidiCharType * pbase_dir,
+ FriBidiChar *str,
+ gint len, FriBidiCharType *pbase_dir,
/* output */
- TypeLink ** ptype_rl_list, gint * pmax_level)
+ TypeLink **ptype_rl_list, gint *pmax_level)
{
gint base_level, base_dir;
gint max_level;
gint i;
- gint prev_last_strong, last_strong;
- FriBidiCharType *char_type;
TypeLink *type_rl_list, *explicits_list, *explicits_list_end, *pp;
+ DBG ("Entering fribidi_analyse_string()\n");
+
/* Determinate character types */
- char_type = g_new (FriBidiCharType, len);
- for (i = 0; i < len; i++)
- char_type[i] = _pango_fribidi_get_type (str[i]);
+ DBG (" Determine character types\n");
+ {
+ FriBidiCharType char_type[len];
+ for (i = 0; i < len; i++)
+ char_type[i] = _pango_fribidi_get_type (str[i]);
- /* Run length encode the character types */
- type_rl_list = run_length_encode_types (char_type, len);
- g_free (char_type);
+ /* Run length encode the character types */
+ type_rl_list = run_length_encode_types (char_type, len);
+ }
+ DBG (" Determine character types, Done\n");
init_list (&explicits_list, &explicits_list_end);
- /* Find the base level */
+ /* Find base level */
+ DBG (" Finding the base level\n");
if (FRIBIDI_IS_STRONG (*pbase_dir))
base_level = FRIBIDI_DIR_TO_LEVEL (*pbase_dir);
/* P2. P3. Search for first strong character and use its direction as
@@ -639,36 +631,36 @@ fribidi_analyse_string ( /* input */
base_level = FRIBIDI_DIR_TO_LEVEL (*pbase_dir);
}
base_dir = FRIBIDI_LEVEL_TO_DIR (base_level);
+ DBG2 (" Base level : %c\n", fribidi_char_from_level (base_level));
+ DBG2 (" Base dir : %c\n", fribidi_char_from_type (base_dir));
+ DBG (" Finding the base level, Done\n");
#ifdef DEBUG
if (fribidi_debug)
{
- fprintf (stderr, "Base level : %c\n",
- fribidi_char_from_level (base_level));
- fprintf (stderr, "Base dir : %c\n",
- fribidi_char_from_type (base_dir));
print_types_re (type_rl_list);
}
#endif
/* Explicit Levels and Directions */
- DBG ("Explicit Levels and Directions.\n");
+ DBG ("Explicit Levels and Directions\n");
{
/* X1. Begin by setting the current embedding level to the paragraph
embedding level. Set the directional override status to neutral.
Process each character iteratively, applying rules X2 through X9.
Only embedding levels from 0 to 61 are valid in this phase. */
- gint level = base_level;
- gint override = FRIBIDI_TYPE_ON;
- gint new_level, new_override;
- /* stack */
- gint stack_size = 0;
- gint over_pushed = 0;
- gint first_interval = 0;
- level_info *status_stack = g_new (level_info, MAX_LEVEL + 2);
- TypeLink *temp_link = new_type_link ();
+ gint level, override, new_level, new_override, i;
+ gint stack_size, over_pushed, first_interval;
+ LevelInfo *status_stack;
+ TypeLink temp_link;
- gint i;
+ level = base_level;
+ override = FRIBIDI_TYPE_ON;
+ /* stack */
+ stack_size = 0;
+ over_pushed = 0;
+ first_interval = 0;
+ status_stack = g_new(LevelInfo, MAX_LEVEL + 2);
for (pp = type_rl_list->next; pp->next; pp = pp->next)
{
@@ -702,10 +694,10 @@ fribidi_analyse_string ( /* input */
}
/* X9. Remove all RLE, LRE, RLO, LRO, PDF, and BN codes. */
/* Remove element and add it to explicits_list */
- temp_link->next = pp->next;
+ temp_link.next = pp->next;
pp->level = FRIBIDI_LEVEL_REMOVED;
move_element_before (pp, explicits_list_end);
- pp = temp_link;
+ pp = &temp_link;
}
else
{
@@ -729,12 +721,10 @@ fribidi_analyse_string ( /* input */
/* Implementing X8. It has no effect on a single paragraph! */
level = base_level;
override = FRIBIDI_TYPE_ON;
- status_stack -= stack_size;
stack_size = 0;
over_pushed = 0;
- free_type_link (temp_link);
- g_free (status_stack);
+ g_free(status_stack);
}
/* X10. The remaining rules are applied to each run of characters at the
same level. For each run, determine the start-of-level-run (sor) and
@@ -759,7 +749,7 @@ fribidi_analyse_string ( /* input */
#endif
/* 4. Resolving weak types */
- DBG ("Resolving weak types.\n");
+ DBG ("Resolving weak types\n");
{
gint last_strong, prev_type_org, w4;
@@ -881,10 +871,8 @@ fribidi_analyse_string ( /* input */
#endif
/* 5. Resolving Neutral Types */
- DBG ("Resolving neutral types.\n");
+ DBG ("Resolving neutral types\n");
{
- gint prev_type, next_type;
-
/* N1. and N2.
For each neutral, resolve it. */
for (pp = type_rl_list->next; pp->next; pp = pp->next)
@@ -915,7 +903,7 @@ fribidi_analyse_string ( /* input */
#endif
/* 6. Resolving implicit levels */
- DBG ("Resolving implicit levels.\n");
+ DBG ("Resolving implicit levels\n");
{
max_level = base_level;
@@ -952,7 +940,7 @@ fribidi_analyse_string ( /* input */
/* Reinsert the explicit codes & bn's that already removed, from the
explicits_list to type_rl_list. */
- DBG ("Reinserting explicit codes.\n");
+ DBG ("Reinserting explicit codes\n");
{
TypeLink *p;
@@ -974,7 +962,7 @@ fribidi_analyse_string ( /* input */
}
#endif
- DBG ("Reset the embedding levels.\n");
+ DBG ("Reset the embedding levels\n");
{
gint j, k, state, pos;
TypeLink *p, *q, *list, *list_end;
@@ -984,24 +972,23 @@ fribidi_analyse_string ( /* input */
q = list_end;
state = 1;
pos = len - 1;
- for (j = len - 1; j >= 0; j--)
+ for (j = len - 1; j >= -1; j--)
{
- k = _pango_fribidi_get_type (str[j]);
+ /* if state is on at the very first of string, do this too. */
+ if (j >= 0)
+ k = _pango_fribidi_get_type (str[j]);
+ else
+ k = FRIBIDI_TYPE_ON;
if (!state && FRIBIDI_IS_SEPARATOR (k))
{
state = 1;
pos = j;
}
- else
- if (state
- && !(j && FRIBIDI_IS_EXPLICIT_OR_SEPARATOR_OR_BN_OR_WS (k)))
+ else if (state && !FRIBIDI_IS_EXPLICIT_OR_SEPARATOR_OR_BN_OR_WS (k))
{
- /* if state is on at the very first of string, do this too. */
- if (!j)
- j--;
state = 0;
p = new_type_link ();
- p->prev = p->next = 0;
+ p->prev = p->next = NULL;
p->pos = j + 1;
p->len = pos - j;
p->type = base_dir;
@@ -1025,37 +1012,55 @@ fribidi_analyse_string ( /* input */
*ptype_rl_list = type_rl_list;
*pmax_level = max_level;
*pbase_dir = base_dir;
+
+ DBG ("Leaving fribidi_analyse_string()\n");
+ return;
}
/*======================================================================
-// Frees up the rl_list, must be called after each call to
-// fribidi_analyse_string(), after the list is not needed anymore.
-//----------------------------------------------------------------------*/
-void
-free_rl_list (TypeLink * type_rl_list)
+ * Frees up the rl_list, must be called after each call to
+ * fribidi_analyse_string(), after the list is not needed anymore.
+ *----------------------------------------------------------------------*/
+static void
+free_rl_list (TypeLink *type_rl_list)
{
- TypeLink *p, *pp;
+ TypeLink *pp;
+
+ DBG ("Entering free_rl_list()\n");
+
if (!type_rl_list)
- return;
+ {
+ DBG ("Leaving free_rl_list()\n");
+ return;
+ }
+
#ifdef USE_SIMPLE_MALLOC
- for (pp = type_rl_list; pp; pp = pp->next)
+ pp = type_rl_list;
+ while (pp)
{
- p = pp->next;
- g_free (pp);
+ TypeLink *p;
+
+ p = pp;
+ pp = pp->next;
+ free_type_link (p);
};
#else
for (pp = type_rl_list->next; pp->next; pp = pp->next)
- /*Nothing */ ;
+ /* Nothing */ ;
pp->next = free_type_links;
free_type_links = type_rl_list;
type_rl_list = NULL;
#endif
+
+ DBG ("Leaving free_rl_list()\n");
+ return;
}
static gboolean mirroring = TRUE;
-gboolean fribidi_mirroring_status (void)
+gboolean
+fribidi_mirroring_status (void)
{
return mirroring;
}
@@ -1067,30 +1072,33 @@ fribidi_set_mirroring (gboolean mirror)
}
/*======================================================================
-// Here starts the exposed front end functions.
-//----------------------------------------------------------------------*/
+ * Here starts the exposed front end functions.
+ *----------------------------------------------------------------------*/
/*======================================================================
-// fribidi_embedding_levels() is used in order to just get the
-// embedding levels.
-//----------------------------------------------------------------------*/
-void
-pango_log2vis_get_embedding_levels (
- /* input */
- gunichar * str,
- int len,
- PangoDirection *pbase_dir,
+ * fribidi_log2vis_get_embedding_levels() is used in order to just get
+ * the embedding levels.
+ *----------------------------------------------------------------------*/
+gboolean
+pango_log2vis_get_embedding_levels ( /* input */
+ gunichar *str,
+ int len, PangoDirection *pbase_dir,
/* output */
- guint8 * embedding_level_list)
+ guint8 *embedding_level_list)
{
TypeLink *type_rl_list, *pp;
gint max_level;
FriBidiCharType fribidi_base_dir;
-
+
+ DBG ("Entering fribidi_log2vis_get_embedding_levels()\n");
+
fribidi_base_dir = (*pbase_dir == PANGO_DIRECTION_LTR) ? FRIBIDI_TYPE_L : FRIBIDI_TYPE_R;
-
+
if (len == 0)
- return;
+ {
+ DBG ("Leaving fribidi_log2vis_get_embedding_levels()\n");
+ return TRUE;
+ }
fribidi_analyse_string (str, len, &fribidi_base_dir,
/* output */
@@ -1107,6 +1115,9 @@ pango_log2vis_get_embedding_levels (
}
free_rl_list (type_rl_list);
-
+
*pbase_dir = (fribidi_base_dir == FRIBIDI_TYPE_L) ? PANGO_DIRECTION_LTR : PANGO_DIRECTION_RTL;
+
+ DBG ("Leaving fribidi_log2vis_get_embedding_levels()\n");
+ return TRUE;
}
diff --git a/pango/mini-fribidi/fribidi-0.9.0.patch b/pango/mini-fribidi/fribidi.patch
index 6611cf5a..8f405489 100644
--- a/pango/mini-fribidi/fribidi-0.9.0.patch
+++ b/pango/mini-fribidi/fribidi.patch
@@ -1,37 +1,26 @@
---- /home/otaylor/fribidi-0.9.0/fribidi.c Wed Mar 28 01:55:42 2001
-+++ ./fribidi.c Fri Apr 13 14:26:35 2001
-@@ -20,9 +20,13 @@
- * For licensing issues, contact <dov@imagic.weizmann.ac.il> and
+--- /home/otaylor/cvs/fribidi/fribidi.c Wed Apr 11 09:30:56 2001
++++ fribidi.c Mon Apr 16 18:02:02 2001
+@@ -21,10 +21,10 @@
* <fwpg@sharif.edu>.
*/
--
+
+-#ifdef HAVE_CONFIG_H
+-#include <config.h>
+-#endif
-#include "fribidi.h"
--#include "config.h"
-+
+#include <glib.h>
+#include "pango/pango-utils.h"
+#include "fribidi_types.h"
+
-+#undef DEBUG
-+
#ifdef DEBUG
#include <stdio.h>
#endif
-@@ -87,6 +91,7 @@
+@@ -90,30 +90,6 @@
#endif
}
-+#ifdef DEBUG
- static gint
- bidi_string_strlen (FriBidiChar * str)
- {
-@@ -97,30 +102,7 @@
-
- return len;
- }
--
-static void
--bidi_string_reverse (FriBidiChar * str, gint len)
+-bidi_string_reverse (FriBidiChar *str, gint len)
-{
- gint i;
- for (i = 0; i < len / 2; i++)
@@ -43,7 +32,7 @@
-}
-
-static void
--index_array_reverse (FriBidiStrIndex * arr, gint len)
+-index_array_reverse (FriBidiStrIndex *arr, gint len)
-{
- gint i;
- for (i = 0; i < len / 2; i++)
@@ -53,102 +42,84 @@
- arr[len - 1 - i] = tmp;
- }
-}
-+#endif
-
+-
#ifndef USE_SIMPLE_MALLOC
static TypeLink *free_type_links = NULL;
-@@ -231,7 +213,7 @@
- codes that are removed from rl_list, to reinsert them later by calling
- the override_list.
- */
--static void *
-+static void
- init_list (TypeLink ** start, TypeLink ** end)
- {
- TypeLink *list = NULL;
-@@ -601,7 +583,7 @@
- fprintf (stderr, "Org. types : ");
- for (i = 0; i < bidi_string_strlen (str); i++)
+ #endif
+@@ -595,7 +571,7 @@
+ fprintf (stderr, " Org. types : ");
+ for (i = 0; str[i]; i++)
fprintf (stderr, "%c",
- fribidi_char_from_type (fribidi_get_type (str[i])));
+ fribidi_char_from_type (_pango_fribidi_get_type (str[i])));
fprintf (stderr, "\n");
}
#endif
-@@ -626,7 +608,7 @@
- /* Determinate character types */
- char_type = g_new (FriBidiCharType, len);
- for (i = 0; i < len; i++)
-- char_type[i] = fribidi_get_type (str[i]);
-+ char_type[i] = _pango_fribidi_get_type (str[i]);
-
- /* Run length encode the character types */
- type_rl_list = run_length_encode_types (char_type, len);
-@@ -812,7 +794,7 @@
- /* Resolving dependency of loops for rules W1 and W2, so we
- can merge them in one loop. */
- if (next_type == FRIBIDI_TYPE_NSM)
-- RL_TYPE (pp->next) == FRIBIDI_TYPE_AN;
-+ RL_TYPE (pp->next) = FRIBIDI_TYPE_AN;
- }
- }
+@@ -622,7 +598,7 @@
+ {
+ FriBidiCharType char_type[len];
+ for (i = 0; i < len; i++)
+- char_type[i] = fribidi_get_type (str[i]);
++ char_type[i] = _pango_fribidi_get_type (str[i]);
-@@ -1004,7 +986,7 @@
- pos = len - 1;
- for (j = len - 1; j >= 0; j--)
+ /* Run length encode the character types */
+ type_rl_list = run_length_encode_types (char_type, len);
+@@ -1000,7 +976,7 @@
{
-- k = fribidi_get_type (str[j]);
-+ k = _pango_fribidi_get_type (str[j]);
+ /* if state is on at the very first of string, do this too. */
+ if (j >= 0)
+- k = fribidi_get_type (str[j]);
++ k = _pango_fribidi_get_type (str[j]);
+ else
+ k = FRIBIDI_TYPE_ON;
if (!state && FRIBIDI_IS_SEPARATOR (k))
- {
- state = 1;
-@@ -1054,7 +1036,7 @@
- {
-
- TypeLink *p, *pp;
-- if (!pp)
-+ if (!type_rl_list)
- return;
- #ifdef USE_SIMPLE_MALLOC
- for (pp = type_rl_list; pp; pp = pp->next)
-@@ -1089,169 +1071,28 @@
- //----------------------------------------------------------------------*/
+@@ -1100,209 +1076,31 @@
+ *----------------------------------------------------------------------*/
/*======================================================================
--// fribidi_remove_explicits() removes explicit marks, and returns the
--// new length.
--//----------------------------------------------------------------------*/
--gint fribidi_remove_explicits (FriBidiChar * str, gint length)
+- * fribidi_remove_explicits() removes explicit marks, and returns the
+- * new length.
+- *----------------------------------------------------------------------*/
+-gint
+-fribidi_remove_explicits (FriBidiChar *str, gint length)
-{
- gint i, j;
-
+- DBG ("Entering fribidi_remove_explicits()\n");
- j = 0;
- for (i = 0; i < length; i++)
-- if (!FRIBIDI_IS_EXPLICIT (fribidi_get_type (str[i])))
+- if (!FRIBIDI_IS_EXPLICIT (fribidi_get_type (str[i]))
+- && str[i] != UNI_LRM && str[i] != UNI_RLM)
- str[j++] = str[i];
-
+- DBG ("Leaving fribidi_remove_explicits()\n");
- return j;
-}
-
-/*======================================================================
--// fribidi_log2vis() calls the function_analyse_string() and then
--// does reordering and fills in the output strings.
--//----------------------------------------------------------------------*/
--void
+- * fribidi_log2vis() calls the function_analyse_string() and then
+- * does reordering and fills in the output strings.
+- *----------------------------------------------------------------------*/
+-gboolean
-fribidi_log2vis ( /* input */
-- FriBidiChar * str, gint len, FriBidiCharType * pbase_dir,
+- FriBidiChar *str, gint len, FriBidiCharType *pbase_dir,
- /* output */
-- FriBidiChar * visual_str,
-- FriBidiStrIndex * position_L_to_V_list,
-- FriBidiStrIndex * position_V_to_L_list,
-- guint8 * embedding_level_list)
+- FriBidiChar *visual_str,
+- FriBidiStrIndex *position_L_to_V_list,
+- FriBidiStrIndex *position_V_to_L_list,
+- guint8 *embedding_level_list)
-{
- TypeLink *type_rl_list, *pp = NULL;
- gint max_level;
- gboolean private_V_to_L = FALSE;
-
+- DBG ("Entering fribidi_log2vis()\n");
+-
- if (len == 0)
-- return;
+- {
+- DBG ("Leaving fribidi_log2vis()\n");
+- return TRUE;
+- }
-
- /* If l2v is to be calculated we must have l2v as well. If it is not
- given by the caller, we have to make a private instance of it. */
@@ -164,63 +135,81 @@
- fprintf (stderr, "%s: cannot handle strings > %d characters\n",
- PACKAGE, FRIBIDI_MAX_STRING_LENGTH);
-#endif
-- return;
+- return FALSE;
- }
- fribidi_analyse_string (str, len, pbase_dir,
- /* output */
- &type_rl_list, &max_level);
-
- /* 7. Reordering resolved levels */
-- DBG ("Reordering resolved levels.\n");
+- DBG ("Reordering resolved levels\n");
- {
- gint level_idx;
-- gint i, j;
+- gint i;
-
- /* TBD: L3 */
-
- /* Set up the ordering array to sorted order */
- if (position_V_to_L_list)
-- for (i = 0; i < len + 1; i++)
-- position_V_to_L_list[i] = i;
+- {
+- DBG (" Initialize position_V_to_L_list\n");
+- for (i = 0; i < len; i++)
+- position_V_to_L_list[i] = i;
+- DBG (" Initialize position_V_to_L_list, Done\n");
+- }
- /* Copy the logical string to the visual */
- if (visual_str)
-- for (i = 0; i < len + 1; i++)
-- visual_str[i] = str[i];
+- {
+- DBG (" Initialize visual_str\n");
+- for (i = 0; i <= len; i++)
+- visual_str[i] = str[i];
+- visual_str[len] = 0;
+- DBG (" Initialize visual_str, Done\n");
+- }
-
- /* Assign the embedding level array */
- if (embedding_level_list)
-- for (pp = type_rl_list->next; pp->next; pp = pp->next)
-- {
-- gint i;
-- gint pos = RL_POS (pp);
-- gint len = RL_LEN (pp);
-- gint level = RL_LEVEL (pp);
-- for (i = 0; i < len; i++)
-- embedding_level_list[pos + i] = level;
-- }
+- {
+- DBG (" Fill the embedding levels array\n");
+- for (pp = type_rl_list->next; pp->next; pp = pp->next)
+- {
+- gint i, pos, len, level;
+-
+- pos = pp->pos;
+- len = pp->len;
+- level = pp->level;
+- for (i = 0; i < len; i++)
+- embedding_level_list[pos + i] = level;
+- }
+- DBG (" Fill the embedding levels array, Done\n");
+- }
-
- /* Reorder both the outstring and the order array */
- if (visual_str || position_V_to_L_list)
- {
--
- if (mirroring && visual_str)
-- /* L4. Mirror all characters that are in odd levels and have mirrors. */
-- for (pp = type_rl_list->next; pp->next; pp = pp->next)
-- {
-- if (RL_LEVEL (pp) & 1)
-- {
-- gint i;
-- for (i = RL_POS (pp); i < RL_POS (pp) + RL_LEN (pp); i++)
-- {
-- FriBidiChar mirrored_ch;
-- if (fribidi_get_mirror_char
-- (visual_str[i], &mirrored_ch))
-- visual_str[i] = mirrored_ch;
-- }
-- }
-- }
+- {
+- /* L4. Mirror all characters that are in odd levels and have mirrors. */
+- DBG (" Mirroring\n");
+- for (pp = type_rl_list->next; pp->next; pp = pp->next)
+- {
+- if (pp->level & 1)
+- {
+- gint i;
+- for (i = RL_POS (pp); i < RL_POS (pp) + RL_LEN (pp); i++)
+- {
+- FriBidiChar mirrored_ch;
+- if (fribidi_get_mirror_char
+- (visual_str[i], &mirrored_ch))
+- visual_str[i] = mirrored_ch;
+- }
+- }
+- }
+- DBG (" Mirroring, Done\n");
+- }
-
- /* L2. Reorder. */
+- DBG (" Reordering\n");
- for (level_idx = max_level; level_idx > 0; level_idx--)
- {
- for (pp = type_rl_list->next; pp->next; pp = pp->next)
@@ -244,62 +233,75 @@
- }
- }
- }
+- DBG (" Reordering, Done\n");
- }
-
- /* Convert the v2l list to l2v */
- if (position_L_to_V_list)
-- for (i = 0; i < len; i++)
-- position_L_to_V_list[position_V_to_L_list[i]] = i;
+- {
+- DBG (" Converting v2l list to l2v\n");
+- for (i = 0; i <= len; i++)
+- position_L_to_V_list[position_V_to_L_list[i]] = i;
+- DBG (" Converting v2l list to l2v, Done\n");
+- }
- }
+- DBG ("Reordering resolved levels, Done\n");
-
- if (private_V_to_L)
- g_free (position_V_to_L_list);
-
- free_rl_list (type_rl_list);
-
+- DBG ("Leaving fribidi_log2vis()\n");
+- return TRUE;
+-
-}
-
-/*======================================================================
- // fribidi_embedding_levels() is used in order to just get the
- // embedding levels.
- //----------------------------------------------------------------------*/
- void
--fribidi_log2vis_get_embedding_levels (
-+pango_log2vis_get_embedding_levels (
- /* input */
-- FriBidiChar * str,
-- gint len, FriBidiCharType * pbase_dir,
-+ gunichar * str,
-+ int len,
-+ PangoDirection *pbase_dir,
+ * fribidi_log2vis_get_embedding_levels() is used in order to just get
+ * the embedding levels.
+ *----------------------------------------------------------------------*/
+ gboolean
+-fribidi_log2vis_get_embedding_levels ( /* input */
+- FriBidiChar *str,
+- gint len, FriBidiCharType *pbase_dir,
++pango_log2vis_get_embedding_levels ( /* input */
++ gunichar *str,
++ int len, PangoDirection *pbase_dir,
/* output */
- guint8 * embedding_level_list)
+ guint8 *embedding_level_list)
{
TypeLink *type_rl_list, *pp;
gint max_level;
--
-- if (len = 0)
+ FriBidiCharType fribidi_base_dir;
-+
+
+ DBG ("Entering fribidi_log2vis_get_embedding_levels()\n");
+
+ fribidi_base_dir = (*pbase_dir == PANGO_DIRECTION_LTR) ? FRIBIDI_TYPE_L : FRIBIDI_TYPE_R;
-+
-+ if (len == 0)
- return;
++
+ if (len == 0)
+ {
+ DBG ("Leaving fribidi_log2vis_get_embedding_levels()\n");
+ return TRUE;
+ }
- fribidi_analyse_string (str, len, pbase_dir,
+ fribidi_analyse_string (str, len, &fribidi_base_dir,
/* output */
&type_rl_list, &max_level);
-@@ -1266,28 +1107,6 @@
+@@ -1317,31 +1115,9 @@
}
free_rl_list (type_rl_list);
-+
++
+ *pbase_dir = (fribidi_base_dir == FRIBIDI_TYPE_L) ? PANGO_DIRECTION_LTR : PANGO_DIRECTION_RTL;
+
+ DBG ("Leaving fribidi_log2vis_get_embedding_levels()\n");
+ return TRUE;
}
-
--guchar *fribidi_version_info =
+-gchar *fribidi_version_info =
- "Copyright (C) 2001 FriBidi Project.\n"
- PACKAGE " comes with NO WARRANTY, to the extent permitted by law.\n"
- "You may redistribute copies of " PACKAGE " under the terms of\n"
@@ -322,8 +324,8 @@
-#endif
-#endif
- ;
---- /home/otaylor/fribidi-0.9.0/fribidi_get_type.c Wed Mar 28 01:55:42 2001
-+++ ./fribidi_get_type.c Fri Apr 13 14:15:44 2001
+--- /home/otaylor/cvs/fribidi/fribidi_get_type.c Mon Apr 9 08:40:57 2001
++++ fribidi_get_type.c Mon Apr 16 17:50:54 2001
@@ -23,7 +23,9 @@
#include <stdio.h>
@@ -336,37 +338,43 @@
#ifdef MEM_OPTIMIZED
@@ -34,7 +36,7 @@
- // fribidi_get_type() returns the bidi type of a character.
- //----------------------------------------------------------------------*/
+ * fribidi_get_type() returns the bidi type of a character.
+ *----------------------------------------------------------------------*/
FriBidiCharType
-fribidi_get_type (FriBidiChar uch)
+_pango_fribidi_get_type(FriBidiChar uch)
{
int i = uch % 256, j = uch / 256;
FriBidiPropCharType *block = FriBidiPropertyBlocks[j];
-@@ -80,7 +82,7 @@
- }
+@@ -81,10 +83,10 @@
}
--gboolean fribidi_get_mirror_char ( /* Input */
-+gboolean pango_get_mirror_char ( /* Input */
- FriBidiChar ch,
- /* Output */
- FriBidiChar * mirrored_ch)
---- /home/otaylor/fribidi-0.9.0/fribidi_tables.i Wed Mar 28 03:02:09 2001
-+++ ./fribidi_tables.i Fri Apr 13 14:22:07 2001
-@@ -3,8 +3,6 @@
- // and BidiMirroring.txt, version 1, by the perl script CreateGetType.pl.
- //----------------------------------------------------------------------*/
+ gboolean
+-fribidi_get_mirror_char ( /* Input */
+- FriBidiChar ch,
+- /* Output */
+- FriBidiChar *mirrored_ch)
++pango_get_mirror_char ( /* Input */
++ FriBidiChar ch,
++ /* Output */
++ FriBidiChar * mirrored_ch)
+ {
+ int pos, step;
+ gboolean found;
+--- /home/otaylor/cvs/fribidi/fribidi_tables.i Sat Apr 7 14:54:47 2001
++++ fribidi_tables.i Mon Apr 16 17:53:51 2001
+@@ -4,8 +4,6 @@
+ *----------------------------------------------------------------------*/
+ /* *INDENT-OFF* */
-#include "fribidi.h"
-
#define WS FRIBIDI_PROP_TYPE_WS
#define BS FRIBIDI_PROP_TYPE_BS
#define EO FRIBIDI_PROP_TYPE_EO
---- /home/otaylor/fribidi-0.9.0/fribidi_types.h Wed Mar 28 01:55:42 2001
-+++ ./fribidi_types.h Fri Apr 13 14:04:11 2001
-@@ -281,4 +281,6 @@
+--- /home/otaylor/cvs/fribidi/fribidi_types.h Mon Apr 9 08:40:57 2001
++++ fribidi_types.h Mon Apr 16 17:52:01 2001
+@@ -279,4 +279,6 @@
#define FRIBIDI_MAX_STRING_LENGTH 65535
#endif
diff --git a/pango/mini-fribidi/fribidi_get_type.c b/pango/mini-fribidi/fribidi_get_type.c
index e93643fd..b49b7eb3 100644
--- a/pango/mini-fribidi/fribidi_get_type.c
+++ b/pango/mini-fribidi/fribidi_get_type.c
@@ -33,8 +33,8 @@ extern FriBidiCharType prop_to_type[];
#endif
/*======================================================================
-// fribidi_get_type() returns the bidi type of a character.
-//----------------------------------------------------------------------*/
+ * fribidi_get_type() returns the bidi type of a character.
+ *----------------------------------------------------------------------*/
FriBidiCharType
_pango_fribidi_get_type(FriBidiChar uch)
{
@@ -82,13 +82,14 @@ _pango_fribidi_get_type(FriBidiChar uch)
}
}
-gboolean pango_get_mirror_char ( /* Input */
- FriBidiChar ch,
- /* Output */
- FriBidiChar * mirrored_ch)
+gboolean
+pango_get_mirror_char ( /* Input */
+ FriBidiChar ch,
+ /* Output */
+ FriBidiChar * mirrored_ch)
{
int pos, step;
- gboolean found = FALSE;
+ gboolean found;
pos = step = (nFriBidiMirroredChars / 2) + 1;
@@ -117,5 +118,10 @@ gboolean pango_get_mirror_char ( /* Input */
*mirrored_ch = FriBidiMirroredChars[pos].mirrored_ch;
found = TRUE;
}
+ else
+ {
+ *mirrored_ch = ch;
+ found = FALSE;
+ }
return found;
}
diff --git a/pango/mini-fribidi/fribidi_tables.i b/pango/mini-fribidi/fribidi_tables.i
index 850487ac..fb619aa7 100644
--- a/pango/mini-fribidi/fribidi_tables.i
+++ b/pango/mini-fribidi/fribidi_tables.i
@@ -1,7 +1,8 @@
/*========================================================================
-// This file was automatically created from PropList.txt, version 3.0.1,
-// and BidiMirroring.txt, version 1, by the perl script CreateGetType.pl.
-//----------------------------------------------------------------------*/
+ * This file was automatically created from PropList.txt, version 3.0.1,
+ * and BidiMirroring.txt, version 1, by the perl script CreateGetType.pl.
+ *----------------------------------------------------------------------*/
+/* *INDENT-OFF* */
#define WS FRIBIDI_PROP_TYPE_WS
#define BS FRIBIDI_PROP_TYPE_BS
@@ -1097,3 +1098,6 @@ struct {
};
gint nFriBidiMirroredChars = 140;
+
+
+/* *INDENT-ON* */
diff --git a/pango/mini-fribidi/fribidi_types.h b/pango/mini-fribidi/fribidi_types.h
index 427737c7..19a920ef 100644
--- a/pango/mini-fribidi/fribidi_types.h
+++ b/pango/mini-fribidi/fribidi_types.h
@@ -60,8 +60,6 @@ typedef enum
/* Can be on only if FRIBIDI_MASK_EXPLICIT is also on. */
FRIBIDI_MASK_OVERRIDE = 0x00004000, /* Is explicit override: LRO, RLO */
- /* Can be on for SOT and EOT sentinels only, not a valid char if is on. */
-
/* The following must be to make types pairwise different, some of them can
be removed but are here because of efficiency (make queries faster). */
@@ -223,9 +221,9 @@ FriBidiCharType;
FRIBIDI_TYPE_ON)
-guchar fribidi_char_from_type (FriBidiCharType c);
+gchar fribidi_char_from_type (FriBidiCharType c);
-guchar *fribidi_type_name (FriBidiCharType c);
+gchar *fribidi_type_name (FriBidiCharType c);
/* Define character types that fribidi_tables.i uses. if MEM_OPTIMIZED