[FriBidi-commit] fribidi/gen.tab Makefile.am, 1.15,
1.16 gen-unicode-version.c, 1.8, 1.9
Behdad Esfahbod
behdad at freedesktop.org
Tue Jun 7 01:43:19 PDT 2005
Update of /cvs/fribidi/fribidi/gen.tab
In directory gabe:/tmp/cvs-serv17088
Modified Files:
Makefile.am gen-unicode-version.c
Log Message:
In Unicode 4.1.0, the ReadMe.txt doesn't contain the Unicode version anymore.
Updated to read version from BidiMirroring.txt, if not found in ReadMe.txt.
Index: Makefile.am
===================================================================
RCS file: /cvs/fribidi/fribidi/gen.tab/Makefile.am,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- Makefile.am 3 Jul 2004 11:36:15 -0000 1.15
+++ Makefile.am 7 Jun 2005 08:43:17 -0000 1.16
@@ -4,10 +4,10 @@
gen-joining-type-tab \
gen-mirroring-tab
+gen_unicode_version_SOURCES = gen-unicode-version.c
gen_bidi_type_tab_SOURCES = gen-bidi-type-tab.c packtab.c packtab.h
gen_joining_type_tab_SOURCES = gen-joining-type-tab.c packtab.c packtab.h
gen_mirroring_tab_SOURCES = gen-mirroring-tab.c packtab.c packtab.h
-gen_unicode_version_SOURCES = gen-unicode-version.c
CLEANFILES = $(EXTRA_PROGRAMS)
DISTCLEANFILES =
@@ -91,9 +91,10 @@
fribidi-unicode-version.h: \
ReadMe.txt \
+ BidiMirroring.txt \
$(gen_unicode_version_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) $(gen_unicode_version)
- ./$(gen_unicode_version) $< > $@ \
+ ./$(gen_unicode_version) $^ > $@ \
|| ($(RM) $@ && false)
# generate all generators:
Index: gen-unicode-version.c
===================================================================
RCS file: /cvs/fribidi/fribidi/gen.tab/gen-unicode-version.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- gen-unicode-version.c 27 Aug 2004 21:55:59 -0000 1.8
+++ gen-unicode-version.c 7 Jun 2005 08:43:17 -0000 1.9
@@ -90,43 +90,56 @@
strcpy (unicode_version, "(unknown)");
}
-static void
-read_read_me_txt (
+#define READ_VERSION(prefix) ((where = strstr(buf, prefix)) && \
+ (3 == sscanf (where, \
+ prefix"%d.%d.%d", &version_major, &version_minor, &version_micro)))
+
+static int
+read_file (
FILE *f
)
{
- const char *s;
+ int found = 0;
+
+ version_micro = 0;
while (fgets (buf, sizeof buf, f))
- if ((s = strstr (buf, "Version")))
- {
- sscanf (s, "Version %d.%d.%d", &version_major, &version_minor,
- &version_micro);
- sprintf (unicode_version, "%d.%d.%d", version_major, version_minor,
- version_micro);
- return;
- }
- die ("error: version not found");
+ {
+ const char *where;
+
+ if (READ_VERSION ("Version ") || READ_VERSION ("Unicode "))
+ {
+ found = 1;
+ break;
+ }
+ }
+
+ if (!found)
+ return 0;
+
+ sprintf (unicode_version, "%d.%d.%d", version_major, version_minor,
+ version_micro);
+ return 1;
}
-static void
+static int
read_data (
const char *data_file_type,
const char *data_file_name
)
{
FILE *f;
+ int status;
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, "ReadMe.txt"))
- read_read_me_txt (f);
- else
- die2 ("error: unknown data-file type %s", data_file_type);
+ status = read_file (f);
fclose (f);
+
+ return status;
}
static void
@@ -135,7 +148,7 @@
)
{
fprintf (stderr,
- "Generating `" outputname "' , it may take up to a few minutes\n");
+ "Generating `" outputname "'\n");
printf ("/* " outputname "\n * generated by " appname " (" FRIBIDI_NAME " "
FRIBIDI_VERSION ")\n" " * from the file %s */\n\n", data_file_type);
@@ -162,16 +175,28 @@
const char **argv
)
{
- const char *data_file_type = "ReadMe.txt";
+ const char *data_file_type;
+ int i;
+ int found = 0;
if (argc < 2)
- die2 ("usage:\n " appname " /path/to/%s [junk...]", data_file_type);
+ die ("usage:\n " appname " /path/to/a/UCD/file [/path/to/more/UCD/files ...]");
{
- const char *data_file_name = argv[1];
+ const char *data_file_name;
init ();
- read_data (data_file_type, data_file_name);
+ for (i = 1; i < argc && !found; i++) {
+ data_file_name = argv[i];
+ data_file_type = strrchr (data_file_name, '/');
+ if (data_file_type)
+ data_file_type++;
+ else
+ data_file_type = data_file_name;
+ found = read_data (data_file_type, data_file_name);
+ }
+ if (!found)
+ die ("error: version not found");
gen_unicode_version (data_file_type);
}
More information about the fribidi-commit
mailing list