From: behdad Date: Wed, 12 May 2004 07:06:21 +0000 (+0000) Subject: Updated the gen.tab to work again. Other fixes here and there. X-Git-Tag: FRIBIDI_0_19_1~99 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d7b141a2521ad40a1c75c0aeb43920225bd08317;p=fribidi Updated the gen.tab to work again. Other fixes here and there. --- diff --git a/.indent.pro b/.indent.pro index 53cc4ff..27e1cd5 100644 --- a/.indent.pro +++ b/.indent.pro @@ -1,6 +1,7 @@ -gnu -bfda -bfde +-T FILE -T LevelInfo -T FriBidiChar -T FriBidiStrIndex diff --git a/TODO b/TODO index 66b3345..7fbf9b3 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,7 @@ Implementation issues: +* Better bootstrap script: steal from GNOME autogen.sh. + * Test ./configure without pkg-config installed. * Update all files headers/footers. For c/h files, lib/fribidi-mirroring.[ch] diff --git a/bin/fribidi-main.c b/bin/fribidi-main.c index c89aa33..be98f1d 100644 --- a/bin/fribidi-main.c +++ b/bin/fribidi-main.c @@ -1,10 +1,10 @@ /* FriBidi * fribidi-main.c - command line program for libfribidi * - * $Id: fribidi-main.c,v 1.4 2004-05-07 06:30:37 behdad Exp $ + * $Id: fribidi-main.c,v 1.5 2004-05-12 07:06:21 behdad Exp $ * $Author: behdad $ - * $Date: 2004-05-07 06:30:37 $ - * $Revision: 1.4 $ + * $Date: 2004-05-12 07:06:21 $ + * $Revision: 1.5 $ * $Source: /home/behdad/src/fdo/fribidi/togit/git/../fribidi/fribidi2/bin/fribidi-main.c,v $ * * Authors: @@ -62,9 +62,6 @@ #if HAVE_STRINGS_H # include #endif -#if HAVE_SYS_TIMES_H -# include -#endif #include "getopt.h" @@ -73,7 +70,7 @@ #define MAX_STR_LEN 65000 -#define ALLOCATE(tp,ln) ((tp *) malloc (sizeof (tp) * (ln))) +#define ALLOCATE(tp,ln) ((tp *) fribidi_malloc (sizeof (tp) * (ln))) static void die2 ( diff --git a/bootstrap b/bootstrap index 698da99..3b7e777 100755 --- a/bootstrap +++ b/bootstrap @@ -1,9 +1,9 @@ #! /bin/sh ############################################################################## -# $Id: bootstrap,v 1.1 2004-04-25 18:47:56 behdad Exp $ +# $Id: bootstrap,v 1.2 2004-05-12 07:06:21 behdad Exp $ # $Author: behdad -# $Date: 2004-04-25 18:47:56 $ -# $Revision: 1.1 $ +# $Date: 2004-05-12 07:06:21 $ +# $Revision: 1.2 $ # $Source: /home/behdad/src/fdo/fribidi/togit/git/../fribidi/fribidi2/bootstrap,v $ ############################################################################## # -*- Bootstrap -*- @@ -102,7 +102,8 @@ fi if test -n "$MAKE"; then if test -f ./configure; then - $DRYRUN ./configure $HELP $VERSION || exit 1 + $DRYRUN ./configure $HELP $VERSION \ + --enable-maintainer-mode --enable-compile-warnings || exit 1 fi if test -f Makefile; then $DRYRUN make || exit 1 diff --git a/charset/fribidi-char-sets.c b/charset/fribidi-char-sets.c index c1ebc39..edaada3 100644 --- a/charset/fribidi-char-sets.c +++ b/charset/fribidi-char-sets.c @@ -1,10 +1,10 @@ /* FriBidi * fribidi-char-sets.c - character set conversion routines * - * $Id: fribidi-char-sets.c,v 1.2 2004-05-03 22:05:19 behdad Exp $ + * $Id: fribidi-char-sets.c,v 1.3 2004-05-12 07:06:21 behdad Exp $ * $Author: behdad $ - * $Date: 2004-05-03 22:05:19 $ - * $Revision: 1.2 $ + * $Date: 2004-05-12 07:06:21 $ + * $Revision: 1.3 $ * $Source: /home/behdad/src/fdo/fribidi/togit/git/../fribidi/fribidi2/charset/fribidi-char-sets.c,v $ * * Authors: @@ -107,7 +107,7 @@ static FriBidiCharSetHandler char_sets[FRIBIDI_CHAR_SETS_NUM + 1] = { }; #if !FRIBIDI_USE_GLIB -static char +static inline char toupper ( /* input */ char c @@ -116,7 +116,7 @@ toupper ( return c < 'a' || c > 'z' ? c : c + 'A' - 'a'; } -static int +static inline int fribidi_strcasecmp ( /* input */ const char *s1, @@ -128,7 +128,7 @@ fribidi_strcasecmp ( s1++; s2++; } - return *s1 - *s2; + return toupper(*s1) - toupper(*s2); } #else /* FRIBIDI_USE_GLIB */ # include diff --git a/gen.tab/Makefile.am b/gen.tab/Makefile.am index e69de29..7123fe4 100644 --- a/gen.tab/Makefile.am +++ b/gen.tab/Makefile.am @@ -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 diff --git a/gen.tab/gen-bidi-type-tab.c b/gen.tab/gen-bidi-type-tab.c index dbfa590..7d341dd 100644 --- a/gen.tab/gen-bidi-type-tab.c +++ b/gen.tab/gen-bidi-type-tab.c @@ -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: gen-bidi-type-tab.c,v 1.2 2004-05-12 07:06:21 behdad Exp $ + * $Author: behdad $ + * $Date: 2004-05-12 07:06:21 $ + * $Revision: 1.2 $ + * $Source: /home/behdad/src/fdo/fribidi/togit/git/../fribidi/fribidi2/gen.tab/gen-bidi-type-tab.c,v $ + * + * 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 . + * For licensing issues, contact . */ -#include +#include + +#include + #include -#include -#include "packtab.h" -#ifdef HAVE_CONFIG_H -#include "config.h" +#if STDC_HEADERS +# include +# include +#else +# if HAVE_STDLIB_H +# include +# 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 +# endif +# include #endif +#if HAVE_STRINGS_H +# include +#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 +# undef _FRIBIDI_ADD_ALIAS +# undef _FRIBIDI_ADD_TYPE + NUM_TYPES +}; + struct { char *name; @@ -61,34 +97,17 @@ struct } 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 +# 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 @@ get_type ( 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 @@ init_table ( 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 (stderr, "Reading `%s'\n", data_file_name); + if (!(f = fopen (data_file_name, "rt"))) + die2 ("error: cannot open `%s' for reading", data_file_name); - fprintf (f, "#ifndef %s\n#define %s\n\n#include \"fribidi.h\"\n\n", - FILENAME, FILENAME); + 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); - 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"); + fclose(f); +} - fprintf (f, "#define PACKTAB_UINT8 fribidi_uint8\n"); - fprintf (f, "#define PACKTAB_UINT16 fribidi_uint16\n"); - fprintf (f, "#define PACKTAB_UINT32 fribidi_uint32\n"); +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); + + printf ("#define PACKTAB_UINT8 fribidi_uint8\n" + "#define PACKTAB_UINT16 fribidi_uint16\n" + "#define PACKTAB_UINT32 fribidi_uint32\n\n"); 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"); + (table, FRIBIDI_UNICODE_CHARS, 1, max_depth, 3, names, + "char", table_name, macro_name, stdout)) + die ("error: insufficient memory, decrease max_depth"); - for (i = type_names_count - 1; i >= 0; i--) - if (names[i]) - fprintf (f, "#undef %s\n", names[i]); - - 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); - - fclose (f); + printf ("/* End of generated " outputname " */\n"); } int @@ -246,22 +237,23 @@ main ( 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; } diff --git a/gen.tab/gen-mirroring-tab.c b/gen.tab/gen-mirroring-tab.c index 611b1b4..912b94f 100644 --- a/gen.tab/gen-mirroring-tab.c +++ b/gen.tab/gen-mirroring-tab.c @@ -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: gen-mirroring-tab.c,v 1.2 2004-05-12 07:06:21 behdad Exp $ + * $Author: behdad $ + * $Date: 2004-05-12 07:06:21 $ + * $Revision: 1.2 $ + * $Source: /home/behdad/src/fdo/fribidi/togit/git/../fribidi/fribidi2/gen.tab/gen-mirroring-tab.c,v $ + * + * 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 . + * For licensing issues, contact . */ -#include +#include + +#include + #include -#include -#ifdef HAVE_CONFIG_H -#include +#if STDC_HEADERS +# include +# include +#else +# if HAVE_STDLIB_H +# include +# endif +#endif +#if HAVE_STRING_H +# if !STDC_HEADERS && HAVE_MEMORY_H +# include +# endif +# include +#endif +#if HAVE_STRINGS_H +# include #endif -#include "fribidi_unicode.h" + +#define appname "gen-mirroring-tab" +#define outputname "mirroring.tab.i" + +static void +die ( + char *msg +) +{ + fprintf (stderr, appname ": %s\n", msg); + exit (1); +} static void -err2 ( +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); - - 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++) + FriBidiChar 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 @@ main ( 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; } diff --git a/gen.tab/packtab.c b/gen.tab/packtab.c index 311090a..f90127a 100644 --- a/gen.tab/packtab.c +++ b/gen.tab/packtab.c @@ -37,10 +37,8 @@ static int pow[22], cluster, cmpcluster; 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 @@ write_source ( 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 @@ write_out ( { 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 @@ pack_table ( 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)); diff --git a/lib/bidi-types-list.h b/lib/bidi-types-list.h index 2628962..9540025 100644 --- a/lib/bidi-types-list.h +++ b/lib/bidi-types-list.h @@ -2,10 +2,10 @@ /* FriBidi * bidi-types-list.h - list of bidi types * - * $Id: bidi-types-list.h,v 1.4 2004-05-07 06:30:38 behdad Exp $ + * $Id: bidi-types-list.h,v 1.5 2004-05-12 07:06:21 behdad Exp $ * $Author: behdad $ - * $Date: 2004-05-07 06:30:38 $ - * $Revision: 1.4 $ + * $Date: 2004-05-12 07:06:21 $ + * $Revision: 1.5 $ * $Source: /home/behdad/src/fdo/fribidi/togit/git/../fribidi/fribidi2/lib/Attic/bidi-types-list.h,v $ * * Author: @@ -36,6 +36,9 @@ #ifndef _FRIBIDI_ADD_TYPE # define _FRIBIDI_ADD_TYPE(x,y) #endif +#ifndef _FRIBIDI_ADD_ALIAS +# define _FRIBIDI_ADD_ALIAS(x1,x2) +#endif /* Bidi types from the standard. */ _FRIBIDI_ADD_TYPE (LTR, 'L') /* Left-To-Right letter */ @@ -58,6 +61,15 @@ _FRIBIDI_ADD_TYPE (LRO, '+') /* Left-to-Right Override */ _FRIBIDI_ADD_TYPE (RLO, '+') /* Right-to-Left Override */ _FRIBIDI_ADD_TYPE (PDF, '-') /* Pop Directional Flag */ +#ifdef _FRIBIDI_ADD_ALIAS +/* The followings are just aliases to types, but with the name that appears in + * the Unicode database. */ +_FRIBIDI_ADD_ALIAS (L, LTR) +_FRIBIDI_ADD_ALIAS (R, RTL) +_FRIBIDI_ADD_ALIAS (B, BS) +_FRIBIDI_ADD_ALIAS (S, SS) +#endif /* _FRIBIDI_ADD_ALIAS */ + #ifdef _FRIBIDI_PSEUDO_TYPES /* The following two types are not official Unicode bidi types, but used for * paragraph direction handling only. */ diff --git a/lib/common.h b/lib/common.h index 9f0c8ad..4fab82b 100644 --- a/lib/common.h +++ b/lib/common.h @@ -1,10 +1,10 @@ /* FriBidi * common.h - common include for library sources * - * $Id: common.h,v 1.6 2004-05-07 06:30:38 behdad Exp $ + * $Id: common.h,v 1.7 2004-05-12 07:06:21 behdad Exp $ * $Author: behdad $ - * $Date: 2004-05-07 06:30:38 $ - * $Revision: 1.6 $ + * $Date: 2004-05-12 07:06:21 $ + * $Revision: 1.7 $ * $Source: /home/behdad/src/fdo/fribidi/togit/git/../fribidi/fribidi2/lib/common.h,v $ * * Author: @@ -107,7 +107,11 @@ # define fribidi_malloc (void *) malloc # endif /* !HAVE_STDLIB_H */ # define fribidi_free free -#endif /* !fribidi_malloc */ +#else /* fribidi_malloc */ +# ifndef fribidi_free +# error You should define fribidi_free too when you define fribidi_malloc. +# endif /* !fribidi_free */ +#endif /* fribidi_malloc */ /* FRIBIDI_CHUNK_SIZE is the number of bytes in each chunk of memory being * allocated for data structure pools. */ diff --git a/lib/fribidi-bidi-type.c b/lib/fribidi-bidi-type.c index cb098d3..b63331f 100644 --- a/lib/fribidi-bidi-type.c +++ b/lib/fribidi-bidi-type.c @@ -1,10 +1,10 @@ /* FriBidi * fribidi-bidi-type.c - get character bidi type * - * $Id: fribidi-bidi-type.c,v 1.4 2004-05-07 06:30:38 behdad Exp $ + * $Id: fribidi-bidi-type.c,v 1.5 2004-05-12 07:06:21 behdad Exp $ * $Author: behdad $ - * $Date: 2004-05-07 06:30:38 $ - * $Revision: 1.4 $ + * $Date: 2004-05-12 07:06:21 $ + * $Revision: 1.5 $ * $Source: /home/behdad/src/fdo/fribidi/togit/git/../fribidi/fribidi2/lib/Attic/fribidi-bidi-type.c,v $ * * Authors: @@ -68,7 +68,7 @@ get_bidi_type ( ) { if (uch < 0x110000) - return prop_to_type[FRIBIDI_GET_TYPE (uch)]; + return prop_to_type[FRIBIDI_GET_BIDI_TYPE (uch)]; else return FRIBIDI_TYPE_LTR; /* Non-Unicode chars */ diff --git a/lib/fribidi-mirroring.h b/lib/fribidi-mirroring.h index d6e1581..6cbae01 100644 --- a/lib/fribidi-mirroring.h +++ b/lib/fribidi-mirroring.h @@ -21,10 +21,10 @@ * * For licensing issues, contact . */ -/* $Id: fribidi-mirroring.h,v 1.2 2004-04-27 15:23:25 behdad Exp $ +/* $Id: fribidi-mirroring.h,v 1.3 2004-05-12 07:06:21 behdad Exp $ * $Author: behdad $ - * $Date: 2004-04-27 15:23:25 $ - * $Revision: 1.2 $ + * $Date: 2004-05-12 07:06:21 $ + * $Revision: 1.3 $ * $Source: /home/behdad/src/fdo/fribidi/togit/git/../fribidi/fribidi2/lib/fribidi-mirroring.h,v $ * * Author: @@ -42,9 +42,10 @@ #define fribidi_get_mirror_char FRIBIDI_NAMESPACE(get_mirror_char) /* fribidi_get_mirror_char - get mirrored character * - * This function finds the mirrored of a character. If input character is a - * mirroring character, the matching mirrored character is put in the output, - * otherwise the input character itself is put. + * This function finds the mirrored equivalent of a character. If the input + * character is a declared as a mirroring character in the Unicode standard + * and has a mirrored equivalent. The matching mirrored character is put in + * the output, otherwise the input character itself is put. * * Returns: if the character has a mirror or not. */