[FriBidi-commit] fribidi/lib bidi-types.h, 1.5, 1.6 common.h, 1.14, 1.15 fribidi-bidi-types.h, 1.12, 1.13 fribidi-bidi.c, 1.16, 1.17 fribidi-bidi.h, 1.12, 1.13 fribidi-joining.c, 1.2, 1.3 fribidi-run.c, 1.5, 1.6 fribidi-unicode.h, 1.3, 1.4 fribidi.c, 1.13, 1.14 run.h, 1.6, 1.7

Behdad Esfahbod behdad at pdx.freedesktop.org
Mon Jun 21 11:49:25 PDT 2004


Update of /cvs/fribidi/fribidi/lib
In directory pdx:/tmp/cvs-serv30411/lib

Modified Files:
	bidi-types.h common.h fribidi-bidi-types.h fribidi-bidi.c 
	fribidi-bidi.h fribidi-joining.c fribidi-run.c 
	fribidi-unicode.h fribidi.c run.h 
Log Message:
We need bidi_types all over the place (in joining, in shaping, ...), so
make them mandatory.  As a consequence, many of our functions don't need str
anymore:  they just need this bidi_types.


Index: bidi-types.h
===================================================================
RCS file: /cvs/fribidi/fribidi/lib/bidi-types.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- bidi-types.h	14 Jun 2004 17:00:33 -0000	1.5
+++ bidi-types.h	21 Jun 2004 18:49:23 -0000	1.6
@@ -53,8 +53,6 @@
 
 #endif /* DEBUG */
 
-#define BIDI_TYPE(i) (bidi_types ? bidi_types[(i)] : fribidi_get_bidi_type(str[(i)]))
-
 #include <fribidi-enddecls.h>
 
 #endif /* !_BIDI_TYPES_H */

Index: common.h
===================================================================
RCS file: /cvs/fribidi/fribidi/lib/common.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- common.h	15 Jun 2004 11:52:02 -0000	1.14
+++ common.h	21 Jun 2004 18:49:23 -0000	1.15
@@ -166,6 +166,11 @@
 # define _GNU_SOURCE
 #endif /* !_GNU_SOURCE */
 
+/* We respect our own rules. */
+#define FRIBIDI_STRICT 1
+#undef FRIBIDI_COMPAT
+
+
 #include "debug.h"
 
 #endif /* !_COMMON_H */

Index: fribidi-bidi-types.h
===================================================================
RCS file: /cvs/fribidi/fribidi/lib/fribidi-bidi-types.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- fribidi-bidi-types.h	18 Jun 2004 19:21:33 -0000	1.12
+++ fribidi-bidi-types.h	21 Jun 2004 18:49:23 -0000	1.13
@@ -224,16 +224,20 @@
 
 #endif
 
-/* For lazy people... */
+/* Please don't use these two type names, use FRIBIDI_PAR_* form instead. */
 #define FRIBIDI_TYPE_WLTR	FRIBIDI_PAR_WLTR
-#define FRIBIDI_TYPE_WL		FRIBIDI_PAR_WLTR
 #define FRIBIDI_TYPE_WRTL	FRIBIDI_PAR_WRTL
+
+/* These are here just for lazy people. */
+#if !FRIBIDI_STRICT
+#define FRIBIDI_TYPE_WL		FRIBIDI_PAR_WLTR
 #define FRIBIDI_TYPE_WR		FRIBIDI_PAR_WRTL
 #define FRIBIDI_TYPE_L		FRIBIDI_PAR_LTR
 #define FRIBIDI_TYPE_R		FRIBIDI_PAR_RTL
 #define FRIBIDI_TYPE_N		FRIBIDI_PAR_ON
 #define FRIBIDI_TYPE_B		FRIBIDI_TYPE_BS
 #define FRIBIDI_TYPE_S		FRIBIDI_TYPE_SS
+#endif /* !FRIBIDI_STRICT */
 
 
 /*

Index: fribidi-bidi.c
===================================================================
RCS file: /cvs/fribidi/fribidi/lib/fribidi-bidi.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- fribidi-bidi.c	21 Jun 2004 16:15:27 -0000	1.16
+++ fribidi-bidi.c	21 Jun 2004 18:49:23 -0000	1.17
@@ -198,18 +198,17 @@
 static void
 print_bidi_string (
   /* input */
-  const FriBidiChar *str,
-  const FriBidiStrIndex len,
-  const FriBidiCharType *bidi_types
+  const FriBidiCharType *bidi_types,
+  const FriBidiStrIndex len
 )
 {
   register FriBidiStrIndex i;
 
-  fribidi_assert (str || bidi_types);
+  fribidi_assert (bidi_types);
 
   MSG ("  Org. types : ");
   for (i = 0; i < len; i++)
-    MSG2 ("%c", fribidi_char_from_bidi_type (BIDI_TYPE (i)));
+    MSG2 ("%c", fribidi_char_from_bidi_type (bidi_types[i]));
   MSG ("\n");
 }
 #endif /* DEBUG */
@@ -308,18 +307,17 @@
 FRIBIDI_ENTRY FriBidiParType
 fribidi_get_par_direction (
   /* input */
-  const FriBidiChar *str,
-  const FriBidiStrIndex len,
-  const FriBidiCharType *bidi_types
+  const FriBidiCharType *bidi_types,
+  const FriBidiStrIndex len
 )
 {
   register FriBidiStrIndex i;
 
-  fribidi_assert (str || bidi_types);
+  fribidi_assert (bidi_types);
 
   for (i = 0; i < len; i++)
-    if (FRIBIDI_IS_LETTER (BIDI_TYPE (i)))
-      return FRIBIDI_IS_RTL (BIDI_TYPE (i)) ? FRIBIDI_PAR_RTL :
+    if (FRIBIDI_IS_LETTER (bidi_types[i]))
+      return FRIBIDI_IS_RTL (bidi_types[i]) ? FRIBIDI_PAR_RTL :
 	FRIBIDI_PAR_LTR;
 
   return FRIBIDI_PAR_ON;
@@ -328,9 +326,8 @@
 FRIBIDI_ENTRY FriBidiLevel
 fribidi_get_par_embedding_levels (
   /* input */
-  const FriBidiChar *str,
-  const FriBidiStrIndex len,
   const FriBidiCharType *bidi_types,
+  const FriBidiStrIndex len,
   /* input and output */
   FriBidiParType *pbase_dir,
   /* output */
@@ -349,16 +346,16 @@
       goto out;
     }
 
-  DBG ("entering fribidi_get_par_embedding_levels");
+  DBG ("in fribidi_get_par_embedding_levels");
 
-  fribidi_assert (str || bidi_types);
+  fribidi_assert (bidi_types);
   fribidi_assert (pbase_dir);
   fribidi_assert (embedding_levels);
 
   /* Determinate character types */
   {
     /* Get run-length encoded character types */
-    main_run_list = run_list_encode_bidi_types (str, len, bidi_types);
+    main_run_list = run_list_encode_bidi_types (bidi_types, len);
     if UNLIKELY
       (!main_run_list) goto out;
   }
@@ -512,7 +509,7 @@
     (fribidi_debug_status ())
     {
       print_types_re (main_run_list);
-      print_bidi_string (str, len, bidi_types);
+      print_bidi_string (bidi_types, len);
       print_resolved_levels (main_run_list);
       print_resolved_types (main_run_list);
     }
@@ -716,7 +713,7 @@
   if UNLIKELY
     (fribidi_debug_status ())
     {
-      print_bidi_string (str, len, bidi_types);
+      print_bidi_string (bidi_types, len);
       print_resolved_levels (main_run_list);
       print_resolved_types (main_run_list);
     }
@@ -772,7 +769,7 @@
       {
 	/* close up the open link at the end */
 	if (j >= 0)
-	  char_type = BIDI_TYPE (j);
+	  char_type = bidi_types[j];
 	else
 	  char_type = FRIBIDI_TYPE_ON;
 	if (!state && FRIBIDI_IS_SEPARATOR (char_type))
@@ -877,11 +874,10 @@
 
 FRIBIDI_ENTRY FriBidiLevel
 fribidi_reorder_line (
-  const FriBidiChar *str,
   /* input */
+  const FriBidiCharType *bidi_types,
   const FriBidiStrIndex len,
   const FriBidiStrIndex off,
-  const FriBidiCharType *bidi_types,
   const FriBidiParType base_dir,
   /* input and output */
   FriBidiLevel *embedding_levels,
@@ -915,12 +911,9 @@
 
   DBG ("in fribidi_reorder_line");
 
-  fribidi_assert (str || visual_str || bidi_types);
+  fribidi_assert (bidi_types);
   fribidi_assert (embedding_levels);
 
-  if (!str)
-    str = visual_str;
-
   DBG ("reset the embedding levels, 4. whitespace at the end of line");
   {
     register FriBidiStrIndex i;
@@ -928,7 +921,7 @@
     /* L1. Reset the embedding levels of some chars:
        4. any sequence of white space characters at the end of the line. */
     for (i = off + len - 1; i >= off &&
-	 FRIBIDI_IS_EXPLICIT_OR_BN_OR_WS (BIDI_TYPE (i)); i--)
+	 FRIBIDI_IS_EXPLICIT_OR_BN_OR_WS (bidi_types[i]); i--)
       embedding_levels[i] = FRIBIDI_DIR_TO_LEVEL (base_dir);
   }
 
@@ -962,13 +955,13 @@
 	  /* L3. Reorder NSMs. */
 	  for (i = off + len - 1; i >= off; i--)
 	    if (FRIBIDI_LEVEL_IS_RTL (embedding_levels[i])
-		&& BIDI_TYPE (i) == FRIBIDI_TYPE_NSM)
+		&& bidi_types[i] == FRIBIDI_TYPE_NSM)
 	      {
 		register FriBidiStrIndex seq_end = i;
 		level = embedding_levels[i];
 
 		for (i--; i >= off &&
-		     FRIBIDI_IS_EXPLICIT_OR_BN_OR_NSM (BIDI_TYPE (i))
+		     FRIBIDI_IS_EXPLICIT_OR_BN_OR_NSM (bidi_types[i])
 		     && embedding_levels[i] == level; i--)
 		  ;
 

Index: fribidi-bidi.h
===================================================================
RCS file: /cvs/fribidi/fribidi/lib/fribidi-bidi.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- fribidi-bidi.h	21 Jun 2004 16:15:27 -0000	1.12
+++ fribidi-bidi.h	21 Jun 2004 18:49:23 -0000	1.13
@@ -49,12 +49,6 @@
  * as defined by rule P2 of the Unicode Bidirectional Algorithm available at
  * http://www.unicode.org/reports/tr9/#P2.
  *
- * You can provide either the string, or the bidi types; or both.
- * If bidi_types are provided, they are used as the bidi types of characters
- * in the string, otherwise the types are computed from the characters in str.
- * Providing bidi types if available at your side, saves you a few cycles.
- * Bidi types can be obtained by calling fribidi_get_bidi_types().
- *
  * You typically do not need this function as
  * fribidi_get_par_embedding_levels() knows how to compute base direction
  * itself, but you may need this to implement a more sophisticated paragraph
@@ -69,9 +63,8 @@
  * only LTR, RTL, or ON.
  */
 FRIBIDI_ENTRY FriBidiParType fribidi_get_par_direction (
-  const FriBidiChar *str,	/* input paragraph string */
-  const FriBidiStrIndex len,	/* input string length */
-  const FriBidiCharType *bidi_types	/* input bidi types */
+  const FriBidiCharType *bidi_types,	/* input bidi types */
+  const FriBidiStrIndex len	/* input string length */
 );
 
 #define fribidi_get_par_embedding_levels FRIBIDI_NAMESPACE(get_par_embedding_levels)
@@ -84,12 +77,6 @@
  *  implemented in fribidi_remove_bidi_marks().  Part 4 of L1 is implemented
  *  in fribidi_reorder_line().
  *
- * You can provide either the string, or the bidi types; or both.
- * If bidi_types are provided, they are used as the bidi types of characters
- * in the string, otherwise the types are computed from the characters in str.
- * Providing bidi types if available at your side, saves you a few cycles.
- * Bidi types can be obtained by calling fribidi_get_bidi_types().
- *
  * There are a few macros defined in fribidi-bidi-types.h to work with this
  * embedding levels.
  *
@@ -98,9 +85,8 @@
  */
 FRIBIDI_ENTRY FriBidiLevel
 fribidi_get_par_embedding_levels (
-  const FriBidiChar *str,	/* input paragraph string */
-  const FriBidiStrIndex len,	/* input string length of the paragraph */
   const FriBidiCharType *bidi_types,	/* input 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 */
@@ -116,20 +102,6 @@
  *
  * As a side effect it also sets position maps if not NULL.
  *
- * You can provide either the string str, or the bidi types; or both.  If
- * bidi_types are provided, they are used as the bidi types of characters in
- * the string, otherwise the types are computed from the characters in str.
- * If neither str nor bidi types are provided, visual_str is used instead.
- * Feel free to pass the same string as both str and visual_str, but if you
- * done extensive complicated shaping in visual_str, you better provide
- * logical string as str.  There is no known differences yet between providing
- * logical or visual string as str.
- *
- * If you have obtained the embedding levels using custom bidi types, you
- * should provide the same types to this function for valid resutls.
- * Providing bidi types if available at your side, saves you a few cycles, and
- * you don't need to provide str anymore.
- *
  * You should provide the resolved paragraph direction and embedding levels as
  * set by fribidi_get_par_embedding_levels().  Also note that the embedding
  * levels may change a bit.  To be exact, the embedding level of any sequence
@@ -146,11 +118,10 @@
  * occured (memory allocation failure most probably).
  */
      FRIBIDI_ENTRY FriBidiLevel fribidi_reorder_line (
-  const FriBidiChar *str,	/* input string */
+  const FriBidiCharType *bidi_types,	/* input bidi types */
   const FriBidiStrIndex len,	/* input length of the line */
   const FriBidiStrIndex off,	/* input offset of the beginning of the line
 				   in the paragraph */
-  const FriBidiCharType *bidi_types,	/* input bidi types */
   const FriBidiParType base_dir,	/* resolved paragraph base direction */
   FriBidiLevel *embedding_levels,	/* list of embedding levels,
 					   as returned by

Index: fribidi-joining.c
===================================================================
RCS file: /cvs/fribidi/fribidi/lib/fribidi-joining.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- fribidi-joining.c	15 Jun 2004 11:52:02 -0000	1.2
+++ fribidi-joining.c	21 Jun 2004 18:49:23 -0000	1.3
@@ -70,6 +70,15 @@
 #endif /* DEBUG */
 
 
+#if FRIBIDI_JOIN_WITHIN_RUN_LEVEL
+/* Join within same level run (to be proposed for inclusion in Unicode 4.1) */
+# define FRIBIDI_JOINING_RUN(l) (l)
+#else /* !FRIBIDI_JOIN_WITHIN_RUN_LEVEL */
+/* Join within same directional run (current rule in Unicode 4.0.1) */
+# define FRIBIDI_JOINING_RUN(l) FRIBIDI_LEVEL_IS_RTL(l)
+#endif /* !FRIBIDI_JOIN_WITHIN_RUN_LEVEL */
+
+
 FRIBIDI_ENTRY void
 fribidi_join_arabic (
   /* input */
@@ -82,7 +91,7 @@
   if UNLIKELY
     (len == 0) return;
 
-  DBG ("entering fribidi_join_arabic");
+  DBG ("in fribidi_join_arabic");
 
   fribidi_assert (embedding_levels);
   fribidi_assert (ar_props);

Index: fribidi-run.c
===================================================================
RCS file: /cvs/fribidi/fribidi/lib/fribidi-run.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- fribidi-run.c	14 Jun 2004 18:43:53 -0000	1.5
+++ fribidi-run.c	21 Jun 2004 18:49:23 -0000	1.6
@@ -156,16 +156,15 @@
 FriBidiRun *
 run_list_encode_bidi_types (
   /* input */
-  const FriBidiChar *str,
-  const FriBidiStrIndex len,
-  const FriBidiCharType *bidi_types
+  const FriBidiCharType *bidi_types,
+  const FriBidiStrIndex len
 )
 {
   FriBidiRun *list, *last;
   register FriBidiRun *run = NULL;
   FriBidiStrIndex i;
 
-  fribidi_assert (str || bidi_types);
+  fribidi_assert (bidi_types);
 
   /* Create the list sentinel */
   list = new_run_list ();
@@ -176,7 +175,7 @@
   /* Scan over the character types */
   for (i = 0; i < len; i++)
     {
-      register FriBidiCharType char_type = BIDI_TYPE (i);
+      register FriBidiCharType char_type = bidi_types[i];
       if (char_type != last->type)
 	{
 	  run = new_run ();

Index: fribidi-unicode.h
===================================================================
RCS file: /cvs/fribidi/fribidi/lib/fribidi-unicode.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- fribidi-unicode.h	12 May 2004 08:17:19 -0000	1.3
+++ fribidi-unicode.h	21 Jun 2004 18:49:23 -0000	1.4
@@ -55,7 +55,7 @@
 extern const char *fribidi_unicode_version;
 
 
-/* The Unicode Bidirectional Algorithm constants */
+/* Unicode Bidirectional Algorithm definitions: */
 
 /* Number of types defined in the bidi algorithm */
 #define FRIBIDI_BIDI_NUM_TYPES			19
@@ -66,6 +66,12 @@
 #define FRIBIDI_BIDI_MAX_RESOLVED_LEVELS	63
 
 
+/* Unicode Arabic joining/shaping definitions: */
+
+/* Unicode 4.0.1: join within "directional run", not "level run". */
+#undef FRIBIDI_JOIN_WITHIN_RUN_LEVEL
+
+
 /* A few Unicode characters */
 
 /* Bidirectional marks */
@@ -91,7 +97,8 @@
 #define FRIBIDI_CHAR_ARABIC_ZERO	0x0660
 #define FRIBIDI_CHAR_PERSIAN_ZERO	0x06F0
 
-/* These are here just for compatibility. */
+/* These are here just for lazy people. */
+#if !FRIBIDI_STRICT
 #define UNI_MAX_BIDI_LEVEL	FRIBIDI_BIDI_MAX_EXPLICIT_LEVEL
 #define UNI_LRM			FRIBIDI_CHAR_LRM
 #define UNI_RLM			FRIBIDI_CHAR_RLM
@@ -107,6 +114,7 @@
 #define UNI_ARABIC_ALEF		FRIBIDI_CHAR_ARABIC_ALEF
 #define UNI_ARABIC_ZERO		FRIBIDI_CHAR_ARABIC_ZERO
 #define UNI_FARSI_ZERO		FRIBIDI_CHAR_PERSIAN_ZERO
+#endif /* !FRIBIDI_STRICT */
 
 #include "fribidi-enddecls.h"
 

Index: fribidi.c
===================================================================
RCS file: /cvs/fribidi/fribidi/lib/fribidi.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- fribidi.c	21 Jun 2004 16:15:27 -0000	1.13
+++ fribidi.c	21 Jun 2004 18:49:23 -0000	1.14
@@ -146,6 +146,7 @@
   fribidi_boolean private_embedding_levels = false;
   fribidi_boolean status = false;
   FriBidiArabicProps *ar_props = NULL;
+  FriBidiCharType *bidi_types = NULL;
 
   if UNLIKELY
     (len == 0)
@@ -159,6 +160,12 @@
   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]);
@@ -167,7 +174,7 @@
       private_embedding_levels = true;
     }
 
-  max_level = fribidi_get_par_embedding_levels (str, len, NULL, pbase_dir,
+  max_level = fribidi_get_par_embedding_levels (bidi_types, len, pbase_dir,
 						embedding_levels) - 1;
   if UNLIKELY
     (max_level < 0) goto out;
@@ -201,7 +208,7 @@
     }
 
   status =
-    fribidi_reorder_line (str, len, 0, NULL, *pbase_dir,
+    fribidi_reorder_line (bidi_types, len, 0, *pbase_dir,
 			  embedding_levels, visual_str,
 			  positions_L_to_V, positions_V_to_L);
 
@@ -216,6 +223,9 @@
   if (ar_props)
     fribidi_free (ar_props);
 
+  if (bidi_types)
+    fribidi_free (bidi_types);
+
   return status ? max_level + 1 : 0;
 }
 

Index: run.h
===================================================================
RCS file: /cvs/fribidi/fribidi/lib/run.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- run.h	14 Jun 2004 17:00:33 -0000	1.6
+++ run.h	21 Jun 2004 18:49:23 -0000	1.7
@@ -82,9 +82,8 @@
 
 #define run_list_encode_bidi_types FRIBIDI_PRIVATESPACE(run_list_encode_bidi_types)
      FriBidiRun *run_list_encode_bidi_types (
-  const FriBidiChar *str,
-  const FriBidiStrIndex len,
-  const FriBidiCharType *bidi_types
+  const FriBidiCharType *bidi_types,
+  const FriBidiStrIndex len
 )
      FRIBIDI_GNUC_HIDDEN FRIBIDI_GNUC_WARN_UNUSED;
 




More information about the FriBidi-Commit mailing list