summaryrefslogtreecommitdiff
path: root/regen/unicode_constants.pl
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2015-06-20 17:20:46 -0600
committerKarl Williamson <khw@cpan.org>2015-07-28 22:15:52 -0600
commit4b4853d16345f6e2c9f1778b427e272e196a86ed (patch)
treee1ee10707b55dfd37d40f38cc1c08d65d2ce7cc2 /regen/unicode_constants.pl
parentbc0c431d24db5d53336b0cf45c467a04034775da (diff)
downloadperl-4b4853d16345f6e2c9f1778b427e272e196a86ed.tar.gz
regen/unicode_constants.pl: Generate #defines giving which Unicode version
Future commits will want to take different actions depending on which Unicode version is being used.
Diffstat (limited to 'regen/unicode_constants.pl')
-rw-r--r--regen/unicode_constants.pl21
1 files changed, 17 insertions, 4 deletions
diff --git a/regen/unicode_constants.pl b/regen/unicode_constants.pl
index a1978ded95..c8ed64a951 100644
--- a/regen/unicode_constants.pl
+++ b/regen/unicode_constants.pl
@@ -3,6 +3,7 @@ use strict;
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', '>',
@@ -14,10 +15,11 @@ print $out_fh <<END;
#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:
@@ -28,6 +30,17 @@ print $out_fh <<END;
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>;