[FriBidi-commit] fribidi/gen.tab Makefile.am, 1.1.1.1, 1.2 gen-bidi-type-tab.c, 1.1.1.1, 1.2 gen-mirroring-tab.c, 1.1.1.1, 1.2 packtab.c, 1.1.1.1, 1.2

Behdad Esfahbod behdad at pdx.freedesktop.org
Wed May 12 00:06:24 PDT 2004


Update of /cvs/fribidi/fribidi/gen.tab
In directory pdx:/tmp/cvs-serv7241/gen.tab

Modified Files:
	Makefile.am gen-bidi-type-tab.c gen-mirroring-tab.c packtab.c 
Log Message:
Updated the gen.tab to work again.  Other fixes here and there.


Index: Makefile.am
===================================================================
RCS file: /cvs/fribidi/fribidi/gen.tab/Makefile.am,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- a/Makefile.am	25 Apr 2004 18:47:57 -0000	1.1.1.1
+++ b/Makefile.am	12 May 2004 07:06:21 -0000	1.2
@@ -0,0 +1,9 @@
+noinst_PROGRAMS = gen-bidi-type-tab gen-mirroring-tab
+
+gen_bidi_type_tab_SOURCES = gen-bidi-type-tab.c packtab.c packtab.h
+gen_mirroring_tab_SOURCES = gen-mirroring-tab.c
+
+AM_CPPFLAGS = \
+		-I$(top_builddir)/lib \
+		-I$(top_srcdir)/lib \
+		-I$(top_srcdir)/charset

Index: gen-bidi-type-tab.c
===================================================================
RCS file: /cvs/fribidi/fribidi/gen.tab/gen-bidi-type-tab.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- a/gen-bidi-type-tab.c	25 Apr 2004 18:47:57 -0000	1.1.1.1
+++ b/gen-bidi-type-tab.c	12 May 2004 07:06:21 -0000	1.2
@@ -1,59 +1,95 @@
-/* FriBidi - Library of BiDi algorithm
- * Copyright (C) 2001,2002 Behdad Esfahbod. 
+/* FriBidi
+ * gen-bidi-type-tab.c - generate bidi-type.tab.i for libfribidi
+ *
+ * $Id$
+ * $Author$
+ * $Date$
+ * $Revision$
+ * $Source$
+ *
+ * Author:
+ *   Behdad Esfahbod, 2001, 2002, 2004
+ *
+ * Copyright (C) 2004 Sharif FarsiWeb, Inc
+ * Copyright (C) 2001,2002,2004 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 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. 
+ * 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  
+ * 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 <fwpg at sharif.edu>. 
+ * For licensing issues, contact <license at farsiweb.info>.
  */
 
-#include <stdlib.h>
+#include <common.h>
+
+#include <fribidi-unicode.h>
+
 #include <stdio.h>
-#include <string.h>
-#include "packtab.h"
-#ifdef HAVE_CONFIG_H
-#include "config.h"
+#if STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#else
+# if HAVE_STDLIB_H
+#  include <stdlib.h>
+# endif
 #endif
-#include "fribidi_unicode.h"
-
-#ifndef SIZEOF_CHAR
-#define SIZEOF_CHAR sizeof (char)
+#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"
+
+#define appname "gen-bidi-type-tab"
+#define outputname "bidi-type.tab.i"
 
 static void
-err (
+die (
   char *msg
 )
 {
-  fprintf (stderr, "fribidi_create_char_types: %s\n", msg);
+  fprintf (stderr, appname ": %s\n", msg);
   exit (1);
 }
 
 static void
-err2 (
+die2 (
   char *fmt,
   char *p
 )
 {
-  fprintf (stderr, "fribidi_create_char_types: ");
+  fprintf (stderr, appname ": ");
   fprintf (stderr, fmt, p);
   fprintf (stderr, "\n");
   exit (1);
 }
 
-/* *INDENT-OFF* */
+enum FriBidiCharTypeLinearEnum
+{
+# define _FRIBIDI_ADD_TYPE(TYPE,SYMBOL) TYPE,
+# define _FRIBIDI_ADD_ALIAS(TYPE1,TYPE2) TYPE1 = TYPE2,
+# include <bidi-types-list.h>
+# undef _FRIBIDI_ADD_ALIAS
+# undef _FRIBIDI_ADD_TYPE
+  NUM_TYPES
+};
+
 struct
 {
   char *name;
@@ -61,34 +97,17 @@
 }
 type_names[] =
 {
-  {"LTR", 0}, {"L", 0},
-  {"RTL", 1}, {"R", 1},
-  {"AL", 2},
-  {"ON", 3},
-  {"BN", 4},
-  {"AN", 5},
-  {"BS", 6}, {"B", 6},
-  {"CS", 7},
-  {"EN", 8},
-  {"ES", 9},
-  {"ET", 10},
-  {"LRE", 11},
-  {"LRO", 12},
-  {"NSM", 13},
-  {"PDF", 14},
-  {"RLE", 15},
-  {"RLO", 16},
-  {"SS", 17}, {"S", 17},
-  {"WS", 18},
+# define _FRIBIDI_ADD_TYPE(TYPE,SYMBOL) {STRINGIZE(TYPE), TYPE},
+# define _FRIBIDI_ADD_ALIAS(TYPE1,TYPE2) _FRIBIDI_ADD_TYPE(TYPE1, SYMBOL)
+# include <bidi-types-list.h>
+# undef _FRIBIDI_ADD_ALIAS
+# undef _FRIBIDI_ADD_TYPE
 };
-/* *INDENT-ON* */
 
 #define type_names_count (sizeof (type_names) / sizeof (type_names[0]))
 
 static char *names[type_names_count];
 
-static char *unidata_file;
-
 static char
 get_type (
   char *s
@@ -99,28 +118,23 @@
   for (i = 0; i < type_names_count; i++)
     if (!strcmp (s, type_names[i].name))
       return type_names[i].key;
-  err2 ("type name `%s' not found", s);
+  die2 ("type name `%s' not found", s);
   return 0;
 }
 
-#define table_name "FriBidiPropertyBlock"
-#define key_type_name "FriBidiPropCharType"
-#define macro_name "FRIBIDI_GET_TYPE"
-#define function_name "fribidi_get_type_internal"
-#define char_type_name "FriBidiCharType"
-#define char_name "FriBidiChar"
-#define prop_to_type_name "fribidi_prop_to_type"
+#define table_name "FriBidiCharTypeData"
+#define macro_name "FRIBIDI_GET_BIDI_TYPE"
 #define default_type "LTR"
-#define export_api "FRIBIDI_API"
 
 static int table[FRIBIDI_UNICODE_CHARS];
 
 static void
-init_table (
+init_tab (
 )
 {
-  int i;
-  int deftype = get_type (default_type),
+  register int i;
+  register FriBidiChar c;
+  char deftype = get_type (default_type),
     RTL = get_type ("RTL"), AL = get_type ("AL");
 
   for (i = 0; i < type_names_count; i++)
@@ -129,115 +143,92 @@
     names[type_names[i].key] = type_names[i].name;
 
   /* initialize table */
-  for (i = 0; i < FRIBIDI_UNICODE_CHARS; i++)
+  for (c = 0; c < FRIBIDI_UNICODE_CHARS; c++)
     table[i] = deftype;
-  for (i = 0x590; i < 0x600; i++)
+  for (c = 0x0590; c < 0x0600; c++)
     table[i] = RTL;
-  for (i = 0xFB1D; i < 0xFB50; i++)
+  for (c = 0xFB1D; c < 0xFB50; c++)
     table[i] = RTL;
-  for (i = 0x600; i < 0x7C0; i++)
+  for (c = 0x0600; c < 0x07C0; c++)
     table[i] = AL;
-  for (i = 0xFB50; i < 0xFE00; i++)
+  for (c = 0xFB50; c < 0xFE00; c++)
     table[i] = AL;
-  for (i = 0xFE70; i < 0xFF00; i++)
+  for (c = 0xFE70; c < 0xFF00; c++)
     table[i] = AL;
 }
 
 static void
-read_unicode_data (
+read_unicode_data_txt (
+  FILE *f
 )
 {
-  char s[500], tp[10];
+  char s[200], tp[10];
   unsigned int i;
-  FILE *f;
 
-  printf ("Reading `UnicodeData.txt'\n");
-  if (!(f = fopen (unidata_file, "rt")))
-    err2 ("error: cannot open `%s' for reading", unidata_file);
   while (fgets (s, sizeof s, f))
     {
       sscanf (s, "%x;%*[^;];%*[^;];%*[^;];%[^;]", &i, tp);
       table[i] = get_type (tp);
     }
-  fclose (f);
 }
 
-static char *
-headermacro (
-  char *file
+static void
+read_derived_bidi_class_txt (
+  FILE *f
 )
 {
-  char *t = strdup (file);
-  char *p = t;
-  while (*p)
+  char s[200], tp[10];
+  unsigned int i;
+
+  while (fgets (s, sizeof s, f))
     {
-      if (*p >= 'a' && *p <= 'z')
-	*p += 'A' - 'a';
-      else if ((*p < 'A' || *p > 'Z') && (*p < '0' || *p > '9'))
-	*p = '_';
-      p++;
+      sscanf (s, "%x;%*[^;];%*[^;];%*[^;];%[^;]", &i, tp);
+      table[i] = get_type (tp);
     }
-  return t;
 }
 
-static void
-write_char_type (
-  char *file,
-  int max_depth
+static void read_data (
+  char *data_file_type,
+  char *data_file_name
 )
 {
-  int i;
   FILE *f;
-  char *FILENAME = headermacro (file);
 
-  printf ("Writing `%s', it may take a few minutes\n", file);
-  if (!(f = fopen (file, "wt")))
-    err2 ("error: cannot open `%s' for writing", file);
-  fprintf (f, "/*\n"
-	   "  This file was automatically created from UnicodeData.txt version %s\n"
-	   "  by fribidi_create_char_types\n*/\n\n", FRIBIDI_UNICODE_VERSION);
-
-  fprintf (f, "#ifndef %s\n#define %s\n\n#include \"fribidi.h\"\n\n",
-	   FILENAME, FILENAME);
+  fprintf (stderr, "Reading `%s'\n", data_file_name);
+  if (!(f = fopen (data_file_name, "rt")))
+    die2 ("error: cannot open `%s' for reading", data_file_name);
 
-  for (i = 0; i < type_names_count; i++)
-    if (names[i])
-      fprintf (f, "#define %s FRIBIDI_PROP_TYPE_%s\n", names[i], names[i]);
-  fprintf (f, "\n");
+  if (!strcmp(data_file_type, "UnicodeData.txt"))
+    read_unicode_data_txt(f);
+  else if (!strcmp(data_file_type, "DerivedBidiClass.txt"))
+    read_derived_bidi_class_txt(f);
+  else
+    die2 ("error: unknown data-file type %s", data_file_type);
 
-  fprintf (f, "#define PACKTAB_UINT8 fribidi_uint8\n");
-  fprintf (f, "#define PACKTAB_UINT16 fribidi_uint16\n");
-  fprintf (f, "#define PACKTAB_UINT32 fribidi_uint32\n");
+  fclose(f);
+}
 
-  if (!pack_table
-      (table, FRIBIDI_UNICODE_CHARS, SIZEOF_CHAR, max_depth, 3, names,
-       key_type_name, table_name, macro_name, f))
-    err ("error: insufficient memory, decrease max_depth");
+static void
+gen_bidi_type_tab (
+  int max_depth,
+  char *data_file_type
+)
+{
+  fprintf (stderr, "Generating output, it may take up to a few minutes\n");
+  printf (
+	  "/* " outputname " generated by " appname " (" FRIBIDI_NAME FRIBIDI_VERSION ")\n"
+	  " * from the file %s of Unicode version " FRIBIDI_UNICODE_VERSION ". */\n\n", data_file_type);
 
-  for (i = type_names_count - 1; i >= 0; i--)
-    if (names[i])
-      fprintf (f, "#undef %s\n", names[i]);
+  printf ("#define PACKTAB_UINT8 fribidi_uint8\n"
+	  "#define PACKTAB_UINT16 fribidi_uint16\n"
+	  "#define PACKTAB_UINT32 fribidi_uint32\n\n");
 
-  fprintf (f,
-	   "/*======================================================================\n"
-	   " *  %s() returns the bidi type of a character.\n"
-	   " *----------------------------------------------------------------------*/\n"
-	   "%s %s\n"
-	   "%s (%s uch)\n"
-	   "{\n"
-	   "  if (uch < 0x%x)\n"
-	   "    return %s[(unsigned char)%s (uch)];\n"
-	   "  else\n"
-	   "    return FRIBIDI_TYPE_%s;\n"
-	   "  /* Non-Unicode chars */\n"
-	   "}\n"
-	   "\n",
-	   function_name, export_api, char_type_name, function_name,
-	   char_name, FRIBIDI_UNICODE_CHARS, prop_to_type_name, macro_name,
-	   default_type);
-  fprintf (f, "\n#endif /* %s */\n", FILENAME);
+  if (!pack_table
+      (table, FRIBIDI_UNICODE_CHARS, 1, max_depth, 3, names,
+       "char", table_name, macro_name, stdout))
+    die ("error: insufficient memory, decrease max_depth");
 
-  fclose (f);
+  printf ("/* End of generated " outputname " */\n");
 }
 
 int
@@ -246,22 +237,23 @@
   char **argv
 )
 {
-  int max_depth;
-  char file[50], *p;
-  if (argc < 2)
-    err ("usage: fribidi_create_char_types max_depth [UnicodeData.txt path]");
-  p = (argc >= 3) ? argv[2] : "unidata";
-  unidata_file = malloc (50 + strlen (p));
-  sprintf (unidata_file, "%s/UnicodeData.txt", p);
-  max_depth = atoi (argv[1]);
-  if (!max_depth)
-    err ("invalid depth");
-  if (max_depth < 2 || max_depth > 9)
-    err2 ("invalid max_depth `%s', max_depth should be between 2 and 9",
-	  argv[1]);
-  sprintf (file, "fribidi_tab_char_type_%d.i", max_depth);
-  init_table ();
-  read_unicode_data ();
-  write_char_type (file, max_depth);
+  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"
+	 "  * UnicodeData.txt\n"
+	 "  * DerivedBidiClass.txt");
+  {
+  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_tab ();
+  read_data (data_file_type, data_file_name);
+  gen_bidi_type_tab (max_depth, data_file_type);
+  }
+
   return 0;
 }

Index: gen-mirroring-tab.c
===================================================================
RCS file: /cvs/fribidi/fribidi/gen.tab/gen-mirroring-tab.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- a/gen-mirroring-tab.c	25 Apr 2004 18:47:57 -0000	1.1.1.1
+++ b/gen-mirroring-tab.c	12 May 2004 07:06:21 -0000	1.2
@@ -1,138 +1,161 @@
-/* FriBidi - Library of BiDi algorithm
- * Copyright (C) 2001,2002 Behdad Esfahbod. 
+/* FriBidi
+ * gen-mirroring-tab.c - generate mirroring.tab.i for libfribidi
+ *
+ * $Id$
+ * $Author$
+ * $Date$
+ * $Revision$
+ * $Source$
+ *
+ * Author:
+ *   Behdad Esfahbod, 2001, 2002, 2004
+ *
+ * Copyright (C) 2004 Sharif FarsiWeb, Inc
+ * Copyright (C) 2001,2002,2004 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 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. 
+ * 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  
+ * 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 <fwpg at sharif.edu>. 
+ * For licensing issues, contact <license at farsiweb.info>.
  */
 
-#include <stdlib.h>
+#include <common.h>
+
+#include <fribidi-unicode.h>
+
 #include <stdio.h>
-#include <string.h>
-#ifdef HAVE_CONFIG_H
-#include <config.h>
+#if STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#else
+# if HAVE_STDLIB_H
+#  include <stdlib.h>
+# endif
 #endif
-#include "fribidi_unicode.h"
+#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
+
+#define appname "gen-mirroring-tab"
+#define outputname "mirroring.tab.i"
 
 static void
-err2 (
+die (
+  char *msg
+)
+{
+  fprintf (stderr, appname ": %s\n", msg);
+  exit (1);
+}
+
+static void
+die2 (
   char *fmt,
   char *p
 )
 {
-  fprintf (stderr, "fribidi_create_mirroring: error: ");
+  fprintf (stderr, appname ": ");
   fprintf (stderr, fmt, p);
   fprintf (stderr, "\n");
   exit (1);
 }
 
-static int table[0x110000];
-static char *bidi_mirroring_file;
+static FriBidiChar table[FRIBIDI_UNICODE_CHARS];
 
 static int mirroring_count;
 
 static void
-read_bidi_mirroring (
-)
+init_tab()
 {
-  char s[500];
-  unsigned int i, j;
-  FILE *f;
+  register FriBidiChar i;
 
-  for (i = 0; i < 0x110000; i++)
+  for (i = 0; i < FRIBIDI_UNICODE_CHARS; i++)
     table[i] = 0;
   mirroring_count = 0;
-  printf ("Reading `BidiMirroring.txt'\n");
-  if (!(f = fopen (bidi_mirroring_file, "rt")))
-    err2 ("cannot open `%s' for reading", bidi_mirroring_file);
-/*  fgets (s, sizeof s, f);
-  sscanf (s, "# BidiMirroring-%s.txt", bidi_mirroring_version = malloc (20));*/
+}
+
+static void
+read_bidi_mirroring_txt (
+  FILE *f
+)
+{
+  char s[200];
+
   while (fgets (s, sizeof s, f))
     {
+      unsigned long i, j;
+
       if (s[0] == '#' || s[0] == '\0' || s[0] == '\n')
 	continue;
-      sscanf (s, "%x; %x", &i, &j);
+      sscanf (s, "%lx; %lx", &i, &j);
+      if (i >= FRIBIDI_UNICODE_CHARS || j >= FRIBIDI_UNICODE_CHARS)
+      {
+	fprintf(stderr, "ignoring invalid pair %04lX, %04lX\n", i, j);
+	continue;
+      }
       table[i] = j;
-      table[j] = i;
       mirroring_count++;
     }
-  fclose (f);
 }
 
-static char *
-headermacro (
-  char *file
+static void read_data (
+  char *data_file_type,
+  char *data_file_name
 )
 {
-  char *t = strdup (file);
-  char *p = t;
-  while (*p)
-    {
-      if (*p >= 'a' && *p <= 'z')
-	*p += 'A' - 'a';
-      else if ((*p < 'A' || *p > 'Z') && (*p < '0' || *p > '9'))
-	*p = '_';
-      p++;
-    }
-  return t;
+  FILE *f;
+
+  fprintf (stderr, "Reading `%s'\n", data_file_name);
+  if (!(f = fopen (data_file_name, "rt")))
+    die2 ("error: cannot open `%s' for reading", data_file_name);
+
+  if (!strcmp(data_file_type, "BidiMirroring.txt"))
+    read_bidi_mirroring_txt(f);
+  else
+    die2 ("error: unknown data-file-type %s", data_file_type);
+
+  fclose(f);
 }
 
 static void
-write_mirror (
-  char *file
+gen_mirroring_tab (
+  char *data_file_type
 )
 {
-  int i;
-  FILE *f;
-  char *FILENAME = headermacro (file);
+  FriBidiChar i;
 
-  printf ("Writing `%s'\n", file);
-  if (!(f = fopen (file, "wt")))
-    err2 ("cannot open `%s' for writing", file);
-  fprintf (f, "/*\n"
-	   "  This file was automatically created from BidiMirroring.txt, version %s\n"
-	   "  by fribidi_create_mirroring\n*/\n\n", FRIBIDI_UNICODE_VERSION);
-  fprintf (f, "#ifndef %s\n#define %s\n\n#include \"fribidi.h\"\n\n",
-	   FILENAME, FILENAME);
-  fprintf (f, "/*\n"
-	   "  Mirrored characters include all the characters in the Unicode list\n"
-	   "  that have been declared as being mirrored and that have a mirrored\n"
-	   "  equivalent.\n"
-	   "\n"
-	   "  There are lots of characters that are designed as being mirrored\n"
-	   "  but do not have any mirrored glyph, e.g. the sign for there exist.\n");
-  fprintf (f,
-	   "  Are these used in Arabic? That is are all the mathematical signs\n"
-	   "  that are assigned to be mirrorable actually mirrored in Arabic?\n"
-	   "  If that is the case, we'll change the below code to include also\n"
-	   "  characters that mirror to themself. It will then be the responsibility\n"
-	   "  of the display engine to actually mirror these.\n" "*/\n\n");
-  fprintf (f, "/* *INDENT-OFF" "* */\n\n");
-  fprintf (f, "static const struct\n"
-	   "{\n"
-	   "  FriBidiChar ch, mirrored_ch;\n"
-	   "}\n" "FriBidiMirroredChars[] =\n" "{\n");
-  for (i = 0; i < 0x110000; i++)
+  fprintf (stderr, "Generating output, it may take up to a few seconds\n");
+  printf ("/* " outputname " 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])
-      fprintf (f, "  {0x%04X, 0x%04X},\n", i, table[i]);
-  fprintf (f, "} ;\n\n");
-  fprintf (f, "/* *INDE" "NT-ON* */\n\n");
-  fprintf (f, "const int nFriBidiMirroredChars = %d;\n\n", mirroring_count);
-  fprintf (f, "\n#endif /* %s */\n", FILENAME);
-  fclose (f);
+      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 ("/* End of generated " outputname " */\n");
 }
 
 int
@@ -141,12 +164,18 @@
   char **argv
 )
 {
-  char *p;
+  if (argc != 3)
+    die ("usage:\n  " appname " data-file-type data-file-name\n"
+	 "where data-file-type is:\n"
+	 "  * BidiMirroring.txt");
+  {
+  char *data_file_type = argv[1];
+  char *data_file_name = argv[2];
+
+  init_tab ();
+  read_data (data_file_type, data_file_name);
+  gen_mirroring_tab (data_file_type);
+  }
 
-  p = (argc >= 2) ? argv[1] : "unidata";
-  bidi_mirroring_file = malloc (50 + strlen (p));
-  sprintf (bidi_mirroring_file, "%s/BidiMirroring.txt", p);
-  read_bidi_mirroring ();
-  write_mirror ("fribidi_tab_mirroring.i");
   return 0;
 }

Index: packtab.c
===================================================================
RCS file: /cvs/fribidi/fribidi/gen.tab/packtab.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- a/packtab.c	25 Apr 2004 18:47:57 -0000	1.1.1.1
+++ b/packtab.c	12 May 2004 07:06:21 -0000	1.2
@@ -37,10 +37,8 @@
 static char **name, *key_type_name, *table_name, *macro_name;
 static FILE *f;
 
-static void
-init (
-  int *base
-)
+static inline void
+init ()
 {
   int i;
   pow[0] = 1;
@@ -285,9 +283,9 @@
   s = 0;
   nn = n;
   t[0] = N;
-  fprintf (f, "\n" "/* *INDENT-OFF* */\n\n");
+  fprintf (f, "\n" "/* *IND" "ENT-OFF* */\n\n");
   write_array (0);
-  fprintf (f, "/* *INDENT-ON* */\n\n");
+  fprintf (f, "/* *IND" "ENT-ON* */\n\n");
 
   fprintf (f, "#define %s(x)", macro_name);
   j = 1;
@@ -311,9 +309,9 @@
 {
   int i;
   fprintf (f, "/*\n"
-	   "  Automatically generated by packtab.c version %d\n\n"
-	   "  just use %s(key)\n\n"
-	   "  assumed sizeof(%s) == %d\n"
+	   "  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"
 	   "  lookups: %d\n"
 	   "  partition shape: %s",
@@ -351,7 +349,7 @@
   table_name = p_table_name;
   macro_name = p_macro_name;
   f = out;
-  init (base);
+  init ();
   if (!(tab = malloc ((n + 1) * sizeof (tab[0]))))
     return 0;
   memmove (tab[0], base, key_num * sizeof (int));




More information about the FriBidi-Commit mailing list