]> granicus.if.org Git - fribidi/commitdiff
Wow!!! I use the wonderful packtab to compress the mirroring table now! It
authorbehdad <behdad>
Wed, 9 Jun 2004 20:01:00 +0000 (20:01 +0000)
committerbehdad <behdad>
Wed, 9 Jun 2004 20:01:00 +0000 (20:01 +0000)
gives an smaller and faster table than the old binary search one!  Moreover,
packtab deals with tables with empty heads much better.  Voila!

13 files changed:
bin/fribidi-main.c
charset/fribidi-char-sets.c
configure.ac
gen.tab/Makefile.am
gen.tab/gen-bidi-type-tab.c
gen.tab/gen-mirroring-tab.c
gen.tab/packtab.c
gen.tab/packtab.h
lib/fribidi-bidi-type.c
lib/fribidi-bidi-types.h
lib/fribidi-mirroring.c
lib/fribidi-types.h
lib/fribidi.h

index 3d255ecac6be99fdeb1e457a08f334714e119607..5c232afeb7c258c5e78faf09a5e937e29e245e0c 100644 (file)
@@ -1,10 +1,10 @@
 /* FriBidi
  * fribidi-main.c - command line program for libfribidi
  *
- * $Id: fribidi-main.c,v 1.9 2004-06-09 14:59:21 behdad Exp $
+ * $Id: fribidi-main.c,v 1.10 2004-06-09 20:01:00 behdad Exp $
  * $Author: behdad $
- * $Date: 2004-06-09 14:59:21 $
- * $Revision: 1.9 $
+ * $Date: 2004-06-09 20:01:00 $
+ * $Revision: 1.10 $
  * $Source: /home/behdad/src/fdo/fribidi/togit/git/../fribidi/fribidi2/bin/fribidi-main.c,v $
  *
  * Authors:
@@ -185,7 +185,10 @@ version (
   exit (0);
 }
 
-char *my_fribidi_strdup (char *s)
+char *
+my_fribidi_strdup (
+  char *s
+)
 {
   char *m;
 
@@ -193,7 +196,7 @@ char *my_fribidi_strdup (char *s)
   if (!m)
     return NULL;
 
-  strcpy(m, s);
+  strcpy (m, s);
 
   return m;
 }
index ddf635a97c387b2199ac5662af5c455db518b60b..325c55da014f1f54a3a948a23f1336360d9ee106 100644 (file)
@@ -1,10 +1,10 @@
 /* FriBidi
  * fribidi-char-sets.c - character set conversion routines
  *
- * $Id: fribidi-char-sets.c,v 1.5 2004-06-09 14:59:21 behdad Exp $
+ * $Id: fribidi-char-sets.c,v 1.6 2004-06-09 20:01:00 behdad Exp $
  * $Author: behdad $
- * $Date: 2004-06-09 14:59:21 $
- * $Revision: 1.5 $
+ * $Date: 2004-06-09 20:01:00 $
+ * $Revision: 1.6 $
  * $Source: /home/behdad/src/fdo/fribidi/togit/git/../fribidi/fribidi2/charset/fribidi-char-sets.c,v $
  *
  * Authors:
@@ -138,6 +138,7 @@ fribidi_strcasecmp (
   return toupper (*s1) - toupper (*s2);
 }
 #else /* FRIBIDI_USE_GLIB */
+# include <glib/gstrfuncs.h>
 # define fribidi_strcasecmp g_ascii_strcasecmp
 #endif /* FRIBIDI_USE_GLIB */
 
index 99d05a16cc1ea68cd98326376bb32e98f59c4129..4c1fd335db172936314f85cdd2583107aa32a80e 100644 (file)
@@ -3,10 +3,10 @@
 ## Use autoupdate to update this file for newer versions of autoconf.
 ## Use autoscan to check if you need to add something to this file.
 ##############################################################################
-## $Id: configure.ac,v 1.13 2004-06-09 14:59:21 behdad Exp $
+## $Id: configure.ac,v 1.14 2004-06-09 20:01:00 behdad Exp $
 ## $Auther: behdad $
-## $Date: 2004-06-09 14:59:21 $
-## $Revision: 1.13 $
+## $Date: 2004-06-09 20:01:00 $
+## $Revision: 1.14 $
 ## $Source: /home/behdad/src/fdo/fribidi/togit/git/../fribidi/fribidi2/configure.ac,v $
 ##############################################################################
 
@@ -44,7 +44,7 @@ m4_define(fribidi_version,
            fribidi_major_version.fribidi_minor_version.fribidi_micro_version))dnl
 
 AC_INIT([GNU FriBidi],fribidi_version(),[http://freedesktop.org/cgi-bin/bugzilla/enter_bug.cgi?product=FriBidi])
-AC_REVISION([$Id: configure.ac,v 1.13 2004-06-09 14:59:21 behdad Exp $])
+AC_REVISION([$Id: configure.ac,v 1.14 2004-06-09 20:01:00 behdad Exp $])
 AC_CONFIG_SRCDIR(lib/fribidi.h)
 AC_CONFIG_HEADERS(config.h)
 AM_INIT_AUTOMAKE([gnits])
@@ -107,7 +107,6 @@ AC_CHECK_HEADERS([stdlib.h string.h strings.h inttypes.h stdbool.h wchar.h sys/t
 
 # Checks for typedefs and structures.
 AC_C_CONST
-AC_C_INLINE
 AC_C_STRINGIZE
 AC_CHECK_SIZEOF(int)
 SIZEOF_INT=$ac_cv_sizeof_int
index dc263df531882dc99407bdf5d3ecca183f6003e3..99354ad5798b2afe87e8bc53b7ec4739805442d3 100644 (file)
@@ -4,7 +4,7 @@ EXTRA_PROGRAMS = \
                gen-unicode-version
 
 gen_bidi_type_tab_SOURCES = gen-bidi-type-tab.c packtab.c packtab.h
-gen_mirroring_tab_SOURCES = gen-mirroring-tab.c
+gen_mirroring_tab_SOURCES = gen-mirroring-tab.c packtab.c packtab.h
 gen_unicode_version_SOURCES = gen-unicode-version.c
 
 CLEANFILES = $(EXTRA_PROGRAMS)
@@ -74,7 +74,7 @@ BidiMirroring_mirroring.tab.i: \
                $(gen_mirroring_tab_SOURCES)
        $(MAKE) $(AM_MAKEFLAGS) $(gen_mirroring_tab)
        (DATA_FILE_TYPE=`echo $< | sed s,.*/,,`; \
-       ./$(gen_mirroring_tab) \
+       ./$(gen_mirroring_tab) $(COMPRESSION) \
         $$DATA_FILE_TYPE $< > $@ || ($(RM) $@ && false))
 
 mirroring.tab.i:
index bd9fe6038f4b4bd3bd85ed8c069951725e1ceb42..3832c4a6e56c8010a6acb990e50d356f5d5c634e 100644 (file)
@@ -1,10 +1,10 @@
 /* FriBidi
  * gen-bidi-type-tab.c - generate bidi-type.tab.i for libfribidi
  *
- * $Id: gen-bidi-type-tab.c,v 1.10 2004-06-04 09:41:11 behdad Exp $
+ * $Id: gen-bidi-type-tab.c,v 1.11 2004-06-09 20:01:00 behdad Exp $
  * $Author: behdad $
- * $Date: 2004-06-04 09:41:11 $
- * $Revision: 1.10 $
+ * $Date: 2004-06-09 20:01:00 $
+ * $Revision: 1.11 $
  * $Source: /home/behdad/src/fdo/fribidi/togit/git/../fribidi/fribidi2/gen.tab/gen-bidi-type-tab.c,v $
  *
  * Author:
@@ -135,10 +135,10 @@ get_type (
   return 0;
 }
 
-#define table_name "FriBidiCharTypeData"
+#define table_name "Bid"
 #define macro_name "FRIBIDI_GET_BIDI_TYPE"
 
-static int table[FRIBIDI_UNICODE_CHARS];
+static signed int table[FRIBIDI_UNICODE_CHARS];
 static char s[4000];
 
 static void
@@ -316,10 +316,13 @@ gen_bidi_type_tab (
          "#define PACKTAB_UINT32 fribidi_uint32\n\n");
 
   if (!pack_table
-      (table, FRIBIDI_UNICODE_CHARS, 1, max_depth, 3, names,
+      (table, FRIBIDI_UNICODE_CHARS, 1, LTR, max_depth, 3, names,
        "unsigned char", table_name, macro_name, stdout))
     die ("error: insufficient memory, decrease max_depth");
 
+  printf ("#undef PACKTAB_UINT8\n"
+         "#undef PACKTAB_UINT16\n" "#undef PACKTAB_UINT32\n\n");
+
   printf ("/* End of generated " outputname " */\n");
 }
 
index 92d4ad56a4f39fccf70969ca7c2d6b5491348ea4..9656468c28cc0bfb9da47d6bd30800e3fa74cc26 100644 (file)
@@ -1,10 +1,10 @@
 /* FriBidi
- * gen-mirroring-tab.c - generate mirroring.tab.i for libfribidi
+ * gen-mirroring-tab.c - generate bidi-mirroring.i for libfribidi
  *
- * $Id: gen-mirroring-tab.c,v 1.7 2004-05-31 18:43:26 behdad Exp $
+ * $Id: gen-mirroring-tab.c,v 1.8 2004-06-09 20:01:00 behdad Exp $
  * $Author: behdad $
- * $Date: 2004-05-31 18:43:26 $
- * $Revision: 1.7 $
+ * $Date: 2004-06-09 20:01:00 $
+ * $Revision: 1.8 $
  * $Source: /home/behdad/src/fdo/fribidi/togit/git/../fribidi/fribidi2/gen.tab/gen-mirroring-tab.c,v $
  *
  * Author:
@@ -54,6 +54,8 @@
 # include <strings.h>
 #endif
 
+#include "packtab.h"
+
 #define appname "gen-mirroring-tab"
 #define outputname "mirroring.tab.i"
 
@@ -92,20 +94,35 @@ die4 (
   exit (1);
 }
 
-static FriBidiChar table[FRIBIDI_UNICODE_CHARS];
-static char s[4000];
+#define table_name "Mir"
+#define macro_name "FRIBIDI_GET_MIRRORING_DELTA"
 
-static int mirroring_count;
+static signed int table[FRIBIDI_UNICODE_CHARS];
+static char s[4000];
+static signed long max_dist;
 
 static void
 init (
 )
 {
-  register FriBidiChar i;
+  max_dist = 0;
+}
 
-  for (i = 0; i < FRIBIDI_UNICODE_CHARS; i++)
-    table[i] = 0;
-  mirroring_count = 0;
+static void
+clear_tab (
+)
+{
+  register FriBidiChar c;
+
+  for (c = 0; c < FRIBIDI_UNICODE_CHARS; c++)
+    table[c] = 0;
+}
+
+static void
+init_tab_bidi_mirroring_txt (
+)
+{
+  clear_tab ();
 }
 
 static void
@@ -119,6 +136,7 @@ read_bidi_mirroring_txt (
   while (fgets (s, sizeof s, f))
     {
       unsigned long i, j;
+      signed long dist;
       int k;
 
       l++;
@@ -127,10 +145,15 @@ read_bidi_mirroring_txt (
        continue;
 
       k = sscanf (s, "%lx; %lx", &i, &j);
-      if (k != 2 || i >= FRIBIDI_UNICODE_CHARS || j >= FRIBIDI_UNICODE_CHARS)
+      if (k != 2 || i < 0 || i >= FRIBIDI_UNICODE_CHARS || j < 0
+         || j >= FRIBIDI_UNICODE_CHARS)
        die4 ("invalid pair in input at line %ld: %04lX, %04lX", l, i, j);
-      table[i] = j;
-      mirroring_count++;
+      dist = ((signed long) j - (signed long) i);
+      table[i] = dist;
+      if (dist > max_dist)
+       max_dist = dist;
+      else if (-dist > max_dist)
+       max_dist = -dist;
     }
 }
 
@@ -156,27 +179,33 @@ read_data (
 
 static void
 gen_mirroring_tab (
+  int max_depth,
   char *data_file_type
 )
 {
-  FriBidiChar i;
+  int key_bytes;
+  char *key_type;
 
-  fprintf (stderr, "Generating output, it may take up to a few seconds\n");
+  fprintf (stderr, "Generating output, it may take up to a few minutes\n");
   printf ("/* " outputname "\n * generated by " appname " (" FRIBIDI_NAME " "
          FRIBIDI_VERSION ")\n" " * from the file %s of Unicode version "
          FRIBIDI_UNICODE_VERSION ". */\n\n", data_file_type);
 
-  printf ("/* *IND" "ENT-OFF" "* */\n\n");
-  printf
-    ("static const struct _FriBidiMirroredPair FriBidiMirroredChars[] =\n{\n");
-  for (i = 0; i < FRIBIDI_UNICODE_CHARS; i++)
-    if (table[i])
-      printf ("  {0x%04lX, 0x%04lX},\n", (unsigned long) i,
-             (unsigned long) table[i]);
-  printf ("} ;\n\n");
-  printf ("/* *IND" "ENT-ON* */\n\n");
-  printf ("static const int nFriBidiMirroredChars = %d;\n\n",
-         mirroring_count);
+  printf ("#define PACKTAB_UINT8 fribidi_uint8\n"
+         "#define PACKTAB_UINT16 fribidi_uint16\n"
+         "#define PACKTAB_UINT32 fribidi_uint32\n\n");
+
+  key_bytes = max_dist <= 0x7f ? 1 : max_dist < 0x7fff ? 2 : 4;
+  key_type = key_bytes == 1 ? "fribidi_int8" : key_bytes == 2 ?
+    "fribidi_int16" : "fribidi_int32";
+
+  if (!pack_table
+      (table, FRIBIDI_UNICODE_CHARS, key_bytes, 0, max_depth, 1, NULL,
+       key_type, table_name, macro_name, stdout))
+    die ("error: insufficient memory, decrease max_depth");
+
+  printf ("#undef PACKTAB_UINT8\n"
+         "#undef PACKTAB_UINT16\n" "#undef PACKTAB_UINT32\n\n");
 
   printf ("/* End of generated " outputname " */\n");
 }
@@ -187,16 +216,20 @@ main (
   char **argv
 )
 {
-  if (argc != 3)
-    die ("usage:\n  " appname " data-file-type data-file-name\n"
-        "where data-file-type is:\n" "  * BidiMirroring.txt");
+  if (argc != 4)
+    die ("usage:\n  " appname " max-depth data-file-type data-file-name\n"
+        "where data-file-type is one of these:\n" "  * BidiMirroring.txt");
   {
-    char *data_file_type = argv[1];
-    char *data_file_name = argv[2];
+    int max_depth = atoi (argv[1]);
+    char *data_file_type = argv[2];
+    char *data_file_name = argv[3];
+
+    if (max_depth < 2)
+      die ("invalid depth");
 
     init ();
     read_data (data_file_type, data_file_name);
-    gen_mirroring_tab (data_file_type);
+    gen_mirroring_tab (max_depth, data_file_type);
   }
 
   return 0;
index 11c4e8aa06ca969648953428acedf271b285af68..45f762a6c68b6fee3d952fcf5bb2e5801403d64a 100644 (file)
   int key
   1 <= max_depth <= 21
 */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
 #include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#if STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#else
+# if HAVE_STDLIB_H
+#  include <stdlib.h>
+# endif
+#endif
+#if HAVE_STRING_H
+# if !STDC_HEADERS && HAVE_MEMORY_H
+#  include <memory.h>
+# endif
+# include <string.h>
+#endif
+#if HAVE_STRINGS_H
+# include <strings.h>
+#endif
 
 #include "packtab.h"
 
-typedef int uni_table[1024 * 1024 * 2];
-static int n, a, max_depth, N, digits, tab_width, per_row;
+typedef signed int uni_table[1024 * 1024 * 2];
+static int n, a, max_depth, digits, tab_width, per_row;
+static long N;
+signed int def_key;
 static uni_table temp, x, perm, *tab;
-static int pow[22], cluster, cmpcluster;
-static char **name, *key_type_name, *table_name, *macro_name;
+static long pow[22], cluster, cmpcluster;
+static const char *const *name, *key_type_name, *table_name, *macro_name;
 static FILE *f;
 
-static inline void
+static long
+most_binary (
+  long min,
+  long max
+)
+{
+  /* min should be less than max */
+  register int i, ii;
+
+  if (min == max)
+    return max;
+
+  for (i = 21; max < pow[i]; i--)
+    ;
+  ii = i;
+  while (i && !((min ^ max) & pow[i]))
+    i--;
+
+  if (ii == i)
+    {
+      /* min is less than half of max */
+      for (i = 21 - 1; min < pow[i]; i--)
+       ;
+      i++;
+      return pow[i];
+    }
+
+  return max & (pow[i] - 1);
+}
+
+static void
 init (
+  const signed int *table
 )
 {
-  int i;
+  register int i;
+
+  /* initialize powers of two */
   pow[0] = 1;
   for (i = 1; i <= 21; i++)
-    pow[i] = pow[i - 1] * 2;
-  for (n = 21; pow[n] > N || N % pow[n]; n--)
+    pow[i] = pow[i - 1] << 1;
+
+  /* reduce number of elements to get a more binary number */
+  {
+    long essen;
+
+    /* find number of essential items */
+    essen = N - 1;
+    while (essen && table[essen] == def_key)
+      essen--;
+    essen++;
+
+    N = most_binary (essen, N);
+  }
+
+  for (n = 21; N % pow[n]; n--)
     ;
   digits = (n + 3) / 4;
   for (i = 6; i; i--)
@@ -67,9 +136,10 @@ compare (
   return 0;
 }
 
-static int lev, p[22], t[22], c[22], clusters[22], s, nn;
-static int best_lev, best_p[22], best_t[22], best_c[22], best_cluster[22],
-  best_s;
+static int lev, p[22], nn;
+static int best_lev, best_p[22];
+static long c[22], best_c[22], s, best_s;
+static long t[22], best_t[22], clusters[22], best_cluster[22];
 
 static void
 found (
@@ -97,7 +167,8 @@ bt (
   int node_size
 )
 {
-  int i, j, k, y, sbak, key_bytes;
+  long i, j, k, y, sbak;
+  long key_bytes;
 
   if (t[lev] == 1)
     {
@@ -178,11 +249,11 @@ solve (
 
 static void
 write_array (
-  int max_key
+  long max_key
 )
 {
   int i, j, k, y, ii, ofs;
-  char *key_type;
+  const char *key_type;
 
   if (best_t[lev] == 1)
     return;
@@ -228,13 +299,13 @@ write_array (
   key_type = !lev ? key_type_name :
     max_key <= 0xff ? "PACKTAB_UINT8" :
     max_key <= 0xffff ? "PACKTAB_UINT16" : "PACKTAB_UINT32";
-  fprintf (f, "static const %s %sLevel%d[%d*%d] = {", key_type, table_name,
+  fprintf (f, "static const %s %sLev%d[%ld*%d] = {", key_type, table_name,
           best_lev - lev - 1, cluster, k);
   ofs = 0;
   for (ii = 0; ii < k; ii++)
     {
       int kk, jj;
-      fprintf (f, "\n\n#define %sLevel%d_%0*X 0x%0X\n", table_name,
+      fprintf (f, "\n#define %sLev%d_%0*lX 0x%0X", table_name,
               best_lev - lev - 1, digits, x[i] * pow[n - nn], ofs);
       kk = x[i] * cluster;
       if (!lev)
@@ -254,7 +325,7 @@ write_array (
            }
       else
        for (j = 0; j < cluster; j++, kk++)
-         fprintf (f, "\n  %sLevel%d_%0*X,  /* %0*X..%0*X */", table_name,
+         fprintf (f, "\n  %sLev%d_%0*lX,  /* %0*lX..%0*lX */", table_name,
                   best_lev - lev, digits,
                   tab[lev][kk] * pow[n - nn - best_p[lev]], digits,
                   x[i] * pow[n - nn] + j * pow[n - nn - best_p[lev]], digits,
@@ -288,20 +359,26 @@ write_source (
   write_array (0);
   fprintf (f, "/* *IND" "ENT-ON* */\n\n");
 
-  fprintf (f, "#define %s(x)", macro_name);
+  fprintf (f, "#define %s(x) \\\n", macro_name);
+  fprintf (f, "\t((x) >= 0x%lx ? ", N);
+  if (name)
+    fprintf (f, "%s", name[def_key]);
+  else
+    fprintf (f, "%d", def_key);
+  fprintf (f, " : ");
   j = 1;
   for (i = best_lev - 1; i >= 0; i--)
     {
-      fprintf (f, "\t\\\n\t%sLevel%d[(x)", table_name, i);
+      fprintf (f, " \\\n\t%sLev%d[(x)", table_name, i);
       if (j != 1)
        fprintf (f, "/%d", j);
       if (i)
-       fprintf (f, "%%%d +", pow[best_p[best_lev - 1 - i]]);
+       fprintf (f, "%%%ld +", pow[best_p[best_lev - 1 - i]]);
       j *= best_cluster[best_lev - 1 - i];
     }
   for (i = 0; i < best_lev; i++)
     fprintf (f, "]");
-  fprintf (f, "\n\n");
+  fprintf (f, ")\n\n");
 }
 
 static void
@@ -313,36 +390,38 @@ write_out (
           "  generated by packtab.c version %d\n\n"
           "  use %s(key) to access your table\n\n"
           "  assumed sizeof(%s): %d\n"
-          "  required memory: %d\n"
+          "  required memory: %ld\n"
           "  lookups: %d\n"
           "  partition shape: %s",
           packtab_version, macro_name, key_type_name, a, best_s, best_lev,
           table_name);
   for (i = best_lev - 1; i >= 0; i--)
-    fprintf (f, "[%d]", best_cluster[i]);
+    fprintf (f, "[%ld]", best_cluster[i]);
   fprintf (f, "\n" "  different table entries:");
   for (i = best_lev - 1; i >= 0; i--)
-    fprintf (f, " %d", best_c[i]);
+    fprintf (f, " %ld", best_c[i]);
   fprintf (f, "\n*/\n");
   write_source ();
 }
 
 int
 pack_table (
-  int *base,
-  int key_num,
+  const signed int *base,
+  long key_num,
   int key_size,
+  signed int default_key,
   int p_max_depth,
   int p_tab_width,
-  char **p_name,
-  char *p_key_type_name,
-  char *p_table_name,
-  char *p_macro_name,
+  const char *const *p_name,
+  const char *p_key_type_name,
+  const char *p_table_name,
+  const char *p_macro_name,
   FILE *out
 )
 {
   N = key_num;
   a = key_size;
+  def_key = default_key;
   max_depth = p_max_depth;
   tab_width = p_tab_width;
   name = p_name;
@@ -350,10 +429,10 @@ pack_table (
   table_name = p_table_name;
   macro_name = p_macro_name;
   f = out;
-  init ();
+  init (base);
   if (!(tab = malloc ((n + 1) * sizeof (tab[0]))))
     return 0;
-  memmove (tab[0], base, key_num * sizeof (int));
+  memmove (tab[0], base, N * sizeof (base[0]));
   solve ();
   write_out ();
   free (tab);
index 26b8b32e0c1e985382cc1c7d56d3d717d28794da..45741a71ee8780d97f57d175f92f28870cb88bf4 100644 (file)
@@ -30,15 +30,16 @@ extern "C"
 #define packtab_version 2
 
   int pack_table (
-  int *base,
-  int key_num,
+  const signed int *base,
+  long key_num,
   int key_size,
+  signed int default_key,
   int max_depth,
   int tab_width,
-  char **name,
-  char *key_type_name,
-  char *table_name,
-  char *macro_name,
+  const char *const *name,
+  const char *key_type_name,
+  const char *table_name,
+  const char *macro_name,
   FILE *out
   );
 
index 0c097e41f1d8635bb6dd2eaf8f1f174985cbc519..74756260b210caac4f2a50c730420055a160473a 100644 (file)
@@ -1,10 +1,10 @@
 /* FriBidi
  * fribidi-bidi-type.c - get character bidi type
  *
- * $Id: fribidi-bidi-type.c,v 1.10 2004-06-09 14:59:21 behdad Exp $
+ * $Id: fribidi-bidi-type.c,v 1.11 2004-06-09 20:01:00 behdad Exp $
  * $Author: behdad $
- * $Date: 2004-06-09 14:59:21 $
- * $Revision: 1.10 $
+ * $Date: 2004-06-09 20:01:00 $
+ * $Revision: 1.11 $
  * $Source: /home/behdad/src/fdo/fribidi/togit/git/../fribidi/fribidi2/lib/Attic/fribidi-bidi-type.c,v $
  *
  * Authors:
@@ -58,12 +58,8 @@ static const FriBidiCharType linear_enum_to_char_type[] = {
 FRIBIDI_ENTRY FriBidiCharType
 fribidi_get_bidi_type (
   /* input */
-  FriBidiChar uch
+  FriBidiChar ch
 )
 {
-  if (uch < FRIBIDI_UNICODE_CHARS)
-    return linear_enum_to_char_type[FRIBIDI_GET_BIDI_TYPE (uch)];
-  else
-    return FRIBIDI_TYPE_LTR;
-  /* Non-Unicode chars */
+  return linear_enum_to_char_type[FRIBIDI_GET_BIDI_TYPE (ch)];
 }
index 196787f515301faa01d558011d1c17f9a5117634..b0420ef8d6e80de674357667632d1ee718df1c61 100644 (file)
@@ -1,10 +1,10 @@
 /* FriBidi
  * fribidi-bidi-types.h - character bidi types
  *
- * $Id: fribidi-bidi-types.h,v 1.6 2004-06-09 14:59:21 behdad Exp $
+ * $Id: fribidi-bidi-types.h,v 1.7 2004-06-09 20:01:00 behdad Exp $
  * $Author: behdad $
- * $Date: 2004-06-09 14:59:21 $
- * $Revision: 1.6 $
+ * $Date: 2004-06-09 20:01:00 $
+ * $Revision: 1.7 $
  * $Source: /home/behdad/src/fdo/fribidi/togit/git/../fribidi/fribidi2/lib/fribidi-bidi-types.h,v $
  *
  * Author:
@@ -176,7 +176,7 @@ typedef enum
        FRIBIDI_TYPE_##TYPE = FRIBIDI_TYPE_##TYPE##_VAL,
 # include "fribidi-bidi-types-list.h"
 # undef _FRIBIDI_ADD_TYPE
-  _FRIBIDI_TYPE_SENTINEL = FRIBIDI_TYPE_SENTINEL /* Don't use this */
+  _FRIBIDI_TYPE_SENTINEL = FRIBIDI_TYPE_SENTINEL       /* Don't use this */
 } FriBidiCharType;
 
 typedef enum
@@ -187,7 +187,7 @@ typedef enum
 # include "fribidi-bidi-types-list.h"
 # undef _FRIBIDI_ADD_TYPE
 # undef _FRIBIDI_PAR_TYPES
-  _FRIBIDI_PAR_SENTINEL = FRIBIDI_TYPE_SENTINEL /* Don't use this */
+  _FRIBIDI_PAR_SENTINEL = FRIBIDI_TYPE_SENTINEL        /* Don't use this */
 } FriBidiParType;
 
 #else
index 6c1d99592408ea72291240ea2b92de556d96fdd9..eaf1f440762de16d50bb3f9e3d19471ee14623b1 100644 (file)
  * For licensing issues, contact <license@farsiweb.info> or write to
  * Sharif FarsiWeb, Inc., PO Box 13445-389, Tehran, Iran.
  */
-/* $Id: fribidi-mirroring.c,v 1.9 2004-06-09 14:59:21 behdad Exp $
+/* $Id: fribidi-mirroring.c,v 1.10 2004-06-09 20:01:00 behdad Exp $
  * $Author: behdad $
- * $Date: 2004-06-09 14:59:21 $
- * $Revision: 1.9 $
+ * $Date: 2004-06-09 20:01:00 $
+ * $Revision: 1.10 $
  * $Source: /home/behdad/src/fdo/fribidi/togit/git/../fribidi/fribidi2/lib/fribidi-mirroring.c,v $
  *
  * Authors:
 
 #include <fribidi-mirroring.h>
 
-struct _FriBidiMirroredPair
-{
-  FriBidiChar ch, mirrored_ch;
-};
-
 #include "mirroring.tab.i"
 
 FRIBIDI_ENTRY fribidi_boolean
@@ -53,40 +48,11 @@ fribidi_get_mirror_char (
   FriBidiChar *mirrored_ch
 )
 {
-  register int pos;
-  int step;
-  fribidi_boolean found;
-
-  pos = step = (nFriBidiMirroredChars / 2) + 1;
-
-  while LIKELY
-    (step > 1)
-    {
-      FriBidiChar cmp_ch = FriBidiMirroredChars[pos].ch;
-      step = (step + 1) / 2;
-
-      if (cmp_ch < ch)
-       {
-         pos += step;
-         if UNLIKELY
-           (pos >= nFriBidiMirroredChars) pos = nFriBidiMirroredChars - 1;
-       }
-      else if LIKELY
-       (cmp_ch > ch)
-       {
-         pos -= step;
-         if UNLIKELY
-           (pos < 0) pos = 0;
-       }
-      else
-       break;
-    }
-  found = FriBidiMirroredChars[pos].ch == ch;
-
+  register FriBidiChar result;
+  result = FRIBIDI_GET_MIRRORING_DELTA (ch);
   if (mirrored_ch)
-    *mirrored_ch = found ? FriBidiMirroredChars[pos].mirrored_ch : ch;
-
-  return found;
+    *mirrored_ch = ch + result;
+  return result ? true : false;
 }
 
 /* Editor directions:
index d5c92e17e17ea3f649607e20228229b01755b87f..9ed86be4304425373a18db896daccc4549c05688 100644 (file)
@@ -1,10 +1,10 @@
 /* FriBidi
  * fribidi-types.h - define data types for the rest of the library
  *
- * $Id: fribidi-types.h,v 1.5 2004-06-09 14:59:21 behdad Exp $
+ * $Id: fribidi-types.h,v 1.6 2004-06-09 20:01:00 behdad Exp $
  * $Author: behdad $
- * $Date: 2004-06-09 14:59:21 $
- * $Revision: 1.5 $
+ * $Date: 2004-06-09 20:01:00 $
+ * $Revision: 1.6 $
  * $Source: /home/behdad/src/fdo/fribidi/togit/git/../fribidi/fribidi2/lib/fribidi-types.h,v $
  *
  * Author:
 
 
 #if !FRIBIDI_USE_GLIB
-# if HAVE_INTTYPES_H
+# if defined(HAVE_INTTYPES_H) || defined(HAVE_STDINT_H)
 #  ifndef __FRIBIDI_DOC
-#   include <inttypes.h>
+#   if HAVE_INTTYPES_H
+#    include <inttypes.h>
+#   elif HAVE_STDINT_H
+#    include <stdint.h>
+#   endif /* !HAVE_STDINT_H */
 #  endif /* !__FRIBIDI_DOC */
+#  define FRIBIDI_INT8_LOCAL           int8_t
+#  define FRIBIDI_INT16_LOCAL          int16_t
+#  define FRIBIDI_INT32_LOCAL          int32_t
 #  define FRIBIDI_UINT8_LOCAL          uint8_t
 #  define FRIBIDI_UINT16_LOCAL         uint16_t
 #  define FRIBIDI_UINT32_LOCAL         uint32_t
-# else /* !HAVE_INTTYPES_H */
-#  if HAVE_STDINT_H
-#   ifndef __FRIBIDI_DOC
-#    include <stdint.h>
-#   endif /* !__FRIBIDI_DOC */
-#   define FRIBIDI_UINT8_LOCAL         uint8_t
-#   define FRIBIDI_UINT16_LOCAL                uint16_t
-#   define FRIBIDI_UINT32_LOCAL                uint32_t
-#  else        /* !HAVE_STDINT_H */
-#   define FRIBIDI_UINT8_LOCAL         unsigned char
-#   if !defined(SIZEOF_SHORT) || SIZEOF_SHORT >= 2
-#    define FRIBIDI_UINT16_LOCAL       unsigned short
-#   else /* SIZEOF_SHORT < 2 */
-#    define FRIBIDI_UINT16_LOCAL       unsigned int
-#   endif /* SIZEOF_SHORT < 2 */
-#   if !defined(SIZEOF_INT) || SIZEOF_INT >= 4
-#    define FRIBIDI_UINT32_LOCAL       unsigned int
-#   else /* SIZEOF_INT < 4 */
-#    define FRIBIDI_UINT32_LOCAL       unsigned long
-#   endif /* SIZEOF_INT < 4 */
-#  endif /* !HAVE_STDINT_H */
-# endif        /* !HAVE_INTTYPES_H */
+# else /* no int types */
+#  define FRIBIDI_INT8_LOCAL           signed char
+#  define FRIBIDI_UINT8_LOCAL          unsigned char
+#  if !defined(FRIBIDI_SIZEOF_INT) || FRIBIDI_SIZEOF_INT >= 4
+#   define FRIBIDI_INT16_LOCAL         signed short
+#   define FRIBIDI_UINT16_LOCAL                unsigned short
+#   define FRIBIDI_INT32_LOCAL         signed int
+#   define FRIBIDI_UINT32_LOCAL                unsigned int
+#  else        /* SIZEOF_INT < 4 */
+#   define FRIBIDI_INT16_LOCAL         signed int
+#   define FRIBIDI_UINT16_LOCAL                unsigned int
+#   define FRIBIDI_INT32_LOCAL         signed long
+#   define FRIBIDI_UINT32_LOCAL                unsigned long
+#  endif /* SIZEOF_INT < 4 */
+# endif        /* no int types */
 # if HAVE_STDBOOL_H
 #  ifndef __FRIBIDI_DOC
 #   include <stdbool.h>
 #  define FRIBIDI_UNICHAR_LOCAL                fribidi_uint32
 # endif        /* SIZEOF_WCHAR_T < 4 */
 #else /* FRIBIDI_USE_GLIB */
-#  ifndef __FRIBIDI_DOC
-#   include <glib/gtypes.h>
-#   include <glib/gunicode.h>
-#  endif /* !__FRIBIDI_DOC */
+# ifndef __FRIBIDI_DOC
+#  include <glib/gtypes.h>
+#  include <glib/gunicode.h>
+# endif        /* !__FRIBIDI_DOC */
+# define FRIBIDI_INT8_LOCAL            gint8
+# define FRIBIDI_INT16_LOCAL           gint16
+# define FRIBIDI_INT32_LOCAL           gint32
 # define FRIBIDI_UINT8_LOCAL           guint8
 # define FRIBIDI_UINT16_LOCAL          guint16
 # define FRIBIDI_UINT32_LOCAL          guint32
 # define FRIBIDI_UNICHAR_LOCAL         gunichar
 #endif /* FRIBIDI_USE_GLIB */
 
-#ifndef FRIBIDI_UINT8
+#if !FRIBIDI_INT_TYPES
+# define FRIBIDI_INT8  FRIBIDI_INT8_LOCAL
+# define FRIBIDI_INT16 FRIBIDI_INT16_LOCAL
+# define FRIBIDI_INT32 FRIBIDI_INT32_LOCAL
 # define FRIBIDI_UINT8 FRIBIDI_UINT8_LOCAL
-#endif /* !FRIBIDI_UINT8 */
-#ifndef FRIBIDI_UINT16
 # define FRIBIDI_UINT16        FRIBIDI_UINT16_LOCAL
-#endif /* !FRIBIDI_UINT16 */
-#ifndef FRIBIDI_UINT32
 # define FRIBIDI_UINT32        FRIBIDI_UINT32_LOCAL
-#endif /* !FRIBIDI_UINT32 */
+#endif /* !FRIBIDI_INT_TYPES */
 #ifndef FRIBIDI_BOOLEAN
 # define FRIBIDI_BOOLEAN       FRIBIDI_BOOLEAN_LOCAL
 #endif /* !FRIBIDI_BOOLEAN */
 #endif /* FRIBIDI_STR_INDEX */
 
 
+typedef FRIBIDI_UINT8 fribidi_int8;
+typedef FRIBIDI_INT16 fribidi_int16;
+typedef FRIBIDI_INT32 fribidi_int32;
 typedef FRIBIDI_UINT8 fribidi_uint8;
 typedef FRIBIDI_UINT16 fribidi_uint16;
 typedef FRIBIDI_UINT32 fribidi_uint32;
index 1e68b25fbce350bdf24bc445b0340394cf8fd7bb..160884b688d73d8d81365eb3326f32b132b372b2 100644 (file)
@@ -1,10 +1,10 @@
 /* FriBidi
  * fribidi.h - Unicode bidirectional and Arabic joining/shaping algorithms
  *
- * $Id: fribidi.h,v 1.4 2004-06-09 14:59:21 behdad Exp $
+ * $Id: fribidi.h,v 1.5 2004-06-09 20:01:00 behdad Exp $
  * $Author: behdad $
- * $Date: 2004-06-09 14:59:21 $
- * $Revision: 1.4 $
+ * $Date: 2004-06-09 20:01:00 $
+ * $Revision: 1.5 $
  * $Source: /home/behdad/src/fdo/fribidi/togit/git/../fribidi/fribidi2/lib/fribidi.h,v $
  *
  * Author:
@@ -135,7 +135,7 @@ fribidi_remove_bidi_marks (
 
 #define fribidi_version_info FRIBIDI_NAMESPACE(version_info)
 /* An string containing the version information of the library. */
-extern const char *fribidi_version_info;
+     extern const char *fribidi_version_info;
 
 #include "fribidi-enddecls.h"