use warnings;
require 'regen/regen_lib.pl';
require 'regen/charset_translations.pl';
+use Unicode::UCD;
use charnames qw(:loose);
my $out_fh = open_new('unicode_constants.h', '>',
#ifndef H_UNICODE_CONSTANTS /* Guard against nested #includes */
#define H_UNICODE_CONSTANTS 1
-/* This file contains #defines for various Unicode code points. The values
- * the macros expand to are the native Unicode code point, or all or portions
- * of the UTF-8 encoding for the code point. In the former case, the macro
- * name has the suffix "_NATIVE"; otherwise, the suffix "_UTF8".
+/* This file contains #defines for the version of Unicode being used and
+ * various Unicode code points. The values the code point macros expand to
+ * are the native Unicode code point, or all or portions of the UTF-8 encoding
+ * for the code point. In the former case, the macro name has the suffix
+ * "_NATIVE"; otherwise, the suffix "_UTF8".
*
* The macros that have the suffix "_UTF8" may have further suffixes, as
* follows:
END
+my $version = Unicode::UCD::UnicodeVersion();
+my ($major, $dot, $dotdot) = $version =~ / (.*?) \. (.*?) (?: \. (.*) )? $ /x;
+$dotdot = 0 unless defined $dotdot;
+
+print $out_fh <<END;
+#define UNICODE_MAJOR_VERSION $major
+#define UNICODE_DOT_VERSION $dot
+#define UNICODE_DOT_DOT_VERSION $dotdot
+
+END
+
# The data are at __DATA__ in this file.
my @data = <DATA>;
#ifndef H_UNICODE_CONSTANTS /* Guard against nested #includes */
#define H_UNICODE_CONSTANTS 1
-/* This file contains #defines for various Unicode code points. The values
- * the macros expand to are the native Unicode code point, or all or portions
- * of the UTF-8 encoding for the code point. In the former case, the macro
- * name has the suffix "_NATIVE"; otherwise, the suffix "_UTF8".
+/* This file contains #defines for the version of Unicode being used and
+ * various Unicode code points. The values the code point macros expand to
+ * are the native Unicode code point, or all or portions of the UTF-8 encoding
+ * for the code point. In the former case, the macro name has the suffix
+ * "_NATIVE"; otherwise, the suffix "_UTF8".
*
* The macros that have the suffix "_UTF8" may have further suffixes, as
* follows:
* "_TAIL" if instead it represents all but the first byte. This, and
* with no additional suffix are both string constants */
+#define UNICODE_MAJOR_VERSION 8
+#define UNICODE_DOT_VERSION 0
+#define UNICODE_DOT_DOT_VERSION 0
+
#if 'A' == 65 /* ASCII/Latin1 */
# define LATIN_SMALL_LETTER_LONG_S_UTF8 "\xC5\xBF" /* U+017F */