[FriBidi-commit] fribidi/gen.tab Makefile.am, 1.3, 1.4 gen-bidi-type-tab.c, 1.4, 1.5 gen-mirroring-tab.c, 1.3, 1.4 gen-unicode-version.c, 1.1, 1.2 packtab.c, 1.2, 1.3 packtab.h, 1.1.1.1, 1.2

Behdad Esfahbod behdad at pdx.freedesktop.org
Sat May 22 03:35:33 PDT 2004


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

Modified Files:
	Makefile.am gen-bidi-type-tab.c gen-mirroring-tab.c 
	gen-unicode-version.c packtab.c packtab.h 
Log Message:
Making gen-bidi-tab work, and more clean up.


Index: Makefile.am
===================================================================
RCS file: /cvs/fribidi/fribidi/gen.tab/Makefile.am,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- a/Makefile.am	12 May 2004 23:13:55 -0000	1.3
+++ b/Makefile.am	22 May 2004 10:35:30 -0000	1.4
@@ -1,4 +1,4 @@
-noinst_PROGRAMS = \
+EXTRA_PROGRAMS = \
 		gen-bidi-type-tab \
 		gen-mirroring-tab \
 		gen-unicode-version
@@ -7,7 +7,55 @@
 gen_mirroring_tab_SOURCES = gen-mirroring-tab.c
 gen_unicode_version_SOURCES = gen-unicode-version.c
 
+CLEANFILES = $(EXTRA_PROGRAMS)
+
 AM_CPPFLAGS = \
 		-I$(top_builddir)/lib \
 		-I$(top_srcdir)/lib \
-		-I$(top_srcdir)/charset
+		-I$(top_srcdir)/charset \
+		$(MISC_CFLAGS)
+
+VPATH += \
+		$(builddir)/unidata \
+		$(builddir)/unidata/extracted \
+		$(srcdir)/unidata \
+		$(srcdir)/unidata/extracted \
+		$(top_builddir)/lib
+
+# bidi-type.tab.i
+
+COMPRESSION = 4
+
+GEN_BIDI_TYPE_TAB = \
+	$(MAKE) $(AM_MAKEFLAGS) gen-bidi-type-tab && \
+	(DATA_FILE_TYPE=`echo $< | sed s,.*/,,`; \
+	./gen-bidi-type-tab $(COMPRESSION) \
+	 $$DATA_FILE_TYPE $< > $@ || ($(RM) $@ && false))
+
+bidi-type_UnicodeData.tab.i: \
+		UnicodeData.txt \
+		fribidi-unicode-version.h \
+		$(gen_bidi_type_tab_sources)
+
+bidi-type_DerivedBidiClass.tab.i: \
+		DerivedBidiClass.txt \
+		fribidi-unicode-version.h \
+		$(gen_bidi_type_tab_sources)
+
+bidi-type_UnicodeData.tab.i bidi-type_DerivedBidiClass.tab.i:
+	$(GEN_BIDI_TYPE_TAB)
+
+bidi-type.tab.i:
+	@ \
+	($(MAKE) $(AM_MAKEFLAGS) bidi-type_DerivedBidiClass.tab.i \
+	&& mv bidi-type_DerivedBidiClass.tab.i $@) \
+	|| \
+	($(MAKE) $(AM_MAKEFLAGS) bidi-type_UnicodeData.tab.i \
+	&& mv bidi-type_UnicodeData.tab.i $@) \
+	|| \
+	(echo Cannot build $@. \
+	&& false)
+
+BUILT_TEMP_FILES = \
+		bidi-type_DerivedBidiClass.tab.i \
+		bidi-type_UnicodeData.tab.i

Index: gen-bidi-type-tab.c
===================================================================
RCS file: /cvs/fribidi/fribidi/gen.tab/gen-bidi-type-tab.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- a/gen-bidi-type-tab.c	12 May 2004 23:13:55 -0000	1.4
+++ b/gen-bidi-type-tab.c	22 May 2004 10:35:30 -0000	1.5
@@ -80,7 +80,20 @@
   exit (1);
 }
 
-enum FriBidiCharTypeLinearEnum
+static void
+die3 (
+  char *fmt,
+  unsigned long l,
+  char *p
+)
+{
+  fprintf (stderr, appname ": ");
+  fprintf (stderr, fmt, l, p);
+  fprintf (stderr, "\n");
+  exit (1);
+}
+
+enum FriBidiCharTypeLinearEnumOffsetOne
 {
 # define _FRIBIDI_ADD_TYPE(TYPE,SYMBOL) TYPE,
 # define _FRIBIDI_ADD_ALIAS(TYPE1,TYPE2) TYPE1 = TYPE2,
@@ -126,32 +139,64 @@
 #define macro_name "FRIBIDI_GET_BIDI_TYPE"
 
 static int table[FRIBIDI_UNICODE_CHARS];
+static char s[4000];
 
 static void
 init_tab (
 )
 {
-  register int i;
   register FriBidiChar c;
 
-  for (i = 0; i < type_names_count; i++)
-    names[i] = 0;
-  for (i = type_names_count - 1; i >= 0; i--)
-    names[type_names[i].key] = type_names[i].name;
-
-  /* initialize table */
+  /* default types for reserved and noncharacter code points */
   for (c = 0; c < FRIBIDI_UNICODE_CHARS; c++)
-    table[i] = LTR;
+    table[c] = LTR;
+
   for (c = 0x0590; c < 0x0600; c++)
-    table[i] = RTL;
+    table[c] = RTL;
+  for (c = 0x07C0; c < 0x0900; c++)
+    table[c] = RTL;
   for (c = 0xFB1D; c < 0xFB50; c++)
-    table[i] = RTL;
+    table[c] = RTL;
+
   for (c = 0x0600; c < 0x07C0; c++)
-    table[i] = AL;
+    table[c] = AL;
   for (c = 0xFB50; c < 0xFE00; c++)
-    table[i] = AL;
+    table[c] = AL;
   for (c = 0xFE70; c < 0xFF00; c++)
-    table[i] = AL;
+    table[c] = AL;
+
+  for (c = 0x2060; c < 0x2070; c++)
+    table[c] = BN;
+  for (c = 0xFDD0; c < 0xFDF0; c++)
+    table[c] = BN;
+  for (c = 0xFFF0; c < 0xFFF9; c++)
+    table[c] = BN;
+  for (c = 0xFFFF; c < FRIBIDI_UNICODE_CHARS; c += 0x10000)
+    table[c - 1] = table[c] = BN;
+
+  if (FRIBIDI_UNICODE_CHARS > 0x10000)
+    {
+      for (c = 0x10800; c < 0x11000; c++)
+	table[c] = RTL;
+      for (c = 0xE0000; c < 0xE0100; c++)
+	table[c] = BN;
+      for (c = 0xE01F0; c < 0xE1000; c++)
+	table[c] = BN;
+    }
+}
+
+static void
+init (
+)
+{
+  register int i;
+
+  for (i = 0; i < type_names_count; i++)
+    names[i] = 0;
+  for (i = type_names_count - 1; i >= 0; i--)
+    names[type_names[i].key] = type_names[i].name;
+
+  init_tab();
 }
 
 static void
@@ -159,13 +204,24 @@
   FILE *f
 )
 {
-  char s[200], tp[10];
-  unsigned int i;
+  char tp[10];
+  unsigned long c, l;
 
+  l = 0;
   while (fgets (s, sizeof s, f))
     {
-      sscanf (s, "%x;%*[^;];%*[^;];%*[^;];%[^;]", &i, tp);
-      table[i] = get_type (tp);
+      int i;
+
+      l++;
+
+      if (s[0] == '#' || s[0] == '\0' || s[0] == '\n')
+	continue;
+
+      i = sscanf (s, "%lx;%*[^;];%*[^;];%*[^;];%[^; ]", &c, tp);
+      if (i != 2 || c >= FRIBIDI_UNICODE_CHARS)
+	die3 ("invalid input at line %ld: %s", l, s);
+
+      table[c] = get_type (tp);
     }
 }
 
@@ -174,17 +230,37 @@
   FILE *f
 )
 {
-  char s[200], tp[10];
-  unsigned int i;
+  char tp[10];
+  unsigned long c, c2, l;
 
+  l = 0;
   while (fgets (s, sizeof s, f))
     {
-      sscanf (s, "%x;%*[^;];%*[^;];%*[^;];%9[^;]", &i, tp);
-      table[i] = get_type (tp);
+      int i;
+      register char typ;
+
+      l++;
+
+      if (s[0] == '#' || s[0] == '\0' || s[0] == '\n')
+	continue;
+
+      i = sscanf (s, "%lx ; %s", &c, tp);
+      if (i == 2)
+	c2 = c;
+      else
+	i = sscanf (s, "%lx..%lx ; %s", &c, &c2, tp) - 1;
+
+      if (i != 2 || c > c2 || c2 >= FRIBIDI_UNICODE_CHARS)
+	die3 ("invalid input at line %ld: %s", l, s);
+
+      typ = get_type (tp);
+      for (; c <= c2; c++)
+	table[c] = typ;
     }
 }
 
-static void read_data (
+static void
+read_data (
   char *data_file_type,
   char *data_file_name
 )
@@ -195,14 +271,14 @@
   if (!(f = fopen (data_file_name, "rt")))
     die2 ("error: cannot open `%s' for reading", data_file_name);
 
-  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);
+  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);
 
-  fclose(f);
+  fclose (f);
 }
 
 static void
@@ -212,9 +288,9 @@
 )
 {
   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 ("/* " 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 ("#define PACKTAB_UINT8 fribidi_uint8\n"
 	  "#define PACKTAB_UINT16 fribidi_uint16\n"
@@ -237,19 +313,18 @@
   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");
+	 "  * UnicodeData.txt\n" "  * DerivedBidiClass.txt");
   {
-  int max_depth = atoi (argv[1]);
-  char *data_file_type = argv[2];
-  char *data_file_name = argv[3];
+    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");
+    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);
+    init ();
+    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.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- a/gen-mirroring-tab.c	12 May 2004 23:13:55 -0000	1.3
+++ b/gen-mirroring-tab.c	22 May 2004 10:35:30 -0000	1.4
@@ -78,12 +78,28 @@
   exit (1);
 }
 
+static void
+die4 (
+  char *fmt,
+  unsigned long l,
+  char *p,
+  char *q
+)
+{
+  fprintf (stderr, appname ": ");
+  fprintf (stderr, fmt, l, p, q);
+  fprintf (stderr, "\n");
+  exit (1);
+}
+
 static FriBidiChar table[FRIBIDI_UNICODE_CHARS];
+static char s[4000];
 
 static int mirroring_count;
 
 static void
-init_tab()
+init_tab (
+)
 {
   register FriBidiChar i;
 
@@ -97,26 +113,32 @@
   FILE *f
 )
 {
-  char s[200];
+  unsigned long l;
 
+  l = 0;
   while (fgets (s, sizeof s, f))
     {
       unsigned long i, j;
+      int k;
+
+      l++;
 
       if (s[0] == '#' || s[0] == '\0' || s[0] == '\n')
 	continue;
-      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;
-      }
+
+      k = sscanf (s, "%lx; %lx", &i, &j);
+      if (k != 2 || i >= FRIBIDI_UNICODE_CHARS || j >= FRIBIDI_UNICODE_CHARS)
+	{
+	  die4 ("invalid pair in input at line %ld: %04lX, %04lX", l, i, j);
+	  continue;
+	}
       table[i] = j;
       mirroring_count++;
     }
 }
 
-static void read_data (
+static void
+read_data (
   char *data_file_type,
   char *data_file_name
 )
@@ -127,12 +149,12 @@
   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);
+  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);
+  fclose (f);
 }
 
 static void
@@ -143,17 +165,21 @@
   FriBidiChar i;
 
   fprintf (stderr, "Generating output, it may take up to a few seconds\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 ("/* " 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");
+  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 ("  {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 ("static const int nFriBidiMirroredChars = %d;\n\n",
+	  mirroring_count);
 
   printf ("/* End of generated " outputname " */\n");
 }
@@ -166,15 +192,14 @@
 {
   if (argc != 3)
     die ("usage:\n  " appname " data-file-type data-file-name\n"
-	 "where data-file-type is:\n"
-	 "  * BidiMirroring.txt");
+	 "where data-file-type is:\n" "  * BidiMirroring.txt");
   {
-  char *data_file_type = argv[1];
-  char *data_file_name = argv[2];
+    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);
+    init_tab ();
+    read_data (data_file_type, data_file_name);
+    gen_mirroring_tab (data_file_type);
   }
 
   return 0;

Index: gen-unicode-version.c
===================================================================
RCS file: /cvs/fribidi/fribidi/gen.tab/gen-unicode-version.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- a/gen-unicode-version.c	12 May 2004 23:13:55 -0000	1.1
+++ b/gen-unicode-version.c	22 May 2004 10:35:30 -0000	1.2
@@ -99,17 +99,19 @@
 
   while (fgets (s, sizeof s, f))
     if ((p = strstr (s, "Version")))
-    {
-      sscanf (p, "Version %d.%d.%d", &version_major, &version_minor, &version_micro);
-      unicode_version = fribidi_malloc (100);
-      sprintf (unicode_version, "%d.%d.%d", version_major, version_minor,
-	  version_micro);
-      return;
-    }
+      {
+	sscanf (p, "Version %d.%d.%d", &version_major, &version_minor,
+		&version_micro);
+	unicode_version = fribidi_malloc (100);
+	sprintf (unicode_version, "%d.%d.%d", version_major, version_minor,
+		 version_micro);
+	return;
+      }
   die ("error: version not found");
 }
 
-static void read_data (
+static void
+read_data (
   char *data_file_type,
   char *data_file_name
 )
@@ -120,12 +122,12 @@
   if (!(f = fopen (data_file_name, "rt")))
     die2 ("error: cannot open `%s' for reading", data_file_name);
 
-  if (!strcmp(data_file_type, "ReadMe.txt"))
-    read_read_me_txt(f);
+  if (!strcmp (data_file_type, "ReadMe.txt"))
+    read_read_me_txt (f);
   else
     die2 ("error: unknown data-file type %s", data_file_type);
 
-  fclose(f);
+  fclose (f);
 }
 
 static void
@@ -134,9 +136,8 @@
 )
 {
   fprintf (stderr, "Generating output\n");
-  printf (
-	  "/* " outputname "\n * generated by " appname " (" FRIBIDI_NAME FRIBIDI_VERSION ")\n"
-	  " * from the file %s */\n\n", data_file_type);
+  printf ("/* " outputname "\n * generated by " appname " (" FRIBIDI_NAME
+	  FRIBIDI_VERSION ")\n" " * from the file %s */\n\n", data_file_type);
 
   printf ("#define FRIBIDI_UNICODE_VERSION \"%s\"\n"
 	  "#define FRIBIDI_UNICODE_MAJOR_VERSION %d\n"
@@ -155,15 +156,14 @@
 {
   if (argc != 3)
     die ("usage:\n  " appname " data-file-type data-file-name\n"
-	 "where data-file-type is one of these:\n"
-	 "  * ReadMe.txt");
+	 "where data-file-type is one of these:\n" "  * ReadMe.txt");
   {
-  char *data_file_type = argv[1];
-  char *data_file_name = argv[2];
+    char *data_file_type = argv[1];
+    char *data_file_name = argv[2];
 
-  init_tab ();
-  read_data (data_file_type, data_file_name);
-  gen_unicode_version (data_file_type);
+    init_tab ();
+    read_data (data_file_type, data_file_name);
+    gen_unicode_version (data_file_type);
   }
 
   return 0;

Index: packtab.c
===================================================================
RCS file: /cvs/fribidi/fribidi/gen.tab/packtab.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- a/packtab.c	12 May 2004 07:06:21 -0000	1.2
+++ b/packtab.c	22 May 2004 10:35:30 -0000	1.3
@@ -38,7 +38,8 @@
 static FILE *f;
 
 static inline void
-init ()
+init (
+)
 {
   int i;
   pow[0] = 1;
@@ -337,7 +338,7 @@
   char *p_key_type_name,
   char *p_table_name,
   char *p_macro_name,
-  FILE * out
+  FILE *out
 )
 {
   N = key_num;

Index: packtab.h
===================================================================
RCS file: /cvs/fribidi/fribidi/gen.tab/packtab.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- a/packtab.h	25 Apr 2004 18:47:57 -0000	1.1.1.1
+++ b/packtab.h	22 May 2004 10:35:30 -0000	1.2
@@ -39,7 +39,7 @@
   char *key_type_name,
   char *table_name,
   char *macro_name,
-  FILE * out
+  FILE *out
   );
 
 #ifdef	__cplusplus




More information about the FriBidi-Commit mailing list