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 =
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:
/* FriBidi
* gen-unicode-version.c - generate fribidi-unicode-version.h
*
- * $Id: gen-unicode-version.c,v 1.8 2004-08-27 21:55:59 behdad Exp $
+ * $Id: gen-unicode-version.c,v 1.9 2005-06-07 08:43:17 behdad Exp $
* $Author: behdad $
- * $Date: 2004-08-27 21:55:59 $
- * $Revision: 1.8 $
+ * $Date: 2005-06-07 08:43:17 $
+ * $Revision: 1.9 $
* $Source: /home/behdad/src/fdo/fribidi/togit/git/../fribidi/fribidi2/gen.tab/gen-unicode-version.c,v $
*
* Author:
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
)
{
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);
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);
}