[FriBidi-commit] fribidi2/lib Headers.mk, 1.7, 1.8 Makefile.am, 1.14, 1.15 arabic-misc.tab.i, NONE, 1.1 debug.h, 1.7, 1.8 env.h, 1.3, NONE fribidi-arabic.c, NONE, 1.1 fribidi-arabic.h, NONE, 1.1 fribidi-bidi.c, 1.18, 1.19 fribidi-bidi.h, 1.14, 1.15 fribidi-common.h, 1.10, 1.11 fribidi-config.h.in, 1.4, 1.5 fribidi-deprecated.c, NONE, 1.1 fribidi-deprecated.h, NONE, 1.1 fribidi-env.c, 1.3, NONE fribidi-env.h, 1.2, NONE fribidi-flags.h, NONE, 1.1 fribidi-joining-types.c, 1.3, 1.4 fribidi-joining-types.h, 1.4, 1.5 fribidi-joining.c, 1.4, 1.5 fribidi-mem.c, 1.6, 1.7 fribidi-mirroring.c, 1.14, 1.15 fribidi-run.c, 1.6, 1.7 fribidi-shape.c, NONE, 1.1 fribidi-shape.h, NONE, 1.1 fribidi-types.h, 1.10, 1.11 fribidi-unicode.h, 1.5, 1.6 fribidi.c, 1.16, 1.17 fribidi.h, 1.8, 1.9 joining-types.h, 1.2, 1.3

Behdad Esfahbod behdad at freedesktop.org
Wed Nov 2 17:39:03 PST 2005


Update of /cvs/fribidi/fribidi2/lib
In directory gabe:/tmp/cvs-serv12087/lib

Modified Files:
	Headers.mk Makefile.am debug.h fribidi-bidi.c fribidi-bidi.h 
	fribidi-common.h fribidi-config.h.in fribidi-joining-types.c 
	fribidi-joining-types.h fribidi-joining.c fribidi-mem.c 
	fribidi-mirroring.c fribidi-run.c fribidi-types.h 
	fribidi-unicode.h fribidi.c fribidi.h joining-types.h 
Added Files:
	arabic-misc.tab.i fribidi-arabic.c fribidi-arabic.h 
	fribidi-deprecated.c fribidi-deprecated.h fribidi-flags.h 
	fribidi-shape.c fribidi-shape.h 
Removed Files:
	env.h fribidi-env.c fribidi-env.h 
Log Message:
Arabic shaping support added.


Index: Headers.mk
===================================================================
RCS file: /cvs/fribidi/fribidi2/lib/Headers.mk,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- Headers.mk	14 Jun 2004 18:43:53 -0000	1.7
+++ Headers.mk	3 Nov 2005 01:39:01 -0000	1.8
@@ -1,15 +1,18 @@
 libfribidi_la_headers = \
+		fribidi-arabic.h \
 		fribidi-begindecls.h \
 		fribidi-bidi.h \
 		fribidi-bidi-types.h \
 		fribidi-bidi-types-list.h \
 		fribidi-common.h \
+		fribidi-deprecated.h \
 		fribidi-enddecls.h \
-		fribidi-env.h \
+		fribidi-flags.h \
 		fribidi-joining.h \
 		fribidi-joining-types.h \
 		fribidi-joining-types-list.h \
 		fribidi-mirroring.h \
+		fribidi-shape.h \
 		fribidi-types.h \
 		fribidi-unicode.h \
 		fribidi-unicode-version.h \

Index: Makefile.am
===================================================================
RCS file: /cvs/fribidi/fribidi2/lib/Makefile.am,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- Makefile.am	3 Jul 2004 11:36:15 -0000	1.14
+++ Makefile.am	3 Nov 2005 01:39:01 -0000	1.15
@@ -32,20 +32,23 @@
 nodist_pkginclude_HEADERS = fribidi-config.h
 
 libfribidi_la_SOURCES =	\
+		arabic-misc.tab.i \
+		arabic-shaping.tab.i \
 		bidi-type.tab.i \
 		bidi-types.h \
 		common.h \
 		debug.h \
-		env.h \
 		fribidi.c \
+		fribidi-arabic.c \
 		fribidi-bidi.c \
 		fribidi-bidi-types.c \
-		fribidi-env.c \
+		fribidi-deprecated.c \
 		fribidi-joining.c \
 		fribidi-joining-types.c \
 		fribidi-mem.c \
 		fribidi-mirroring.c \
 		fribidi-run.c \
+		fribidi-shape.c \
 		joining-type.tab.i \
 		joining-types.h \
 		mem.h \
@@ -54,6 +57,7 @@
 
 GENERATEDSOURCES = \
 		fribidi-unicode-version.h \
+		arabic-shaping.tab.i \
 		bidi-type.tab.i \
 		joining-type.tab.i \
 		mirroring.tab.i

--- NEW FILE: arabic-misc.tab.i ---
/* The tables in this file should all be sorted on their first item. */

/* *INDENT-OFF* */

const PairMap mandatory_liga_table[] = {
  {{0xFEDF, 0xFE82}, 0xFEF5},
  {{0xFEDF, 0xFE84}, 0xFEF7},
  {{0xFEDF, 0xFE88}, 0xFEF9},
  {{0xFEDF, 0xFE8E}, 0xFEFB},
  {{0xFEE0, 0xFE82}, 0xFEE6},
  {{0xFEE0, 0xFE84}, 0xFEF8},
  {{0xFEE0, 0xFE88}, 0xFEFA},
  {{0xFEE0, 0xFE8E}, 0xFEFC},
};


const PairMap console_liga_table[] = {
  {{0x0640, 0xFC60}, 0xFCF2},
  {{0x0640, 0xFC61}, 0xFCF3},
  {{0x0640, 0xFC62}, 0xFCF4},
  {{0x0640, 0xFE70}, 0xFE71},
  {{0x0640, 0xFE76}, 0xFE77},
  {{0x0640, 0xFE78}, 0xFE79},
  {{0x0640, 0xFE7A}, 0xFE7B},
  {{0x0640, 0xFE7C}, 0xFE7D},
  {{0x0640, 0xFE7E}, 0xFE7F},
  {{0xFBE8, 0x0654}, 0xFE8B},
  {{0xFBE9, 0x0654}, 0xFE8C},
  {{0xFBFC, 0x0654}, 0xFE89},
  {{0xFBFC, 0x0670}, 0xFC5D},
  {{0xFBFD, 0x0654}, 0xFE8A},
  {{0xFBFD, 0x0670}, 0xFC90},
  {{0xFE7C, 0x0670}, 0xFC63},
  {{0xFE7C, 0xFE72}, 0xFC5E},
  {{0xFE7C, 0xFE74}, 0xFC5F},
  {{0xFE7C, 0xFE76}, 0xFC60},
  {{0xFE7C, 0xFE78}, 0xFC61},
  {{0xFE7C, 0xFE7A}, 0xFC62},
  {{0xFE7D, 0xFE76}, 0xFCF2},
  {{0xFE7D, 0xFE77}, 0xFCF2},
  {{0xFE7D, 0xFE78}, 0xFCF3},
  {{0xFE7D, 0xFE79}, 0xFCF3},
  {{0xFE7D, 0xFE7A}, 0xFCF4},
  {{0xFE7D, 0xFE7B}, 0xFCF4},
  {{0xFE8D, 0x0653}, 0xFE81},
  {{0xFE8D, 0x0654}, 0xFE83},
  {{0xFE8D, 0x0655}, 0xFE87},
  {{0xFE8D, 0xFE70}, 0xFD3D},
  {{0xFE8E, 0x0653}, 0xFE82},
  {{0xFE8E, 0x0654}, 0xFE84},
  {{0xFE8E, 0x0655}, 0xFE88},
  {{0xFE8E, 0xFE70}, 0xFD3C},
  {{0xFEE9, 0x0654}, 0xFBA4},
  {{0xFEEA, 0x0654}, 0xFBA5},
  {{0xFEED, 0x0654}, 0xFE85},
  {{0xFEEE, 0x0654}, 0xFE86},
  {{0xFEEF, 0x0654}, 0xFE89},
  {{0xFEEF, 0x0670}, 0xFC5D},
  {{0xFEF0, 0x0654}, 0xFE8A},
  {{0xFEF0, 0x0670}, 0xFC90},
  {{0xFEF1, 0x0654}, 0xFE89},
  {{0xFEF1, 0x0670}, 0xFC5D},
  {{0xFEF2, 0x0654}, 0xFE8A},
  {{0xFEF2, 0x0670}, 0xFC90},
  {{0xFEF3, 0x0654}, 0xFE8B},
  {{0xFEF4, 0x0654}, 0xFE8C},
  {{0xFEFB, 0x0653}, 0xFEF5},
  {{0xFEFB, 0x0654}, 0xFEF7},
  {{0xFEFB, 0x0655}, 0xFEF9},
  {{0xFEFC, 0x0653}, 0xFEF6},
  {{0xFEFC, 0x0654}, 0xFEF8},
  {{0xFEFC, 0x0655}, 0xFEFA},
};


static const FriBidiChar NSMShap[][4] = {
  {0xFE70, 0xFE71, 0xFE70, 0xFE71,},
  {0xFE72, 0xFE72, 0xFE72, 0xFE72,},
  {0xFE74, 0xFE74, 0xFE74, 0xFE74,},
  {0xFE76, 0xFE77, 0xFE76, 0xFE77,},
  {0xFE78, 0xFE79, 0xFE78, 0xFE79,},
  {0xFE7A, 0xFE7B, 0xFE7A, 0xFE7B,},
  {0xFE7C, 0xFE7D, 0xFE7C, 0xFE7D,},
  {0xFE7E, 0xFE7F, 0xFE7E, 0xFE7F,},
};

/* *INDENT-ON* */

#ifndef FRIBIDI_ACCESS_SHAPE_TABLE
# define FRIBIDI_ACCESS_SHAPE_TABLE(table,min,max,x,shape) \
	(((x)<(min)||(x)>(max))?(x):(table)[(x)-(min)][(shape)])
#endif

#define FRIBIDI_GET_ARABIC_SHAPE_NSM(x,shape) FRIBIDI_ACCESS_SHAPE_TABLE(NSMShap, 0x064B, 0x0652, (x), (shape))

Index: debug.h
===================================================================
RCS file: /cvs/fribidi/fribidi2/lib/debug.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- debug.h	13 Jun 2004 20:11:42 -0000	1.7
+++ debug.h	3 Nov 2005 01:39:01 -0000	1.8
@@ -73,7 +73,6 @@
 #endif /* !MSG */
 
 #ifndef DBG
-# include <fribidi-env.h>
 # define DBG(s) \
 	FRIBIDI_BEGIN_STMT \
 	if (fribidi_debug_status()) MSG(FRIBIDI ": " s "\n"); \

--- env.h DELETED ---

--- NEW FILE: fribidi-arabic.c ---
/* fribidi-arabic.c - Arabic shaping
 *
 * Copyright (C) 2005  Behdad Esfahbod
 *
 * This file is part of GNU FriBidi.
 * 
 * GNU FriBidi 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.
 * 
 * GNU FriBidi 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 GNU FriBidi; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 * 
 * For licensing issues, contact <license at farsiweb.info> or write to
 * Sharif FarsiWeb, Inc., PO Box 13445-389, Tehran, Iran.
 */
/* $Id: fribidi-arabic.c,v 1.1 2005/11/03 01:39:01 behdad Exp $
 * $Author: behdad $
 * $Date: 2005/11/03 01:39:01 $
 * $Revision: 1.1 $
 * $Source: /cvs/fribidi/fribidi2/lib/fribidi-arabic.c,v $
 *
 * Author(s):
 *   Behdad Esfahbod, 2005
 */

#include "common.h"

#if HAVE_STDLIB_H
# include <stdlib.h>
#endif


#include <fribidi-arabic.h>
#include <fribidi-unicode.h>


typedef struct _PairMap {
  FriBidiChar pair[2], to;
} PairMap;


#define FRIBIDI_ACCESS_SHAPE_TABLE(table,min,max,x,shape) (table), (min), (max)
# define FRIBIDI_ACCESS_SHAPE_TABLE_REAL(table,min,max,x,shape) \
	(((x)<(min)||(x)>(max))?(x):(table)[(x)-(min)][(shape)])

#include "arabic-shaping.tab.i"
#include "arabic-misc.tab.i"


static void
fribidi_shape_arabic_joining (
  /* input */
  const FriBidiChar table[][4],
  FriBidiChar min,
  FriBidiChar max,
  const FriBidiStrIndex len,
  const FriBidiArabicProp *ar_props,
  /* input and output */
  FriBidiChar *str
)
{
  register FriBidiStrIndex i;

  for (i = 0; i < len; i++)
    if (FRIBIDI_ARAB_SHAPES(ar_props[i]))
      str[i] = FRIBIDI_ACCESS_SHAPE_TABLE_REAL (table, min, max, str[i], FRIBIDI_JOIN_SHAPE (ar_props[i]));
}



static int
comp_PairMap (const void *pa, const void *pb)
{
  PairMap *a = (PairMap *)pa;
  PairMap *b = (PairMap *)pb;

  if (a->pair[0] != b->pair[0])
    return a->pair[0] < b->pair[0] ? -1 : +1;
  else
    return a->pair[1] < b->pair[1] ? -1 :
           a->pair[1] > b->pair[1] ? +1 :
	   0;
}


static FriBidiChar
find_pair_match (const PairMap *table, int size, FriBidiChar first, FriBidiChar second)
{
  PairMap *match;
  PairMap x = {{first, second}, 0};
  match = bsearch (&x, table, size, sizeof (table[0]), comp_PairMap);
  return match ? match->to : 0;
}

#define PAIR_MATCH(table,len,first,second) \
	((first)<(table[0].pair[0])||(first)>(table[len-1].pair[0])?0: \
	 find_pair_match(table, len, first, second))

static void
fribidi_shape_arabic_ligature (
  /* input */
  const PairMap *table,
  int size,
  const FriBidiLevel *embedding_levels,
  const FriBidiStrIndex len,
  /* input and output */
  FriBidiArabicProp *ar_props,
  FriBidiChar *str
)
{
  /* TODO: This doesn't form ligatures for even-level Arabic text.
   * no big problem though. */
  register FriBidiStrIndex i;

  for (i = 0; i < len - 1; i++) {
    register FriBidiChar c;
    if (FRIBIDI_LEVEL_IS_RTL(embedding_levels[i]) &&
	embedding_levels[i] == embedding_levels[i+1] &&
	(c = PAIR_MATCH(table, size, str[i], str[i+1])))
      {
	str[i] = FRIBIDI_CHAR_FILL;
	FRIBIDI_SET_BITS(ar_props[i], FRIBIDI_MASK_LIGATURED);
	str[i+1] = c;
      }
  }
}

#define DO_LIGATURING(table, levels, len, ar_props, str) \
	fribidi_shape_arabic_ligature ((table), sizeof(table)/sizeof((table)[0]), levels, len, ar_props, str)

#define DO_SHAPING(tablemacro, len, ar_props, str) \
	fribidi_shape_arabic_joining (tablemacro(,), len, ar_props, str);
	



FRIBIDI_ENTRY void
fribidi_shape_arabic (
  /* input */
  FriBidiFlags flags,
  const FriBidiLevel *embedding_levels,
  const FriBidiStrIndex len,
  /* input and output */
  FriBidiArabicProp *ar_props,
  FriBidiChar *str
)
{
  DBG ("in fribidi_shape_arabic");

  if UNLIKELY
    (len == 0 || !str) return;

  DBG ("in fribidi_shape");

  fribidi_assert (ar_props);

  if (FRIBIDI_TEST_BITS (flags, FRIBIDI_FLAG_SHAPE_ARAB_PRES))
    {
      DO_SHAPING (FRIBIDI_GET_ARABIC_SHAPE_PRES, len, ar_props, str);
    }

  if (FRIBIDI_TEST_BITS (flags, FRIBIDI_FLAG_SHAPE_ARAB_LIGA))
    {
      DO_LIGATURING (mandatory_liga_table, embedding_levels, len, ar_props, str);
    }

  if (FRIBIDI_TEST_BITS (flags, FRIBIDI_FLAG_SHAPE_ARAB_CONSOLE))
    {
      DO_LIGATURING (console_liga_table, embedding_levels, len, ar_props, str);
      DO_SHAPING (FRIBIDI_GET_ARABIC_SHAPE_NSM, len, ar_props, str);
    }
}

/* Editor directions:
 * Local Variables:
 *   mode: c
 *   c-basic-offset: 2
 *   indent-tabs-mode: t
 *   tab-width: 8
 * End:
 * vim: textwidth=78: autoindent: cindent: shiftwidth=2: tabstop=8:
 */

--- NEW FILE: fribidi-arabic.h ---
/* fribidi-arabic.h - do Arabic shaping to presentation forms
 *
 * Copyright (C) 2005  Behdad Esfahbod
 * 
 * This file is part of GNU FriBidi.
 * 
 * GNU FriBidi 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.
 * 
 * GNU FriBidi 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 GNU FriBidi; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 * 
 * For licensing issues, contact <license at farsiweb.info> or write to
 * Sharif FarsiWeb, Inc., PO Box 13445-389, Tehran, Iran.
 */
/* $Id: fribidi-arabic.h,v 1.1 2005/11/03 01:39:01 behdad Exp $
 * $Author: behdad $
 * $Date: 2005/11/03 01:39:01 $
 * $Revision: 1.1 $
 * $Source: /cvs/fribidi/fribidi2/lib/fribidi-arabic.h,v $
 *
 * Author(s):
 *   Behdad Esfahbod, 2005
 */
#ifndef _FRIBIDI_ARABIC_H
#define _FRIBIDI_ARABIC_H

#include "fribidi-common.h"

#include "fribidi-types.h"
#include "fribidi-flags.h"
#include "fribidi-bidi-types.h"
#include "fribidi-joining.h"

#include "fribidi-begindecls.h"


#define fribidi_shape_arabic FRIBIDI_NAMESPACE(shape_arabic)
/* fribidi_shape_arabic - do Arabic shaping
 *
 * The actual shaping that is done depends on the flags set.  Only flags
 * starting with FRIBIDI_FLAG_SHAPE_ARAB_ affect this function.
 * Currently these are:
 *
 *	* FRIBIDI_FLAG_SHAPE_MIRRORING: Do mirroring.
 *	* FRIBIDI_FLAG_SHAPE_ARAB_PRES: Shape Arabic characters to their
 *					presentation form glyphs.
 *	* FRIBIDI_FLAG_SHAPE_ARAB_LIGA: Form mandatory Arabic ligatures.
 *	* FRIBIDI_FLAG_SHAPE_ARAB_CONSOLE: Perform additional Arabic shaping
 *					   suitable for text rendered on
 *					   grid terminals with no mark
 *					   rendering capabilities.
 *
 * Of the above, FRIBIDI_FLAG_SHAPE_ARAB_CONSOLE is only used in special
 * cases, but the rest are recommended in any enviroment that doesn't have
 * other means for doing Arabic shaping.  The set of extra flags that enable
 * this level of Arabic support has a shortcut named FRIBIDI_FLAGS_ARABIC.
 */
FRIBIDI_ENTRY void
fribidi_shape_arabic (
  FriBidiFlags flags, /* shaping flags */
  const FriBidiLevel *embedding_levels,
  const FriBidiStrIndex len,	/* input string length */
  FriBidiArabicProp *ar_props, /* input/output Arabic properties as
				* computed by fribidi_join_arabic */
  FriBidiChar *str		/* string to shape */
);

#include "fribidi-enddecls.h"

#endif /* !_FRIBIDI_ARABIC_H */
/* Editor directions:
 * Local Variables:
 *   mode: c
 *   c-basic-offset: 2
 *   indent-tabs-mode: t
 *   tab-width: 8
 * End:
 * vim: textwidth=78: autoindent: cindent: shiftwidth=2: tabstop=8:
 */

Index: fribidi-bidi.c
===================================================================
RCS file: /cvs/fribidi/fribidi2/lib/fribidi-bidi.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- fribidi-bidi.c	30 Jul 2005 09:06:28 -0000	1.18
+++ fribidi-bidi.c	3 Nov 2005 01:39:01 -0000	1.19
@@ -38,10 +38,8 @@
 #include <fribidi-bidi.h>
 #include <fribidi-mirroring.h>
 #include <fribidi-unicode.h>
-#include <fribidi-env.h>
 
 #include "mem.h"
-#include "env.h"
 #include "bidi-types.h"
 #include "run.h"
 
@@ -875,6 +873,7 @@
 FRIBIDI_ENTRY FriBidiLevel
 fribidi_reorder_line (
   /* input */
+  FriBidiFlags flags, /* reorder flags */
   const FriBidiCharType *bidi_types,
   const FriBidiStrIndex len,
   const FriBidiStrIndex off,
@@ -883,11 +882,9 @@
   FriBidiLevel *embedding_levels,
   FriBidiChar *visual_str,
   /* output */
-  FriBidiStrIndex *positions_L_to_V,
-  FriBidiStrIndex *positions_V_to_L
+  FriBidiStrIndex *map
 )
 {
-  fribidi_boolean private_V_to_L = false;
   fribidi_boolean status = false;
   FriBidiLevel max_level = 0;
 
@@ -898,17 +895,6 @@
       goto out;
     }
 
-  if UNLIKELY
-    ((unsigned long) off + (unsigned long) len >
-     FRIBIDI_MAX_STRING_LENGTH && (positions_V_to_L || positions_L_to_V))
-    {
-#     if DEBUG
-      MSG2 (FRIBIDI ": cannot handle strings > %lu characters\n",
-	    (unsigned long) FRIBIDI_MAX_STRING_LENGTH);
-#     endif /* DEBUG */
-      goto out;
-    }
-
   DBG ("in fribidi_reorder_line");
 
   fribidi_assert (bidi_types);
@@ -925,32 +911,14 @@
       embedding_levels[i] = FRIBIDI_DIR_TO_LEVEL (base_dir);
   }
 
-  /* If l2v is to be calculated we must have v2l as well. If it is not
-     given by the caller, we have to make a private instance of it. */
-  if (positions_L_to_V && !positions_V_to_L)
-    {
-      positions_V_to_L = fribidi_malloc (sizeof (positions_V_to_L[0]) * len);
-      if UNLIKELY
-	(!positions_V_to_L) goto out;
-      private_V_to_L = true;
-    }
-
-
   /* 7. Reordering resolved levels */
   {
     register FriBidiLevel level;
     register FriBidiStrIndex i;
 
-    /* Set up the ordering array to identity order */
-    if (positions_V_to_L)
-      {
-	for (i = off + len - 1; i >= off; i--)
-	  positions_V_to_L[i] = i;
-      }
-
     /* Reorder both the outstring and the order array */
     {
-      if (fribidi_reorder_nsm_status ())
+      if (FRIBIDI_TEST_BITS (flags, FRIBIDI_FLAG_REORDER_NSM))
 	{
 	  /* L3. Reorder NSMs. */
 	  for (i = off + len - 1; i >= off; i--)
@@ -975,10 +943,9 @@
 		  {
 		    bidi_string_reverse (visual_str + i, seq_end - i + 1);
 		  }
-		if (positions_V_to_L)
+		if (map)
 		  {
-		    index_array_reverse (positions_V_to_L + i,
-					 seq_end - i + 1);
+		    index_array_reverse (map + i, seq_end - i + 1);
 		  }
 	      }
 	}
@@ -1002,26 +969,17 @@
 
 	      if (visual_str)
 		bidi_string_reverse (visual_str + i + 1, seq_end - i);
-	      if (positions_V_to_L)
-		index_array_reverse (positions_V_to_L + i + 1, seq_end - i);
+	      if (map)
+		index_array_reverse (map + i + 1, seq_end - i);
 	    }
     }
 
-    /* Convert the v2l list to l2v */
-    if (positions_L_to_V)
-      {
-	for (i = off + len - 1; i >= off; i--)
-	  positions_L_to_V[positions_V_to_L[i]] = i;
-      }
   }
 
   status = true;
 
 out:
 
-  if (private_V_to_L)
-    fribidi_free (positions_V_to_L);
-
   return status ? max_level + 1 : 0;
 }
 

Index: fribidi-bidi.h
===================================================================
RCS file: /cvs/fribidi/fribidi2/lib/fribidi-bidi.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- fribidi-bidi.h	21 Jun 2004 21:15:31 -0000	1.14
+++ fribidi-bidi.h	3 Nov 2005 01:39:01 -0000	1.15
@@ -38,6 +38,7 @@
 #include "fribidi-common.h"
 
 #include "fribidi-types.h"
+#include "fribidi-flags.h"
 #include "fribidi-bidi-types.h"
 
 #include "fribidi-begindecls.h"
@@ -55,9 +56,8 @@
  * direction handling.  Note that you can pass more than a paragraph to this
  * function and the direction of the first non-neutral paragraph is returned,
  * which is a very good heuristic to set direction of the neutral paragraphs
- * at the beginning of text.  For other neutral paragraphs, better you use the
- * direction of the previous paragraph.  This is today known as the best
- * auto-paragraph-direction-detection scheme!
+ * at the beginning of text.  For other neutral paragraphs, you better use the
+ * direction of the previous paragraph.
  *
  * Returns: Base pargraph direction.  No weak paragraph direction is returned,
  * only LTR, RTL, or ON.
@@ -111,15 +111,22 @@
  * (That is part 4 of rule L1).
  *
  * Note that the bidi types and embedding levels are not reordered.  You can
- * reorder these (or any other) arrays using the position_L_to_V_map later.
+ * reorder these (or any other) arrays using the map later.  The user is
+ * responsible to initialize map to something sensible, like an identity
+ * mapping, or pass NULL if no map is needed.
  *
- * Some features of this function can be turned on/off using environmental
- * settings functions fribidi_env_*().
+ * There is an optional part to this function, which is whether non-spacing
+ * marks for right-to-left parts of the text should be reordered to come after
+ * their base characters in the visual string or not.  Most rendering engines
+ * expect this behavior, but console-based systems for example do not like it.
+ * This is controlled by the FRIBIDI_FLAG_REORDER_NSM flag.  The flag is on
+ * in FRIBIDI_FLAGS_DEFAULT.
  *
  * Returns: Maximum level found in this line plus one, or zero if any error
  * occured (memory allocation failure most probably).
  */
      FRIBIDI_ENTRY FriBidiLevel fribidi_reorder_line (
+  FriBidiFlags flags, /* reorder flags */
   const FriBidiCharType *bidi_types,	/* input list of bidi types as returned by
 					   fribidi_get_bidi_types() */
   const FriBidiStrIndex len,	/* input length of the line */
@@ -130,10 +137,8 @@
 					   as returned by
 					   fribidi_get_par_embedding_levels */
   FriBidiChar *visual_str,	/* visual string to reorder */
-  FriBidiStrIndex *positions_L_to_V,	/* output mapping from logical to
-					   visual string positions */
-  FriBidiStrIndex *positions_V_to_L	/* output mapping from visual string
-					   back to logical string positions */
+  FriBidiStrIndex *map		/* a map of string indices which is reordered
+				 * to reflect where each glyph ends up. */
 ) FRIBIDI_GNUC_WARN_UNUSED;
 
 #include "fribidi-enddecls.h"

Index: fribidi-common.h
===================================================================
RCS file: /cvs/fribidi/fribidi2/lib/fribidi-common.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- fribidi-common.h	23 Jun 2004 22:26:06 -0000	1.10
+++ fribidi-common.h	3 Nov 2005 01:39:01 -0000	1.11
@@ -101,6 +101,29 @@
 # endif	/* !__cplusplus */
 #endif /* !FRIBIDI_BEGIN_DECLS */
 
+
+
+
+#define fribidi_debug_status FRIBIDI_NAMESPACE(debug_status)
+FRIBIDI_ENTRY int fribidi_debug_status (
+  void
+);
+#define fribidi_set_debug FRIBIDI_NAMESPACE(set_debug)
+FRIBIDI_ENTRY int
+fribidi_set_debug (
+  int state		/* new state to set */
+);
+
+
+
+
+
+
+
+
+
+
+
 #endif /* !_FRIBIDI_COMMON_H */
 /* Editor directions:
  * vim:textwidth=78:tabstop=8:shiftwidth=2:autoindent:cindent

Index: fribidi-config.h.in
===================================================================
RCS file: /cvs/fribidi/fribidi2/lib/fribidi-config.h.in,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- fribidi-config.h.in	14 Jun 2004 18:43:53 -0000	1.4
+++ fribidi-config.h.in	3 Nov 2005 01:39:01 -0000	1.5
@@ -14,9 +14,6 @@
 #define FRIBIDI_INTERFACE_VERSION @FRIBIDI_INTERFACE_VERSION@
 #define FRIBIDI_INTERFACE_VERSION_STRING "@FRIBIDI_INTERFACE_VERSION@"
 
-/* Define to 1 if you don't want Arabic joining/shaping code in the library */
-#define FRIBIDI_NO_ARABIC @FRIBIDI_NO_ARABIC@
-
 /* Define to 1 if you want charset conversion codes in the library */
 #define FRIBIDI_CHARSETS @FRIBIDI_CHARSETS@
 

--- NEW FILE: fribidi-deprecated.c ---
/* FriBidi
 * fribidi-deprecated.c - deprecated interfaces.
 *
 * $Id: fribidi-deprecated.c,v 1.1 2005/11/03 01:39:01 behdad Exp $
 * $Author: behdad $
 * $Date: 2005/11/03 01:39:01 $
 * $Revision: 1.1 $
 * $Source: /cvs/fribidi/fribidi2/lib/fribidi-deprecated.c,v $
 *
 * Authors:
 *   Behdad Esfahbod, 2001, 2002, 2004
 *   Dov Grobgeld, 1999, 2000
 *
 * Copyright (C) 2004 Sharif FarsiWeb, Inc
 * Copyright (C) 2001,2002 Behdad Esfahbod
 * Copyright (C) 1999,2000 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., 59 Temple Place, Suite 330,
 * Boston, MA 02111-1307, USA
 * 
 * For licensing issues, contact <license at farsiweb.info>.
 */

#include "common.h"

#include <fribidi-deprecated.h>
#include <fribidi.h>

#if !FRIBIDI_NO_DEPRECATED

static FriBidiFlags flags = FRIBIDI_FLAGS_DEFAULT | FRIBIDI_FLAGS_ARABIC;

FRIBIDI_ENTRY fribidi_boolean
fribidi_set_mirroring (
  /* input */
  fribidi_boolean state
)
{
  return FRIBIDI_ADJUST_AND_TEST_BITS (flags, FRIBIDI_FLAG_SHAPE_MIRRORING, state);
}

FRIBIDI_ENTRY fribidi_boolean
fribidi_mirroring_status (
  void
)
{
  return FRIBIDI_TEST_BITS (flags, FRIBIDI_FLAG_SHAPE_MIRRORING);
}

FRIBIDI_ENTRY fribidi_boolean
fribidi_set_reorder_nsm (
  /* input */
  fribidi_boolean state
)
{
  return FRIBIDI_ADJUST_AND_TEST_BITS (flags, FRIBIDI_FLAG_REORDER_NSM, state);
}

fribidi_boolean
fribidi_reorder_nsm_status (
  void
)
{
  return FRIBIDI_TEST_BITS (flags, FRIBIDI_FLAG_REORDER_NSM);
}




FRIBIDI_ENTRY FriBidiLevel
fribidi_log2vis_get_embedding_levels (
  const FriBidiCharType *bidi_types,	/* input list of bidi types as returned by
					   fribidi_get_bidi_types() */
  const FriBidiStrIndex len,	/* input string length of the paragraph */
  FriBidiParType *pbase_dir,	/* requested and resolved paragraph
				 * base direction */
  FriBidiLevel *embedding_levels	/* output list of embedding levels */
)
{
  return fribidi_get_par_embedding_levels (bidi_types, len, pbase_dir, embedding_levels);
}

FRIBIDI_ENTRY FriBidiCharType
fribidi_get_type (
  FriBidiChar ch		/* input character */
)
{
  return fribidi_get_bidi_type (ch);
}



FRIBIDI_ENTRY FriBidiStrIndex
fribidi_remove_bidi_marks (
  FriBidiChar *str,
  const FriBidiStrIndex len,
  FriBidiStrIndex *positions_to_this,
  FriBidiStrIndex *position_from_this_list,
  FriBidiLevel *embedding_levels
)
{
  register FriBidiStrIndex i, j = 0;
  fribidi_boolean private_from_this = false;
  fribidi_boolean status = false;

  if UNLIKELY
    (len == 0)
    {
      status = true;
      goto out;
    }

  DBG ("in fribidi_remove_bidi_marks");

  fribidi_assert (str);

  /* If to_this is not NULL, we must have from_this as well. If it is
     not given by the caller, we have to make a private instance of it. */
  if (positions_to_this && !position_from_this_list)
    {
      position_from_this_list = fribidi_malloc (sizeof
						(position_from_this_list[0]) *
						len);
      if UNLIKELY
	(!position_from_this_list) goto out;
      private_from_this = true;
      for (i = 0; i < len; i++)
	position_from_this_list[positions_to_this[i]] = i;
    }

  for (i = 0; i < len; i++)
    if (!FRIBIDI_IS_EXPLICIT_OR_BN (fribidi_get_bidi_type (str[i]))
	&& str[i] != FRIBIDI_CHAR_LRM && str[i] != FRIBIDI_CHAR_RLM)
      {
	str[j] = str[i];
	if (embedding_levels)
	  embedding_levels[j] = embedding_levels[i];
	if (position_from_this_list)
	  position_from_this_list[j] = position_from_this_list[i];
	j++;
      }

  /* Convert the from_this list to to_this */
  if (positions_to_this)
    {
      for (i = 0; i < len; i++)
	positions_to_this[i] = -1;
      for (i = 0; i < len; i++)
	positions_to_this[position_from_this_list[i]] = i;
    }

  status = true;

out:

  if (private_from_this)
    fribidi_free (position_from_this_list);

  return status ? j : -1;
}



FRIBIDI_ENTRY FriBidiLevel
fribidi_log2vis (
  /* input */
  const FriBidiChar *str,
  FriBidiStrIndex len,
  /* input and output */
  FriBidiParType *pbase_dir,
  /* output */
  FriBidiChar *visual_str,
  FriBidiStrIndex *positions_L_to_V,
  FriBidiStrIndex *positions_V_to_L,
  FriBidiLevel *embedding_levels
)
{
  register FriBidiStrIndex i;
  FriBidiLevel max_level = 0;
  fribidi_boolean private_V_to_L = false;
  fribidi_boolean private_embedding_levels = false;
  fribidi_boolean status = false;
  FriBidiArabicProp *ar_props = NULL;
  FriBidiCharType *bidi_types = NULL;

  if UNLIKELY
    (len == 0)
    {
      status = true;
      goto out;
    }

  DBG ("in fribidi_log2vis");

  fribidi_assert (str);
  fribidi_assert (pbase_dir);

  bidi_types = fribidi_malloc (len * sizeof bidi_types[0]);
  if (!bidi_types)
    goto out;

  fribidi_get_bidi_types (str, len, bidi_types);

  if (!embedding_levels)
    {
      embedding_levels = fribidi_malloc (len * sizeof embedding_levels[0]);
      if (!embedding_levels)
	goto out;
      private_embedding_levels = true;
    }

  max_level = fribidi_get_par_embedding_levels (bidi_types, len, pbase_dir,
						embedding_levels) - 1;
  if UNLIKELY
    (max_level < 0) goto out;

  /* If l2v is to be calculated we must have v2l as well. If it is not
     given by the caller, we have to make a private instance of it. */
  if (positions_L_to_V && !positions_V_to_L)
    {
      positions_V_to_L =
	(FriBidiStrIndex *) fribidi_malloc (sizeof (FriBidiStrIndex) * len);
      if (!positions_V_to_L)
	goto out;
      private_V_to_L = true;
    }

  /* Set up the ordering array to identity order */
  if (positions_V_to_L)
    {
      for (i = 0; i < len; i++)
	positions_V_to_L[i] = i;
    }


  if (visual_str)
    {
      for (i = len - 1; i >= 0; i--)
	visual_str[i] = str[i];

      /* Arabic joining */
      ar_props = fribidi_malloc (len * sizeof ar_props[0]);
      fribidi_get_joining_types (str, len, ar_props);
      fribidi_join_arabic (bidi_types, len, embedding_levels, ar_props);

      fribidi_shape (flags, embedding_levels, len, ar_props, visual_str);
    }

  status =
    fribidi_reorder_line (flags, bidi_types, len, 0, *pbase_dir,
			  embedding_levels, visual_str,
			  positions_V_to_L);

  /* Convert the v2l list to l2v */
  if (positions_L_to_V)
    {
      for (i = 0; i < len; i++)
	positions_L_to_V[i] = -1;
      for (i = 0; i < len; i++)
	positions_L_to_V[positions_V_to_L[i]] = i;
    }

out:

  if (private_V_to_L)
    fribidi_free (positions_V_to_L);

  if (private_embedding_levels)
    fribidi_free (embedding_levels);

  if (ar_props)
    fribidi_free (ar_props);

  if (bidi_types)
    fribidi_free (bidi_types);

  return status ? max_level + 1 : 0;
}

#endif /* !FRIBIDI_NO_DEPRECATED */

/* Editor directions:
 * vim:textwidth=78:tabstop=8:shiftwidth=2:autoindent:cindent
 */

--- NEW FILE: fribidi-deprecated.h ---
/* FriBidi
 * fribidi-deprecated.h - Deprecated interfaces
 *
 * $Id: fribidi-deprecated.h,v 1.1 2005/11/03 01:39:01 behdad Exp $
 * $Author: behdad $
 * $Date: 2005/11/03 01:39:01 $
 * $Revision: 1.1 $
 * $Source: /cvs/fribidi/fribidi2/lib/fribidi-deprecated.h,v $
 *
 * Author:
 *   Behdad Esfahbod, 2004, 2005
 *
 * Copyright (C) 2004 Sharif FarsiWeb, Inc
 * Copyright (C) 2004, 2005 Behdad Esfahbod
 * 
 * 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., 59 Temple Place, Suite 330,
 * Boston, MA 02111-1307, USA
 * 
 * For licensing issues, contact <license at farsiweb.info>.
 */
#ifndef _FRIBIDI_DEPRECATED_H
#define _FRIBIDI_DEPRECATED_H

#include "fribidi-common.h"

#include "fribidi-types.h"

#include "fribidi-bidi-types.h"

#include "fribidi-begindecls.h"



#define fribidi_mirroring_status FRIBIDI_NAMESPACE(mirroring_status)
/* fribidi_mirroring_status - get current mirroring status
 *
 * This function is deprecated and only used with other deprecated functions.
 */
     FRIBIDI_ENTRY fribidi_boolean fribidi_mirroring_status (
  void
) FRIBIDI_GNUC_DEPRECATED;

#define fribidi_set_mirroring FRIBIDI_NAMESPACE(set_mirroring)
/* fribidi_set_mirroring - set mirroring on or off
 *
 * This function is used to turn character mirroring on or off.
 * Character mirroring is the act of replacing a mirrorable glyph
 * (character), eg. left paranthesis, with the matching glyph, 
 * eg. right paranthesis, in a right-to-left resolved context.
 * If your rendering engine does mirroring itself, you may want to 
 * turn it off here.
 *
 * This flag is on by default.
 * This function is deprecated and only used with other deprecated functions.
 *
 * Returns: the new mirroring status.
 */
     FRIBIDI_ENTRY fribidi_boolean fribidi_set_mirroring (
  fribidi_boolean state		/* new state to set */
) FRIBIDI_GNUC_DEPRECATED;


#define fribidi_reorder_nsm_status FRIBIDI_NAMESPACE(reorder_nsm_status)
/* fribidi_reorder_nsm_status - get current marks reordering status
 *
 * This function is deprecated and only used with other deprecated functions.
 */
     FRIBIDI_ENTRY fribidi_boolean fribidi_reorder_nsm_status (
  void
) FRIBIDI_GNUC_DEPRECATED;

#define fribidi_set_reorder_nsm FRIBIDI_NAMESPACE(set_reorder_nsm)
/* fribidi_set_reorder_nsm - set marks reordering on or off
 *
 * This function is used to turn non-spacing marks reordering on or
 * off.  Reordering non-spacing marks is the act of placing non-spacing
 * marks (bidi class NSM) after their base character in a right-to-left
 * resolved context.  If your rendering engine expects non-spacing marks
 * always after the base character in the memory representation of the
 * visual string, you need this option on.  An example of where people
 * may need it off is when rendering in the console when non-spacing
 * marks cannot be applied on top of the base character.
 *
 * This flag is on by default.
 * This function is deprecated and only used with other deprecated functions.
 *
 * Returns: the new marks reordering status.
 */
     FRIBIDI_ENTRY fribidi_boolean fribidi_set_reorder_nsm (
  fribidi_boolean state		/* new state to set */
) FRIBIDI_GNUC_DEPRECATED;




/* fribidi_log2vis_get_embedding_levels - get embedding levels
 *
 * Deprecated. Replaced by fribidi_get_par_embedding_levels.
 */
#define fribidi_log2vis_get_embedding_levels FRIBIDI_NAMESPACE(log2vis_get_embedding_levels)
FRIBIDI_ENTRY FriBidiLevel
fribidi_log2vis_get_embedding_levels (
  const FriBidiCharType *bidi_types,	/* input list of bidi types as returned by
					   fribidi_get_bidi_types() */
  const FriBidiStrIndex len,	/* input string length of the paragraph */
  FriBidiParType *pbase_dir,	/* requested and resolved paragraph
				 * base direction */
  FriBidiLevel *embedding_levels	/* output list of embedding levels */
);

/* fribidi_get_type - get character bidi type
 *
 * Deprecated. Replaced by fribidi_get_bidi_type.
 */
#define fribidi_get_type FRIBIDI_NAMESPACE(get_type)
FRIBIDI_ENTRY FriBidiCharType
fribidi_get_type (
  FriBidiChar ch		/* input character */
);


#define fribidi_remove_bidi_marks FRIBIDI_NAMESPACE(remove_bidi_marks)
/* fribidi_remove_bidi_marks - remove bidi marks out of an string
 *
 * This function removes the bidi and boundary-neutral marks out of an string
 * and the accompanying lists.  It implements rule X9 of the Unicode
 * Bidirectional Algorithm available at
 * http://www.unicode.org/reports/tr9/#X9, with the exception that it removes
 * U+200E LEFT-TO-RIGHT MARK and U+200F RIGHT-TO-LEFT MARK too.
 *
 * If any of the input lists are NULL, the list is skipped.  If str is the
 * visual string, then positions_to_this is  positions_L_to_V and
 * position_from_this_list is positions_V_to_L;  if str is the logical
 * string, the other way. Moreover, the position maps should be filled with
 * valid entries.
 * 
 * A position map pointing to a removed character is filled with -1. By the
 * way, you should not use embedding_levels if str is visual string.
 * 
 * For best results this function should be run on a whole paragraph, not
 * lines; but feel free to do otherwise if you know what you are doing.
 * Deprecated.  Use fribidi_remove_special_chars instead.
 *
 * Returns: New length of the string, or -1 if an error occured (memory
 * allocation failure most probably).
 */
FRIBIDI_ENTRY FriBidiStrIndex
fribidi_remove_bidi_marks (
  FriBidiChar *str,		/* input string to clean */
  const FriBidiStrIndex len,	/* input string length */
  FriBidiStrIndex *positions_to_this,	/* list mapping positions to the
					   order used in str */
  FriBidiStrIndex *position_from_this_list,	/* list mapping positions from the
						   order used in str */
  FriBidiLevel *embedding_levels	/* list of embedding levels */
)
     FRIBIDI_GNUC_WARN_UNUSED FRIBIDI_GNUC_DEPRECATED;


#define fribidi_log2vis FRIBIDI_NAMESPACE(log2vis)
/* fribidi_log2vis - get visual string
 *
 * This function converts the logical input string to the visual output
 * strings as specified by the Unicode Bidirectional Algorithm.  As a side
 * effect it also generates mapping lists between the two strings, and the
 * list of embedding levels as defined by the algorithm.
 *
 * If NULL is passed as any of the the lists, the list is ignored and not
 * filled.
 *
 * This function is obsolete because it only handles one-line paragraphs. 
 * Please consider using other functions instead.  Deprecated.
 *
 * Returns: Maximum level found plus one, or zero if any error occured
 * (memory allocation failure most probably).
 */
     FRIBIDI_ENTRY FriBidiLevel fribidi_log2vis (
  const FriBidiChar *str,	/* input logical string */
  const FriBidiStrIndex len,	/* input string length */
  FriBidiParType *pbase_dir,	/* requested and resolved paragraph
				 * base direction */
  FriBidiChar *visual_str,	/* output visual string */
  FriBidiStrIndex *positions_L_to_V,	/* output mapping from logical to 
					 * visual string positions */
  FriBidiStrIndex *positions_V_to_L,	/* output mapping from visual string
					 * back to the logical string
					 * positions */
  FriBidiLevel *embedding_levels	/* output list of embedding levels */
)
     FRIBIDI_GNUC_WARN_UNUSED FRIBIDI_GNUC_DEPRECATED;


#include "fribidi-enddecls.h"

#endif /* !_FRIBIDI_DEPRECATED_H */
/* Editor directions:
 * vim:textwidth=78:tabstop=8:shiftwidth=2:autoindent:cindent
 */

--- fribidi-env.c DELETED ---

--- fribidi-env.h DELETED ---

--- NEW FILE: fribidi-flags.h ---
/* FriBidi
 * fribidi-flags.h - option flags
 *
 * $Id: fribidi-flags.h,v 1.1 2005/11/03 01:39:01 behdad Exp $
 * $Author: behdad $
 * $Date: 2005/11/03 01:39:01 $
 * $Revision: 1.1 $
 * $Source: /cvs/fribidi/fribidi2/lib/fribidi-flags.h,v $
 *
 * Author:
 *   Behdad Esfahbod, 2005
 *
 * Copyright (C) 2005 Behdad Esfahbod
 * 
 * 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., 59 Temple Place, Suite 330,
 * Boston, MA 02111-1307, USA
 *
 * For licensing issues, contact <license at farsiweb.info>.
 */
#ifndef _FRIBIDI_FLAGS_H
#define _FRIBIDI_FLAGS_H

#include "fribidi-common.h"

#include "fribidi-types.h"

#include "fribidi-begindecls.h"

typedef fribidi_uint32 FriBidiFlags;

/* 
 * Define option flags that various functions use. Each mask has
 * only one bit set.
 */

#define FRIBIDI_FLAG_SHAPE_MIRRORING	0x00000001
#define FRIBIDI_FLAG_REORDER_NSM	0x00000002

#define FRIBIDI_FLAG_SHAPE_ARAB_PRES	0x00000100
#define FRIBIDI_FLAG_SHAPE_ARAB_LIGA	0x00000200
#define FRIBIDI_FLAG_SHAPE_ARAB_CONSOLE	0x00000400

#define FRIBIDI_FLAG_REMOVE_BIDI	0x00010000
#define FRIBIDI_FLAG_REMOVE_JOINING	0x00020000
#define FRIBIDI_FLAG_REMOVE_SPECIALS	0x00040000


/*
 * And their combinations.
 */

#define FRIBIDI_FLAGS_DEFAULT		( \
	FRIBIDI_FLAG_SHAPE_MIRRORING	| \
	FRIBIDI_FLAG_REORDER_NSM	| \
	FRIBIDI_FLAG_REMOVE_SPECIALS	)

#define FRIBIDI_FLAGS_ARABIC		( \
	FRIBIDI_FLAG_SHAPE_ARAB_PRES	| \
	FRIBIDI_FLAG_SHAPE_ARAB_LIGA	)

#include "fribidi-enddecls.h"

#endif /* !_FRIBIDI_FLAGS_H */
/* Editor directions:
 * vim:textwidth=78:tabstop=8:shiftwidth=2:autoindent:cindent
 */

Index: fribidi-joining-types.c
===================================================================
RCS file: /cvs/fribidi/fribidi2/lib/fribidi-joining-types.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- fribidi-joining-types.c	15 Jun 2004 11:52:02 -0000	1.3
+++ fribidi-joining-types.c	3 Nov 2005 01:39:01 -0000	1.4
@@ -33,8 +33,6 @@
 
 #include "common.h"
 
-#if !FRIBIDI_NO_ARABIC
-
 #include <fribidi-joining-types.h>
 
 #include "joining-types.h"
@@ -115,8 +113,6 @@
 
 #endif /* DEBUG */
 
-#endif /* !FRIBIDI_NO_ARABIC */
-
 /* Editor directions:
  * vim:textwidth=78:tabstop=8:shiftwidth=2:autoindent:cindent
  */

Index: fribidi-joining-types.h
===================================================================
RCS file: /cvs/fribidi/fribidi2/lib/fribidi-joining-types.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- fribidi-joining-types.h	21 Jun 2004 21:15:31 -0000	1.4
+++ fribidi-joining-types.h	3 Nov 2005 01:39:01 -0000	1.5
@@ -198,6 +198,9 @@
 	(FRIBIDI_LEVEL_IS_RTL (level) ? FRIBIDI_MASK_JOINS_LEFT	\
 				      : FRIBIDI_MASK_JOINS_RIGHT)
 
+#define FRIBIDI_JOIN_SHAPE(p)	\
+	((p) & ( FRIBIDI_MASK_JOINS_RIGHT | FRIBIDI_MASK_JOINS_LEFT ))
+
 /* Functions finally */
 
 

Index: fribidi-joining.c
===================================================================
RCS file: /cvs/fribidi/fribidi2/lib/fribidi-joining.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- fribidi-joining.c	21 Jun 2004 21:15:31 -0000	1.4
+++ fribidi-joining.c	3 Nov 2005 01:39:01 -0000	1.5
@@ -33,13 +33,9 @@
 
 #include "common.h"
 
-#if !FRIBIDI_NO_ARABIC
-
 #include <fribidi-joining.h>
-#include <fribidi-env.h>
 
 #include "mem.h"
-#include "env.h"
 #include "bidi-types.h"
 #include "joining-types.h"
 
@@ -107,8 +103,8 @@
 
   /* The joining algorithm turned out very very dirty :(.  That's what happens
    * when you follow the standard which has never been implemented closely
-   * before.  We assume "level run" instead of "directional run", which is a
-   * proposed update to be considered for Unicode 4.1. */
+   * before.
+   */
 
   /* 8.2 Arabic - Cursive Joining */
   DBG ("Arabic cursive joining");
@@ -147,7 +143,19 @@
 		    FRIBIDI_UNSET_BITS (ar_props[i], joins_preceding_mask);
 		}
 	      else if (!FRIBIDI_TEST_BITS (ar_props[i], joins_preceding_mask))
-		disjoin = true;
+	        {
+		  disjoin = true;
+		}
+	      else
+	        {
+		  register FriBidiStrIndex j;
+		  /* This is a FriBidi extension:  we set joining properties
+		   * for skipped characters in between, so we can put NSMs on tatweel
+		   * later if we want.  Useful on console for example.
+		   */
+		  for (j = saved + 1; j < i; j++)
+		    FRIBIDI_SET_BITS (ar_props[j], joins_preceding_mask | saved_joins_following_mask);
+		}
 	    }
 
 	  if (disjoin && saved_shapes)
@@ -164,17 +172,9 @@
 		FRIBIDI_TEST_BITS (ar_props[i], saved_joins_following_mask);
 	    }
 	}
-    if (joins && saved_shapes)
+    if ((joins) && saved_shapes)
       FRIBIDI_UNSET_BITS (ar_props[saved], saved_joins_following_mask);
 
-    /* if joining on transparents then... */
-    /* This is a FriBidi extension:  we set joining properties
-     * for skipped characters in between. 
-     for (saved++; saved < i; saved++)
-     FRIBIDI_SET_BITS (ar_props[saved],
-     joins_preceding_mask |
-     joins_following_mask);
-     */
   }
 
 # if DEBUG
@@ -188,8 +188,6 @@
   DBG ("leaving fribidi_join_arabic");
 }
 
-#endif /* !FRIBIDI_NO_ARABIC */
-
 /* Editor directions:
  * vim:textwidth=78:tabstop=8:shiftwidth=2:autoindent:cindent
  */

Index: fribidi-mem.c
===================================================================
RCS file: /cvs/fribidi/fribidi2/lib/fribidi-mem.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- fribidi-mem.c	22 May 2004 11:21:40 -0000	1.6
+++ fribidi-mem.c	3 Nov 2005 01:39:01 -0000	1.7
@@ -36,6 +36,7 @@
 #include "mem.h"
 
 #if !FRIBIDI_USE_GLIB
+#if !USE_SIMPLE_MALLOC
 
 struct _FriBidiMemChunk
 {
@@ -129,6 +130,7 @@
   fribidi_free (mem_chunk);
 }
 
+#endif /* !USE_SIMPLE_MALLOC */
 #endif /* !FRIBIDI_USE_GLIB */
 
 /* Editor directions:

Index: fribidi-mirroring.c
===================================================================
RCS file: /cvs/fribidi/fribidi2/lib/fribidi-mirroring.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- fribidi-mirroring.c	28 Sep 2004 07:58:57 -0000	1.14
+++ fribidi-mirroring.c	3 Nov 2005 01:39:01 -0000	1.15
@@ -69,11 +69,11 @@
 
   DBG ("in fribidi_shape_mirroring");
 
-  fribidi_assert (embedding_levels);
-
   if UNLIKELY
     (len == 0 || !str) return;
 
+  fribidi_assert (embedding_levels);
+
   /* L4. Mirror all characters that are in odd levels and have mirrors. */
   for (i = len - 1; i >= 0; i--)
     if (FRIBIDI_LEVEL_IS_RTL (embedding_levels[i]))

Index: fribidi-run.c
===================================================================
RCS file: /cvs/fribidi/fribidi2/lib/fribidi-run.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- fribidi-run.c	21 Jun 2004 18:49:23 -0000	1.6
+++ fribidi-run.c	3 Nov 2005 01:39:01 -0000	1.7
@@ -38,15 +38,20 @@
 #include <fribidi-bidi-types.h>
 
 #include "run.h"
-#include "env.h"
+#include "mem.h"
 #include "bidi-types.h"
 
+#if !USE_SIMPLE_MALLOC
+static FriBidiRun *free_runs = NULL;
+#endif
+
 FriBidiRun *
 new_run (
   void
 )
 {
   register FriBidiRun *run;
+  static FriBidiMemChunk *run_mem_chunk = NULL;
 
 #if USE_SIMPLE_MALLOC
   run = fribidi_malloc (sizeof (FriBidiRun));

--- NEW FILE: fribidi-shape.c ---
/* FriBidi
 * fribidi-shape.c - shaping
 *
 * $Id: fribidi-shape.c,v 1.1 2005/11/03 01:39:01 behdad Exp $
 * $Author: behdad $
 * $Date: 2005/11/03 01:39:01 $
 * $Revision: 1.1 $
 * $Source: /cvs/fribidi/fribidi2/lib/fribidi-shape.c,v $
 *
 * Authors:
 *   Behdad Esfahbod, 2001, 2002, 2004
 *   Dov Grobgeld, 1999, 2000
 *
 * Copyright (C) 2005 Behdad Esfahbod
 * 
 * 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., 59 Temple Place, Suite 330,
 * Boston, MA 02111-1307, USA
 * 
 * For licensing issues, contact <license at farsiweb.info>.
 */

#include "common.h"

#include <fribidi-shape.h>
#include <fribidi-mirroring.h>
#include <fribidi-arabic.h>


FRIBIDI_ENTRY void
fribidi_shape (
  /* input */
  FriBidiFlags flags,
  const FriBidiLevel *embedding_levels,
  const FriBidiStrIndex len,
  /* input and output */
  FriBidiArabicProp *ar_props,
  FriBidiChar *str
)
{
  if UNLIKELY
    (len == 0 || !str) return;

  DBG ("in fribidi_shape");

  fribidi_assert (embedding_levels);

  if (ar_props)
    fribidi_shape_arabic (flags, embedding_levels, len, ar_props, str);

  if (FRIBIDI_TEST_BITS (flags, FRIBIDI_FLAG_SHAPE_MIRRORING))
    fribidi_shape_mirroring (embedding_levels, len, str);
}


/* Editor directions:
 * vim:textwidth=78:tabstop=8:shiftwidth=2:autoindent:cindent
 */

--- NEW FILE: fribidi-shape.h ---
/* FriBidi
 * fribidi-shape.h - shaping
 *
 * $Id: fribidi-shape.h,v 1.1 2005/11/03 01:39:01 behdad Exp $
 * $Author: behdad $
 * $Date: 2005/11/03 01:39:01 $
 * $Revision: 1.1 $
 * $Source: /cvs/fribidi/fribidi2/lib/fribidi-shape.h,v $
 *
 * Author:
 *   Behdad Esfahbod, 2004
 *
 * Copyright (C) 2004 Sharif FarsiWeb, Inc
 * 
 * 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., 59 Temple Place, Suite 330,
 * Boston, MA 02111-1307, USA
 * 
 * For licensing issues, contact <license at farsiweb.info>.
 */
#ifndef _FRIBIDI_SHAPE_H
#define _FRIBIDI_SHAPE_H

#include "fribidi-types.h"
#include "fribidi-flags.h"
#include "fribidi-bidi-types.h"
#include "fribidi-joining-types.h"

#include "fribidi-begindecls.h"


#define fribidi_shape FRIBIDI_NAMESPACE(shape)
/* fribidi_shape - do bidi-aware shaping
 *
 * This function does all shaping work that depends on the resolved embedding
 * levels of the characters.  Currently it does mirroring and Arabic shaping,
 * but the list may grow in the future.  This function is a wrapper around
 * fribidi_shape_mirroring and fribidi_shape_arabic.
 *
 * The flags parameter specifies which shapings are applied.  The only flags
 * affecting the functionality of this function are those beginning with
 * FRIBIDI_FLAG_SHAPE_.  Of these, only FRIBIDI_FLAG_SHAPE_MIRRORING is on
 * in FRIBIDI_FLAGS_DEFAULT.  For details of the Arabic-specific flags see
 * fribidi_shape_arabic.  If ar_props is NULL, no Arabic shaping is performed.
 *
 * Feel free to do your own shaping before or after calling this function,
 * but you should take care of embedding levels yourself then.
 */
FRIBIDI_ENTRY void fribidi_shape (
  FriBidiFlags flags, /* shaping flags */
  const FriBidiLevel *embedding_levels,	/* input list of embedding
					   levels, as returned by
					   fribidi_get_par_embedding_levels */
  const FriBidiStrIndex len,	/* input string length */
  FriBidiArabicProp *ar_props, /* input/output Arabic properties as
				       * computed by fribidi_join_arabic */
  FriBidiChar *str		/* string to shape */
);


#include "fribidi-enddecls.h"

#endif /* !_FRIBIDI_SHAPE_H */
/* Editor directions:
 * vim:textwidth=78:tabstop=8:shiftwidth=2:autoindent:cindent
 */

Index: fribidi-types.h
===================================================================
RCS file: /cvs/fribidi/fribidi2/lib/fribidi-types.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- fribidi-types.h	30 Jul 2005 09:06:28 -0000	1.10
+++ fribidi-types.h	3 Nov 2005 01:39:01 -0000	1.11
@@ -138,21 +138,21 @@
 
 /* A few macros for working with bits */
 
-#define FRIBIDI_TEST_BITS(x, mask) ((x) & (mask))
+#define FRIBIDI_TEST_BITS(x, mask) (((x) & (mask)) ? 1 : 0)
 
 #define FRIBIDI_INCLUDE_BITS(x, mask) ((x) | (mask))
 
 #define FRIBIDI_EXCLUDE_BITS(x, mask) ((x) & ~(mask))
 
-#define FRIBIDI_SET_BITS(x, mask)	\
-	FRIBIDI_BEGIN_STMT	\
-	(x) |= (mask);	\
-	FRIBIDI_END_STMT
+#define FRIBIDI_SET_BITS(x, mask)	((x) |= (mask))
 
-#define FRIBIDI_UNSET_BITS(x, mask)	\
-	FRIBIDI_BEGIN_STMT	\
-	(x) &= ~(mask);	\
-	FRIBIDI_END_STMT
+#define FRIBIDI_UNSET_BITS(x, mask)	((x) &= ~(mask))
+
+#define FRIBIDI_ADJUST_BITS(x, mask, cond)	\
+	((x) = ((x) & ~(mask)) | ((cond) ? (mask) : 0))
+
+#define FRIBIDI_ADJUST_AND_TEST_BITS(x, mask, cond)	\
+	FRIBIDI_TEST_BITS(FRIBIDI_ADJUST_BITS((x), (mask), (cond)), (mask))
 
 #include "fribidi-enddecls.h"
 

Index: fribidi-unicode.h
===================================================================
RCS file: /cvs/fribidi/fribidi2/lib/fribidi-unicode.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- fribidi-unicode.h	21 Jun 2004 21:15:31 -0000	1.5
+++ fribidi-unicode.h	3 Nov 2005 01:39:01 -0000	1.6
@@ -91,6 +91,12 @@
 #define FRIBIDI_CHAR_ARABIC_ZERO	0x0660
 #define FRIBIDI_CHAR_PERSIAN_ZERO	0x06F0
 
+/* Misc */
+#define FRIBIDI_CHAR_ZWNBSP		0xFEFF
+
+/* Char we place for a deleted slot, to delete later */
+#define FRIBIDI_CHAR_FILL		FRIBIDI_CHAR_ZWNBSP
+
 /* These are here just for lazy people. */
 #if !FRIBIDI_STRICT
 #define UNI_MAX_BIDI_LEVEL	FRIBIDI_BIDI_MAX_EXPLICIT_LEVEL

Index: fribidi.c
===================================================================
RCS file: /cvs/fribidi/fribidi2/lib/fribidi.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- fribidi.c	30 Jul 2005 09:06:28 -0000	1.16
+++ fribidi.c	3 Nov 2005 01:39:01 -0000	1.17
@@ -37,199 +37,37 @@
 
 #include <fribidi.h>
 
-FRIBIDI_ENTRY void
-fribidi_shape (
-  /* input */
-  const FriBidiLevel *embedding_levels,
-  const FriBidiStrIndex len,
-  /* input and output */
-  FriBidiChar *str
-)
-{
-  if UNLIKELY
-    (len == 0 || !str) return;
-
-  DBG ("in fribidi_shape");
-
-  fribidi_assert (embedding_levels);
-
-  fribidi_shape_mirroring (embedding_levels, len, str);
-}
-
+#if DEBUG
+static int flag_debug = false;
+#endif
 
-FRIBIDI_ENTRY FriBidiStrIndex
-fribidi_remove_bidi_marks (
-  FriBidiChar *str,
-  const FriBidiStrIndex len,
-  FriBidiStrIndex *positions_to_this,
-  FriBidiStrIndex *position_from_this_list,
-  FriBidiLevel *embedding_levels
+FRIBIDI_ENTRY fribidi_boolean
+fribidi_debug_status (
+  void
 )
 {
-  register FriBidiStrIndex i, j = 0;
-  fribidi_boolean private_from_this = false;
-  fribidi_boolean status = false;
-
-  if UNLIKELY
-    (len == 0)
-    {
-      status = true;
-      goto out;
-    }
-
-  DBG ("in fribidi_remove_bidi_marks");
-
-  fribidi_assert (str);
-
-  /* If to_this is to not NULL, we must have from_this as well. If it is
-     not given by the caller, we have to make a private instance of it. */
-  if (positions_to_this && !position_from_this_list)
-    {
-      position_from_this_list = fribidi_malloc (sizeof
-						(position_from_this_list[0]) *
-						len);
-      if UNLIKELY
-	(!position_from_this_list) goto out;
-      private_from_this = true;
-      for (i = 0; i < len; i++)
-	position_from_this_list[positions_to_this[i]] = i;
-    }
-
-  for (i = 0; i < len; i++)
-    if (!FRIBIDI_IS_EXPLICIT_OR_BN (fribidi_get_bidi_type (str[i]))
-	&& str[i] != FRIBIDI_CHAR_LRM && str[i] != FRIBIDI_CHAR_RLM)
-      {
-	str[j] = str[i];
-	if (embedding_levels)
-	  embedding_levels[j] = embedding_levels[i];
-	if (position_from_this_list)
-	  position_from_this_list[j] = position_from_this_list[i];
-	j++;
-      }
-
-  /* Convert the from_this list to to_this */
-  if (positions_to_this)
-    {
-      for (i = 0; i < len; i++)
-	positions_to_this[i] = -1;
-      for (i = 0; i < len; i++)
-	positions_to_this[position_from_this_list[i]] = i;
-    }
-
-  status = true;
-
-out:
-
-  if (private_from_this)
-    fribidi_free (position_from_this_list);
-
-  return status ? j : -1;
+#if DEBUG
+  return flag_debug;
+#else
+  return false;
+#endif
 }
 
-
-FRIBIDI_ENTRY FriBidiLevel
-fribidi_log2vis (
+FRIBIDI_ENTRY fribidi_boolean
+fribidi_set_debug (
   /* input */
-  const FriBidiChar *str,
-  FriBidiStrIndex len,
-  /* input and output */
-  FriBidiParType *pbase_dir,
-  /* output */
-  FriBidiChar *visual_str,
-  FriBidiStrIndex *positions_L_to_V,
-  FriBidiStrIndex *positions_V_to_L,
-  FriBidiLevel *embedding_levels
+  fribidi_boolean state
 )
 {
-  FriBidiLevel max_level = 0;
-  fribidi_boolean private_V_to_L = false;
-  fribidi_boolean private_embedding_levels = false;
-  fribidi_boolean status = false;
-  FriBidiArabicProp *ar_props = NULL;
-  FriBidiCharType *bidi_types = NULL;
-
-  if UNLIKELY
-    (len == 0)
-    {
-      status = true;
-      goto out;
-    }
-
-  DBG ("in fribidi_log2vis");
-
-  fribidi_assert (str);
-  fribidi_assert (pbase_dir);
-
-  bidi_types = fribidi_malloc (len * sizeof bidi_types[0]);
-  if (!bidi_types)
-    goto out;
-
-  fribidi_get_bidi_types (str, len, bidi_types);
-
-  if (!embedding_levels)
-    {
-      embedding_levels = fribidi_malloc (len * sizeof embedding_levels[0]);
-      if (!embedding_levels)
-	goto out;
-      private_embedding_levels = true;
-    }
-
-  max_level = fribidi_get_par_embedding_levels (bidi_types, len, pbase_dir,
-						embedding_levels) - 1;
-  if UNLIKELY
-    (max_level < 0) goto out;
-
-  if (visual_str)
-    {
-      register FriBidiStrIndex i;
-
-      for (i = len - 1; i >= 0; i--)
-	visual_str[i] = str[i];
-
-#if !FRIBIDI_NO_ARABIC
-      /* Arabic joining */
-      ar_props = fribidi_malloc (len * sizeof ar_props[0]);
-      fribidi_get_joining_types (str, len, ar_props);
-      fribidi_join_arabic (bidi_types, len, embedding_levels, ar_props);
-#endif /* !FRIBIDI_NO_ARABIC */
-
-      fribidi_shape (embedding_levels, len, visual_str);
-    }
-
-  /* If l2v is to be calculated we must have v2l as well. If it is not
-     given by the caller, we have to make a private instance of it. */
-  if (positions_L_to_V && !positions_V_to_L)
-    {
-      positions_V_to_L =
-	(FriBidiStrIndex *) fribidi_malloc (sizeof (FriBidiStrIndex) * len);
-      if (!positions_V_to_L)
-	goto out;
-      private_V_to_L = true;
-    }
-
-  status =
-    fribidi_reorder_line (bidi_types, len, 0, *pbase_dir,
-			  embedding_levels, visual_str,
-			  positions_L_to_V, positions_V_to_L);
-
-out:
-
-  if (private_V_to_L)
-    fribidi_free (positions_V_to_L);
-
-  if (private_embedding_levels)
-    fribidi_free (embedding_levels);
-
-  if (ar_props)
-    fribidi_free (ar_props);
-
-  if (bidi_types)
-    fribidi_free (bidi_types);
-
-  return status ? max_level + 1 : 0;
+#if DEBUG
+  return flag_debug = state;
+#else
+  return false;
+#endif
 }
 
 
+
 const char *fribidi_unicode_version = FRIBIDI_UNICODE_VERSION;
 
 const char *fribidi_version_info =
@@ -253,11 +91,12 @@
 #endif /* !FRIBIDI_USE_GLIB */
   ".\n\n"
   "Copyright (C) 2004  Sharif FarsiWeb, Inc.\n"
-  "Copyright (C) 2004  Behdad Esfahbod\n"
+  "Copyright (C) 2001, 2002, 2004, 2005  Behdad Esfahbod\n"
+  "Copyright (C) 1999, 2000  Dov Grobgeld\n"
   FRIBIDI_NAME " comes with NO WARRANTY, to the extent permitted by law.\n"
   "You may redistribute copies of " FRIBIDI_NAME " under\n"
   "the terms of the GNU Lesser General Public License.\n"
-  "For more information about these matters, see the file named COPYING.\n"
+  "For more information about these matters, see the file named COPYING.\n\n"
   "Written by Behdad Esfahbod and Dov Grobgeld.\n";
 
 /* Editor directions:

Index: fribidi.h
===================================================================
RCS file: /cvs/fribidi/fribidi2/lib/fribidi.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- fribidi.h	21 Jun 2004 21:15:31 -0000	1.8
+++ fribidi.h	3 Nov 2005 01:39:01 -0000	1.9
@@ -34,117 +34,27 @@
 
 #include "fribidi-unicode.h"
 #include "fribidi-types.h"
-#include "fribidi-env.h"
-#include "fribidi-mirroring.h"
+#include "fribidi-flags.h"
 #include "fribidi-bidi-types.h"
 #include "fribidi-bidi.h"
-#if !FRIBIDI_NO_ARABIC
 #include "fribidi-joining-types.h"
 #include "fribidi-joining.h"
-#else
-typedef void FriBidiJoiningType typedef void FriBidiArabicProp
-#endif				/* !FRIBIDI_NO_ARABIC */
+#include "fribidi-mirroring.h"
+#include "fribidi-arabic.h"
+#include "fribidi-shape.h"
+
+
 #if FRIBIDI_CHARSETS
 # include "fribidi-char-sets.h"
 #endif				/* FRIBIDI_CHARSETS */
-#include "fribidi-begindecls.h"
-/* See fribidi-bidi.h for the core functions
- * fribidi_get_par_embedding_levels() and fribidi_reorder_line() which are
- * probably the main calls you need.  See README for a better understanding of
- * what calls you need.
- */
-#define fribidi_shape FRIBIDI_NAMESPACE(shape)
-/* fribidi_shape - do bidi-dependent shaping
- *
- * This function does all shaping work that depends on the resolved embedding
- * levels of the characters.  Currently it does mirroring and Arabic shaping,
- * but the list may grow later.
- *
- * Individual shaping features can be turned on/off using environmental
- * setting functions fribidi_env_*().  Feel free to do your own shaping before
- * or after calling this function, but you should take care of embedding
- * levels yourself then.
- */
-FRIBIDI_ENTRY void fribidi_shape (
-  const FriBidiLevel *embedding_levels,	/* input list of embedding
-					   levels, as returned by
-					   fribidi_get_par_embedding_levels */
-  const FriBidiStrIndex len,	/* input string length */
-  FriBidiChar *str		/* string to shape */
-);
-
-#define fribidi_remove_bidi_marks FRIBIDI_NAMESPACE(remove_bidi_marks)
-/* fribidi_remove_bidi_marks - remove bidi marks out of an string
- *
- * This function removes the bidi and boundary-neutral marks out of an string
- * and the accompanying lists.  It implements rule X9 of the Unicode
- * Bidirectional Algorithm available at
- * http://www.unicode.org/reports/tr9/#X9, with the exception that it removes
- * U+200E LEFT-TO-RIGHT MARK and U+200F RIGHT-TO-LEFT MARK too.
- *
- * If any of the input lists are NULL, the list is skipped.  If str is the
- * visual string, then positions_to_this is  positions_L_to_V and
- * position_from_this_list is positions_V_to_L;  if str is the logical
- * string, the other way.Moreover, the position maps should be filled with
- * valid entries.
- * 
- * A position map pointing to a removed character is filled with -1. By the
- * way, you should not use embedding_levels if str is visual string.
- * 
- * For best results this function should be run on a whole paragraph, not
- * lines; but feel free to do otherwise if you know what you are doing.
- *
- * Returns: New length of the string, or -1 if an error occured (memory
- * allocation failure most probably).
- */
-FRIBIDI_ENTRY FriBidiStrIndex
-fribidi_remove_bidi_marks (
-  FriBidiChar *str,		/* input string to clean */
-  const FriBidiStrIndex len,	/* input string length */
-  FriBidiStrIndex *positions_to_this,	/* list mapping positions to the
-					   order used in str */
-  FriBidiStrIndex *position_from_this_list,	/* list mapping positions from the
-						   order used in str */
-  FriBidiLevel *embedding_levels	/* list of embedding levels */
-) FRIBIDI_GNUC_WARN_UNUSED;
 
 
-/* Deprecated interface: */
+#if !FRIBIDI_NO_DEPRECATED
+# include "fribidi-deprecated.h"
+#endif				/* !FRIBIDI_NO_DEPRECATED */
 
-#define fribidi_log2vis FRIBIDI_NAMESPACE(log2vis)
-/* fribidi_log2vis - get visual string
- *
- * This function converts the logical input string to the visual output
- * strings as specified by the Unicode Bidirectional Algorithm.  As a side
- * effect it also generates mapping lists between the two strings, and the
- * list of embedding levels as defined by the algorithm.
- *
- * If NULL is passed as any of the the lists, the list is ignored and not
- * filled.
- *
- * This function is obsolete because it only handles one-line paragraphs. 
- * Please consider using other functions instead.  Deprecated.
- *
- * Returns: Maximum level found plus one, or zero if any error occured
- * (memory allocation failure most probably).
- */
-     FRIBIDI_ENTRY FriBidiLevel fribidi_log2vis (
-  const FriBidiChar *str,	/* input logical string */
-  const FriBidiStrIndex len,	/* input string length */
-  FriBidiParType *pbase_dir,	/* requested and resolved paragraph
-				 * base direction */
-  FriBidiChar *visual_str,	/* output visual string */
-  FriBidiStrIndex *positions_L_to_V,	/* output mapping from logical to 
-					 * visual string positions */
-  FriBidiStrIndex *positions_V_to_L,	/* output mapping from visual string
-					 * back to the logical string
-					 * positions */
-  FriBidiLevel *embedding_levels	/* output list of embedding levels */
-)
-     FRIBIDI_GNUC_WARN_UNUSED FRIBIDI_GNUC_DEPRECATED;
 
-#define fribidi_log2vis_get_embedding_levels fribidi_get_par_embedding_levels
-#define fribidi_get_type fribidi_get_bidi_type
+#include "fribidi-begindecls.h"
 
 
 

Index: joining-types.h
===================================================================
RCS file: /cvs/fribidi/fribidi2/lib/joining-types.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- joining-types.h	15 Jun 2004 11:52:02 -0000	1.2
+++ joining-types.h	3 Nov 2005 01:39:01 -0000	1.3
@@ -46,7 +46,7 @@
 char
 fribidi_char_from_joining_type (
   FriBidiJoiningType j,		/* input joining type */
-  fribidi_boolean visual	/* in visual context or logincal? */
+  fribidi_boolean visual	/* in visual context or logical? */
 ) FRIBIDI_GNUC_HIDDEN;
 
 #endif /* DEBUG */



More information about the fribidi-commit mailing list