1
/* FriBidi - Library of BiDi algorithm
2
* Copyright (C) 2001,2002 Behdad Esfahbod.
4
* This library is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU Lesser General Public
6
* License as published by the Free Software Foundation; either
7
* version 2.1 of the License, or (at your option) any later version.
9
* This library is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* Lesser General Public License for more details.
14
* You should have received a copy of the GNU Lesser General Public License
15
* along with this library, in a file named COPYING; if not, write to the
16
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
17
* Boston, MA 02111-1307, USA
19
* For licensing issues, contact <fwpg@sharif.edu>.
28
#include "fribidi_unicode.h"
31
err2 (const char *fmt, char *p)
33
fprintf (stderr, "fribidi_create_mirroring: error: ");
34
fprintf (stderr, fmt, p);
35
fprintf (stderr, "\n");
39
static int table[0x110000];
40
static char *bidi_mirroring_file;
42
static int mirroring_count;
45
read_bidi_mirroring (void)
51
for (i = 0; i < 0x110000; i++)
54
printf ("Reading `BidiMirroring.txt'\n");
55
if (!(f = fopen (bidi_mirroring_file, "rt")))
56
err2 ("cannot open `%s' for reading", bidi_mirroring_file);
57
/* fgets (s, sizeof s, f);
58
sscanf (s, "# BidiMirroring-%s.txt", bidi_mirroring_version = malloc (20));*/
59
while (fgets (s, sizeof s, f))
61
if (s[0] == '#' || s[0] == '\0' || s[0] == '\n')
63
sscanf (s, "%x; %x", &i, &j);
72
headermacro (char *file)
74
char *t = strdup (file);
78
if (*p >= 'a' && *p <= 'z')
80
else if ((*p < 'A' || *p > 'Z') && (*p < '0' || *p > '9'))
88
write_mirror (char *file)
92
char *FILENAME = headermacro (file);
94
printf ("Writing `%s'\n", file);
95
if (!(f = fopen (file, "wt")))
96
err2 ("cannot open `%s' for writing", file);
98
" This file was automatically created from BidiMirroring.txt, version %s\n"
99
" by fribidi_create_mirroring\n*/\n\n", FRIBIDI_UNICODE_VERSION);
100
fprintf (f, "#ifndef %s\n#define %s\n\n#include \"fribidi.h\"\n\n",
103
" Mirrored characters include all the characters in the Unicode list\n"
104
" that have been declared as being mirrored and that have a mirrored\n"
107
" There are lots of characters that are designed as being mirrored\n"
108
" but do not have any mirrored glyph, e.g. the sign for there exist.\n");
110
" Are these used in Arabic? That is are all the mathematical signs\n"
111
" that are assigned to be mirrorable actually mirrored in Arabic?\n"
112
" If that is the case, we'll change the below code to include also\n"
113
" characters that mirror to themself. It will then be the responsibility\n"
114
" of the display engine to actually mirror these.\n" "*/\n\n");
115
fprintf (f, "/* *INDENT-OFF" "* */\n\n");
116
fprintf (f, "static const struct\n"
118
" FriBidiChar ch, mirrored_ch;\n"
119
"}\n" "FriBidiMirroredChars[] =\n" "{\n");
120
for (i = 0; i < 0x110000; i++)
122
fprintf (f, " {0x%04X, 0x%04X},\n", i, table[i]);
123
fprintf (f, "} ;\n\n");
124
fprintf (f, "/* *INDE" "NT-ON* */\n\n");
125
fprintf (f, "const int nFriBidiMirroredChars = %d;\n\n", mirroring_count);
126
fprintf (f, "\n#endif /* %s */\n", FILENAME);
131
main (int argc, char **argv)
135
p = (argc >= 2) ? argv[1] : "unidata";
136
bidi_mirroring_file = malloc (50 + strlen (p));
137
sprintf (bidi_mirroring_file, "%s/BidiMirroring.txt", p);
138
read_bidi_mirroring ();
139
write_mirror ("fribidi_tab_mirroring.i");