From 24d75cf7f42251ccb7a00f5469d8e172cf10061d Mon Sep 17 00:00:00 2001 From: behdad Date: Tue, 7 Jun 2005 08:43:17 +0000 Subject: [PATCH] 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. --- gen.tab/Makefile.am | 5 ++- gen.tab/gen-unicode-version.c | 75 +++++++++++++++++++++++------------ gen.tab/unidata/ReadMe.txt | 3 -- 3 files changed, 53 insertions(+), 30 deletions(-) diff --git a/gen.tab/Makefile.am b/gen.tab/Makefile.am index aaf3061..89de496 100644 --- a/gen.tab/Makefile.am +++ b/gen.tab/Makefile.am @@ -4,10 +4,10 @@ EXTRA_PROGRAMS = \ 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 @@ gen_unicode_version = gen-unicode-version$(EXEEXT) 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: diff --git a/gen.tab/gen-unicode-version.c b/gen.tab/gen-unicode-version.c index 91d701a..cdd7d6f 100644 --- a/gen.tab/gen-unicode-version.c +++ b/gen.tab/gen-unicode-version.c @@ -1,10 +1,10 @@ /* 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: @@ -90,43 +90,56 @@ init ( 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 @@ gen_unicode_version ( ) { 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 @@ main ( 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); } diff --git a/gen.tab/unidata/ReadMe.txt b/gen.tab/unidata/ReadMe.txt index 5b75c53..0ad5623 100644 --- a/gen.tab/unidata/ReadMe.txt +++ b/gen.tab/unidata/ReadMe.txt @@ -22,6 +22,3 @@ Otherwise the version number of the UCD is part of the path name. The file UCD.html in this directory, as well as any file headers, where present, also identify the version of the UCD. - -=== added === -Unicode Standard, Version 4.1.0 -- 2.50.1