From f2cba0d13ff36653fbd88ddbce22f67f071c99e0 Mon Sep 17 00:00:00 2001 From: Kevin Newton Date: Mon, 16 Nov 2026 11:15:44 -0500 Subject: [PATCH 01/20] Generate the unicode tables from the Unicode Character Database --- bin/prism | 77 +++++++++++++++++++++++++++++++++++++++----------- src/encoding.c | 3 ++ 2 files changed, 63 insertions(+), 17 deletions(-) diff --git a/bin/prism b/bin/prism index 217397e68f..21828c0612 100755 --- a/bin/prism +++ b/bin/prism @@ -148,7 +148,7 @@ module Prism end lookup_table(found) - unicode_lists(found) if found == Encoding::UTF_8 || found == Encoding::UTF8_MAC + unicode_lists if found == Encoding::UTF_8 || found == Encoding::UTF8_MAC end # bin/prism error [source] @@ -432,26 +432,69 @@ module Prism puts "};" end + # The version of the Unicode Character Database that the unicode tables + # are generated from. It is the newest version that any version of Ruby + # that prism supports uses: Unicode 17.0.0, for Ruby 4.0 and 4.1. + UNICODE_VERSION = "17.0.0" + + # Read a file of the Unicode Character Database at UNICODE_VERSION. Each + # file is downloaded once from unicode.org and kept in tmp/unicode. + def unicode_data(path) + cache = File.expand_path("../tmp/unicode/#{UNICODE_VERSION}/#{path}", __dir__) + + unless File.exist?(cache) + require "fileutils" + require "net/http" + + uri = URI("https://www.unicode.org/Public/#{UNICODE_VERSION}/ucd/#{path}") + response = Net::HTTP.get_response(uri) + raise "could not download #{uri}: #{response.code} #{response.message}" unless response.is_a?(Net::HTTPSuccess) + + FileUtils.mkdir_p(File.dirname(cache)) + File.write(cache, response.body) + end + + File.read(cache) + end + + # Return the codepoints that have the given property in the given file of + # the Unicode Character Database. Each line of the file gives a codepoint + # or a range of codepoints and a property, as in "0041..005A ; Alphabetic". + def unicode_property(path, property) + codepoints = [] + + unicode_data(path).each_line do |line| + fields = line.sub(/#.*/, "").split(";").map(&:strip) + next unless fields.length == 2 && fields[1] == property + + low, high = fields[0].split("..").map { |value| Integer(value, 16) } + codepoints.concat((low..(high || low)).to_a) + end + + raise "no codepoints have #{property} in #{path}" if codepoints.empty? + codepoints + end + # Generate the multistage lookup tables of unicode codepoint properties # for a given encoding. A codepoint's properties live in the leaf table, # reached by indexing the root table with its high bits and the middle # table with its next five bits. Identical middle and leaf blocks are - # shared, which is what keeps the tables small. Titlecase letters count as - # uppercase because they can begin a constant name. - def unicode_lists(encoding) - encoding = Encoding::UTF_8 - - values = - (0...0x110000).map do |codepoint| - next 0 if (0xD800..0xDFFF).cover?(codepoint) - character = codepoint.chr(encoding) - - value = 0 - value |= (1 << 0) if character.match?(/[[:alpha:]]/) - value |= (1 << 1) if character.match?(/[[:alnum:]]/) - value |= (1 << 2) if character.match?(/[[:upper:]\p{Lt}]/) - value - end + # shared, which is what keeps the tables small. + # + # The properties are those that the regular expression engine gives the + # POSIX classes, from the Unicode Character Database at UNICODE_VERSION: + # + # * Alphabetic is the Alphabetic property, as in [[:alpha:]]. + # * Alphanumeric is Alphabetic or a decimal digit (Nd), as in [[:alnum:]]. + # * Uppercase is the Uppercase property, as in [[:upper:]], or a titlecase + # letter (Lt), since either can begin a constant name. + def unicode_lists + values = Array.new(0x110000, 0) + + unicode_property("DerivedCoreProperties.txt", "Alphabetic").each { |codepoint| values[codepoint] |= (1 << 0) | (1 << 1) } + unicode_property("extracted/DerivedGeneralCategory.txt", "Nd").each { |codepoint| values[codepoint] |= (1 << 1) } + unicode_property("DerivedCoreProperties.txt", "Uppercase").each { |codepoint| values[codepoint] |= (1 << 2) } + unicode_property("extracted/DerivedGeneralCategory.txt", "Lt").each { |codepoint| values[codepoint] |= (1 << 2) } names = { 0 => "N", 2 => "D", 3 => "A", 7 => "U" } unknown = values.uniq - names.keys diff --git a/src/encoding.c b/src/encoding.c index 4f061b395e..d7fd4e9a87 100644 --- a/src/encoding.c +++ b/src/encoding.c @@ -15,6 +15,9 @@ typedef uint32_t pm_unicode_codepoint_t; * copy, so the tables stay small, and every lookup is three loads with no * searching. Codepoints at or above UNICODE_CODEPOINTS_MAXIMUM have no * properties. + * + * The tables are Unicode 17.0.0. `bin/prism encoding UTF-8` generates them from + * the Unicode Character Database at that version. */ #define UNICODE_CODEPOINTS_MAXIMUM 0x33500 From 27c85c9ed0a1fe6a8343050d73318729bd66eafe Mon Sep 17 00:00:00 2001 From: Kevin Newton Date: Mon, 16 Nov 2026 12:51:09 -0500 Subject: [PATCH 02/20] Match Unicode version per Ruby parsing version --- CHANGELOG.md | 1 + bin/prism | 91 ++++- include/prism/internal/encoding.h | 21 +- src/encoding.c | 536 +++++++++++++++++------------- src/prism.c | 14 +- src/string_query.c | 2 +- 6 files changed, 397 insertions(+), 268 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 796e0a5f29..b861d6a425 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a - `PRISM_BUILD_MINIMAL` now excludes the full set of encodings, as `PRISM_ENCODING_EXCLUDE_FULL` does. - In CESU-8, a surrogate is a valid character only as half of a surrogate pair. - A `\M-`, `\C-`, or `\c` escape may wrap an escape of any ASCII character, such as `"\M-\<0x01>"`, as CRuby allows. +- Whether a name is a constant follows the version of Unicode of the Ruby that is targeted: Unicode 15.0.0 for Ruby 3.3 and 3.4, and Unicode 17.0.0 for Ruby 4.0 and 4.1. A name that starts with a letter that became uppercase in Unicode 16.0.0 or 17.0.0, such as the Garay capital letters, is now a local variable name when targeting Ruby 3.3 or 3.4. ## [2.1.0] - 2026-10-28 diff --git a/bin/prism b/bin/prism index 21828c0612..f2425ff30c 100755 --- a/bin/prism +++ b/bin/prism @@ -432,21 +432,38 @@ module Prism puts "};" end + # The version of Unicode that each version of Ruby that prism supports + # uses, from oldest to newest. The functions in src/encoding.c that take a + # version of Ruby answer for its version of Unicode from what this + # generates. + RUBY_UNICODE_VERSIONS = { + "3.3" => "15.0.0", + "3.4" => "15.0.0", + "4.0" => "17.0.0", + "4.1" => "17.0.0" + } + # The version of the Unicode Character Database that the unicode tables # are generated from. It is the newest version that any version of Ruby - # that prism supports uses: Unicode 17.0.0, for Ruby 4.0 and 4.1. - UNICODE_VERSION = "17.0.0" + # that prism supports uses. + UNICODE_VERSION = RUBY_UNICODE_VERSIONS.values.max_by { |version| Gem::Version.new(version) } + + # The older versions of Unicode that versions of Ruby that prism supports + # use, from oldest to newest. The functions that answer for those versions + # of Ruby check lists of the characters whose properties differ from the + # tables. + UNICODE_OLDER_VERSIONS =(RUBY_UNICODE_VERSIONS.values.uniq - [UNICODE_VERSION]).sort_by { |version| Gem::Version.new(version) } - # Read a file of the Unicode Character Database at UNICODE_VERSION. Each + # Read a file of the Unicode Character Database at the given version. Each # file is downloaded once from unicode.org and kept in tmp/unicode. - def unicode_data(path) - cache = File.expand_path("../tmp/unicode/#{UNICODE_VERSION}/#{path}", __dir__) + def unicode_data(path, version = UNICODE_VERSION) + cache = File.expand_path("../tmp/unicode/#{version}/#{path}", __dir__) unless File.exist?(cache) require "fileutils" require "net/http" - uri = URI("https://www.unicode.org/Public/#{UNICODE_VERSION}/ucd/#{path}") + uri = URI("https://www.unicode.org/Public/#{version}/ucd/#{path}") response = Net::HTTP.get_response(uri) raise "could not download #{uri}: #{response.code} #{response.message}" unless response.is_a?(Net::HTTPSuccess) @@ -458,12 +475,13 @@ module Prism end # Return the codepoints that have the given property in the given file of - # the Unicode Character Database. Each line of the file gives a codepoint - # or a range of codepoints and a property, as in "0041..005A ; Alphabetic". - def unicode_property(path, property) + # the Unicode Character Database at the given version. Each line of the + # file gives a codepoint or a range of codepoints and a property, as in + # "0041..005A ; Alphabetic". + def unicode_property(path, property, version = UNICODE_VERSION) codepoints = [] - unicode_data(path).each_line do |line| + unicode_data(path, version).each_line do |line| fields = line.sub(/#.*/, "").split(";").map(&:strip) next unless fields.length == 2 && fields[1] == property @@ -471,10 +489,18 @@ module Prism codepoints.concat((low..(high || low)).to_a) end - raise "no codepoints have #{property} in #{path}" if codepoints.empty? + raise "no codepoints have #{property} in #{path} at #{version}" if codepoints.empty? codepoints end + # Return the codepoints that can begin a constant name in the given version + # of Unicode: those with the Uppercase property, as in [[:upper:]], and the + # titlecase letters (Lt). + def unicode_uppercase(version = UNICODE_VERSION) + unicode_property("DerivedCoreProperties.txt", "Uppercase", version) | + unicode_property("extracted/DerivedGeneralCategory.txt", "Lt", version) + end + # Generate the multistage lookup tables of unicode codepoint properties # for a given encoding. A codepoint's properties live in the leaf table, # reached by indexing the root table with its high bits and the middle @@ -488,15 +514,28 @@ module Prism # * Alphanumeric is Alphabetic or a decimal digit (Nd), as in [[:alnum:]]. # * Uppercase is the Uppercase property, as in [[:upper:]], or a titlecase # letter (Lt), since either can begin a constant name. + # + # Older versions of Ruby use an older version of Unicode, in which some + # of the uppercase letters of the tables are not uppercase. Another bit + # marks those letters, so that the tables answer for every version of + # Ruby that prism supports. def unicode_lists + raise "one bit marks the letters of one older version of Unicode, but there are #{UNICODE_OLDER_VERSIONS.length}" unless UNICODE_OLDER_VERSIONS.length == 1 + + older = UNICODE_OLDER_VERSIONS.first + older_bit = "PM_UNICODE_#{older.split(".").first}_NOT_UPPERCASE_BIT" + latest_uppercase = unicode_uppercase + older_uppercase = unicode_uppercase(older) + raise "uppercase in Unicode #{older} but not #{UNICODE_VERSION}: #{(older_uppercase - latest_uppercase).inspect}" unless (older_uppercase - latest_uppercase).empty? + values = Array.new(0x110000, 0) unicode_property("DerivedCoreProperties.txt", "Alphabetic").each { |codepoint| values[codepoint] |= (1 << 0) | (1 << 1) } unicode_property("extracted/DerivedGeneralCategory.txt", "Nd").each { |codepoint| values[codepoint] |= (1 << 1) } - unicode_property("DerivedCoreProperties.txt", "Uppercase").each { |codepoint| values[codepoint] |= (1 << 2) } - unicode_property("extracted/DerivedGeneralCategory.txt", "Lt").each { |codepoint| values[codepoint] |= (1 << 2) } + latest_uppercase.each { |codepoint| values[codepoint] |= (1 << 2) } + (latest_uppercase - older_uppercase).each { |codepoint| values[codepoint] |= (1 << 3) } - names = { 0 => "N", 2 => "D", 3 => "A", 7 => "U" } + names = { 0 => "N", 2 => "D", 3 => "A", 7 => "U", 15 => "V" } unknown = values.uniq - names.keys raise "unnamed property values: #{unknown.inspect}" if unknown.any? @@ -522,8 +561,27 @@ module Prism end puts "};" + tables_ruby = RUBY_UNICODE_VERSIONS.find { |_, version| version == UNICODE_VERSION }.first + tables_update = "PM_UNICODE_TABLES_#{UNICODE_VERSION.split(".").first}_UPDATE" + versions = RUBY_UNICODE_VERSIONS.group_by(&:last).map { |version, rubies| " * * Ruby #{rubies.map(&:first).join(" and ")} use Unicode #{version}." } + puts <<~C + /** + * The version of Ruby that updated its version of Unicode to #{UNICODE_VERSION}. + * + #{versions.join("\n")} + */ + #define #{tables_update} PM_OPTIONS_VERSION_CRUBY_#{tables_ruby.tr(".", "_")} + + /** + * The unicode tables use the fourth bit of each property byte to mark the + * letters that are uppercase or titlecase in the tables but not in Unicode + * #{older}, which the versions of Ruby before #{tables_update} + * use. + */ + #define #{older_bit} (1 << 3) + /* No properties. */ #define N 0 @@ -535,6 +593,9 @@ module Prism /* An uppercase or titlecase letter: alphabetic, alphanumeric, and uppercase. */ #define U (PRISM_ENCODING_ALPHABETIC_BIT | PRISM_ENCODING_ALPHANUMERIC_BIT | PRISM_ENCODING_UPPERCASE_BIT) + + /* An uppercase or titlecase letter that is not one in Unicode #{older}. */ + #define V (PRISM_ENCODING_ALPHABETIC_BIT | PRISM_ENCODING_ALPHANUMERIC_BIT | PRISM_ENCODING_UPPERCASE_BIT | #{older_bit}) C puts "\nstatic const uint8_t pm_unicode_leaf[#{leaf_blocks.length}][8] = {" @@ -543,7 +604,7 @@ module Prism end puts "};" - puts "\n#undef N\n#undef D\n#undef A\n#undef U" + puts "\n#undef N\n#undef D\n#undef A\n#undef U\n#undef V" end # Deduplicate the given blocks. The block made entirely of the given empty diff --git a/include/prism/internal/encoding.h b/include/prism/internal/encoding.h index fcfc933356..0837eff1fc 100644 --- a/include/prism/internal/encoding.h +++ b/include/prism/internal/encoding.h @@ -3,6 +3,7 @@ #include "prism/compiler/inline.h" #include "prism/excludes.h" +#include "prism/internal/options.h" #include #include @@ -111,7 +112,9 @@ size_t pm_encoding_char_width(const pm_encoding_t *encoding, const uint8_t *b, p /* * Return the number of bytes in the next character in the given encoding if it - * has the given PRISM_ENCODING_*_BIT property, or 0 otherwise. + * has the given PRISM_ENCODING_*_BIT property, or 0 otherwise. In an encoding + * whose characters are Unicode code points, this answers for the version of + * Unicode that the tables are. */ size_t pm_encoding_property_char(const pm_encoding_t *encoding, uint8_t property, const uint8_t *b, ptrdiff_t n); @@ -134,12 +137,12 @@ pm_encoding_alnum_char(const pm_encoding_t *encoding, const uint8_t *b, ptrdiff_ } /* - * Return true if the next character in the given encoding is uppercase. + * Return true if the next character in the given encoding is uppercase, or + * titlecase, in the given version of Ruby. Such a character begins a constant + * name. The version only matters for an encoding whose characters are Unicode + * code points, since each version of Ruby uses a version of Unicode. */ -static PRISM_INLINE bool -pm_encoding_isupper_char(const pm_encoding_t *encoding, const uint8_t *b, ptrdiff_t n) { - return pm_encoding_property_char(encoding, PRISM_ENCODING_UPPERCASE_BIT, b, n) != 0; -} +bool pm_encoding_isupper_char(const pm_encoding_t *encoding, const uint8_t *b, ptrdiff_t n, pm_options_version_t version); /* Return the size of the next character in the UTF-8 encoding. */ size_t pm_encoding_utf_8_char_width(const uint8_t *b, ptrdiff_t n); @@ -157,10 +160,10 @@ size_t pm_encoding_utf_8_alpha_char(const uint8_t *b, ptrdiff_t n); size_t pm_encoding_utf_8_alnum_char(const uint8_t *b, ptrdiff_t n); /* - * Return true if the next character in the UTF-8 encoding if it is an uppercase - * character. + * Return true if the next character in the UTF-8 encoding is uppercase, or + * titlecase, in the given version of Ruby. */ -bool pm_encoding_utf_8_isupper_char(const uint8_t *b, ptrdiff_t n); +bool pm_encoding_utf_8_isupper_char(const uint8_t *b, ptrdiff_t n, pm_options_version_t version); /* * This lookup table indicates whether a US-ASCII character is alphabetical, diff --git a/src/encoding.c b/src/encoding.c index d7fd4e9a87..9dd3fa576a 100644 --- a/src/encoding.c +++ b/src/encoding.c @@ -1,5 +1,6 @@ #include "prism/internal/encoding.h" +#include "prism/compiler/branch.h" #include "prism/internal/assert.h" #include "prism/internal/strncasecmp.h" @@ -80,87 +81,87 @@ static const uint8_t pm_unicode_middle[129][32] = { [0x00] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, [0x01] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }, [0x02] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x06 }, - [0x03] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x06, 0x2D, 0x02, 0x02, 0x2E, 0x0C, 0x01, 0x01, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x1D, 0x1C, 0x02, 0x02, 0x2F, 0x59, 0x01, 0x01, 0x05, 0x01 }, - [0x04] = { 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x30, 0x30, 0x3E, 0x03, 0x03, 0x03, 0x03, 0x03, 0x5A, 0x3F, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, 0x30, 0x64, 0x03, 0x03, 0x3F, 0x03 }, - [0x05] = { 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x40, 0x65, 0x66, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x31, 0x01, 0x0D, 0x00, 0x0A, 0x67, 0x00, 0x00 }, - [0x06] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1D, 0x00, 0x00, 0x00, 0x18, 0x01, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x02, 0x6D, 0x41, 0x01, 0x01, 0x01, 0x6E, 0x6F, 0x03, 0x03, 0x03, 0x70, 0x71 }, - [0x07] = { 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x03, 0x72, 0x42, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x73, 0x74, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 }, - [0x08] = { 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x2D, 0x02, 0x02, 0x02, 0x2F, 0x29, 0x01, 0x01, 0x01, 0x01, 0x01, 0x09, 0x00, 0x00, 0x00, 0x00, 0x01, 0x12, 0x75, 0x00, 0x01, 0x01, 0x01, 0x2A, 0x08, 0x00 }, - [0x09] = { 0x00, 0x00, 0x01, 0x08, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0C, 0x04, 0x76, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x11, 0x0A, 0x0C, 0x43, 0x04, 0x77 }, - [0x0A] = { 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x15, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0D, 0x00, 0x04, 0x22, 0x01, 0x01, 0x01, 0x08, 0x78, 0x1C }, + [0x03] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x06, 0x2D, 0x02, 0x02, 0x2E, 0x0C, 0x01, 0x01, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x1D, 0x1C, 0x02, 0x02, 0x2F, 0x5A, 0x01, 0x01, 0x05, 0x01 }, + [0x04] = { 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x30, 0x30, 0x3F, 0x03, 0x03, 0x03, 0x03, 0x03, 0x5B, 0x40, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, 0x64, 0x30, 0x65, 0x03, 0x03, 0x40, 0x03 }, + [0x05] = { 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x41, 0x66, 0x67, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x31, 0x01, 0x0D, 0x00, 0x0A, 0x68, 0x00, 0x00 }, + [0x06] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1D, 0x00, 0x00, 0x00, 0x18, 0x01, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x02, 0x6E, 0x42, 0x01, 0x01, 0x01, 0x6F, 0x70, 0x03, 0x03, 0x03, 0x71, 0x72 }, + [0x07] = { 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x03, 0x73, 0x43, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x74, 0x75, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 }, + [0x08] = { 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x2D, 0x02, 0x02, 0x02, 0x2F, 0x2A, 0x01, 0x01, 0x01, 0x01, 0x01, 0x09, 0x00, 0x00, 0x00, 0x00, 0x01, 0x12, 0x76, 0x00, 0x01, 0x01, 0x01, 0x2B, 0x08, 0x00 }, + [0x09] = { 0x00, 0x00, 0x01, 0x08, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0C, 0x04, 0x77, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x11, 0x0A, 0x0C, 0x44, 0x04, 0x78 }, + [0x0A] = { 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x15, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0D, 0x00, 0x04, 0x22, 0x01, 0x01, 0x01, 0x08, 0x79, 0x1C }, [0x0B] = { 0x01, 0x01, 0x01, 0x10, 0x01, 0x0A, 0x00, 0x00, 0x01, 0x01, 0x01, 0x09, 0x01, 0x08, 0x01, 0x01, 0x01, 0x0C, 0x0E, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0D, 0x1E, 0x01, 0x18, 0x0D, 0x01, 0x01 }, - [0x0C] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x11, 0x01, 0x13, 0x43, 0x01, 0x19, 0x04, 0x0C, 0x01, 0x11, 0x16, 0x1F, 0x01, 0x01, 0x0F, 0x79, 0x20, 0x16, 0x7A, 0x0E, 0x44, 0x19, 0x04, 0x0D, 0x45 }, - [0x0D] = { 0x23, 0x2A, 0x1F, 0x01, 0x01, 0x0F, 0x7B, 0x31, 0x2A, 0x32, 0x29, 0x46, 0x24, 0x04, 0x07, 0x00, 0x23, 0x12, 0x17, 0x01, 0x01, 0x0F, 0x33, 0x20, 0x12, 0x34, 0x09, 0x00, 0x19, 0x04, 0x00, 0x47 }, - [0x0E] = { 0x23, 0x16, 0x1F, 0x01, 0x01, 0x0F, 0x33, 0x20, 0x16, 0x32, 0x21, 0x44, 0x19, 0x04, 0x29, 0x00, 0x7C, 0x25, 0x1A, 0x48, 0x7D, 0x25, 0x01, 0x31, 0x25, 0x35, 0x49, 0x00, 0x24, 0x04, 0x00, 0x00 }, - [0x0F] = { 0x01, 0x13, 0x0F, 0x01, 0x01, 0x0F, 0x01, 0x20, 0x13, 0x35, 0x4A, 0x36, 0x19, 0x04, 0x00, 0x00, 0x11, 0x13, 0x0F, 0x01, 0x01, 0x0F, 0x11, 0x20, 0x13, 0x35, 0x4A, 0x4B, 0x19, 0x04, 0x7E, 0x00 }, - [0x10] = { 0x01, 0x13, 0x0F, 0x01, 0x01, 0x01, 0x01, 0x37, 0x13, 0x7F, 0x1E, 0x0E, 0x19, 0x04, 0x00, 0x10, 0x23, 0x01, 0x05, 0x10, 0x01, 0x01, 0x17, 0x4C, 0x05, 0x0E, 0x38, 0x01, 0x24, 0x04, 0x80, 0x00 }, - [0x11] = { 0x0C, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x08, 0x05, 0x1D, 0x04, 0x06, 0x00, 0x00, 0x00, 0x00, 0x48, 0x14, 0x01, 0x01, 0x81, 0x01, 0x01, 0x82, 0x38, 0x1D, 0x04, 0x83, 0x00, 0x00, 0x00, 0x00 }, + [0x0C] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x11, 0x01, 0x13, 0x44, 0x01, 0x19, 0x04, 0x0C, 0x01, 0x11, 0x16, 0x1F, 0x01, 0x01, 0x0F, 0x7A, 0x20, 0x16, 0x7B, 0x0E, 0x45, 0x19, 0x04, 0x0D, 0x46 }, + [0x0D] = { 0x23, 0x2B, 0x1F, 0x01, 0x01, 0x0F, 0x7C, 0x31, 0x2B, 0x32, 0x2A, 0x47, 0x24, 0x04, 0x07, 0x00, 0x23, 0x12, 0x17, 0x01, 0x01, 0x0F, 0x33, 0x20, 0x12, 0x34, 0x09, 0x00, 0x19, 0x04, 0x00, 0x48 }, + [0x0E] = { 0x23, 0x16, 0x1F, 0x01, 0x01, 0x0F, 0x33, 0x20, 0x16, 0x32, 0x21, 0x45, 0x19, 0x04, 0x2A, 0x00, 0x7D, 0x25, 0x1A, 0x49, 0x7E, 0x25, 0x01, 0x31, 0x25, 0x35, 0x4A, 0x00, 0x24, 0x04, 0x00, 0x00 }, + [0x0F] = { 0x01, 0x13, 0x0F, 0x01, 0x01, 0x0F, 0x01, 0x20, 0x13, 0x35, 0x4B, 0x36, 0x19, 0x04, 0x00, 0x00, 0x11, 0x13, 0x0F, 0x01, 0x01, 0x0F, 0x11, 0x20, 0x13, 0x35, 0x4B, 0x4C, 0x19, 0x04, 0x7F, 0x00 }, + [0x10] = { 0x01, 0x13, 0x0F, 0x01, 0x01, 0x01, 0x01, 0x37, 0x13, 0x80, 0x1E, 0x0E, 0x19, 0x04, 0x00, 0x10, 0x23, 0x01, 0x05, 0x10, 0x01, 0x01, 0x17, 0x4D, 0x05, 0x0E, 0x38, 0x01, 0x24, 0x04, 0x81, 0x00 }, + [0x11] = { 0x0C, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x08, 0x05, 0x1D, 0x04, 0x06, 0x00, 0x00, 0x00, 0x00, 0x49, 0x14, 0x01, 0x01, 0x82, 0x01, 0x01, 0x83, 0x38, 0x1D, 0x04, 0x84, 0x00, 0x00, 0x00, 0x00 }, [0x12] = { 0x09, 0x00, 0x00, 0x00, 0x04, 0x06, 0x00, 0x00, 0x01, 0x0C, 0x01, 0x01, 0x01, 0x0A, 0x0C, 0x01, 0x0B, 0x01, 0x01, 0x0C, 0x01, 0x01, 0x01, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x13] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05, 0x1F, 0x04, 0x06, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x04, 0x84, 0x02, 0x02, 0x02, 0x02, 0x85, 0x86, 0x01, 0x01, 0x01, 0x01, 0x01, 0x14 }, + [0x13] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05, 0x1F, 0x04, 0x06, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x04, 0x85, 0x02, 0x02, 0x02, 0x02, 0x86, 0x87, 0x01, 0x01, 0x01, 0x01, 0x01, 0x14 }, [0x14] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x1A, 0x05, 0x1A, 0x01, 0x01, 0x01, 0x01, 0x01, 0x1A, 0x01, 0x01, 0x01, 0x01, 0x1A, 0x05, 0x1A, 0x01, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01 }, - [0x15] = { 0x01, 0x01, 0x1A, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x08, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x2B, 0x07 }, + [0x15] = { 0x01, 0x01, 0x1A, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x08, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x39, 0x07 }, [0x16] = { 0x0C, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }, [0x17] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x16, 0x01, 0x01, 0x0C, 0x01, 0x01, 0x08, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x25, 0x01, 0x09 }, - [0x18] = { 0x01, 0x01, 0x0B, 0x0E, 0x01, 0x01, 0x0B, 0x00, 0x01, 0x01, 0x0B, 0x00, 0x01, 0x13, 0x87, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x4D, 0x01, 0x01, 0x09, 0x0E, 0x45, 0x04, 0x06, 0x00, 0x00 }, + [0x18] = { 0x01, 0x01, 0x0B, 0x0E, 0x01, 0x01, 0x0B, 0x00, 0x01, 0x01, 0x0B, 0x00, 0x01, 0x13, 0x88, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x4E, 0x01, 0x01, 0x09, 0x0E, 0x46, 0x04, 0x06, 0x00, 0x00 }, [0x19] = { 0x00, 0x00, 0x04, 0x06, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x09, 0x01, 0x01, 0x01, 0x01, 0x01, 0x08, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x07, 0x00 }, [0x1A] = { 0x01, 0x01, 0x01, 0x05, 0x01, 0x0B, 0x01, 0x09, 0x24, 0x04, 0x01, 0x01, 0x01, 0x07, 0x0A, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0B, 0x01, 0x01, 0x01, 0x0D, 0x04, 0x06, 0x00, 0x00, 0x00, 0x00 }, - [0x1B] = { 0x01, 0x01, 0x01, 0x0B, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05, 0x0C, 0x01, 0x0A, 0x00, 0x04, 0x06, 0x04, 0x06, 0x0E, 0x00, 0x00, 0x0E, 0x09, 0x4B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x1C] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x11, 0x01, 0x11, 0x0A, 0x04, 0x06, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x88, 0x04, 0x22, 0x01, 0x01, 0x01, 0x01, 0x12, 0x01, 0x0D, 0x00 }, - [0x1D] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05, 0x00, 0x04, 0x89, 0x04, 0x22, 0x01, 0x01, 0x01, 0x07, 0x01, 0x8A, 0x02, 0x02, 0x02, 0x02, 0x02, 0x4E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8B, 0x26, 0x1C }, + [0x1B] = { 0x01, 0x01, 0x01, 0x0B, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05, 0x0C, 0x01, 0x0A, 0x00, 0x04, 0x06, 0x04, 0x06, 0x0E, 0x00, 0x00, 0x0E, 0x09, 0x4C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + [0x1C] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x11, 0x01, 0x11, 0x0A, 0x04, 0x06, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x89, 0x04, 0x22, 0x01, 0x01, 0x01, 0x01, 0x12, 0x01, 0x0D, 0x00 }, + [0x1D] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05, 0x00, 0x04, 0x8A, 0x04, 0x22, 0x01, 0x01, 0x01, 0x07, 0x01, 0x8B, 0x02, 0x02, 0x02, 0x02, 0x02, 0x4F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8C, 0x26, 0x1C }, [0x1E] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x18, 0x01, 0x01, 0x01, 0x0A, 0x00 }, - [0x1F] = { 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x8C, 0x8D, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 }, - [0x20] = { 0x01, 0x02, 0x07, 0x2B, 0x01, 0x02, 0x01, 0x02, 0x07, 0x2B, 0x01, 0x8E, 0x01, 0x02, 0x01, 0x07, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x13, 0x8F, 0x4F, 0x39, 0x4D, 0x50, 0x01, 0x39, 0x4F, 0x39 }, - [0x21] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x29, 0x0E, 0x00, 0x00, 0x01, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x22] = { 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x41, 0x96, 0x97, 0x51, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x98, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x23] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x99, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x0D, 0x00, 0x00 }, - [0x24] = { 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x9A, 0x9B, 0x9C, 0x52, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x9D, 0x9E, 0x9F, 0x00 }, + [0x1F] = { 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x8D, 0x8E, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 }, + [0x20] = { 0x01, 0x02, 0x07, 0x39, 0x01, 0x02, 0x01, 0x02, 0x07, 0x39, 0x01, 0x8F, 0x01, 0x02, 0x01, 0x07, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x13, 0x90, 0x50, 0x3A, 0x4E, 0x51, 0x01, 0x3A, 0x50, 0x3A }, + [0x21] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2A, 0x0E, 0x00, 0x00, 0x01, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + [0x22] = { 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x42, 0x97, 0x98, 0x52, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x99, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + [0x23] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9A, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x0D, 0x00, 0x00 }, + [0x24] = { 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x9B, 0x9C, 0x9D, 0x53, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x9E, 0x9F, 0xA0, 0x00 }, [0x25] = { 0x01, 0x01, 0x01, 0x01, 0x12, 0x1D, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0E, 0x00, 0x00, 0x01, 0x01, 0x05, 0x00, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x01, 0x01, 0x01, 0x01 }, [0x26] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x27] = { 0x15, 0x00, 0x00, 0x00, 0x0C, 0x0D, 0x3A, 0x0A, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05, 0x15, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x14 }, + [0x27] = { 0x15, 0x00, 0x00, 0x00, 0x0C, 0x0D, 0x3B, 0x0A, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05, 0x15, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x14 }, [0x28] = { 0x15, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01 }, [0x29] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, [0x2A] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x07 }, - [0x2B] = { 0x01, 0x0A, 0x01, 0x01, 0x04, 0xA0, 0x00, 0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0xA1, 0x1E, 0x53, 0x03, 0x03, 0x03, 0x40, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00 }, - [0x2C] = { 0x00, 0x00, 0x0E, 0x01, 0x42, 0x03, 0x3E, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0xA2, 0x03, 0xA3, 0xA4, 0x03, 0x03, 0xA5, 0xA6, 0x03, 0xA7, 0xA8, 0x03, 0xA9, 0x00, 0x00, 0xAA, 0x01 }, - [0x2D] = { 0x12, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0B, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x4C, 0x00, 0x04, 0x06, 0x00, 0x00, 0x10, 0xAB }, - [0x2E] = { 0x04, 0x22, 0x01, 0x01, 0x01, 0x08, 0x01, 0x01, 0x01, 0x01, 0x08, 0x00, 0x01, 0x01, 0x01, 0x0A, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x14, 0x01, 0x00, 0x0E, 0x04, 0x06, 0x01, 0x01, 0x04, 0xAC }, - [0x2F] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05, 0x00, 0x01, 0x07, 0x04, 0x06, 0x01, 0x01, 0x05, 0x10, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05, 0xAD, 0x00, 0x00, 0xAE, 0x01, 0x01, 0xAF, 0x00 }, + [0x2B] = { 0x01, 0x0A, 0x01, 0x01, 0x04, 0xA1, 0x00, 0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0xA2, 0x1E, 0x54, 0x03, 0x03, 0x03, 0x41, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00 }, + [0x2C] = { 0x00, 0x00, 0x0E, 0x01, 0x43, 0x03, 0x3F, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0xA3, 0x03, 0xA4, 0xA5, 0x03, 0x03, 0xA6, 0xA7, 0x03, 0xA8, 0xA9, 0xAA, 0xAB, 0x00, 0x00, 0xAC, 0x01 }, + [0x2D] = { 0x12, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0B, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x4D, 0x00, 0x04, 0x06, 0x00, 0x00, 0x10, 0xAD }, + [0x2E] = { 0x04, 0x22, 0x01, 0x01, 0x01, 0x08, 0x01, 0x01, 0x01, 0x01, 0x08, 0x00, 0x01, 0x01, 0x01, 0x0A, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x14, 0x01, 0x00, 0x0E, 0x04, 0x06, 0x01, 0x01, 0x04, 0xAE }, + [0x2F] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05, 0x00, 0x01, 0x07, 0x04, 0x06, 0x01, 0x01, 0x05, 0x10, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05, 0xAF, 0x00, 0x00, 0xB0, 0x01, 0x01, 0xB1, 0x00 }, [0x30] = { 0x2C, 0x2C, 0x2C, 0x00, 0x05, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x14, 0x01, 0x0D, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x08, 0x04, 0x06 }, [0x31] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0B, 0x00, 0x01, 0x01, 0x05, 0x18, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0B }, [0x32] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x07, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0D, 0x00, 0x00, 0x00, 0x00 }, - [0x33] = { 0x05, 0x00, 0x18, 0x15, 0x01, 0x0F, 0x05, 0x38, 0x54, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0D, 0x00, 0x00, 0x00, 0x18, 0x01, 0x01, 0x01, 0x01, 0x01 }, + [0x33] = { 0x05, 0x00, 0x18, 0x15, 0x01, 0x0F, 0x05, 0x38, 0x55, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0D, 0x00, 0x00, 0x00, 0x18, 0x01, 0x01, 0x01, 0x01, 0x01 }, [0x34] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x07, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x10, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0B }, [0x35] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0A }, - [0x36] = { 0x00, 0x00, 0x04, 0x06, 0x2D, 0x02, 0x02, 0x2E, 0x0C, 0x01, 0x01, 0x08, 0x21, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05, 0x10, 0x10, 0x10, 0x55, 0x00, 0x00, 0x00, 0x00 }, - [0x37] = { 0x01, 0x11, 0x01, 0x01, 0x05, 0x01, 0x01, 0xB0, 0x01, 0x07, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x08 }, + [0x36] = { 0x00, 0x00, 0x04, 0x06, 0x2D, 0x02, 0x02, 0x2E, 0x0C, 0x01, 0x01, 0x08, 0x21, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05, 0x10, 0x10, 0x10, 0x56, 0x00, 0x00, 0x00, 0x00 }, + [0x37] = { 0x01, 0x11, 0x01, 0x01, 0x05, 0x01, 0x01, 0xB2, 0x01, 0x07, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x08 }, [0x38] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, [0x39] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x0A, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x3A] = { 0x01, 0x01, 0x01, 0x01, 0x00, 0x15, 0x01, 0x01, 0x01, 0x08, 0x01, 0x01, 0x01, 0x01, 0x01, 0x08, 0x01, 0x01, 0x01, 0x07, 0x01, 0x01, 0x01, 0x01, 0x0B, 0x01, 0x3A, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x3B] = { 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x07, 0x04, 0x06, 0x02, 0x02, 0x02, 0x02, 0x50, 0x01, 0x01, 0x01, 0x01, 0x0B }, - [0x3C] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0B, 0x00, 0x02, 0x56, 0x02, 0x56, 0xB1, 0x01, 0x17, 0x01, 0x17, 0x34, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0B, 0x00 }, + [0x3A] = { 0x01, 0x01, 0x01, 0x01, 0x00, 0x15, 0x01, 0x01, 0x01, 0x08, 0x01, 0x01, 0x01, 0x01, 0x01, 0x08, 0x01, 0x01, 0x01, 0x07, 0x01, 0x01, 0x01, 0x01, 0x0B, 0x01, 0x3B, 0x00, 0x00, 0x00, 0x00, 0x00 }, + [0x3B] = { 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x07, 0x04, 0x06, 0x02, 0x02, 0x02, 0x02, 0x51, 0x01, 0x01, 0x01, 0x01, 0x0B }, + [0x3C] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0B, 0x00, 0x02, 0x57, 0x02, 0x57, 0xB3, 0x01, 0x17, 0x01, 0x17, 0x34, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0B, 0x00 }, [0x3D] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05, 0x00, 0x01, 0x01, 0x07, 0x00, 0x01, 0x00, 0x00, 0x00, 0x12, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0F, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x3E] = { 0x07, 0x0F, 0x01, 0x01, 0x01, 0x01, 0x12, 0xB2, 0x01, 0x01, 0x07, 0x00, 0x01, 0x01, 0x05, 0x00, 0x01, 0x01, 0x01, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x36, 0x00 }, + [0x3E] = { 0x07, 0x0F, 0x01, 0x01, 0x01, 0x01, 0x12, 0xB4, 0x01, 0x01, 0x07, 0x00, 0x01, 0x01, 0x05, 0x00, 0x01, 0x01, 0x01, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x36, 0x00 }, [0x3F] = { 0x01, 0x01, 0x07, 0x00, 0x01, 0x01, 0x01, 0x0D, 0x01, 0x01, 0x01, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, [0x40] = { 0x26, 0x1E, 0x11, 0x0C, 0x01, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x0A, 0x01, 0x01, 0x01, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0C, 0x01, 0x01, 0x0A, 0x00, 0x00, 0x00 }, [0x41] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x07, 0x00, 0x01, 0x01, 0x07, 0x00, 0x01, 0x01, 0x08, 0x00, 0x01, 0x01, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, [0x42] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x2E, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x08, 0x00 }, - [0x43] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x04, 0x06, 0x04, 0x22, 0x02, 0x02, 0x2B, 0xB3, 0x01, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x44] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x34, 0x0D, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55 }, + [0x43] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x04, 0x06, 0x04, 0x22, 0x27, 0x27, 0xB5, 0xB6, 0x01, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + [0x44] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x34, 0x0D, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x56 }, [0x45] = { 0x01, 0x01, 0x01, 0x0A, 0x0E, 0x00, 0x01, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x0A, 0x00, 0x00, 0x00, 0x01, 0x01, 0x05, 0x00 }, - [0x46] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x07, 0x00, 0x00, 0x00, 0x24, 0x04, 0x3A, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x09, 0x1C, 0x00, 0x01, 0x01, 0x01, 0x09, 0x04, 0x06 }, - [0x47] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0xB4, 0x04, 0x1E, 0x00, 0x01, 0x01, 0x01, 0x01, 0xB5, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x47, 0x21, 0x04, 0xB6, 0x00, 0x00, 0x00, 0x00 }, - [0x48] = { 0x01, 0x01, 0x17, 0x01, 0x01, 0x01, 0x16, 0x21, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0xB7, 0x01, 0x12, 0x01, 0x09, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x09, 0x04, 0x06 }, - [0x49] = { 0x11, 0x16, 0x1F, 0x01, 0x01, 0x0F, 0x33, 0x20, 0x16, 0x32, 0x49, 0x15, 0x0B, 0x00, 0x00, 0x00, 0x01, 0xB8, 0x01, 0x01, 0x01, 0x01, 0x12, 0x01, 0xB9, 0x36, 0x57, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x4A] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0xBA, 0x08, 0x04, 0xBB, 0x0D, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0xBC, 0x00, 0x04, 0x06, 0x00, 0x00, 0x00, 0x00 }, + [0x46] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x07, 0x00, 0x00, 0x00, 0x24, 0x04, 0x3B, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x09, 0x1C, 0x00, 0x01, 0x01, 0x01, 0x09, 0x04, 0x06 }, + [0x47] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0xB7, 0x04, 0x1E, 0x00, 0x01, 0x01, 0x01, 0x01, 0xB8, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x48, 0x21, 0x04, 0xB9, 0x00, 0x00, 0x00, 0x00 }, + [0x48] = { 0x01, 0x01, 0x17, 0x01, 0x01, 0x01, 0x16, 0x21, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0xBA, 0x01, 0x12, 0x01, 0x09, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x09, 0x04, 0x06 }, + [0x49] = { 0x11, 0x16, 0x1F, 0x01, 0x01, 0x0F, 0x33, 0x20, 0x16, 0x32, 0x4A, 0x15, 0x0B, 0x00, 0x00, 0x00, 0x01, 0xBB, 0x01, 0x01, 0x01, 0x01, 0x12, 0x01, 0xBC, 0x36, 0x58, 0x00, 0x00, 0x00, 0x00, 0x00 }, + [0x4A] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0xBD, 0x08, 0x04, 0xBE, 0x0D, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0xBF, 0x00, 0x04, 0x06, 0x00, 0x00, 0x00, 0x00 }, [0x4B] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x07, 0x05, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00 }, - [0x4C] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05, 0xBD, 0x00, 0x04, 0x06, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x07, 0x09, 0x04, 0x06, 0x04, 0x04, 0xBE, 0x00, 0x00, 0x00 }, + [0x4C] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05, 0xC0, 0x00, 0x04, 0x06, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x07, 0x09, 0x04, 0x06, 0x04, 0x04, 0xC1, 0x00, 0x00, 0x00 }, [0x4D] = { 0x01, 0x01, 0x01, 0x37, 0x01, 0x08, 0x04, 0x06, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, [0x4E] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x04, 0x06, 0x00, 0x0E }, - [0x4F] = { 0x05, 0xBF, 0x26, 0x01, 0x01, 0x01, 0x12, 0xC0, 0x08, 0x00, 0x04, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x01, 0x01, 0x01, 0x01, 0x01, 0x10, 0xC1, 0x00, 0x00, 0x00 }, + [0x4F] = { 0x05, 0xC2, 0x26, 0x01, 0x01, 0x01, 0x12, 0xC3, 0x08, 0x00, 0x04, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x01, 0x01, 0x01, 0x01, 0x01, 0x10, 0xC4, 0x00, 0x00, 0x00 }, [0x50] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x37, 0x05, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x1D, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x09 }, [0x51] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x09, 0x00, 0x04, 0x06 }, [0x52] = { 0x01, 0x0F, 0x01, 0x01, 0x01, 0x01, 0x05, 0x05, 0x09, 0x00, 0x04, 0x06, 0x00, 0x00, 0x10, 0x01, 0x01, 0x01, 0x10, 0x01, 0x01, 0x0C, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x53] = { 0x05, 0x17, 0x01, 0x01, 0x01, 0x01, 0x05, 0xC2, 0xC3, 0x00, 0x04, 0x06, 0x12, 0x0F, 0x01, 0x01, 0x01, 0x05, 0xC4, 0x09, 0x04, 0x06, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0B, 0x04, 0x06, 0x00, 0x00 }, + [0x53] = { 0x05, 0x17, 0x01, 0x01, 0x01, 0x01, 0x05, 0xC5, 0xC6, 0x00, 0x04, 0x06, 0x12, 0x0F, 0x01, 0x01, 0x01, 0x05, 0xC7, 0x09, 0x04, 0x06, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0B, 0x04, 0x06, 0x00, 0x00 }, [0x54] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x05, 0x00 }, [0x55] = { 0x01, 0x01, 0x0F, 0x01, 0x01, 0x01, 0x01, 0x25, 0x09, 0x00, 0x04, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, [0x56] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, @@ -174,30 +175,30 @@ static const uint8_t pm_unicode_middle[129][32] = { [0x5E] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x09, 0x01, 0x01, 0x01, 0x05, 0x04, 0x06, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05, 0x04, 0x06, 0x01, 0x01, 0x01, 0x07, 0x00, 0x00 }, [0x5F] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x0B, 0x00, 0x04, 0x06, 0x18, 0x01, 0x01, 0x15, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, [0x60] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0A, 0x04, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x61] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0xC5, 0x01, 0x01, 0x0B, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x62] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x2A, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0E, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC6, 0x00, 0x05, 0x00 }, + [0x61] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x27, 0x27, 0x27, 0xC8, 0x01, 0x01, 0x0B, 0x00, 0x00, 0x00, 0x00, 0x00 }, + [0x62] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x2B, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0E, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC9, 0x00, 0x05, 0x00 }, [0x63] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x0E }, [0x64] = { 0x01, 0x01, 0x01, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x08, 0x00 }, [0x65] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x26 }, - [0x66] = { 0x01, 0x01, 0x01, 0x01, 0x08, 0x00, 0x1C, 0x00, 0x00, 0x00, 0xC7, 0x00, 0x1E, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }, + [0x66] = { 0x01, 0x01, 0x01, 0x01, 0x08, 0x00, 0x1C, 0x00, 0x00, 0x00, 0xCA, 0x00, 0x1E, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }, [0x67] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0B }, - [0x68] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x08, 0x01, 0x0A, 0x01, 0x09, 0x01, 0x51, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x69] = { 0x02, 0x02, 0x02, 0x1B, 0x01, 0x01, 0x27, 0x02, 0x02, 0x28, 0x13, 0x01, 0x01, 0x02, 0x02, 0x02, 0x1B, 0x01, 0x01, 0xC8, 0xC9, 0xCA, 0x28, 0xCB, 0x11, 0x01, 0x02, 0x02, 0x02, 0x1B, 0x01, 0x01 }, - [0x6A] = { 0xCC, 0x4E, 0xCD, 0x58, 0x01, 0x01, 0x01, 0xCE, 0xCF, 0xD0, 0x3B, 0x01, 0x01, 0x27, 0x02, 0x02, 0x28, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x1B, 0x01, 0x01, 0x27, 0x02, 0x02, 0x28, 0x01, 0x01 }, - [0x6B] = { 0x01, 0x02, 0x02, 0x02, 0x1B, 0x01, 0x01, 0x27, 0x02, 0x02, 0x28, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x1B, 0x01, 0x01, 0x07, 0x02, 0x02, 0x02, 0x3B, 0x01, 0x01, 0x14, 0xD1, 0x02, 0x02, 0xD2 }, - [0x6C] = { 0x01, 0x01, 0x13, 0x27, 0x02, 0x02, 0x58, 0x01, 0x01, 0x05, 0x52, 0x02, 0x02, 0x2F, 0x01, 0x01, 0x01, 0x0F, 0x02, 0x02, 0x02, 0x3B, 0x01, 0x01, 0x14, 0xD3, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04 }, + [0x68] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x08, 0x01, 0x0A, 0x01, 0x09, 0x01, 0x52, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + [0x69] = { 0x02, 0x02, 0x02, 0x1B, 0x01, 0x01, 0x28, 0x02, 0x02, 0x29, 0x13, 0x01, 0x01, 0x02, 0x02, 0x02, 0x1B, 0x01, 0x01, 0xCB, 0xCC, 0xCD, 0x29, 0xCE, 0x11, 0x01, 0x02, 0x02, 0x02, 0x1B, 0x01, 0x01 }, + [0x6A] = { 0xCF, 0x4F, 0xD0, 0x59, 0x01, 0x01, 0x01, 0xD1, 0xD2, 0xD3, 0x3C, 0x01, 0x01, 0x28, 0x02, 0x02, 0x29, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x1B, 0x01, 0x01, 0x28, 0x02, 0x02, 0x29, 0x01, 0x01 }, + [0x6B] = { 0x01, 0x02, 0x02, 0x02, 0x1B, 0x01, 0x01, 0x28, 0x02, 0x02, 0x29, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x1B, 0x01, 0x01, 0x07, 0x02, 0x02, 0x02, 0x3C, 0x01, 0x01, 0x14, 0xD4, 0x02, 0x02, 0xD5 }, + [0x6C] = { 0x01, 0x01, 0x13, 0x28, 0x02, 0x02, 0x59, 0x01, 0x01, 0x05, 0x53, 0x02, 0x02, 0x2F, 0x01, 0x01, 0x01, 0x0F, 0x02, 0x02, 0x02, 0x3C, 0x01, 0x01, 0x14, 0xD6, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04 }, [0x6D] = { 0x01, 0x01, 0x01, 0x05, 0x15, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x6E] = { 0x05, 0x01, 0x01, 0x1F, 0x54, 0x08, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x07, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x6F] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x0A, 0x0E, 0x07, 0x04, 0xD4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + [0x6E] = { 0x05, 0x01, 0x01, 0x1F, 0x55, 0x08, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x07, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + [0x6F] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x0A, 0x0E, 0x07, 0x04, 0xD7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, [0x70] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x07, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0B, 0x04, 0x06 }, [0x71] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x0B, 0x04, 0x06 }, - [0x72] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x07, 0xD5, 0xD6 }, + [0x72] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x07, 0xD8, 0xD9 }, [0x73] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x05, 0x01, 0x01, 0x07, 0x21 }, [0x74] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x26, 0x01, 0x05 }, [0x75] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x76] = { 0x02, 0x02, 0x02, 0x02, 0x1B, 0x01, 0x01, 0x01, 0x53, 0xD7, 0x04, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x77] = { 0x11, 0x01, 0x01, 0x01, 0x3C, 0x0C, 0x14, 0x57, 0xD8, 0xD9, 0x3C, 0xDA, 0x3C, 0x14, 0x14, 0x46, 0x01, 0x17, 0x01, 0x0B, 0x23, 0x17, 0x01, 0x0B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x78] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x3D, 0x02, 0x02, 0x02, 0x3D, 0x02, 0x02, 0x02, 0x3D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + [0x76] = { 0x02, 0x02, 0x02, 0x02, 0x1B, 0x01, 0x01, 0x01, 0x54, 0xDA, 0x04, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + [0x77] = { 0x11, 0x01, 0x01, 0x01, 0x3D, 0x0C, 0x14, 0x58, 0xDB, 0xDC, 0x3D, 0xDD, 0x3D, 0x14, 0x14, 0x47, 0x01, 0x17, 0x01, 0x0B, 0x23, 0x17, 0x01, 0x0B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + [0x78] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x3E, 0x02, 0x02, 0x02, 0x3E, 0x02, 0x02, 0x02, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, [0x79] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00 }, [0x7A] = { 0x01, 0x01, 0x01, 0x07, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }, [0x7B] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x07, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }, @@ -208,6 +209,22 @@ static const uint8_t pm_unicode_middle[129][32] = { [0x80] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, }; +/** + * The version of Ruby that updated its version of Unicode to 17.0.0. + * + * * Ruby 3.3 and 3.4 use Unicode 15.0.0. + * * Ruby 4.0 and 4.1 use Unicode 17.0.0. + */ +#define PM_UNICODE_TABLES_17_UPDATE PM_OPTIONS_VERSION_CRUBY_4_0 + +/** + * The unicode tables use the fourth bit of each property byte to mark the + * letters that are uppercase or titlecase in the tables but not in Unicode + * 15.0.0, which the versions of Ruby before PM_UNICODE_TABLES_17_UPDATE + * use. + */ +#define PM_UNICODE_15_NOT_UPPERCASE_BIT (1 << 3) + /* No properties. */ #define N 0 @@ -220,7 +237,10 @@ static const uint8_t pm_unicode_middle[129][32] = { /* An uppercase or titlecase letter: alphabetic, alphanumeric, and uppercase. */ #define U (PRISM_ENCODING_ALPHABETIC_BIT | PRISM_ENCODING_ALPHANUMERIC_BIT | PRISM_ENCODING_UPPERCASE_BIT) -static const uint8_t pm_unicode_leaf[219][8] = { +/* An uppercase or titlecase letter that is not one in Unicode 15.0.0. */ +#define V (PRISM_ENCODING_ALPHABETIC_BIT | PRISM_ENCODING_ALPHANUMERIC_BIT | PRISM_ENCODING_UPPERCASE_BIT | PM_UNICODE_15_NOT_UPPERCASE_BIT) + +static const uint8_t pm_unicode_leaf[222][8] = { [0x00] = { N, N, N, N, N, N, N, N }, [0x01] = { A, A, A, A, A, A, A, A }, [0x02] = { U, U, U, U, U, U, U, U }, @@ -260,11 +280,11 @@ static const uint8_t pm_unicode_leaf[219][8] = { [0x24] = { N, N, N, N, N, N, D, D }, [0x25] = { A, A, A, N, N, N, A, A }, [0x26] = { A, A, A, A, N, A, A, N }, - [0x27] = { A, A, A, A, U, U, U, U }, - [0x28] = { U, U, U, U, U, U, A, A }, - [0x29] = { N, A, N, N, N, N, N, N }, - [0x2A] = { A, A, A, N, N, N, N, A }, - [0x2B] = { U, U, U, U, U, U, N, N }, + [0x27] = { V, V, V, V, V, V, V, V }, + [0x28] = { A, A, A, A, U, U, U, U }, + [0x29] = { U, U, U, U, U, U, A, A }, + [0x2A] = { N, A, N, N, N, N, N, N }, + [0x2B] = { A, A, A, N, N, N, N, A }, [0x2C] = { N, A, A, A, A, A, A, N }, [0x2D] = { N, U, U, U, U, U, U, U }, [0x2E] = { U, U, U, N, N, N, N, N }, @@ -278,174 +298,178 @@ static const uint8_t pm_unicode_leaf[219][8] = { [0x36] = { A, A, A, N, A, A, N, N }, [0x37] = { A, A, A, N, N, A, A, A }, [0x38] = { A, A, A, A, A, N, A, N }, - [0x39] = { U, U, U, U, U, N, N, N }, - [0x3A] = { N, A, A, A, A, A, N, N }, - [0x3B] = { U, N, A, A, A, A, A, A }, - [0x3C] = { N, A, A, N, A, N, N, A }, - [0x3D] = { U, U, N, N, N, N, N, N }, - [0x3E] = { A, A, U, A, U, A, U, A }, - [0x3F] = { A, U, U, A, U, A, U, U }, - [0x40] = { U, A, U, A, A, A, A, A }, - [0x41] = { U, U, U, U, A, A, A, A }, - [0x42] = { N, N, U, A, U, A, U, A }, - [0x43] = { A, N, N, N, N, A, A, A }, - [0x44] = { N, N, N, N, A, A, N, A }, - [0x45] = { N, N, N, N, A, N, N, N }, - [0x46] = { N, A, A, A, A, N, A, N }, - [0x47] = { N, A, A, A, A, N, N, N }, - [0x48] = { N, A, A, N, A, N, A, A }, - [0x49] = { A, N, N, N, N, N, N, A }, - [0x4A] = { N, N, N, N, N, A, A, N }, - [0x4B] = { N, N, N, N, A, A, A, N }, - [0x4C] = { A, A, A, A, N, A, N, N }, - [0x4D] = { A, A, A, A, N, N, A, A }, - [0x4E] = { U, U, U, N, N, U, U, U }, - [0x4F] = { N, N, A, A, A, N, A, A }, - [0x50] = { U, U, U, U, N, N, N, N }, - [0x51] = { A, A, N, N, N, N, A, N }, - [0x52] = { A, A, A, A, A, A, U, U }, - [0x53] = { A, A, A, A, N, N, N, A }, - [0x54] = { A, A, N, A, A, N, A, A }, - [0x55] = { N, N, A, A, A, N, N, N }, - [0x56] = { U, U, U, N, U, U, U, U }, - [0x57] = { N, A, N, A, N, N, N, N }, - [0x58] = { U, U, U, U, U, N, A, A }, - [0x59] = { U, U, U, U, U, U, U, A }, - [0x5A] = { U, U, A, U, A, U, A, A }, - [0x5B] = { A, U, U, U, A, A, U, U }, - [0x5C] = { U, U, A, U, U, A, U, U }, - [0x5D] = { U, A, A, A, U, U, A, U }, - [0x5E] = { U, A, U, A, U, A, U, U }, - [0x5F] = { A, U, A, A, U, A, U, U }, - [0x60] = { A, U, U, U, A, U, A, U }, - [0x61] = { U, A, A, A, U, A, A, A }, - [0x62] = { A, A, A, A, U, U, A, U }, - [0x63] = { U, A, U, U, A, U, A, U }, - [0x64] = { A, U, A, U, A, A, U, A }, - [0x65] = { A, A, U, U, A, U, U, A }, - [0x66] = { A, U, A, U, U, U, U, A }, - [0x67] = { N, N, N, N, A, N, A, N }, - [0x68] = { U, A, U, A, A, N, U, A }, - [0x69] = { N, N, A, A, A, A, N, U }, - [0x6A] = { N, N, N, N, N, N, U, N }, - [0x6B] = { U, U, U, N, U, N, U, U }, - [0x6C] = { A, U, U, U, U, U, U, U }, - [0x6D] = { U, U, N, U, U, U, U, U }, - [0x6E] = { A, A, A, A, A, A, A, U }, - [0x6F] = { A, A, U, U, U, A, A, A }, - [0x70] = { A, A, A, A, U, A, N, U }, - [0x71] = { A, U, U, A, A, U, U, U }, - [0x72] = { U, A, N, N, N, N, N, N }, - [0x73] = { U, U, A, U, A, U, A, U }, - [0x74] = { A, U, A, U, A, U, A, A }, - [0x75] = { N, A, A, N, A, A, N, A }, - [0x76] = { D, D, N, N, N, N, A, A }, - [0x77] = { D, D, A, A, A, N, N, A }, - [0x78] = { N, N, N, N, A, A, N, N }, - [0x79] = { A, N, A, N, N, N, A, A }, - [0x7A] = { A, N, N, A, A, N, A, N }, - [0x7B] = { A, N, A, A, N, A, A, N }, - [0x7C] = { N, N, A, A, N, A, A, A }, - [0x7D] = { N, N, N, A, A, N, N, N }, - [0x7E] = { N, A, A, A, N, N, N, N }, - [0x7F] = { A, N, A, A, A, N, A, N }, - [0x80] = { N, N, A, A, N, N, N, N }, - [0x81] = { A, A, A, A, N, A, N, A }, - [0x82] = { A, A, N, A, A, A, N, N }, - [0x83] = { D, D, N, N, A, A, A, A }, - [0x84] = { D, D, A, A, A, A, N, N }, - [0x85] = { U, U, U, U, U, U, N, U }, - [0x86] = { N, N, N, N, N, U, N, N }, - [0x87] = { A, N, A, A, N, N, N, N }, - [0x88] = { A, A, N, N, A, A, A, A }, - [0x89] = { D, D, N, N, N, A, A, A }, - [0x8A] = { A, U, A, N, N, N, N, N }, - [0x8B] = { N, A, A, A, A, N, A, A }, - [0x8C] = { U, A, U, A, U, A, A, A }, - [0x8D] = { A, A, A, A, A, A, U, A }, - [0x8E] = { N, U, N, U, N, U, N, U }, - [0x8F] = { U, U, U, U, U, N, A, N }, - [0x90] = { N, N, U, N, N, N, N, U }, - [0x91] = { N, N, A, U, U, U, A, A }, - [0x92] = { U, U, U, A, N, U, N, N }, - [0x93] = { N, U, U, U, U, U, N, N }, - [0x94] = { N, N, N, N, U, N, U, N }, - [0x95] = { U, N, U, U, U, U, N, A }, - [0x96] = { A, A, N, N, A, A, U, U }, - [0x97] = { N, N, N, N, N, U, A, A }, - [0x98] = { A, A, A, U, A, A, A, A }, - [0x99] = { N, N, N, N, N, N, U, U }, - [0x9A] = { U, A, U, U, U, A, A, U }, - [0x9B] = { A, U, A, U, A, U, U, U }, - [0x9C] = { U, A, U, A, A, U, A, A }, - [0x9D] = { U, A, U, A, A, N, N, N }, - [0x9E] = { N, N, N, U, A, U, A, N }, - [0x9F] = { N, N, U, A, N, N, N, N }, - [0xA0] = { D, D, A, A, N, N, N, N }, - [0xA1] = { U, A, U, A, U, A, A, N }, - [0xA2] = { A, U, A, U, A, U, U, A }, - [0xA3] = { A, N, N, U, A, U, A, A }, - [0xA4] = { U, A, U, A, A, A, U, A }, - [0xA5] = { U, A, U, U, U, U, U, A }, - [0xA6] = { U, U, U, U, U, A, U, A }, - [0xA7] = { U, A, U, A, U, U, U, U }, - [0xA8] = { A, U, A, U, U, A, U, A }, - [0xA9] = { U, A, U, A, U, N, N, N }, - [0xAA] = { N, A, A, A, A, U, A, A }, - [0xAB] = { N, N, N, A, N, A, A, A }, - [0xAC] = { D, D, A, A, A, A, A, N }, - [0xAD] = { A, N, A, N, N, N, N, N }, - [0xAE] = { N, N, N, A, A, A, N, N }, - [0xAF] = { N, N, A, A, A, A, N, N }, - [0xB0] = { A, A, A, N, A, A, N, A }, - [0xB1] = { U, U, U, N, U, U, N, A }, - [0xB2] = { A, N, N, N, A, N, N, A }, - [0xB3] = { N, A, N, N, N, N, N, A }, - [0xB4] = { A, A, A, N, N, N, D, D }, - [0xB5] = { A, A, A, N, N, N, A, N }, - [0xB6] = { D, D, A, N, A, N, N, N }, - [0xB7] = { A, N, A, A, A, A, N, A }, - [0xB8] = { A, A, N, A, N, N, A, N }, - [0xB9] = { A, N, A, N, N, A, N, A }, - [0xBA] = { A, A, N, A, A, A, N, A }, - [0xBB] = { D, D, N, N, N, N, N, A }, - [0xBC] = { A, A, N, N, A, A, N, A }, - [0xBD] = { A, N, N, N, A, N, N, N }, - [0xBE] = { D, D, D, D, N, N, N, N }, - [0xBF] = { N, A, N, N, A, A, A, A }, - [0xC0] = { A, N, N, A, A, N, N, A }, - [0xC1] = { N, A, N, A, A, N, N, N }, - [0xC2] = { N, N, A, N, A, A, N, A }, - [0xC3] = { A, A, N, A, N, N, A, A }, - [0xC4] = { A, A, N, A, A, A, A, N }, - [0xC5] = { U, N, N, A, A, A, A, A }, - [0xC6] = { A, A, N, A, N, N, N, N }, - [0xC7] = { A, A, A, N, N, A, N, N }, - [0xC8] = { A, A, A, A, U, N, U, U }, - [0xC9] = { N, N, U, N, N, U, U, N }, - [0xCA] = { N, U, U, U, U, N, U, U }, - [0xCB] = { A, A, N, A, N, A, A, A }, - [0xCC] = { A, A, A, A, U, U, N, U }, - [0xCD] = { U, U, U, U, U, N, U, U }, - [0xCE] = { U, U, N, U, U, U, U, N }, - [0xCF] = { U, U, U, U, U, N, U, N }, - [0xD0] = { N, N, U, U, U, U, U, U }, - [0xD1] = { A, A, U, U, U, U, U, U }, - [0xD2] = { U, U, U, N, A, A, A, A }, - [0xD3] = { A, A, U, A, N, N, D, D }, - [0xD4] = { D, D, N, N, N, N, A, N }, - [0xD5] = { A, D, D, D, D, D, D, D }, - [0xD6] = { D, D, D, N, N, N, N, N }, - [0xD7] = { N, N, N, A, N, N, N, N }, - [0xD8] = { N, N, A, N, N, N, N, A }, - [0xD9] = { N, A, N, A, N, A, A, A }, - [0xDA] = { N, A, N, A, N, A, N, A }, + [0x39] = { U, U, U, U, U, U, N, N }, + [0x3A] = { U, U, U, U, U, N, N, N }, + [0x3B] = { N, A, A, A, A, A, N, N }, + [0x3C] = { U, N, A, A, A, A, A, A }, + [0x3D] = { N, A, A, N, A, N, N, A }, + [0x3E] = { U, U, N, N, N, N, N, N }, + [0x3F] = { A, A, U, A, U, A, U, A }, + [0x40] = { A, U, U, A, U, A, U, U }, + [0x41] = { U, A, U, A, A, A, A, A }, + [0x42] = { U, U, U, U, A, A, A, A }, + [0x43] = { N, N, U, A, U, A, U, A }, + [0x44] = { A, N, N, N, N, A, A, A }, + [0x45] = { N, N, N, N, A, A, N, A }, + [0x46] = { N, N, N, N, A, N, N, N }, + [0x47] = { N, A, A, A, A, N, A, N }, + [0x48] = { N, A, A, A, A, N, N, N }, + [0x49] = { N, A, A, N, A, N, A, A }, + [0x4A] = { A, N, N, N, N, N, N, A }, + [0x4B] = { N, N, N, N, N, A, A, N }, + [0x4C] = { N, N, N, N, A, A, A, N }, + [0x4D] = { A, A, A, A, N, A, N, N }, + [0x4E] = { A, A, A, A, N, N, A, A }, + [0x4F] = { U, U, U, N, N, U, U, U }, + [0x50] = { N, N, A, A, A, N, A, A }, + [0x51] = { U, U, U, U, N, N, N, N }, + [0x52] = { A, A, N, N, N, N, A, N }, + [0x53] = { A, A, A, A, A, A, U, U }, + [0x54] = { A, A, A, A, N, N, N, A }, + [0x55] = { A, A, N, A, A, N, A, A }, + [0x56] = { N, N, A, A, A, N, N, N }, + [0x57] = { U, U, U, N, U, U, U, U }, + [0x58] = { N, A, N, A, N, N, N, N }, + [0x59] = { U, U, U, U, U, N, A, A }, + [0x5A] = { U, U, U, U, U, U, U, A }, + [0x5B] = { U, U, A, U, A, U, A, A }, + [0x5C] = { A, U, U, U, A, A, U, U }, + [0x5D] = { U, U, A, U, U, A, U, U }, + [0x5E] = { U, A, A, A, U, U, A, U }, + [0x5F] = { U, A, U, A, U, A, U, U }, + [0x60] = { A, U, A, A, U, A, U, U }, + [0x61] = { A, U, U, U, A, U, A, U }, + [0x62] = { U, A, A, A, U, A, A, A }, + [0x63] = { A, A, A, A, U, U, A, U }, + [0x64] = { U, A, U, U, A, U, A, U }, + [0x65] = { A, U, A, U, A, A, U, A }, + [0x66] = { A, A, U, U, A, U, U, A }, + [0x67] = { A, U, A, U, U, U, U, A }, + [0x68] = { N, N, N, N, A, N, A, N }, + [0x69] = { U, A, U, A, A, N, U, A }, + [0x6A] = { N, N, A, A, A, A, N, U }, + [0x6B] = { N, N, N, N, N, N, U, N }, + [0x6C] = { U, U, U, N, U, N, U, U }, + [0x6D] = { A, U, U, U, U, U, U, U }, + [0x6E] = { U, U, N, U, U, U, U, U }, + [0x6F] = { A, A, A, A, A, A, A, U }, + [0x70] = { A, A, U, U, U, A, A, A }, + [0x71] = { A, A, A, A, U, A, N, U }, + [0x72] = { A, U, U, A, A, U, U, U }, + [0x73] = { U, A, N, N, N, N, N, N }, + [0x74] = { U, U, A, U, A, U, A, U }, + [0x75] = { A, U, A, U, A, U, A, A }, + [0x76] = { N, A, A, N, A, A, N, A }, + [0x77] = { D, D, N, N, N, N, A, A }, + [0x78] = { D, D, A, A, A, N, N, A }, + [0x79] = { N, N, N, N, A, A, N, N }, + [0x7A] = { A, N, A, N, N, N, A, A }, + [0x7B] = { A, N, N, A, A, N, A, N }, + [0x7C] = { A, N, A, A, N, A, A, N }, + [0x7D] = { N, N, A, A, N, A, A, A }, + [0x7E] = { N, N, N, A, A, N, N, N }, + [0x7F] = { N, A, A, A, N, N, N, N }, + [0x80] = { A, N, A, A, A, N, A, N }, + [0x81] = { N, N, A, A, N, N, N, N }, + [0x82] = { A, A, A, A, N, A, N, A }, + [0x83] = { A, A, N, A, A, A, N, N }, + [0x84] = { D, D, N, N, A, A, A, A }, + [0x85] = { D, D, A, A, A, A, N, N }, + [0x86] = { U, U, U, U, U, U, N, U }, + [0x87] = { N, N, N, N, N, U, N, N }, + [0x88] = { A, N, A, A, N, N, N, N }, + [0x89] = { A, A, N, N, A, A, A, A }, + [0x8A] = { D, D, N, N, N, A, A, A }, + [0x8B] = { A, V, A, N, N, N, N, N }, + [0x8C] = { N, A, A, A, A, N, A, A }, + [0x8D] = { U, A, U, A, U, A, A, A }, + [0x8E] = { A, A, A, A, A, A, U, A }, + [0x8F] = { N, U, N, U, N, U, N, U }, + [0x90] = { U, U, U, U, U, N, A, N }, + [0x91] = { N, N, U, N, N, N, N, U }, + [0x92] = { N, N, A, U, U, U, A, A }, + [0x93] = { U, U, U, A, N, U, N, N }, + [0x94] = { N, U, U, U, U, U, N, N }, + [0x95] = { N, N, N, N, U, N, U, N }, + [0x96] = { U, N, U, U, U, U, N, A }, + [0x97] = { A, A, N, N, A, A, U, U }, + [0x98] = { N, N, N, N, N, U, A, A }, + [0x99] = { A, A, A, U, A, A, A, A }, + [0x9A] = { N, N, N, N, N, N, U, U }, + [0x9B] = { U, A, U, U, U, A, A, U }, + [0x9C] = { A, U, A, U, A, U, U, U }, + [0x9D] = { U, A, U, A, A, U, A, A }, + [0x9E] = { U, A, U, A, A, N, N, N }, + [0x9F] = { N, N, N, U, A, U, A, N }, + [0xA0] = { N, N, U, A, N, N, N, N }, + [0xA1] = { D, D, A, A, N, N, N, N }, + [0xA2] = { U, A, U, A, U, A, A, N }, + [0xA3] = { A, U, A, U, A, U, U, A }, + [0xA4] = { A, N, N, U, A, U, A, A }, + [0xA5] = { U, A, U, A, A, A, U, A }, + [0xA6] = { U, A, U, U, U, U, U, A }, + [0xA7] = { U, U, U, U, U, A, U, A }, + [0xA8] = { U, A, U, A, U, U, U, U }, + [0xA9] = { A, U, A, V, V, A, V, A }, + [0xAA] = { U, A, V, A, V, A, U, A }, + [0xAB] = { U, A, V, A, V, N, N, N }, + [0xAC] = { N, A, A, A, A, U, A, A }, + [0xAD] = { N, N, N, A, N, A, A, A }, + [0xAE] = { D, D, A, A, A, A, A, N }, + [0xAF] = { A, N, A, N, N, N, N, N }, + [0xB0] = { N, N, N, A, A, A, N, N }, + [0xB1] = { N, N, A, A, A, A, N, N }, + [0xB2] = { A, A, A, N, A, A, N, A }, + [0xB3] = { U, U, U, N, U, U, N, A }, + [0xB4] = { A, N, N, N, A, N, N, A }, + [0xB5] = { V, V, V, V, V, V, N, N }, + [0xB6] = { N, A, N, N, N, N, N, A }, + [0xB7] = { A, A, A, N, N, N, D, D }, + [0xB8] = { A, A, A, N, N, N, A, N }, + [0xB9] = { D, D, A, N, A, N, N, N }, + [0xBA] = { A, N, A, A, A, A, N, A }, + [0xBB] = { A, A, N, A, N, N, A, N }, + [0xBC] = { A, N, A, N, N, A, N, A }, + [0xBD] = { A, A, N, A, A, A, N, A }, + [0xBE] = { D, D, N, N, N, N, N, A }, + [0xBF] = { A, A, N, N, A, A, N, A }, + [0xC0] = { A, N, N, N, A, N, N, N }, + [0xC1] = { D, D, D, D, N, N, N, N }, + [0xC2] = { N, A, N, N, A, A, A, A }, + [0xC3] = { A, N, N, A, A, N, N, A }, + [0xC4] = { N, A, N, A, A, N, N, N }, + [0xC5] = { N, N, A, N, A, A, N, A }, + [0xC6] = { A, A, N, A, N, N, A, A }, + [0xC7] = { A, A, N, A, A, A, A, N }, + [0xC8] = { V, N, N, A, A, A, A, A }, + [0xC9] = { A, A, N, A, N, N, N, N }, + [0xCA] = { A, A, A, N, N, A, N, N }, + [0xCB] = { A, A, A, A, U, N, U, U }, + [0xCC] = { N, N, U, N, N, U, U, N }, + [0xCD] = { N, U, U, U, U, N, U, U }, + [0xCE] = { A, A, N, A, N, A, A, A }, + [0xCF] = { A, A, A, A, U, U, N, U }, + [0xD0] = { U, U, U, U, U, N, U, U }, + [0xD1] = { U, U, N, U, U, U, U, N }, + [0xD2] = { U, U, U, U, U, N, U, N }, + [0xD3] = { N, N, U, U, U, U, U, U }, + [0xD4] = { A, A, U, U, U, U, U, U }, + [0xD5] = { U, U, U, N, A, A, A, A }, + [0xD6] = { A, A, U, A, N, N, D, D }, + [0xD7] = { D, D, N, N, N, N, A, N }, + [0xD8] = { A, D, D, D, D, D, D, D }, + [0xD9] = { D, D, D, N, N, N, N, N }, + [0xDA] = { N, N, N, A, N, N, N, N }, + [0xDB] = { N, N, A, N, N, N, N, A }, + [0xDC] = { N, A, N, A, N, A, A, A }, + [0xDD] = { N, A, N, A, N, A, N, A }, }; #undef N #undef D #undef A #undef U +#undef V /** * Each element of the following table contains a bitfield that indicates a @@ -486,6 +510,25 @@ pm_unicode_codepoint_properties(pm_unicode_codepoint_t codepoint) { return pm_unicode_leaf[leaf][codepoint & 0x7]; } +/** + * Return true if the code point is uppercase, or titlecase, in the version of + * Unicode of the given version of Ruby. + */ +static bool +pm_unicode_uppercase_p(pm_unicode_codepoint_t codepoint, pm_options_version_t version) { + uint8_t properties = pm_unicode_codepoint_properties(codepoint); + bool uppercase = (properties & PRISM_ENCODING_UPPERCASE_BIT) != 0; + + /* The tables say if it is an uppercase codepoint in the latest version of + * Unicode that Ruby uses. If we are parsing as an older version, then we + * need to exclude more recently added codepoint ranges. */ + if (PRISM_UNLIKELY(version < PM_UNICODE_TABLES_17_UPDATE && (properties & PM_UNICODE_15_NOT_UPPERCASE_BIT))) { + uppercase = false; + } + + return uppercase; +} + /** * A state transition table for decoding UTF-8. * @@ -617,11 +660,11 @@ pm_encoding_utf_8_alnum_char(const uint8_t *b, ptrdiff_t n) { } /** - * Return true if the next character in the UTF-8 encoding if it is an uppercase - * character. + * Return true if the next character in the UTF-8 encoding is uppercase, or + * titlecase, in the given version of Ruby. */ bool -pm_encoding_utf_8_isupper_char(const uint8_t *b, ptrdiff_t n) { +pm_encoding_utf_8_isupper_char(const uint8_t *b, ptrdiff_t n, pm_options_version_t version) { if (n == 0) { return 0; } @@ -633,7 +676,7 @@ pm_encoding_utf_8_isupper_char(const uint8_t *b, ptrdiff_t n) { size_t width; pm_unicode_codepoint_t codepoint = pm_utf_8_codepoint(b, n, &width); - return (pm_unicode_codepoint_properties(codepoint) & PRISM_ENCODING_UPPERCASE_BIT) ? true : false; + return pm_unicode_uppercase_p(codepoint, version); } #ifndef PRISM_ENCODING_EXCLUDE_FULL @@ -1583,7 +1626,7 @@ pm_encoding_property_char(const pm_encoding_t *encoding, uint8_t property, const case PRISM_ENCODING_ALPHANUMERIC_BIT: return pm_encoding_utf_8_alnum_char(b, n); default: - return pm_encoding_utf_8_isupper_char(b, n) ? pm_encoding_utf_8_char_width(b, n) : 0; + return pm_encoding_utf_8_isupper_char(b, n, PM_OPTIONS_VERSION_LATEST) ? pm_encoding_utf_8_char_width(b, n) : 0; } case PM_ENCODING_KIND_ASCII: case PM_ENCODING_KIND_SINGLE_BYTE: @@ -1618,6 +1661,27 @@ pm_encoding_property_char(const pm_encoding_t *encoding, uint8_t property, const } } +/** + * Return true if the next character in the given encoding is uppercase, or + * titlecase, in the given version of Ruby. The answer depends on the version + * only in an encoding whose characters are Unicode code points. + */ +bool +pm_encoding_isupper_char(const pm_encoding_t *encoding, const uint8_t *b, ptrdiff_t n, pm_options_version_t version) { + switch (encoding->kind) { + case PM_ENCODING_KIND_UTF_8: + return pm_encoding_utf_8_isupper_char(b, n, version); +#ifndef PRISM_ENCODING_EXCLUDE_FULL + case PM_ENCODING_KIND_CESU_8: { + size_t width = pm_encoding_cesu_8_char_width(b, n); + return width != 0 && pm_unicode_uppercase_p(pm_cesu_8_codepoint(b, width), version); + } +#endif + default: + return pm_encoding_property_char(encoding, PRISM_ENCODING_UPPERCASE_BIT, b, n) != 0; + } +} + #undef PM_ENCODING_ALNUM #undef PM_ENCODING_FORMS_PROPERTY_CHAR #undef PM_ENCODING_FORMS_CHAR_WIDTH diff --git a/src/prism.c b/src/prism.c index b0baad56a5..338289a1c5 100644 --- a/src/prism.c +++ b/src/prism.c @@ -8736,7 +8736,7 @@ lex_identifier(pm_parser_t *parser, bool previous_command_start) { } if (encoding_changed) { - return pm_encoding_isupper_char(parser->encoding, current_start, end - current_start) ? PM_TOKEN_CONSTANT : PM_TOKEN_IDENTIFIER; + return pm_encoding_isupper_char(parser->encoding, current_start, end - current_start, parser->version) ? PM_TOKEN_CONSTANT : PM_TOKEN_IDENTIFIER; } /* Identifiers usually start with an ASCII byte, for which the uppercase @@ -8745,7 +8745,7 @@ lex_identifier(pm_parser_t *parser, bool previous_command_start) { if (*current_start < 0x80) { return (*current_start >= 'A' && *current_start <= 'Z') ? PM_TOKEN_CONSTANT : PM_TOKEN_IDENTIFIER; } - return pm_encoding_utf_8_isupper_char(current_start, end - current_start) ? PM_TOKEN_CONSTANT : PM_TOKEN_IDENTIFIER; + return pm_encoding_utf_8_isupper_char(current_start, end - current_start, parser->version) ? PM_TOKEN_CONSTANT : PM_TOKEN_IDENTIFIER; } /** @@ -14009,7 +14009,7 @@ parse_assocs(pm_parser_t *parser, pm_static_literals_t *literals, pm_node_t *nod if (token_begins_expression_p(parser->current.type)) { value = parse_value_expression(parser, PM_BINDING_POWER_DEFINED, PM_PARSE_ACCEPTS_DO_BLOCK, PM_ERR_HASH_EXPRESSION_AFTER_LABEL, (uint16_t) (depth + 1)); } else { - if (pm_encoding_isupper_char(parser->encoding, label.start, (label.end - 1) - label.start)) { + if (pm_encoding_isupper_char(parser->encoding, label.start, (label.end - 1) - label.start, parser->version)) { pm_token_t constant = { .type = PM_TOKEN_CONSTANT, .start = label.start, .end = label.end - 1 }; value = UP(pm_constant_read_node_create(parser, &constant)); } else { @@ -14150,7 +14150,7 @@ pm_constant_path_command_call_p(const pm_parser_t *parser, const pm_call_node_t call->call_operator_loc.length > 0 && parser->start[call->call_operator_loc.start] == ':' && call->message_loc.length > 0 && - pm_encoding_isupper_char(parser->encoding, parser->start + call->message_loc.start, (ptrdiff_t) call->message_loc.length) + pm_encoding_isupper_char(parser->encoding, parser->start + call->message_loc.start, (ptrdiff_t) call->message_loc.length, parser->version) ); } @@ -14927,7 +14927,7 @@ parse_parameters( pm_token_t local = name; local.end -= 1; - if (parser->encoding_changed ? pm_encoding_isupper_char(parser->encoding, local.start, local.end - local.start) : pm_encoding_utf_8_isupper_char(local.start, local.end - local.start)) { + if (parser->encoding_changed ? pm_encoding_isupper_char(parser->encoding, local.start, local.end - local.start, parser->version) : pm_encoding_utf_8_isupper_char(local.start, local.end - local.start, parser->version)) { pm_parser_err(parser, PM_TOKEN_START(parser, &local), PM_TOKEN_LENGTH(&local), PM_ERR_ARGUMENT_FORMAL_CONSTANT); } else if (local.end[-1] == '!' || local.end[-1] == '?') { PM_PARSER_ERR_TOKEN_FORMAT_CONTENT(parser, &local, PM_ERR_INVALID_LOCAL_VARIABLE_WRITE); @@ -17324,9 +17324,9 @@ pm_slice_is_valid_local(const pm_parser_t *parser, const uint8_t *start, const u // Next, ensure that it's not an uppercase character. if (parser->encoding_changed) { - if (pm_encoding_isupper_char(parser->encoding, start, length)) return false; + if (pm_encoding_isupper_char(parser->encoding, start, length, parser->version)) return false; } else { - if (pm_encoding_utf_8_isupper_char(start, length)) return false; + if (pm_encoding_utf_8_isupper_char(start, length, parser->version)) return false; } // Next, iterate through all of the bytes of the string to ensure that they diff --git a/src/string_query.c b/src/string_query.c index 3c9fb5d7d4..bf96acd5d4 100644 --- a/src/string_query.c +++ b/src/string_query.c @@ -52,7 +52,7 @@ pm_slice_type(const uint8_t *source, size_t length, const char *encoding_name) { // determine the type of the slice based on the first character const uint8_t *end = source + length; - pm_slice_type_t result = pm_encoding_isupper_char(encoding, source, end - source) ? PM_SLICE_TYPE_CONSTANT : PM_SLICE_TYPE_LOCAL; + pm_slice_type_t result = pm_encoding_isupper_char(encoding, source, end - source, PM_OPTIONS_VERSION_LATEST) ? PM_SLICE_TYPE_CONSTANT : PM_SLICE_TYPE_LOCAL; // next, iterate through all of the bytes of the string to ensure that they // are all valid identifier characters From 4c48d635568cf96c9911985e931b30b17dc23f8f Mon Sep 17 00:00:00 2001 From: Kevin Newton Date: Mon, 16 Nov 2026 17:02:55 -0500 Subject: [PATCH 03/20] Create pm_options_version_supported_p --- include/prism/internal/options.h | 7 +++++ include/prism/options.h | 10 +++++++ src/options.c | 47 ++++++++++++++++++++++---------- 3 files changed, 50 insertions(+), 14 deletions(-) diff --git a/include/prism/internal/options.h b/include/prism/internal/options.h index 71fa1a6b95..1bdba84ca7 100644 --- a/include/prism/internal/options.h +++ b/include/prism/internal/options.h @@ -46,6 +46,13 @@ typedef enum { PM_OPTIONS_VERSION_LATEST = PM_OPTIONS_VERSION_CRUBY_4_1 } pm_options_version_t; +/* + * Read the version of Ruby that the given string names, such as "3.4", "4.0.1", + * or "latest", into the given version. NULL names the latest version. Returns + * false, leaving the version alone, if prism does not support the version. + */ +bool pm_options_version_parse(const char *version, size_t length, pm_options_version_t *result); + /* The options that can be passed to the parser. */ struct pm_options_t { /* diff --git a/include/prism/options.h b/include/prism/options.h index 58062061c3..d8de746eee 100644 --- a/include/prism/options.h +++ b/include/prism/options.h @@ -205,6 +205,16 @@ PRISM_EXPORTED_FUNCTION void pm_options_command_line_set(pm_options_t *options, */ PRISM_EXPORTED_FUNCTION bool pm_options_version_set(pm_options_t *options, const char *version, size_t length) PRISM_NONNULL(1); +/** + * Check whether prism supports the given version of Ruby, written the way that + * pm_options_version_set reads it, such as "3.4", "4.0.1", or "latest". + * + * @param version The version to check. + * @param length The length of the version string. + * @returns Whether or not prism supports the version. + */ +PRISM_EXPORTED_FUNCTION bool pm_options_version_supported_p(const char *version, size_t length) PRISM_NONNULL(1); + /** * Set the version option on the given options struct to the lowest version of * Ruby that prism supports. diff --git a/src/options.c b/src/options.c index b15b01ed88..bc06dc440a 100644 --- a/src/options.c +++ b/src/options.c @@ -122,35 +122,35 @@ is_number(const char *string, size_t length) { } /** - * Set the version option on the given options struct by parsing the given - * string. If the string contains an invalid option, this returns false. - * Otherwise, it returns true. + * Read the version of Ruby that the given string names, such as "3.4", "4.0.1", + * or "latest", into the given version. NULL names the latest version. Returns + * false, leaving the version alone, if prism does not support the version. */ bool -pm_options_version_set(pm_options_t *options, const char *version, size_t length) { +pm_options_version_parse(const char *version, size_t length, pm_options_version_t *result) { if (version == NULL) { - options->version = PM_OPTIONS_VERSION_LATEST; + *result = PM_OPTIONS_VERSION_LATEST; return true; } if (length == 3) { if (memcmp(version, "3.3", 3) == 0) { - options->version = PM_OPTIONS_VERSION_CRUBY_3_3; + *result = PM_OPTIONS_VERSION_CRUBY_3_3; return true; } if (memcmp(version, "3.4", 3) == 0) { - options->version = PM_OPTIONS_VERSION_CRUBY_3_4; + *result = PM_OPTIONS_VERSION_CRUBY_3_4; return true; } if (memcmp(version, "3.5", 3) == 0 || memcmp(version, "4.0", 3) == 0) { - options->version = PM_OPTIONS_VERSION_CRUBY_4_0; + *result = PM_OPTIONS_VERSION_CRUBY_4_0; return true; } if (memcmp(version, "4.1", 3) == 0) { - options->version = PM_OPTIONS_VERSION_CRUBY_4_1; + *result = PM_OPTIONS_VERSION_CRUBY_4_1; return true; } @@ -159,29 +159,29 @@ pm_options_version_set(pm_options_t *options, const char *version, size_t length if (length >= 4 && is_number(version + 4, length - 4)) { if (memcmp(version, "3.3.", 4) == 0) { - options->version = PM_OPTIONS_VERSION_CRUBY_3_3; + *result = PM_OPTIONS_VERSION_CRUBY_3_3; return true; } if (memcmp(version, "3.4.", 4) == 0) { - options->version = PM_OPTIONS_VERSION_CRUBY_3_4; + *result = PM_OPTIONS_VERSION_CRUBY_3_4; return true; } if (memcmp(version, "3.5.", 4) == 0 || memcmp(version, "4.0.", 4) == 0) { - options->version = PM_OPTIONS_VERSION_CRUBY_4_0; + *result = PM_OPTIONS_VERSION_CRUBY_4_0; return true; } if (memcmp(version, "4.1.", 4) == 0) { - options->version = PM_OPTIONS_VERSION_CRUBY_4_1; + *result = PM_OPTIONS_VERSION_CRUBY_4_1; return true; } } if (length == 6) { if (memcmp(version, "latest", 6) == 0) { - options->version = PM_OPTIONS_VERSION_LATEST; + *result = PM_OPTIONS_VERSION_LATEST; return true; } } @@ -189,6 +189,25 @@ pm_options_version_set(pm_options_t *options, const char *version, size_t length return false; } +/** + * Set the version option on the given options struct by parsing the given + * string. If the string contains an invalid option, this returns false. + * Otherwise, it returns true. + */ +bool +pm_options_version_set(pm_options_t *options, const char *version, size_t length) { + return pm_options_version_parse(version, length, &options->version); +} + +/** + * Check whether prism supports the given version of Ruby. + */ +bool +pm_options_version_supported_p(const char *version, size_t length) { + pm_options_version_t result; + return pm_options_version_parse(version, length, &result); +} + /** * Set the version option on the given options struct to the lowest version of * Ruby that prism supports. From 19dbae99a3b42a3171137bacd74e321a1e65c47f Mon Sep 17 00:00:00 2001 From: Kevin Newton Date: Mon, 16 Nov 2026 17:39:23 -0500 Subject: [PATCH 04/20] Accept version keyword for string queries --- CHANGELOG.md | 3 + ext/prism/extension.c | 126 ++++++++++++++++++++++----- include/prism/string_query.h | 31 +++++-- lib/prism/ffi.rb | 33 +++++-- lib/prism/string_query.rb | 36 ++++---- rbi/generated/prism/string_query.rbi | 32 +++---- rust/ruby-prism-sys/src/bindings.rs | 27 +++++- rust/ruby-prism/src/lib.rs | 41 +++++---- rust/ruby-prism/src/string_query.rs | 23 +++-- sig/generated/prism/string_query.rbs | 24 ++--- src/string_query.c | 44 +++++++--- test/prism/ruby/string_query_test.rb | 28 +++--- 12 files changed, 314 insertions(+), 134 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b861d6a425..b437a95b2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a ### Added - `pm_options_stack_budget_set` was added to the C API. It sets the number of bytes of C stack the parser may use before reporting a `stack_exhausted` error, instead of overflowing the stack. `SIZE_MAX` means no budget, which is the default. The nesting depth limit alone assumes a stack of roughly 8MB, so embedders that parse on a smaller stack, such as a thread's or a fiber's, should pass a budget. +- `Prism::StringQuery` methods accept a `version:` keyword, just like the parse methods. It defaults to the nearest version to the running Ruby. This matters for `constant?`, because Ruby 4.0 recognizes more uppercase letters than Ruby 3.4. +- `StringQuery::version` was added to the Rust bindings. It picks the Ruby version that a query checks against. The default is the latest version. - A new `stack` error level, for errors that should raise `SystemStackError`. Its only error is `stack_exhausted`, reported once per parse when the stack budget is used up. It is separate from `nesting_too_deep`, which stays a syntax error, because the same source may parse with more stack. When errors are formatted, a `stack_exhausted` error takes precedence over the syntax errors around it, as argument and load errors do. The level is `:stack` in Ruby, `"stack"` in JavaScript, `ERROR_STACK` in Java, and `PM_ERROR_LEVEL_STACK` in C and Rust. ### Changed @@ -17,6 +19,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a - `PRISM_BUILD_MINIMAL` now excludes the full set of encodings, as `PRISM_ENCODING_EXCLUDE_FULL` does. - In CESU-8, a surrogate is a valid character only as half of a surrogate pair. - A `\M-`, `\C-`, or `\c` escape may wrap an escape of any ASCII character, such as `"\M-\<0x01>"`, as CRuby allows. +- The `pm_string_query_*` functions take a Ruby version as their last argument, written like the strings that `pm_options_version_set` accepts. Pass `NULL` for the latest version. An unknown version returns the new `PM_STRING_QUERY_ERROR_VERSION`. - Whether a name is a constant follows the version of Unicode of the Ruby that is targeted: Unicode 15.0.0 for Ruby 3.3 and 3.4, and Unicode 17.0.0 for Ruby 4.0 and 4.1. A name that starts with a letter that became uppercase in Unicode 16.0.0 or 17.0.0, such as the Garay capital letters, is now a local variable name when targeting Ruby 3.3 or 3.4. ## [2.1.0] - 2026-10-28 diff --git a/ext/prism/extension.c b/ext/prism/extension.c index 20c74e0e40..7cb3225510 100644 --- a/ext/prism/extension.c +++ b/ext/prism/extension.c @@ -200,6 +200,15 @@ build_options_scopes(pm_options_t *options, VALUE scopes) { } } +/** + * Return true if the running Ruby is older than 3.3, the lowest version of Ruby + * that prism supports. + */ +static bool +ruby_version_before_lowest_p(void) { + return ruby_version[0] < '3' || (ruby_version[0] == '3' && ruby_version[2] < '3'); +} + /** * Set the version option to the syntax version of the currently running Ruby, * or to the closest version prism supports if it does not know that one. @@ -208,7 +217,7 @@ static void options_version_set_nearest(pm_options_t *options) { if (!pm_options_version_set(options, ruby_version, 3)) { // Prism doesn't know this specific version. Is it lower? - if (ruby_version[0] < '3' || (ruby_version[0] == '3' && ruby_version[2] < '3')) { + if (ruby_version_before_lowest_p()) { pm_options_version_set_lowest(options); } else { // Must be higher. @@ -1594,13 +1603,63 @@ parse_file_failure_p(int argc, VALUE *argv, VALUE self) { /* String query methods */ /******************************************************************************/ +/** + * Return the version that a string query answers for by default: the running + * Ruby if prism supports it, otherwise the closest version that it does. 3.3 is + * the lowest version that prism supports, and NULL is the latest. + */ +static const char * +string_query_nearest_version(void) { + if (pm_options_version_supported_p(ruby_version, 3)) return ruby_version; + return ruby_version_before_lowest_p() ? "3.3" : NULL; +} + +/** + * Read the arguments of a string query, which look like (string, version: + * nil), and return the version that the query takes. The version is read the + * way the version: option of the parse methods reads it: the nearest version to + * the running Ruby by default or with "nearest", and the running Ruby with + * "current", which prism must support. Any other version is passed on as it is, + * and the query itself checks it. + */ +static const char * +string_query_arguments(int argc, VALUE *argv, VALUE *string) { + VALUE keywords; + rb_scan_args(argc, argv, "1:", string, &keywords); + check_string(*string); + + VALUE value = Qundef; + if (!NIL_P(keywords)) { + ID keys[1] = { rb_id_option_version }; + rb_get_kwargs(keywords, keys, 0, 1, &value); + } + + if (value == Qundef || NIL_P(value)) return string_query_nearest_version(); + + const char *version = StringValueCStr(value); + if (strcmp(version, "nearest") == 0) return string_query_nearest_version(); + + if (strcmp(version, "current") == 0) { + if (!pm_options_version_supported_p(ruby_version, 3)) { + rb_exc_raise(rb_exc_new_cstr(rb_cPrismCurrentVersionError, ruby_version)); + } + + return ruby_version; + } + + return version; +} + /** * Process the result of a call to a string query method and return an - * appropriate value. + * appropriate value. The version is the one that the query was given. */ static VALUE -string_query(pm_string_query_t result) { +string_query(pm_string_query_t result, const char *version) { switch (result) { + case PM_STRING_QUERY_ERROR_VERSION: + rb_raise(rb_eArgError, "invalid version: %s", version); + return Qfalse; case PM_STRING_QUERY_ERROR: rb_raise(rb_eArgError, "Invalid or non ascii-compatible encoding"); return Qfalse; @@ -1609,64 +1668,85 @@ string_query(pm_string_query_t result) { case PM_STRING_QUERY_TRUE: return Qtrue; } + return Qfalse; } /** * :markup: markdown * call-seq: - * local?(string) -> bool + * local?(string, version: nil) -> bool * * Returns true if the string constitutes a valid local variable name. Note that * this means the names that can be set through Binding#local_variable_set, not * necessarily the ones that can be set through a local variable assignment. + * + * The version is the version of Ruby to answer for, as the `version` option of + * the parse methods reads it. It defaults to the nearest version to the running + * Ruby. */ static VALUE -string_query_local_p(VALUE self, VALUE string) { - const uint8_t *source = (const uint8_t *) check_string(string); - return string_query(pm_string_query_local(source, RSTRING_LEN(string), rb_enc_get(string)->name)); +string_query_local_p(int argc, VALUE *argv, VALUE self) { + VALUE string; + const char *version = string_query_arguments(argc, argv, &string); + return string_query(pm_string_query_local((const uint8_t *) RSTRING_PTR(string), RSTRING_LEN(string), rb_enc_get(string)->name, version), version); } /** * :markup: markdown * call-seq: - * constant?(string) -> bool + * constant?(string, version: nil) -> bool * * Returns true if the string constitutes a valid constant name. Note that this * means the names that can be set through Module#const_set, not necessarily the * ones that can be set through a constant assignment. + * + * The version is the version of Ruby to answer for, as the `version` option of + * the parse methods reads it. It defaults to the nearest version to the running + * Ruby. Which letters begin a constant name depends on it. */ static VALUE -string_query_constant_p(VALUE self, VALUE string) { - const uint8_t *source = (const uint8_t *) check_string(string); - return string_query(pm_string_query_constant(source, RSTRING_LEN(string), rb_enc_get(string)->name)); +string_query_constant_p(int argc, VALUE *argv, VALUE self) { + VALUE string; + const char *version = string_query_arguments(argc, argv, &string); + return string_query(pm_string_query_constant((const uint8_t *) RSTRING_PTR(string), RSTRING_LEN(string), rb_enc_get(string)->name, version), version); } /** * :markup: markdown * call-seq: - * method_name?(string) -> bool + * method_name?(string, version: nil) -> bool * * Returns true if the string constitutes a valid method name. + * + * The version is the version of Ruby to answer for, as the `version` option of + * the parse methods reads it. It defaults to the nearest version to the running + * Ruby. */ static VALUE -string_query_method_name_p(VALUE self, VALUE string) { - const uint8_t *source = (const uint8_t *) check_string(string); - return string_query(pm_string_query_method_name(source, RSTRING_LEN(string), rb_enc_get(string)->name)); +string_query_method_name_p(int argc, VALUE *argv, VALUE self) { + VALUE string; + const char *version = string_query_arguments(argc, argv, &string); + return string_query(pm_string_query_method_name((const uint8_t *) RSTRING_PTR(string), RSTRING_LEN(string), rb_enc_get(string)->name, version), version); } /** * :markup: markdown * call-seq: - * keyword?(string) -> bool + * keyword?(string, version: nil) -> bool * * Returns true if the string is a valid keyword, such as `if`, `defined?`, or * `__FILE__`. + * + * The version is the version of Ruby to answer for, as the `version` option of + * the parse methods reads it. It defaults to the nearest version to the running + * Ruby. */ static VALUE -string_query_keyword_p(VALUE self, VALUE string) { - const uint8_t *source = (const uint8_t *) check_string(string); - return string_query(pm_string_query_keyword(source, RSTRING_LEN(string), rb_enc_get(string)->name)); +string_query_keyword_p(int argc, VALUE *argv, VALUE self) { + VALUE string; + const char *version = string_query_arguments(argc, argv, &string); + return string_query(pm_string_query_keyword((const uint8_t *) RSTRING_PTR(string), RSTRING_LEN(string), rb_enc_get(string)->name, version), version); } /******************************************************************************/ @@ -1766,10 +1846,10 @@ Init_prism(void) { rb_define_singleton_method(rb_cPrism, "dump_file", dump_file, -1); #endif - rb_define_singleton_method(rb_cPrismStringQuery, "local?", string_query_local_p, 1); - rb_define_singleton_method(rb_cPrismStringQuery, "constant?", string_query_constant_p, 1); - rb_define_singleton_method(rb_cPrismStringQuery, "method_name?", string_query_method_name_p, 1); - rb_define_singleton_method(rb_cPrismStringQuery, "keyword?", string_query_keyword_p, 1); + rb_define_singleton_method(rb_cPrismStringQuery, "local?", string_query_local_p, -1); + rb_define_singleton_method(rb_cPrismStringQuery, "constant?", string_query_constant_p, -1); + rb_define_singleton_method(rb_cPrismStringQuery, "method_name?", string_query_method_name_p, -1); + rb_define_singleton_method(rb_cPrismStringQuery, "keyword?", string_query_keyword_p, -1); Init_prism_api_node(); } diff --git a/include/prism/string_query.h b/include/prism/string_query.h index 2ad1d7c48f..d8e138aa0b 100644 --- a/include/prism/string_query.h +++ b/include/prism/string_query.h @@ -21,6 +21,9 @@ extern "C" { * Represents the results of a slice query. */ typedef enum { + /** Returned if the version given to a slice query was invalid. */ + PM_STRING_QUERY_ERROR_VERSION = -2, + /** Returned if the encoding given to a slice query was invalid. */ PM_STRING_QUERY_ERROR = -1, @@ -37,10 +40,13 @@ typedef enum { * @param source The source to check. * @param length The length of the source. * @param encoding_name The name of the encoding of the source. + * @param version The version of Ruby to answer for, as pm_options_version_set + * reads it, such as "3.4" or "latest". NULL is the latest version. * @returns PM_STRING_QUERY_TRUE if the query is true, PM_STRING_QUERY_FALSE if - * the query is false, and PM_STRING_QUERY_ERROR if the encoding was invalid. + * the query is false, PM_STRING_QUERY_ERROR if the encoding was invalid, and + * PM_STRING_QUERY_ERROR_VERSION if the version was invalid. */ -PRISM_EXPORTED_FUNCTION pm_string_query_t pm_string_query_local(const uint8_t *source, size_t length, const char *encoding_name) PRISM_NONNULL(1, 3); +PRISM_EXPORTED_FUNCTION pm_string_query_t pm_string_query_local(const uint8_t *source, size_t length, const char *encoding_name, const char *version) PRISM_NONNULL(1, 3); /** * Check that the slice is a valid constant name. @@ -48,10 +54,13 @@ PRISM_EXPORTED_FUNCTION pm_string_query_t pm_string_query_local(const uint8_t *s * @param source The source to check. * @param length The length of the source. * @param encoding_name The name of the encoding of the source. + * @param version The version of Ruby to answer for, as pm_options_version_set + * reads it, such as "3.4" or "latest". NULL is the latest version. * @returns PM_STRING_QUERY_TRUE if the query is true, PM_STRING_QUERY_FALSE if - * the query is false, and PM_STRING_QUERY_ERROR if the encoding was invalid. + * the query is false, PM_STRING_QUERY_ERROR if the encoding was invalid, and + * PM_STRING_QUERY_ERROR_VERSION if the version was invalid. */ -PRISM_EXPORTED_FUNCTION pm_string_query_t pm_string_query_constant(const uint8_t *source, size_t length, const char *encoding_name) PRISM_NONNULL(1, 3); +PRISM_EXPORTED_FUNCTION pm_string_query_t pm_string_query_constant(const uint8_t *source, size_t length, const char *encoding_name, const char *version) PRISM_NONNULL(1, 3); /** * Check that the slice is a valid method name. @@ -59,10 +68,13 @@ PRISM_EXPORTED_FUNCTION pm_string_query_t pm_string_query_constant(const uint8_t * @param source The source to check. * @param length The length of the source. * @param encoding_name The name of the encoding of the source. + * @param version The version of Ruby to answer for, as pm_options_version_set + * reads it, such as "3.4" or "latest". NULL is the latest version. * @returns PM_STRING_QUERY_TRUE if the query is true, PM_STRING_QUERY_FALSE if - * the query is false, and PM_STRING_QUERY_ERROR if the encoding was invalid. + * the query is false, PM_STRING_QUERY_ERROR if the encoding was invalid, and + * PM_STRING_QUERY_ERROR_VERSION if the version was invalid. */ -PRISM_EXPORTED_FUNCTION pm_string_query_t pm_string_query_method_name(const uint8_t *source, size_t length, const char *encoding_name) PRISM_NONNULL(1, 3); +PRISM_EXPORTED_FUNCTION pm_string_query_t pm_string_query_method_name(const uint8_t *source, size_t length, const char *encoding_name, const char *version) PRISM_NONNULL(1, 3); /** * Check that the slice is a keyword. @@ -70,10 +82,13 @@ PRISM_EXPORTED_FUNCTION pm_string_query_t pm_string_query_method_name(const uint * @param source The source to check. * @param length The length of the source. * @param encoding_name The name of the encoding of the source. + * @param version The version of Ruby to answer for, as pm_options_version_set + * reads it, such as "3.4" or "latest". NULL is the latest version. * @returns PM_STRING_QUERY_TRUE if the query is true, PM_STRING_QUERY_FALSE if - * the query is false, and PM_STRING_QUERY_ERROR if the encoding was invalid. + * the query is false, PM_STRING_QUERY_ERROR if the encoding was invalid, and + * PM_STRING_QUERY_ERROR_VERSION if the version was invalid. */ -PRISM_EXPORTED_FUNCTION pm_string_query_t pm_string_query_keyword(const uint8_t *source, size_t length, const char *encoding_name) PRISM_NONNULL(1, 3); +PRISM_EXPORTED_FUNCTION pm_string_query_t pm_string_query_keyword(const uint8_t *source, size_t length, const char *encoding_name, const char *version) PRISM_NONNULL(1, 3); #ifdef __cplusplus } diff --git a/lib/prism/ffi.rb b/lib/prism/ffi.rb index f3158cbb5d..85215fa722 100644 --- a/lib/prism/ffi.rb +++ b/lib/prism/ffi.rb @@ -94,7 +94,7 @@ def self.load_exported_functions_from(header, *functions, callbacks) callback :pm_source_stream_feof_t, [:pointer], :int pm_source_init_result_values = %i[PM_SOURCE_INIT_SUCCESS PM_SOURCE_INIT_ERROR_GENERIC PM_SOURCE_INIT_ERROR_DIRECTORY PM_SOURCE_INIT_ERROR_NON_REGULAR] enum :pm_source_init_result_t, pm_source_init_result_values - enum :pm_string_query_t, [:PM_STRING_QUERY_ERROR, -1, :PM_STRING_QUERY_FALSE, :PM_STRING_QUERY_TRUE] + enum :pm_string_query_t, [:PM_STRING_QUERY_ERROR_VERSION, -2, :PM_STRING_QUERY_ERROR, -1, :PM_STRING_QUERY_FALSE, :PM_STRING_QUERY_TRUE] enum :pm_errors_format_type_t, [:PM_ERRORS_FORMAT_PLAIN, 1, :PM_ERRORS_FORMAT_STYLE, :PM_ERRORS_FORMAT_COLOR] # Ractor-safe lookup table for pm_source_init_result_t, since FFI's @@ -709,32 +709,47 @@ def dump_options(options) # Here we are going to patch StringQuery to put in the class-level methods so # that it can maintain a consistent interface class StringQuery # :nodoc: + # The version strings that the string queries take, by the number that the + # version option of the parse methods dumps for each version. The latest + # version is nil. + VERSIONS = { 0 => nil, 1 => "3.3", 2 => "3.4", 3 => "4.0", 4 => "4.1" }.freeze + private_constant :VERSIONS + class << self # Mirrors the C extension's StringQuery::local? method. - def local?(string) - query(LibRubyParser.pm_string_query_local(string, string.bytesize, string.encoding.name)) + def local?(string, version: nil) + query(LibRubyParser.pm_string_query_local(string, string.bytesize, string.encoding.name, query_version(version))) end # Mirrors the C extension's StringQuery::constant? method. - def constant?(string) - query(LibRubyParser.pm_string_query_constant(string, string.bytesize, string.encoding.name)) + def constant?(string, version: nil) + query(LibRubyParser.pm_string_query_constant(string, string.bytesize, string.encoding.name, query_version(version))) end # Mirrors the C extension's StringQuery::method_name? method. - def method_name?(string) - query(LibRubyParser.pm_string_query_method_name(string, string.bytesize, string.encoding.name)) + def method_name?(string, version: nil) + query(LibRubyParser.pm_string_query_method_name(string, string.bytesize, string.encoding.name, query_version(version))) end # Mirrors the C extension's StringQuery::keyword? method. - def keyword?(string) - query(LibRubyParser.pm_string_query_keyword(string, string.bytesize, string.encoding.name)) + def keyword?(string, version: nil) + query(LibRubyParser.pm_string_query_keyword(string, string.bytesize, string.encoding.name, query_version(version))) end private + # Read the version option of a string query the same way that the version + # option of the parse methods is read, which raises for a version that is + # not valid, into the version string that the query takes. + def query_version(version) + VERSIONS.fetch(Prism.__send__(:dump_options_version, version)) + end + # Parse the enum result and return an appropriate boolean. def query(result) case result + when :PM_STRING_QUERY_ERROR_VERSION + raise ArgumentError, "invalid version" when :PM_STRING_QUERY_ERROR raise ArgumentError, "Invalid or non ascii-compatible encoding" when :PM_STRING_QUERY_FALSE diff --git a/lib/prism/string_query.rb b/lib/prism/string_query.rb index be1f2c02d0..b4fc5a9fd0 100644 --- a/lib/prism/string_query.rb +++ b/lib/prism/string_query.rb @@ -7,11 +7,15 @@ module Prism # Query methods that allow categorizing strings based on their context for # where they could be valid in a Ruby syntax tree. class StringQuery + # Each query takes the version of Ruby to answer for, as the version option + # of the parse methods reads it. It defaults to the nearest version to the + # running Ruby. + # # @rbs! - # def self.local?: (String string) -> bool - # def self.constant?: (String string) -> bool - # def self.method_name?: (String string) -> bool - # def self.keyword?: (String string) -> bool + # def self.local?: (String string, ?version: String?) -> bool + # def self.constant?: (String string, ?version: String?) -> bool + # def self.method_name?: (String string, ?version: String?) -> bool + # def self.keyword?: (String string, ?version: String?) -> bool # The string that this query is wrapping. attr_reader :string #: String @@ -25,30 +29,30 @@ def initialize(string) # Whether or not this string is a valid local variable name. # - #: () -> bool - def local? - StringQuery.local?(string) + #: (?version: String?) -> bool + def local?(version: nil) + StringQuery.local?(string, version: version) end # Whether or not this string is a valid constant name. # - #: () -> bool - def constant? - StringQuery.constant?(string) + #: (?version: String?) -> bool + def constant?(version: nil) + StringQuery.constant?(string, version: version) end # Whether or not this string is a valid method name. # - #: () -> bool - def method_name? - StringQuery.method_name?(string) + #: (?version: String?) -> bool + def method_name?(version: nil) + StringQuery.method_name?(string, version: version) end # Whether or not this string is a valid keyword. # - #: () -> bool - def keyword? - StringQuery.keyword?(string) + #: (?version: String?) -> bool + def keyword?(version: nil) + StringQuery.keyword?(string, version: version) end end end diff --git a/rbi/generated/prism/string_query.rbi b/rbi/generated/prism/string_query.rbi index cbfdf6529a..4b5c21d81a 100644 --- a/rbi/generated/prism/string_query.rbi +++ b/rbi/generated/prism/string_query.rbi @@ -4,17 +4,17 @@ module Prism # Query methods that allow categorizing strings based on their context for # where they could be valid in a Ruby syntax tree. class StringQuery - sig { params(string: String).returns(T::Boolean) } - def self.local?(string); end + sig { params(string: String, version: ::T.nilable(String)).returns(T::Boolean) } + def self.local?(string, version: T.unsafe(nil)); end - sig { params(string: String).returns(T::Boolean) } - def self.constant?(string); end + sig { params(string: String, version: ::T.nilable(String)).returns(T::Boolean) } + def self.constant?(string, version: T.unsafe(nil)); end - sig { params(string: String).returns(T::Boolean) } - def self.method_name?(string); end + sig { params(string: String, version: ::T.nilable(String)).returns(T::Boolean) } + def self.method_name?(string, version: T.unsafe(nil)); end - sig { params(string: String).returns(T::Boolean) } - def self.keyword?(string); end + sig { params(string: String, version: ::T.nilable(String)).returns(T::Boolean) } + def self.keyword?(string, version: T.unsafe(nil)); end # The string that this query is wrapping. sig { returns(String) } @@ -25,19 +25,19 @@ module Prism def initialize(string); end # Whether or not this string is a valid local variable name. - sig { returns(T::Boolean) } - def local?; end + sig { params(version: ::T.nilable(String)).returns(T::Boolean) } + def local?(version: T.unsafe(nil)); end # Whether or not this string is a valid constant name. - sig { returns(T::Boolean) } - def constant?; end + sig { params(version: ::T.nilable(String)).returns(T::Boolean) } + def constant?(version: T.unsafe(nil)); end # Whether or not this string is a valid method name. - sig { returns(T::Boolean) } - def method_name?; end + sig { params(version: ::T.nilable(String)).returns(T::Boolean) } + def method_name?(version: T.unsafe(nil)); end # Whether or not this string is a valid keyword. - sig { returns(T::Boolean) } - def keyword?; end + sig { params(version: ::T.nilable(String)).returns(T::Boolean) } + def keyword?(version: T.unsafe(nil)); end end end diff --git a/rust/ruby-prism-sys/src/bindings.rs b/rust/ruby-prism-sys/src/bindings.rs index 690d810dda..d3fe4ea573 100644 --- a/rust/ruby-prism-sys/src/bindings.rs +++ b/rust/ruby-prism-sys/src/bindings.rs @@ -9696,6 +9696,9 @@ pub const PM_OPTIONS_COMMAND_LINE_P: u8 = 16; searches the input file for a shebang that includes "ruby". */ pub const PM_OPTIONS_COMMAND_LINE_X: u8 = 32; +/** Returned if the version given to a slice query was invalid. +*/ +pub const PM_STRING_QUERY_ERROR_VERSION: pm_string_query_t = -2; /** Returned if the encoding given to a slice query was invalid. */ pub const PM_STRING_QUERY_ERROR: pm_string_query_t = -1; @@ -12161,52 +12164,68 @@ unsafe extern "C" { @param source The source to check. @param length The length of the source. @param encoding_name The name of the encoding of the source. + @param version The version of Ruby to answer for, as pm_options_version_set + reads it, such as "3.4" or "latest". NULL is the latest version. @returns PM_STRING_QUERY_TRUE if the query is true, PM_STRING_QUERY_FALSE if - the query is false, and PM_STRING_QUERY_ERROR if the encoding was invalid. + the query is false, PM_STRING_QUERY_ERROR if the encoding was invalid, and + PM_STRING_QUERY_ERROR_VERSION if the version was invalid. */ pub fn pm_string_query_local( source: *const u8, length: usize, encoding_name: *const ::std::os::raw::c_char, + version: *const ::std::os::raw::c_char, ) -> pm_string_query_t; /** Check that the slice is a valid constant name. @param source The source to check. @param length The length of the source. @param encoding_name The name of the encoding of the source. + @param version The version of Ruby to answer for, as pm_options_version_set + reads it, such as "3.4" or "latest". NULL is the latest version. @returns PM_STRING_QUERY_TRUE if the query is true, PM_STRING_QUERY_FALSE if - the query is false, and PM_STRING_QUERY_ERROR if the encoding was invalid. + the query is false, PM_STRING_QUERY_ERROR if the encoding was invalid, and + PM_STRING_QUERY_ERROR_VERSION if the version was invalid. */ pub fn pm_string_query_constant( source: *const u8, length: usize, encoding_name: *const ::std::os::raw::c_char, + version: *const ::std::os::raw::c_char, ) -> pm_string_query_t; /** Check that the slice is a valid method name. @param source The source to check. @param length The length of the source. @param encoding_name The name of the encoding of the source. + @param version The version of Ruby to answer for, as pm_options_version_set + reads it, such as "3.4" or "latest". NULL is the latest version. @returns PM_STRING_QUERY_TRUE if the query is true, PM_STRING_QUERY_FALSE if - the query is false, and PM_STRING_QUERY_ERROR if the encoding was invalid. + the query is false, PM_STRING_QUERY_ERROR if the encoding was invalid, and + PM_STRING_QUERY_ERROR_VERSION if the version was invalid. */ pub fn pm_string_query_method_name( source: *const u8, length: usize, encoding_name: *const ::std::os::raw::c_char, + version: *const ::std::os::raw::c_char, ) -> pm_string_query_t; /** Check that the slice is a keyword. @param source The source to check. @param length The length of the source. @param encoding_name The name of the encoding of the source. + @param version The version of Ruby to answer for, as pm_options_version_set + reads it, such as "3.4" or "latest". NULL is the latest version. @returns PM_STRING_QUERY_TRUE if the query is true, PM_STRING_QUERY_FALSE if - the query is false, and PM_STRING_QUERY_ERROR if the encoding was invalid. + the query is false, PM_STRING_QUERY_ERROR if the encoding was invalid, and + PM_STRING_QUERY_ERROR_VERSION if the version was invalid. */ pub fn pm_string_query_keyword( source: *const u8, length: usize, encoding_name: *const ::std::os::raw::c_char, + version: *const ::std::os::raw::c_char, ) -> pm_string_query_t; /** The prism version and the serialization format. diff --git a/rust/ruby-prism/src/lib.rs b/rust/ruby-prism/src/lib.rs index 94c7283e95..68e5a6661f 100644 --- a/rust/ruby-prism/src/lib.rs +++ b/rust/ruby-prism/src/lib.rs @@ -53,26 +53,31 @@ pub enum Version { } impl Version { - /// Calls `pm_options_version_set` with the appropriate version string. - /// `Latest` passes `NULL` to get the default behavior. - unsafe fn set_on(self, opts: *mut pm_options_t) { + /// Returns the version string that prism's C functions take for this + /// version, or `None` for `Latest`, which they take as `NULL`. + const fn as_c_str(self) -> Option<&'static std::ffi::CStr> { match self { - Self::Latest => { - pm_options_version_set(opts, std::ptr::null(), 0); - }, - Self::CRuby3_3 => { - pm_options_version_set(opts, c"3.3".as_ptr(), 3); - }, - Self::CRuby3_4 => { - pm_options_version_set(opts, c"3.4".as_ptr(), 3); - }, + Self::Latest => None, + Self::CRuby3_3 => Some(c"3.3"), + Self::CRuby3_4 => Some(c"3.4"), #[allow(deprecated)] - Self::CRuby3_5 | Self::CRuby4_0 => { - pm_options_version_set(opts, c"4.0".as_ptr(), 3); - }, - Self::CRuby4_1 => { - pm_options_version_set(opts, c"4.1".as_ptr(), 3); - }, + Self::CRuby3_5 | Self::CRuby4_0 => Some(c"4.0"), + Self::CRuby4_1 => Some(c"4.1"), + } + } + + /// Returns a pointer to the version string that prism's C functions take + /// for this version, which is `NULL` for `Latest`. + fn as_ptr(self) -> *const std::ffi::c_char { + self.as_c_str().map_or(std::ptr::null(), std::ffi::CStr::as_ptr) + } + + /// Calls `pm_options_version_set` with the appropriate version string. + /// `Latest` needs no call, since the parser uses the latest version when + /// none is set. + unsafe fn set_on(self, opts: *mut pm_options_t) { + if let Some(version) = self.as_c_str() { + pm_options_version_set(opts, version.as_ptr(), version.to_bytes().len()); } } } diff --git a/rust/ruby-prism/src/string_query.rs b/rust/ruby-prism/src/string_query.rs index fc2ffee1ed..e597fcd0df 100644 --- a/rust/ruby-prism/src/string_query.rs +++ b/rust/ruby-prism/src/string_query.rs @@ -3,7 +3,9 @@ use std::ffi::{c_char, CString}; use std::fmt; -use ruby_prism_sys::{pm_string_query_constant, pm_string_query_keyword, pm_string_query_local, pm_string_query_method_name, pm_string_query_t, PM_STRING_QUERY_FALSE, PM_STRING_QUERY_TRUE}; +use ruby_prism_sys::{pm_string_query_constant, pm_string_query_keyword, pm_string_query_local, pm_string_query_method_name, pm_string_query_t, PM_STRING_QUERY_ERROR_VERSION, PM_STRING_QUERY_FALSE, PM_STRING_QUERY_TRUE}; + +use crate::Version; /// The error returned when a string query is given an encoding that prism /// does not know or that is not ASCII-compatible. @@ -21,7 +23,8 @@ impl std::error::Error for InvalidEncodingError {} /// Queries whether a string is a valid name of a given kind in Ruby. /// /// The string is interpreted as UTF-8 unless another encoding is given with -/// [`StringQuery::encoding`]. +/// [`StringQuery::encoding`], and the answer is for the latest version of Ruby +/// unless another version is given with [`StringQuery::version`]. /// /// ``` /// use ruby_prism::StringQuery; @@ -35,13 +38,14 @@ impl std::error::Error for InvalidEncodingError {} pub struct StringQuery<'a> { source: &'a [u8], encoding: &'a str, + version: Version, } impl<'a> StringQuery<'a> { /// Creates a query for the given UTF-8 string. #[must_use] pub const fn new(source: &'a [u8]) -> Self { - Self { source, encoding: "UTF-8" } + Self { source, encoding: "UTF-8", version: Version::Latest } } /// Sets the name of the encoding that the string is in, such as @@ -52,6 +56,14 @@ impl<'a> StringQuery<'a> { self } + /// Sets the version of Ruby to answer for. Which letters begin a constant + /// name depends on the version of Unicode that it uses. + #[must_use] + pub const fn version(mut self, version: Version) -> Self { + self.version = version; + self + } + /// Returns whether the string is a valid local variable name. /// /// # Errors @@ -93,13 +105,14 @@ impl<'a> StringQuery<'a> { self.query(pm_string_query_keyword) } - fn query(&self, function: unsafe extern "C" fn(*const u8, usize, *const c_char) -> pm_string_query_t) -> Result { + fn query(&self, function: unsafe extern "C" fn(*const u8, usize, *const c_char, *const c_char) -> pm_string_query_t) -> Result { // An encoding name with an interior null byte cannot name a known encoding. let encoding = CString::new(self.encoding).map_err(|_| InvalidEncodingError)?; - match unsafe { function(self.source.as_ptr(), self.source.len(), encoding.as_ptr()) } { + match unsafe { function(self.source.as_ptr(), self.source.len(), encoding.as_ptr(), self.version.as_ptr()) } { PM_STRING_QUERY_TRUE => Ok(true), PM_STRING_QUERY_FALSE => Ok(false), + PM_STRING_QUERY_ERROR_VERSION => unreachable!("every Version is a version that prism knows"), _ => Err(InvalidEncodingError), } } diff --git a/sig/generated/prism/string_query.rbs b/sig/generated/prism/string_query.rbs index 4c69845d5b..c7d7ced247 100644 --- a/sig/generated/prism/string_query.rbs +++ b/sig/generated/prism/string_query.rbs @@ -4,13 +4,13 @@ module Prism # Query methods that allow categorizing strings based on their context for # where they could be valid in a Ruby syntax tree. class StringQuery - def self.local?: (String string) -> bool + def self.local?: (String string, ?version: String?) -> bool - def self.constant?: (String string) -> bool + def self.constant?: (String string, ?version: String?) -> bool - def self.method_name?: (String string) -> bool + def self.method_name?: (String string, ?version: String?) -> bool - def self.keyword?: (String string) -> bool + def self.keyword?: (String string, ?version: String?) -> bool # The string that this query is wrapping. attr_reader string: String @@ -22,22 +22,22 @@ module Prism # Whether or not this string is a valid local variable name. # - # : () -> bool - def local?: () -> bool + # : (?version: String?) -> bool + def local?: (?version: String?) -> bool # Whether or not this string is a valid constant name. # - # : () -> bool - def constant?: () -> bool + # : (?version: String?) -> bool + def constant?: (?version: String?) -> bool # Whether or not this string is a valid method name. # - # : () -> bool - def method_name?: () -> bool + # : (?version: String?) -> bool + def method_name?: (?version: String?) -> bool # Whether or not this string is a valid keyword. # - # : () -> bool - def keyword?: () -> bool + # : (?version: String?) -> bool + def keyword?: (?version: String?) -> bool end end diff --git a/src/string_query.c b/src/string_query.c index bf96acd5d4..daff7ff940 100644 --- a/src/string_query.c +++ b/src/string_query.c @@ -3,12 +3,16 @@ #include "prism/internal/assert.h" #include "prism/internal/char.h" #include "prism/internal/encoding.h" +#include "prism/internal/options.h" #include "prism/internal/parser.h" #include /** The category of slice returned from pm_slice_type. */ typedef enum { + /** Returned when the given version is invalid. */ + PM_SLICE_TYPE_ERROR_VERSION = -2, + /** Returned when the given encoding name is invalid. */ PM_SLICE_TYPE_ERROR = -1, @@ -26,14 +30,20 @@ typedef enum { } pm_slice_type_t; /** - * Check that the slice is a valid local variable name or constant. + * Check that the slice is a valid local variable name or constant, in the + * given version of Ruby. The version is read as pm_options_version_set reads + * it, and NULL is the latest version. */ static pm_slice_type_t -pm_slice_type(const uint8_t *source, size_t length, const char *encoding_name) { +pm_slice_type(const uint8_t *source, size_t length, const char *encoding_name, const char *version) { // first, get the right encoding object const pm_encoding_t *encoding = pm_encoding_find((const uint8_t *) encoding_name, (const uint8_t *) (encoding_name + strlen(encoding_name))); if (encoding == NULL) return PM_SLICE_TYPE_ERROR; + /* Then the version of Ruby, which decides which letters are uppercase. */ + pm_options_version_t target; + if (!pm_options_version_parse(version, version == NULL ? 0 : strlen(version), &target)) return PM_SLICE_TYPE_ERROR_VERSION; + // check that there is at least one character if (length == 0) return PM_SLICE_TYPE_NONE; @@ -52,7 +62,7 @@ pm_slice_type(const uint8_t *source, size_t length, const char *encoding_name) { // determine the type of the slice based on the first character const uint8_t *end = source + length; - pm_slice_type_t result = pm_encoding_isupper_char(encoding, source, end - source, PM_OPTIONS_VERSION_LATEST) ? PM_SLICE_TYPE_CONSTANT : PM_SLICE_TYPE_LOCAL; + pm_slice_type_t result = pm_encoding_isupper_char(encoding, source, end - source, target) ? PM_SLICE_TYPE_CONSTANT : PM_SLICE_TYPE_LOCAL; // next, iterate through all of the bytes of the string to ensure that they // are all valid identifier characters @@ -88,8 +98,10 @@ pm_slice_type(const uint8_t *source, size_t length, const char *encoding_name) { * Check that the slice is a valid local variable name. */ pm_string_query_t -pm_string_query_local(const uint8_t *source, size_t length, const char *encoding_name) { - switch (pm_slice_type(source, length, encoding_name)) { +pm_string_query_local(const uint8_t *source, size_t length, const char *encoding_name, const char *version) { + switch (pm_slice_type(source, length, encoding_name, version)) { + case PM_SLICE_TYPE_ERROR_VERSION: + return PM_STRING_QUERY_ERROR_VERSION; case PM_SLICE_TYPE_ERROR: return PM_STRING_QUERY_ERROR; case PM_SLICE_TYPE_NONE: @@ -108,8 +120,10 @@ pm_string_query_local(const uint8_t *source, size_t length, const char *encoding * Check that the slice is a valid constant name. */ pm_string_query_t -pm_string_query_constant(const uint8_t *source, size_t length, const char *encoding_name) { - switch (pm_slice_type(source, length, encoding_name)) { +pm_string_query_constant(const uint8_t *source, size_t length, const char *encoding_name, const char *version) { + switch (pm_slice_type(source, length, encoding_name, version)) { + case PM_SLICE_TYPE_ERROR_VERSION: + return PM_STRING_QUERY_ERROR_VERSION; case PM_SLICE_TYPE_ERROR: return PM_STRING_QUERY_ERROR; case PM_SLICE_TYPE_NONE: @@ -128,13 +142,15 @@ pm_string_query_constant(const uint8_t *source, size_t length, const char *encod * Check that the slice is a valid method name. */ pm_string_query_t -pm_string_query_method_name(const uint8_t *source, size_t length, const char *encoding_name) { +pm_string_query_method_name(const uint8_t *source, size_t length, const char *encoding_name, const char *version) { #define B(p) ((p) ? PM_STRING_QUERY_TRUE : PM_STRING_QUERY_FALSE) #define C1(c) (*source == c) #define C2(s) (memcmp(source, s, 2) == 0) #define C3(s) (memcmp(source, s, 3) == 0) - switch (pm_slice_type(source, length, encoding_name)) { + switch (pm_slice_type(source, length, encoding_name, version)) { + case PM_SLICE_TYPE_ERROR_VERSION: + return PM_STRING_QUERY_ERROR_VERSION; case PM_SLICE_TYPE_ERROR: return PM_STRING_QUERY_ERROR; case PM_SLICE_TYPE_NONE: @@ -168,13 +184,19 @@ pm_string_query_method_name(const uint8_t *source, size_t length, const char *en /** * Check that the slice is a keyword. Keywords are spelled in ASCII, so any - * ASCII-compatible encoding spells them with the same bytes. + * ASCII-compatible encoding spells them with the same bytes. Every version of + * Ruby that prism supports has the same keywords, but the version must still + * be valid. */ pm_string_query_t -pm_string_query_keyword(const uint8_t *source, size_t length, const char *encoding_name) { +pm_string_query_keyword(const uint8_t *source, size_t length, const char *encoding_name, const char *version) { if (pm_encoding_find((const uint8_t *) encoding_name, (const uint8_t *) (encoding_name + strlen(encoding_name))) == NULL) { return PM_STRING_QUERY_ERROR; } + if (version != NULL && !pm_options_version_supported_p(version, strlen(version))) { + return PM_STRING_QUERY_ERROR_VERSION; + } + return pm_keyword_p(source, source + length) ? PM_STRING_QUERY_TRUE : PM_STRING_QUERY_FALSE; } diff --git a/test/prism/ruby/string_query_test.rb b/test/prism/ruby/string_query_test.rb index d9da57f42c..19977bc428 100644 --- a/test/prism/ruby/string_query_test.rb +++ b/test/prism/ruby/string_query_test.rb @@ -103,18 +103,22 @@ def test_invalid_encoding end end - if BACKEND == :FFI - # Ruby strings always have a readable byte after their contents, so call - # the C functions directly with a slice that is immediately followed by a - # method name suffix. That byte is outside the slice and must be ignored. - def test_does_not_read_past_slice - local = FFI::MemoryPointer.from_string("foo?") - assert_equal :PM_STRING_QUERY_TRUE, LibRubyParser.pm_string_query_local(local, 3, "UTF-8") - assert_equal :PM_STRING_QUERY_TRUE, LibRubyParser.pm_string_query_method_name(local, 3, "UTF-8") - - constant = FFI::MemoryPointer.from_string("Foo=") - assert_equal :PM_STRING_QUERY_TRUE, LibRubyParser.pm_string_query_constant(constant, 3, "UTF-8") - end + # Ruby 3.3 and 3.4 use Unicode 15.0.0, and Ruby 4.0 and 4.1 use Unicode + # 17.0.0, in which the Garay capital letters are uppercase. + def test_version + garay = [0x10D50].pack("U") + + refute StringQuery.constant?(garay, version: "3.3") + assert StringQuery.local?(garay, version: "3.4") + assert StringQuery.constant?(garay, version: "4.0") + refute StringQuery.local?(garay, version: "4.1") + assert StringQuery.constant?(garay, version: "latest") + assert StringQuery.constant?(garay, version: "4.0.1") + + assert StringQuery.new(garay).constant?(version: "4.0") + assert StringQuery.new(garay).local?(version: "3.4") + assert StringQuery.new("end").keyword?(version: "3.3") + assert StringQuery.new("a?").method_name?(version: "3.3") end end end From 93906ec7adf831cf01c2df946b94dd5ec0aa7f20 Mon Sep 17 00:00:00 2001 From: Kevin Newton Date: Mon, 16 Nov 2026 17:47:51 -0500 Subject: [PATCH 05/20] Read a ? before a non-ASCII identifier as a ternary operator --- CHANGELOG.md | 1 + snapshots/ternary_operator_non_ascii.txt | 111 ++++++++++++++++++ src/prism.c | 7 +- .../fixtures/ternary_operator_non_ascii.txt | 3 + test/prism/ruby/parser_test.rb | 3 + test/prism/ruby/ruby_parser_test.rb | 1 + 6 files changed, 123 insertions(+), 3 deletions(-) create mode 100644 snapshots/ternary_operator_non_ascii.txt create mode 100644 test/prism/fixtures/ternary_operator_non_ascii.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index b437a95b2b..9a4af7d384 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a - A `\M-`, `\C-`, or `\c` escape may wrap an escape of any ASCII character, such as `"\M-\<0x01>"`, as CRuby allows. - The `pm_string_query_*` functions take a Ruby version as their last argument, written like the strings that `pm_options_version_set` accepts. Pass `NULL` for the latest version. An unknown version returns the new `PM_STRING_QUERY_ERROR_VERSION`. - Whether a name is a constant follows the version of Unicode of the Ruby that is targeted: Unicode 15.0.0 for Ruby 3.3 and 3.4, and Unicode 17.0.0 for Ruby 4.0 and 4.1. A name that starts with a letter that became uppercase in Unicode 16.0.0 or 17.0.0, such as the Garay capital letters, is now a local variable name when targeting Ruby 3.3 or 3.4. +- A `?` followed by two identifier characters is a ternary operator, even when the first one is not ASCII. For example, `a ?☃b : c` used to read `?☃` as a character literal. ## [2.1.0] - 2026-10-28 diff --git a/snapshots/ternary_operator_non_ascii.txt b/snapshots/ternary_operator_non_ascii.txt new file mode 100644 index 0000000000..86564a8e1a --- /dev/null +++ b/snapshots/ternary_operator_non_ascii.txt @@ -0,0 +1,111 @@ +@ ProgramNode (location: (1,0)-(3,16)) +├── flags: ∅ +├── locals: [] +└── statements: + @ StatementsNode (location: (1,0)-(3,16)) + ├── flags: ∅ + └── body: (length: 2) + ├── @ IfNode (location: (1,0)-(1,17)) + │ ├── flags: newline + │ ├── if_keyword_loc: ∅ + │ ├── predicate: + │ │ @ CallNode (location: (1,0)-(1,1)) + │ │ ├── flags: variable_call, ignore_visibility + │ │ ├── receiver: ∅ + │ │ ├── call_operator_loc: ∅ + │ │ ├── name: :a + │ │ ├── message_loc: (1,0)-(1,1) = "a" + │ │ ├── opening_loc: ∅ + │ │ ├── arguments: ∅ + │ │ ├── closing_loc: ∅ + │ │ ├── equal_loc: ∅ + │ │ └── block: ∅ + │ ├── then_keyword_loc: (1,2)-(1,3) = "?" + │ ├── statements: + │ │ @ StatementsNode (location: (1,3)-(1,10)) + │ │ ├── flags: ∅ + │ │ └── body: (length: 1) + │ │ └── @ CallNode (location: (1,3)-(1,10)) + │ │ ├── flags: newline, variable_call, ignore_visibility + │ │ ├── receiver: ∅ + │ │ ├── call_operator_loc: ∅ + │ │ ├── name: :☃var1 + │ │ ├── message_loc: (1,3)-(1,10) = "☃var1" + │ │ ├── opening_loc: ∅ + │ │ ├── arguments: ∅ + │ │ ├── closing_loc: ∅ + │ │ ├── equal_loc: ∅ + │ │ └── block: ∅ + │ ├── subsequent: + │ │ @ ElseNode (location: (1,11)-(1,17)) + │ │ ├── flags: ∅ + │ │ ├── else_keyword_loc: (1,11)-(1,12) = ":" + │ │ ├── statements: + │ │ │ @ StatementsNode (location: (1,13)-(1,17)) + │ │ │ ├── flags: ∅ + │ │ │ └── body: (length: 1) + │ │ │ └── @ CallNode (location: (1,13)-(1,17)) + │ │ │ ├── flags: newline, variable_call, ignore_visibility + │ │ │ ├── receiver: ∅ + │ │ │ ├── call_operator_loc: ∅ + │ │ │ ├── name: :var2 + │ │ │ ├── message_loc: (1,13)-(1,17) = "var2" + │ │ │ ├── opening_loc: ∅ + │ │ │ ├── arguments: ∅ + │ │ │ ├── closing_loc: ∅ + │ │ │ ├── equal_loc: ∅ + │ │ │ └── block: ∅ + │ │ └── end_keyword_loc: ∅ + │ └── end_keyword_loc: ∅ + └── @ IfNode (location: (3,0)-(3,16)) + ├── flags: newline + ├── if_keyword_loc: ∅ + ├── predicate: + │ @ CallNode (location: (3,0)-(3,1)) + │ ├── flags: variable_call, ignore_visibility + │ ├── receiver: ∅ + │ ├── call_operator_loc: ∅ + │ ├── name: :a + │ ├── message_loc: (3,0)-(3,1) = "a" + │ ├── opening_loc: ∅ + │ ├── arguments: ∅ + │ ├── closing_loc: ∅ + │ ├── equal_loc: ∅ + │ └── block: ∅ + ├── then_keyword_loc: (3,2)-(3,3) = "?" + ├── statements: + │ @ StatementsNode (location: (3,3)-(3,9)) + │ ├── flags: ∅ + │ └── body: (length: 1) + │ └── @ CallNode (location: (3,3)-(3,9)) + │ ├── flags: newline, variable_call, ignore_visibility + │ ├── receiver: ∅ + │ ├── call_operator_loc: ∅ + │ ├── name: :αvar1 + │ ├── message_loc: (3,3)-(3,9) = "αvar1" + │ ├── opening_loc: ∅ + │ ├── arguments: ∅ + │ ├── closing_loc: ∅ + │ ├── equal_loc: ∅ + │ └── block: ∅ + ├── subsequent: + │ @ ElseNode (location: (3,10)-(3,16)) + │ ├── flags: ∅ + │ ├── else_keyword_loc: (3,10)-(3,11) = ":" + │ ├── statements: + │ │ @ StatementsNode (location: (3,12)-(3,16)) + │ │ ├── flags: ∅ + │ │ └── body: (length: 1) + │ │ └── @ CallNode (location: (3,12)-(3,16)) + │ │ ├── flags: newline, variable_call, ignore_visibility + │ │ ├── receiver: ∅ + │ │ ├── call_operator_loc: ∅ + │ │ ├── name: :var2 + │ │ ├── message_loc: (3,12)-(3,16) = "var2" + │ │ ├── opening_loc: ∅ + │ │ ├── arguments: ∅ + │ │ ├── closing_loc: ∅ + │ │ ├── equal_loc: ∅ + │ │ └── block: ∅ + │ └── end_keyword_loc: ∅ + └── end_keyword_loc: ∅ diff --git a/src/prism.c b/src/prism.c index 338289a1c5..604e3d4701 100644 --- a/src/prism.c +++ b/src/prism.c @@ -9662,10 +9662,11 @@ lex_question_mark(pm_parser_t *parser) { } else { size_t encoding_width = pm_encoding_char_width(parser->encoding, parser->current.end, parser->end - parser->current.end); - // Ternary operators can have a ? immediately followed by an identifier - // which starts with an underscore. We check for this case here. + /* A ? followed by two identifier characters, as in `a ?bc : d`, is + * the ? of a ternary operator rather than a character literal. Any + * character that is not ASCII is an identifier character. */ if ( - !(pm_encoding_alnum_char(parser->encoding, parser->current.end, parser->end - parser->current.end) || peek(parser) == '_') || + !char_is_identifier(parser, parser->current.end, parser->end - parser->current.end) || ( (parser->current.end + encoding_width >= parser->end) || !char_is_identifier(parser, parser->current.end + encoding_width, parser->end - (parser->current.end + encoding_width)) diff --git a/test/prism/fixtures/ternary_operator_non_ascii.txt b/test/prism/fixtures/ternary_operator_non_ascii.txt new file mode 100644 index 0000000000..3505dd9333 --- /dev/null +++ b/test/prism/fixtures/ternary_operator_non_ascii.txt @@ -0,0 +1,3 @@ +a ?☃var1 : var2 + +a ?αvar1 : var2 diff --git a/test/prism/ruby/parser_test.rb b/test/prism/ruby/parser_test.rb index 71fec07d7e..1efe8e68ce 100644 --- a/test/prism/ruby/parser_test.rb +++ b/test/prism/ruby/parser_test.rb @@ -72,6 +72,9 @@ class ParserTest < TestCase # https://bugs.ruby-lang.org/issues/21168#note-5 "command_method_call_2.txt", + + # ? followed by a character that is not ASCII and not alphanumeric + "ternary_operator_non_ascii.txt", ] # These files contain code that is being parsed incorrectly by the parser diff --git a/test/prism/ruby/ruby_parser_test.rb b/test/prism/ruby/ruby_parser_test.rb index 65d5256bc6..023b0aba61 100644 --- a/test/prism/ruby/ruby_parser_test.rb +++ b/test/prism/ruby/ruby_parser_test.rb @@ -63,6 +63,7 @@ class RubyParserTest < TestCase "spanning_heredoc_newlines.txt", "spanning_heredoc.txt", "symbols.txt", + "ternary_operator_non_ascii.txt", "tilde_heredocs.txt", "unary_method_calls.txt", "unparser/corpus/literal/literal.txt", From e9a997f217c6c3503a4cc438f0ac826ee1ea2a30 Mon Sep 17 00:00:00 2001 From: Kevin Newton Date: Mon, 16 Nov 2026 17:49:51 -0500 Subject: [PATCH 06/20] Allow attributes with non-ASCII names as multiple assignment targets --- CHANGELOG.md | 1 + snapshots/multi_write_non_ascii.txt | 149 ++++++++++++++++++ src/prism.c | 6 +- test/prism/fixtures/multi_write_non_ascii.txt | 5 + 4 files changed, 160 insertions(+), 1 deletion(-) create mode 100644 snapshots/multi_write_non_ascii.txt create mode 100644 test/prism/fixtures/multi_write_non_ascii.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a4af7d384..fbd4a5b731 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a - The `pm_string_query_*` functions take a Ruby version as their last argument, written like the strings that `pm_options_version_set` accepts. Pass `NULL` for the latest version. An unknown version returns the new `PM_STRING_QUERY_ERROR_VERSION`. - Whether a name is a constant follows the version of Unicode of the Ruby that is targeted: Unicode 15.0.0 for Ruby 3.3 and 3.4, and Unicode 17.0.0 for Ruby 4.0 and 4.1. A name that starts with a letter that became uppercase in Unicode 16.0.0 or 17.0.0, such as the Garay capital letters, is now a local variable name when targeting Ruby 3.3 or 3.4. - A `?` followed by two identifier characters is a ternary operator, even when the first one is not ASCII. For example, `a ?☃b : c` used to read `?☃` as a character literal. +- A multiple assignment can write to an attribute whose name starts with a character that is not ASCII, as in `foo.☃, bar = 1, 2`. ## [2.1.0] - 2026-10-28 diff --git a/snapshots/multi_write_non_ascii.txt b/snapshots/multi_write_non_ascii.txt new file mode 100644 index 0000000000..2dae687832 --- /dev/null +++ b/snapshots/multi_write_non_ascii.txt @@ -0,0 +1,149 @@ +@ ProgramNode (location: (1,0)-(5,27)) +├── flags: ∅ +├── locals: [:bar, :a, :b] +└── statements: + @ StatementsNode (location: (1,0)-(5,27)) + ├── flags: ∅ + └── body: (length: 3) + ├── @ MultiWriteNode (location: (1,0)-(1,19)) + │ ├── flags: newline + │ ├── lefts: (length: 2) + │ │ ├── @ CallTargetNode (location: (1,0)-(1,7)) + │ │ │ ├── flags: ∅ + │ │ │ ├── receiver: + │ │ │ │ @ CallNode (location: (1,0)-(1,3)) + │ │ │ │ ├── flags: variable_call, ignore_visibility + │ │ │ │ ├── receiver: ∅ + │ │ │ │ ├── call_operator_loc: ∅ + │ │ │ │ ├── name: :foo + │ │ │ │ ├── message_loc: (1,0)-(1,3) = "foo" + │ │ │ │ ├── opening_loc: ∅ + │ │ │ │ ├── arguments: ∅ + │ │ │ │ ├── closing_loc: ∅ + │ │ │ │ ├── equal_loc: ∅ + │ │ │ │ └── block: ∅ + │ │ │ ├── call_operator_loc: (1,3)-(1,4) = "." + │ │ │ ├── name: :☃= + │ │ │ └── message_loc: (1,4)-(1,7) = "☃" + │ │ └── @ LocalVariableTargetNode (location: (1,9)-(1,12)) + │ │ ├── flags: ∅ + │ │ ├── name: :bar + │ │ └── depth: 0 + │ ├── rest: ∅ + │ ├── rights: (length: 0) + │ ├── lparen_loc: ∅ + │ ├── rparen_loc: ∅ + │ ├── operator_loc: (1,13)-(1,14) = "=" + │ └── value: + │ @ ArrayNode (location: (1,15)-(1,19)) + │ ├── flags: static_literal + │ ├── elements: (length: 2) + │ │ ├── @ IntegerNode (location: (1,15)-(1,16)) + │ │ │ ├── flags: static_literal, decimal + │ │ │ └── value: 1 + │ │ └── @ IntegerNode (location: (1,18)-(1,19)) + │ │ ├── flags: static_literal, decimal + │ │ └── value: 2 + │ ├── opening_loc: ∅ + │ └── closing_loc: ∅ + ├── @ MultiWriteNode (location: (3,0)-(3,18)) + │ ├── flags: newline + │ ├── lefts: (length: 2) + │ │ ├── @ CallTargetNode (location: (3,0)-(3,6)) + │ │ │ ├── flags: ∅ + │ │ │ ├── receiver: + │ │ │ │ @ CallNode (location: (3,0)-(3,3)) + │ │ │ │ ├── flags: variable_call, ignore_visibility + │ │ │ │ ├── receiver: ∅ + │ │ │ │ ├── call_operator_loc: ∅ + │ │ │ │ ├── name: :foo + │ │ │ │ ├── message_loc: (3,0)-(3,3) = "foo" + │ │ │ │ ├── opening_loc: ∅ + │ │ │ │ ├── arguments: ∅ + │ │ │ │ ├── closing_loc: ∅ + │ │ │ │ ├── equal_loc: ∅ + │ │ │ │ └── block: ∅ + │ │ │ ├── call_operator_loc: (3,3)-(3,4) = "." + │ │ │ ├── name: :α= + │ │ │ └── message_loc: (3,4)-(3,6) = "α" + │ │ └── @ LocalVariableTargetNode (location: (3,8)-(3,11)) + │ │ ├── flags: ∅ + │ │ ├── name: :bar + │ │ └── depth: 0 + │ ├── rest: ∅ + │ ├── rights: (length: 0) + │ ├── lparen_loc: ∅ + │ ├── rparen_loc: ∅ + │ ├── operator_loc: (3,12)-(3,13) = "=" + │ └── value: + │ @ ArrayNode (location: (3,14)-(3,18)) + │ ├── flags: static_literal + │ ├── elements: (length: 2) + │ │ ├── @ IntegerNode (location: (3,14)-(3,15)) + │ │ │ ├── flags: static_literal, decimal + │ │ │ └── value: 1 + │ │ └── @ IntegerNode (location: (3,17)-(3,18)) + │ │ ├── flags: static_literal, decimal + │ │ └── value: 2 + │ ├── opening_loc: ∅ + │ └── closing_loc: ∅ + └── @ MultiWriteNode (location: (5,0)-(5,27)) + ├── flags: newline + ├── lefts: (length: 2) + │ ├── @ LocalVariableTargetNode (location: (5,0)-(5,1)) + │ │ ├── flags: ∅ + │ │ ├── name: :a + │ │ └── depth: 0 + │ └── @ MultiTargetNode (location: (5,3)-(5,15)) + │ ├── flags: ∅ + │ ├── lefts: (length: 2) + │ │ ├── @ CallTargetNode (location: (5,4)-(5,11)) + │ │ │ ├── flags: ∅ + │ │ │ ├── receiver: + │ │ │ │ @ CallNode (location: (5,4)-(5,7)) + │ │ │ │ ├── flags: variable_call, ignore_visibility + │ │ │ │ ├── receiver: ∅ + │ │ │ │ ├── call_operator_loc: ∅ + │ │ │ │ ├── name: :foo + │ │ │ │ ├── message_loc: (5,4)-(5,7) = "foo" + │ │ │ │ ├── opening_loc: ∅ + │ │ │ │ ├── arguments: ∅ + │ │ │ │ ├── closing_loc: ∅ + │ │ │ │ ├── equal_loc: ∅ + │ │ │ │ └── block: ∅ + │ │ │ ├── call_operator_loc: (5,7)-(5,8) = "." + │ │ │ ├── name: :☃= + │ │ │ └── message_loc: (5,8)-(5,11) = "☃" + │ │ └── @ LocalVariableTargetNode (location: (5,13)-(5,14)) + │ │ ├── flags: ∅ + │ │ ├── name: :b + │ │ └── depth: 0 + │ ├── rest: ∅ + │ ├── rights: (length: 0) + │ ├── lparen_loc: (5,3)-(5,4) = "(" + │ └── rparen_loc: (5,14)-(5,15) = ")" + ├── rest: ∅ + ├── rights: (length: 0) + ├── lparen_loc: ∅ + ├── rparen_loc: ∅ + ├── operator_loc: (5,16)-(5,17) = "=" + └── value: + @ ArrayNode (location: (5,18)-(5,27)) + ├── flags: ∅ + ├── elements: (length: 2) + │ ├── @ IntegerNode (location: (5,18)-(5,19)) + │ │ ├── flags: static_literal, decimal + │ │ └── value: 1 + │ └── @ ArrayNode (location: (5,21)-(5,27)) + │ ├── flags: static_literal + │ ├── elements: (length: 2) + │ │ ├── @ IntegerNode (location: (5,22)-(5,23)) + │ │ │ ├── flags: static_literal, decimal + │ │ │ └── value: 2 + │ │ └── @ IntegerNode (location: (5,25)-(5,26)) + │ │ ├── flags: static_literal, decimal + │ │ └── value: 3 + │ ├── opening_loc: (5,21)-(5,22) = "[" + │ └── closing_loc: (5,26)-(5,27) = "]" + ├── opening_loc: ∅ + └── closing_loc: ∅ diff --git a/src/prism.c b/src/prism.c index 604e3d4701..9dececa056 100644 --- a/src/prism.c +++ b/src/prism.c @@ -13412,7 +13412,11 @@ parse_target(pm_parser_t *parser, pm_node_t *target, bool multiple, bool splat_p return UP(pm_local_variable_target_node_create(parser, &message_loc, name, 0)); } - if (peek_at(parser, parser->start + call->message_loc.start) == '_' || pm_encoding_alnum_char(parser->encoding, parser->start + call->message_loc.start, (ptrdiff_t) call->message_loc.length)) { + /* An attribute write, as in `foo.bar, baz = 1, 2`, writes to a + * name rather than an operator. A name starts with an + * identifier character, and any character that is not ASCII is + * one. */ + if (char_is_identifier_start(parser, parser->start + call->message_loc.start, (ptrdiff_t) call->message_loc.length)) { if (multiple && PM_NODE_FLAG_P(call, PM_CALL_NODE_FLAGS_SAFE_NAVIGATION)) { pm_parser_err_node(parser, (const pm_node_t *) call, PM_ERR_UNEXPECTED_SAFE_NAVIGATION); } diff --git a/test/prism/fixtures/multi_write_non_ascii.txt b/test/prism/fixtures/multi_write_non_ascii.txt new file mode 100644 index 0000000000..a45e7b9856 --- /dev/null +++ b/test/prism/fixtures/multi_write_non_ascii.txt @@ -0,0 +1,5 @@ +foo.☃, bar = 1, 2 + +foo.α, bar = 1, 2 + +a, (foo.☃, b) = 1, [2, 3] From 56af0b918b495696fb45b62037531e44108568f5 Mon Sep 17 00:00:00 2001 From: Kevin Newton Date: Mon, 16 Nov 2026 18:43:38 -0500 Subject: [PATCH 07/20] Add pm_encoding_ascii_alnum_p for the % literal checks --- include/prism/internal/encoding.h | 9 +++++++++ src/prism.c | 16 ++++++++++------ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/include/prism/internal/encoding.h b/include/prism/internal/encoding.h index 0837eff1fc..c666bff09a 100644 --- a/include/prism/internal/encoding.h +++ b/include/prism/internal/encoding.h @@ -174,6 +174,15 @@ bool pm_encoding_utf_8_isupper_char(const uint8_t *b, ptrdiff_t n, pm_options_ve */ extern const uint8_t pm_encoding_ascii_table[256]; +/* + * Return true if the byte is an ASCII letter or digit. A byte that is not ASCII + * is neither, in every encoding. + */ +static PRISM_INLINE bool +pm_encoding_ascii_alnum_p(uint8_t byte) { + return pm_encoding_ascii_table[byte] & PRISM_ENCODING_ALPHANUMERIC_BIT; +} + /* These are all of the encodings that prism supports. */ typedef enum { PM_ENCODING_UTF_8 = 0, diff --git a/src/prism.c b/src/prism.c index 9dececa056..65854dc2eb 100644 --- a/src/prism.c +++ b/src/prism.c @@ -11224,12 +11224,16 @@ parser_lex(pm_parser_t *parser) { (lex_state_p(parser, PM_LEX_STATE_FITEM) && (peek(parser) == 's')) || lex_state_spcarg_p(parser, space_seen) ) { - if (!pm_encoding_alnum_char(parser->encoding, parser->current.end, parser->end - parser->current.end)) { - if (*parser->current.end >= 0x80) { - pm_parser_err_current(parser, PM_ERR_INVALID_PERCENT); - goto lex_next_token; - } + /* A % followed by a character that is not ASCII is an + * error. If an ASCII letter or digit follows it, that + * character is the type of the literal, as in %q(a). + * Any other character is the delimiter of a string. */ + if (*parser->current.end >= 0x80) { + pm_parser_err_current(parser, PM_ERR_INVALID_PERCENT); + goto lex_next_token; + } + if (!pm_encoding_ascii_alnum_p(*parser->current.end)) { const uint8_t delimiter = pm_lex_percent_delimiter(parser); lex_mode_push_string(parser, true, false, lex_mode_incrementor(delimiter), lex_mode_terminator(delimiter)); LEX(PM_TOKEN_STRING_BEGIN); @@ -11238,7 +11242,7 @@ parser_lex(pm_parser_t *parser) { // Delimiters for %-literals cannot be alphanumeric. We // validate that here. uint8_t delimiter = peek_offset(parser, 1); - if (delimiter >= 0x80 || pm_encoding_alnum_char(parser->encoding, &delimiter, 1)) { + if (delimiter >= 0x80 || pm_encoding_ascii_alnum_p(delimiter)) { pm_parser_err_current(parser, PM_ERR_INVALID_PERCENT); goto lex_next_token; } From e77b29dc82924057714cef0f427c7bdad3716648 Mon Sep 17 00:00:00 2001 From: Kevin Newton Date: Mon, 16 Nov 2026 19:13:07 -0500 Subject: [PATCH 08/20] Check the ASCII characters of names in string queries as ASCII --- include/prism/internal/encoding.h | 9 +++++++++ src/string_query.c | 27 ++++++++++----------------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/include/prism/internal/encoding.h b/include/prism/internal/encoding.h index c666bff09a..9904ca08b2 100644 --- a/include/prism/internal/encoding.h +++ b/include/prism/internal/encoding.h @@ -174,6 +174,15 @@ bool pm_encoding_utf_8_isupper_char(const uint8_t *b, ptrdiff_t n, pm_options_ve */ extern const uint8_t pm_encoding_ascii_table[256]; +/* + * Return true if the byte is an ASCII letter. A byte that is not ASCII is not + * one, in every encoding. + */ +static PRISM_INLINE bool +pm_encoding_ascii_alpha_p(uint8_t byte) { + return pm_encoding_ascii_table[byte] & PRISM_ENCODING_ALPHABETIC_BIT; +} + /* * Return true if the byte is an ASCII letter or digit. A byte that is not ASCII * is neither, in every encoding. diff --git a/src/string_query.c b/src/string_query.c index daff7ff940..76b4752964 100644 --- a/src/string_query.c +++ b/src/string_query.c @@ -47,16 +47,14 @@ pm_slice_type(const uint8_t *source, size_t length, const char *encoding_name, c // check that there is at least one character if (length == 0) return PM_SLICE_TYPE_NONE; + /* A name starts with an ASCII letter, an underscore, or any valid character + * that is not ASCII. */ size_t width; - if ((width = pm_encoding_alpha_char(encoding, source, (ptrdiff_t) length)) != 0) { - // valid because alphabetical - } else if (*source == '_') { - // valid because underscore + if (*source >= 0x80) { + if ((width = pm_encoding_char_width(encoding, source, (ptrdiff_t) length)) == 0) return PM_SLICE_TYPE_NONE; + } else if (pm_encoding_ascii_alpha_p(*source) || (*source == '_')) { width = 1; - } else if ((*source >= 0x80) && ((width = pm_encoding_char_width(encoding, source, (ptrdiff_t) length)) > 0)) { - // valid because multibyte } else { - // invalid because no match return PM_SLICE_TYPE_NONE; } @@ -64,22 +62,17 @@ pm_slice_type(const uint8_t *source, size_t length, const char *encoding_name, c const uint8_t *end = source + length; pm_slice_type_t result = pm_encoding_isupper_char(encoding, source, end - source, target) ? PM_SLICE_TYPE_CONSTANT : PM_SLICE_TYPE_LOCAL; - // next, iterate through all of the bytes of the string to ensure that they - // are all valid identifier characters + /* The rest of a name is ASCII letters, digits, and underscores, and any + * valid characters that are not ASCII. */ source += width; while (source < end) { - if ((width = pm_encoding_alnum_char(encoding, source, end - source)) != 0) { - // valid because alphanumeric + if (*source >= 0x80) { + if ((width = pm_encoding_char_width(encoding, source, end - source)) == 0) break; source += width; - } else if (*source == '_') { - // valid because underscore + } else if (pm_encoding_ascii_alnum_p(*source) || (*source == '_')) { source++; - } else if ((*source >= 0x80) && ((width = pm_encoding_char_width(encoding, source, end - source)) > 0)) { - // valid because multibyte - source += width; } else { - // invalid because no match break; } } From 51288666a092714fb16aaaf5f86eaccd3a21e4aa Mon Sep 17 00:00:00 2001 From: Kevin Newton Date: Mon, 16 Nov 2026 19:17:50 -0500 Subject: [PATCH 09/20] Read the coding magic comment value as ASCII --- include/prism/internal/encoding.h | 18 ------------------ src/prism.c | 3 ++- 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/include/prism/internal/encoding.h b/include/prism/internal/encoding.h index 9904ca08b2..d83a31ce0d 100644 --- a/include/prism/internal/encoding.h +++ b/include/prism/internal/encoding.h @@ -118,24 +118,6 @@ size_t pm_encoding_char_width(const pm_encoding_t *encoding, const uint8_t *b, p */ size_t pm_encoding_property_char(const pm_encoding_t *encoding, uint8_t property, const uint8_t *b, ptrdiff_t n); -/* - * Return the number of bytes in the next character in the given encoding if it - * is alphabetical, or 0 otherwise. - */ -static PRISM_INLINE size_t -pm_encoding_alpha_char(const pm_encoding_t *encoding, const uint8_t *b, ptrdiff_t n) { - return pm_encoding_property_char(encoding, PRISM_ENCODING_ALPHABETIC_BIT, b, n); -} - -/* - * Return the number of bytes in the next character in the given encoding if it - * is alphanumeric, or 0 otherwise. - */ -static PRISM_INLINE size_t -pm_encoding_alnum_char(const pm_encoding_t *encoding, const uint8_t *b, ptrdiff_t n) { - return pm_encoding_property_char(encoding, PRISM_ENCODING_ALPHANUMERIC_BIT, b, n); -} - /* * Return true if the next character in the given encoding is uppercase, or * titlecase, in the given version of Ruby. Such a character begins a constant diff --git a/src/prism.c b/src/prism.c index 65854dc2eb..9be3c2a83a 100644 --- a/src/prism.c +++ b/src/prism.c @@ -7560,8 +7560,9 @@ parser_lex_magic_comment_encoding(pm_parser_t *parser) { cursor++; } + /* The name of an encoding is made of ASCII letters, digits, - and _. */ const uint8_t *value_start = cursor; - while ((*cursor == '-' || *cursor == '_' || pm_encoding_alnum_char(parser->encoding, cursor, 1)) && ++cursor < end); + while ((*cursor == '-' || *cursor == '_' || pm_encoding_ascii_alnum_p(*cursor)) && ++cursor < end); if (!parser_lex_magic_comment_encoding_value(parser, value_start, cursor)) { // If we were unable to parse the encoding value, then we've got an From 2a5372cb9810d02f59b8b5a8996ad760f24654e2 Mon Sep 17 00:00:00 2001 From: Kevin Newton Date: Mon, 16 Nov 2026 19:23:21 -0500 Subject: [PATCH 10/20] Remove the unreachable Unicode branches of pm_encoding_property_char --- include/prism/internal/encoding.h | 20 --------- src/encoding.c | 67 ++----------------------------- 2 files changed, 3 insertions(+), 84 deletions(-) diff --git a/include/prism/internal/encoding.h b/include/prism/internal/encoding.h index d83a31ce0d..3af1d3f09d 100644 --- a/include/prism/internal/encoding.h +++ b/include/prism/internal/encoding.h @@ -110,14 +110,6 @@ pm_encoding_multibyte_p(const pm_encoding_t *encoding) { */ size_t pm_encoding_char_width(const pm_encoding_t *encoding, const uint8_t *b, ptrdiff_t n); -/* - * Return the number of bytes in the next character in the given encoding if it - * has the given PRISM_ENCODING_*_BIT property, or 0 otherwise. In an encoding - * whose characters are Unicode code points, this answers for the version of - * Unicode that the tables are. - */ -size_t pm_encoding_property_char(const pm_encoding_t *encoding, uint8_t property, const uint8_t *b, ptrdiff_t n); - /* * Return true if the next character in the given encoding is uppercase, or * titlecase, in the given version of Ruby. Such a character begins a constant @@ -129,18 +121,6 @@ bool pm_encoding_isupper_char(const pm_encoding_t *encoding, const uint8_t *b, p /* Return the size of the next character in the UTF-8 encoding. */ size_t pm_encoding_utf_8_char_width(const uint8_t *b, ptrdiff_t n); -/* - * Return the size of the next character in the UTF-8 encoding if it is an - * alphabetical character. - */ -size_t pm_encoding_utf_8_alpha_char(const uint8_t *b, ptrdiff_t n); - -/* - * Return the size of the next character in the UTF-8 encoding if it is an - * alphanumeric character. - */ -size_t pm_encoding_utf_8_alnum_char(const uint8_t *b, ptrdiff_t n); - /* * Return true if the next character in the UTF-8 encoding is uppercase, or * titlecase, in the given version of Ruby. diff --git a/src/encoding.c b/src/encoding.c index 9dd3fa576a..eed00099ff 100644 --- a/src/encoding.c +++ b/src/encoding.c @@ -619,46 +619,6 @@ pm_encoding_utf_8_char_width(const uint8_t *b, ptrdiff_t n) { return 0; } -/** - * Return the size of the next character in the UTF-8 encoding if it is an - * alphabetical character. - */ -size_t -pm_encoding_utf_8_alpha_char(const uint8_t *b, ptrdiff_t n) { - if (n == 0) { - return 0; - } - - if (*b < 0x80) { - return (pm_encoding_ascii_table[*b] & PRISM_ENCODING_ALPHABETIC_BIT) ? 1 : 0; - } - - size_t width; - pm_unicode_codepoint_t codepoint = pm_utf_8_codepoint(b, n, &width); - - return (pm_unicode_codepoint_properties(codepoint) & PRISM_ENCODING_ALPHABETIC_BIT) ? width : 0; -} - -/** - * Return the size of the next character in the UTF-8 encoding if it is an - * alphanumeric character. - */ -size_t -pm_encoding_utf_8_alnum_char(const uint8_t *b, ptrdiff_t n) { - if (n == 0) { - return 0; - } - - if (*b < 0x80) { - return (pm_encoding_ascii_table[*b] & (PRISM_ENCODING_ALPHANUMERIC_BIT)) ? 1 : 0; - } - - size_t width; - pm_unicode_codepoint_t codepoint = pm_utf_8_codepoint(b, n, &width); - - return (pm_unicode_codepoint_properties(codepoint) & (PRISM_ENCODING_ALPHANUMERIC_BIT)) ? width : 0; -} - /** * Return true if the next character in the UTF-8 encoding is uppercase, or * titlecase, in the given version of Ruby. @@ -702,15 +662,6 @@ pm_cesu_8_codepoint(const uint8_t *b, size_t width) { } } -/** - * Return true if the character in the CESU-8 encoding that is the given number - * of bytes long has the given property, which is that of its code point. - */ -static bool -pm_cesu_8_property_p(const uint8_t *b, size_t width, uint8_t property) { - return (pm_unicode_codepoint_properties(pm_cesu_8_codepoint(b, width)) & property) != 0; -} - #endif #undef UNICODE_CODEPOINTS_MAXIMUM @@ -1614,20 +1565,12 @@ pm_encoding_char_width(const pm_encoding_t *encoding, const uint8_t *b, ptrdiff_ /** * Return the number of bytes in the next character in the given encoding if it - * has the given PRISM_ENCODING_*_BIT property, or 0 otherwise. + * has the given PRISM_ENCODING_*_BIT property, or 0 otherwise. The encoding is + * one whose characters are not Unicode code points, so not UTF-8 or CESU-8. */ -size_t +static size_t pm_encoding_property_char(const pm_encoding_t *encoding, uint8_t property, const uint8_t *b, ptrdiff_t n) { switch (encoding->kind) { - case PM_ENCODING_KIND_UTF_8: - switch (property) { - case PRISM_ENCODING_ALPHABETIC_BIT: - return pm_encoding_utf_8_alpha_char(b, n); - case PRISM_ENCODING_ALPHANUMERIC_BIT: - return pm_encoding_utf_8_alnum_char(b, n); - default: - return pm_encoding_utf_8_isupper_char(b, n, PM_OPTIONS_VERSION_LATEST) ? pm_encoding_utf_8_char_width(b, n) : 0; - } case PM_ENCODING_KIND_ASCII: case PM_ENCODING_KIND_SINGLE_BYTE: return ((n > 0) && (encoding->table[*b] & property)) ? 1 : 0; @@ -1638,10 +1581,6 @@ pm_encoding_property_char(const pm_encoding_t *encoding, uint8_t property, const #ifndef PRISM_ENCODING_EXCLUDE_FULL case PM_ENCODING_KIND_BIG5: return pm_encoding_big5_property_char(property, b, n); - case PM_ENCODING_KIND_CESU_8: { - size_t width = pm_encoding_cesu_8_char_width(b, n); - return (width != 0 && pm_cesu_8_property_p(b, width, property)) ? width : 0; - } case PM_ENCODING_KIND_CP949: return pm_encoding_cp949_property_char(property, b, n); case PM_ENCODING_KIND_EMACS_MULE: From 67525752c162bed0c8c9fa3f1869375bb56cb470 Mon Sep 17 00:00:00 2001 From: Kevin Newton Date: Mon, 16 Nov 2026 19:55:05 -0500 Subject: [PATCH 11/20] Keep only the uppercase bits in the Unicode tables --- bin/prism | 34 ++- src/encoding.c | 556 +++++++++++++------------------------------------ 2 files changed, 153 insertions(+), 437 deletions(-) diff --git a/bin/prism b/bin/prism index f2425ff30c..4c2023fa01 100755 --- a/bin/prism +++ b/bin/prism @@ -477,7 +477,7 @@ module Prism # Return the codepoints that have the given property in the given file of # the Unicode Character Database at the given version. Each line of the # file gives a codepoint or a range of codepoints and a property, as in - # "0041..005A ; Alphabetic". + # "0041..005A ; Uppercase". def unicode_property(path, property, version = UNICODE_VERSION) codepoints = [] @@ -507,13 +507,11 @@ module Prism # table with its next five bits. Identical middle and leaf blocks are # shared, which is what keeps the tables small. # - # The properties are those that the regular expression engine gives the - # POSIX classes, from the Unicode Character Database at UNICODE_VERSION: - # - # * Alphabetic is the Alphabetic property, as in [[:alpha:]]. - # * Alphanumeric is Alphabetic or a decimal digit (Nd), as in [[:alnum:]]. - # * Uppercase is the Uppercase property, as in [[:upper:]], or a titlecase - # letter (Lt), since either can begin a constant name. + # The tables mark the codepoints that are uppercase in the Unicode + # Character Database at UNICODE_VERSION: those with the Uppercase property, + # as in [[:upper:]], and the titlecase letters (Lt), since either can begin + # a constant name. Every other character that is not ASCII is an identifier + # character, so the tables need no other properties. # # Older versions of Ruby use an older version of Unicode, in which some # of the uppercase letters of the tables are not uppercase. Another bit @@ -530,12 +528,10 @@ module Prism values = Array.new(0x110000, 0) - unicode_property("DerivedCoreProperties.txt", "Alphabetic").each { |codepoint| values[codepoint] |= (1 << 0) | (1 << 1) } - unicode_property("extracted/DerivedGeneralCategory.txt", "Nd").each { |codepoint| values[codepoint] |= (1 << 1) } latest_uppercase.each { |codepoint| values[codepoint] |= (1 << 2) } (latest_uppercase - older_uppercase).each { |codepoint| values[codepoint] |= (1 << 3) } - names = { 0 => "N", 2 => "D", 3 => "A", 7 => "U", 15 => "V" } + names = { 0 => "N", 4 => "U", 12 => "V" } unknown = values.uniq - names.keys raise "unnamed property values: #{unknown.inspect}" if unknown.any? @@ -582,20 +578,14 @@ module Prism */ #define #{older_bit} (1 << 3) - /* No properties. */ + /* Not uppercase. */ #define N 0 - /* A digit: alphanumeric but not alphabetic. */ - #define D (PRISM_ENCODING_ALPHANUMERIC_BIT) - - /* A letter that is not uppercase: alphabetic and alphanumeric. */ - #define A (PRISM_ENCODING_ALPHABETIC_BIT | PRISM_ENCODING_ALPHANUMERIC_BIT) - - /* An uppercase or titlecase letter: alphabetic, alphanumeric, and uppercase. */ - #define U (PRISM_ENCODING_ALPHABETIC_BIT | PRISM_ENCODING_ALPHANUMERIC_BIT | PRISM_ENCODING_UPPERCASE_BIT) + /* An uppercase or titlecase letter. */ + #define U (PRISM_ENCODING_UPPERCASE_BIT) /* An uppercase or titlecase letter that is not one in Unicode #{older}. */ - #define V (PRISM_ENCODING_ALPHABETIC_BIT | PRISM_ENCODING_ALPHANUMERIC_BIT | PRISM_ENCODING_UPPERCASE_BIT | #{older_bit}) + #define V (PRISM_ENCODING_UPPERCASE_BIT | #{older_bit}) C puts "\nstatic const uint8_t pm_unicode_leaf[#{leaf_blocks.length}][8] = {" @@ -604,7 +594,7 @@ module Prism end puts "};" - puts "\n#undef N\n#undef D\n#undef A\n#undef U\n#undef V" + puts "\n#undef N\n#undef U\n#undef V" end # Deduplicate the given blocks. The block made entirely of the given empty diff --git a/src/encoding.c b/src/encoding.c index eed00099ff..cf498183a1 100644 --- a/src/encoding.c +++ b/src/encoding.c @@ -20,193 +20,74 @@ typedef uint32_t pm_unicode_codepoint_t; * The tables are Unicode 17.0.0. `bin/prism encoding UTF-8` generates them from * the Unicode Character Database at that version. */ -#define UNICODE_CODEPOINTS_MAXIMUM 0x33500 - -static const uint8_t pm_unicode_root[821] = { - /* U+00000 */ 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, - /* U+01000 */ 0x13, 0x01, 0x14, 0x15, 0x16, 0x01, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, - /* U+02000 */ 0x21, 0x22, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x25, 0x26, 0x00, - /* U+03000 */ 0x27, 0x28, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - /* U+04000 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x29, 0x01, 0x01, - /* U+05000 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - /* U+06000 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - /* U+07000 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - /* U+08000 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - /* U+09000 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - /* U+0A000 */ 0x01, 0x01, 0x01, 0x01, 0x2A, 0x01, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x01, 0x01, 0x01, 0x01, - /* U+0B000 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - /* U+0C000 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - /* U+0D000 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +#define UNICODE_CODEPOINTS_MAXIMUM 0x1F200 + +static const uint8_t pm_unicode_root[498] = { + /* U+00000 */ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* U+01000 */ 0x07, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x0A, 0x0B, + /* U+02000 */ 0x00, 0x0C, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, + /* U+03000 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* U+04000 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* U+05000 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* U+06000 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* U+07000 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* U+08000 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* U+09000 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* U+0A000 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* U+0B000 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* U+0C000 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* U+0D000 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* U+0E000 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* U+0F000 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x32, 0x33, 0x01, 0x34, 0x35, 0x36, - /* U+10000 */ 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x01, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, - /* U+11000 */ 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, - /* U+12000 */ 0x01, 0x01, 0x01, 0x56, 0x57, 0x58, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x59, - /* U+13000 */ 0x01, 0x01, 0x01, 0x01, 0x5A, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - /* U+14000 */ 0x01, 0x01, 0x01, 0x5B, 0x01, 0x01, 0x5C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* U+0F000 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, + /* U+10000 */ 0x00, 0x00, 0x00, 0x00, 0x12, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x15, 0x00, 0x00, + /* U+11000 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* U+12000 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* U+13000 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* U+14000 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* U+15000 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* U+16000 */ 0x00, 0x5D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x5E, 0x5F, 0x00, 0x60, 0x61, 0x62, - /* U+17000 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - /* U+18000 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x63, 0x64, 0x00, 0x00, + /* U+16000 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17, 0x00, + /* U+17000 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* U+18000 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* U+19000 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* U+1A000 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x65, - /* U+1B000 */ 0x01, 0x66, 0x67, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, - /* U+1C000 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, - /* U+1D000 */ 0x00, 0x00, 0x00, 0x00, 0x69, 0x6A, 0x6B, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6D, - /* U+1E000 */ 0x6E, 0x6F, 0x70, 0x00, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, - /* U+1F000 */ 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, - /* U+20000 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - /* U+21000 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - /* U+22000 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - /* U+23000 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - /* U+24000 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - /* U+25000 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - /* U+26000 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - /* U+27000 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - /* U+28000 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - /* U+29000 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - /* U+2A000 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x79, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - /* U+2B000 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x7A, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - /* U+2C000 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x7B, 0x01, - /* U+2D000 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - /* U+2E000 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x7C, 0x01, 0x01, 0x7D, 0x00, - /* U+2F000 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, - /* U+30000 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - /* U+31000 */ 0x01, 0x01, 0x01, 0x7F, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - /* U+32000 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - /* U+33000 */ 0x01, 0x01, 0x01, 0x01, 0x80, + /* U+1A000 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* U+1B000 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* U+1C000 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* U+1D000 */ 0x00, 0x00, 0x00, 0x00, 0x18, 0x19, 0x1A, 0x1B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* U+1E000 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* U+1F000 */ 0x00, 0x1D, }; -static const uint8_t pm_unicode_middle[129][32] = { +static const uint8_t pm_unicode_middle[30][32] = { [0x00] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x01] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }, - [0x02] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x06 }, - [0x03] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x06, 0x2D, 0x02, 0x02, 0x2E, 0x0C, 0x01, 0x01, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x1D, 0x1C, 0x02, 0x02, 0x2F, 0x5A, 0x01, 0x01, 0x05, 0x01 }, - [0x04] = { 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x30, 0x30, 0x3F, 0x03, 0x03, 0x03, 0x03, 0x03, 0x5B, 0x40, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, 0x64, 0x30, 0x65, 0x03, 0x03, 0x40, 0x03 }, - [0x05] = { 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x41, 0x66, 0x67, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x31, 0x01, 0x0D, 0x00, 0x0A, 0x68, 0x00, 0x00 }, - [0x06] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1D, 0x00, 0x00, 0x00, 0x18, 0x01, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x02, 0x6E, 0x42, 0x01, 0x01, 0x01, 0x6F, 0x70, 0x03, 0x03, 0x03, 0x71, 0x72 }, - [0x07] = { 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x03, 0x73, 0x43, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x74, 0x75, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 }, - [0x08] = { 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x2D, 0x02, 0x02, 0x02, 0x2F, 0x2A, 0x01, 0x01, 0x01, 0x01, 0x01, 0x09, 0x00, 0x00, 0x00, 0x00, 0x01, 0x12, 0x76, 0x00, 0x01, 0x01, 0x01, 0x2B, 0x08, 0x00 }, - [0x09] = { 0x00, 0x00, 0x01, 0x08, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0C, 0x04, 0x77, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x11, 0x0A, 0x0C, 0x44, 0x04, 0x78 }, - [0x0A] = { 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x15, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0D, 0x00, 0x04, 0x22, 0x01, 0x01, 0x01, 0x08, 0x79, 0x1C }, - [0x0B] = { 0x01, 0x01, 0x01, 0x10, 0x01, 0x0A, 0x00, 0x00, 0x01, 0x01, 0x01, 0x09, 0x01, 0x08, 0x01, 0x01, 0x01, 0x0C, 0x0E, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0D, 0x1E, 0x01, 0x18, 0x0D, 0x01, 0x01 }, - [0x0C] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x11, 0x01, 0x13, 0x44, 0x01, 0x19, 0x04, 0x0C, 0x01, 0x11, 0x16, 0x1F, 0x01, 0x01, 0x0F, 0x7A, 0x20, 0x16, 0x7B, 0x0E, 0x45, 0x19, 0x04, 0x0D, 0x46 }, - [0x0D] = { 0x23, 0x2B, 0x1F, 0x01, 0x01, 0x0F, 0x7C, 0x31, 0x2B, 0x32, 0x2A, 0x47, 0x24, 0x04, 0x07, 0x00, 0x23, 0x12, 0x17, 0x01, 0x01, 0x0F, 0x33, 0x20, 0x12, 0x34, 0x09, 0x00, 0x19, 0x04, 0x00, 0x48 }, - [0x0E] = { 0x23, 0x16, 0x1F, 0x01, 0x01, 0x0F, 0x33, 0x20, 0x16, 0x32, 0x21, 0x45, 0x19, 0x04, 0x2A, 0x00, 0x7D, 0x25, 0x1A, 0x49, 0x7E, 0x25, 0x01, 0x31, 0x25, 0x35, 0x4A, 0x00, 0x24, 0x04, 0x00, 0x00 }, - [0x0F] = { 0x01, 0x13, 0x0F, 0x01, 0x01, 0x0F, 0x01, 0x20, 0x13, 0x35, 0x4B, 0x36, 0x19, 0x04, 0x00, 0x00, 0x11, 0x13, 0x0F, 0x01, 0x01, 0x0F, 0x11, 0x20, 0x13, 0x35, 0x4B, 0x4C, 0x19, 0x04, 0x7F, 0x00 }, - [0x10] = { 0x01, 0x13, 0x0F, 0x01, 0x01, 0x01, 0x01, 0x37, 0x13, 0x80, 0x1E, 0x0E, 0x19, 0x04, 0x00, 0x10, 0x23, 0x01, 0x05, 0x10, 0x01, 0x01, 0x17, 0x4D, 0x05, 0x0E, 0x38, 0x01, 0x24, 0x04, 0x81, 0x00 }, - [0x11] = { 0x0C, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x08, 0x05, 0x1D, 0x04, 0x06, 0x00, 0x00, 0x00, 0x00, 0x49, 0x14, 0x01, 0x01, 0x82, 0x01, 0x01, 0x83, 0x38, 0x1D, 0x04, 0x84, 0x00, 0x00, 0x00, 0x00 }, - [0x12] = { 0x09, 0x00, 0x00, 0x00, 0x04, 0x06, 0x00, 0x00, 0x01, 0x0C, 0x01, 0x01, 0x01, 0x0A, 0x0C, 0x01, 0x0B, 0x01, 0x01, 0x0C, 0x01, 0x01, 0x01, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x13] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05, 0x1F, 0x04, 0x06, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x04, 0x85, 0x02, 0x02, 0x02, 0x02, 0x86, 0x87, 0x01, 0x01, 0x01, 0x01, 0x01, 0x14 }, - [0x14] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x1A, 0x05, 0x1A, 0x01, 0x01, 0x01, 0x01, 0x01, 0x1A, 0x01, 0x01, 0x01, 0x01, 0x1A, 0x05, 0x1A, 0x01, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01 }, - [0x15] = { 0x01, 0x01, 0x1A, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x08, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x39, 0x07 }, - [0x16] = { 0x0C, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }, - [0x17] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x16, 0x01, 0x01, 0x0C, 0x01, 0x01, 0x08, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x25, 0x01, 0x09 }, - [0x18] = { 0x01, 0x01, 0x0B, 0x0E, 0x01, 0x01, 0x0B, 0x00, 0x01, 0x01, 0x0B, 0x00, 0x01, 0x13, 0x88, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x4E, 0x01, 0x01, 0x09, 0x0E, 0x46, 0x04, 0x06, 0x00, 0x00 }, - [0x19] = { 0x00, 0x00, 0x04, 0x06, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x09, 0x01, 0x01, 0x01, 0x01, 0x01, 0x08, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x07, 0x00 }, - [0x1A] = { 0x01, 0x01, 0x01, 0x05, 0x01, 0x0B, 0x01, 0x09, 0x24, 0x04, 0x01, 0x01, 0x01, 0x07, 0x0A, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0B, 0x01, 0x01, 0x01, 0x0D, 0x04, 0x06, 0x00, 0x00, 0x00, 0x00 }, - [0x1B] = { 0x01, 0x01, 0x01, 0x0B, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05, 0x0C, 0x01, 0x0A, 0x00, 0x04, 0x06, 0x04, 0x06, 0x0E, 0x00, 0x00, 0x0E, 0x09, 0x4C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x1C] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x11, 0x01, 0x11, 0x0A, 0x04, 0x06, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x89, 0x04, 0x22, 0x01, 0x01, 0x01, 0x01, 0x12, 0x01, 0x0D, 0x00 }, - [0x1D] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05, 0x00, 0x04, 0x8A, 0x04, 0x22, 0x01, 0x01, 0x01, 0x07, 0x01, 0x8B, 0x02, 0x02, 0x02, 0x02, 0x02, 0x4F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8C, 0x26, 0x1C }, - [0x1E] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x18, 0x01, 0x01, 0x01, 0x0A, 0x00 }, - [0x1F] = { 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x8D, 0x8E, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 }, - [0x20] = { 0x01, 0x02, 0x07, 0x39, 0x01, 0x02, 0x01, 0x02, 0x07, 0x39, 0x01, 0x8F, 0x01, 0x02, 0x01, 0x07, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x13, 0x90, 0x50, 0x3A, 0x4E, 0x51, 0x01, 0x3A, 0x50, 0x3A }, - [0x21] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2A, 0x0E, 0x00, 0x00, 0x01, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x22] = { 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x42, 0x97, 0x98, 0x52, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x99, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x23] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9A, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x0D, 0x00, 0x00 }, - [0x24] = { 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x9B, 0x9C, 0x9D, 0x53, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x9E, 0x9F, 0xA0, 0x00 }, - [0x25] = { 0x01, 0x01, 0x01, 0x01, 0x12, 0x1D, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0E, 0x00, 0x00, 0x01, 0x01, 0x05, 0x00, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x01, 0x01, 0x01, 0x01 }, - [0x26] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x27] = { 0x15, 0x00, 0x00, 0x00, 0x0C, 0x0D, 0x3B, 0x0A, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05, 0x15, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x14 }, - [0x28] = { 0x15, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01 }, - [0x29] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x2A] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x07 }, - [0x2B] = { 0x01, 0x0A, 0x01, 0x01, 0x04, 0xA1, 0x00, 0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0xA2, 0x1E, 0x54, 0x03, 0x03, 0x03, 0x41, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00 }, - [0x2C] = { 0x00, 0x00, 0x0E, 0x01, 0x43, 0x03, 0x3F, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0xA3, 0x03, 0xA4, 0xA5, 0x03, 0x03, 0xA6, 0xA7, 0x03, 0xA8, 0xA9, 0xAA, 0xAB, 0x00, 0x00, 0xAC, 0x01 }, - [0x2D] = { 0x12, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0B, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x4D, 0x00, 0x04, 0x06, 0x00, 0x00, 0x10, 0xAD }, - [0x2E] = { 0x04, 0x22, 0x01, 0x01, 0x01, 0x08, 0x01, 0x01, 0x01, 0x01, 0x08, 0x00, 0x01, 0x01, 0x01, 0x0A, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x14, 0x01, 0x00, 0x0E, 0x04, 0x06, 0x01, 0x01, 0x04, 0xAE }, - [0x2F] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05, 0x00, 0x01, 0x07, 0x04, 0x06, 0x01, 0x01, 0x05, 0x10, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05, 0xAF, 0x00, 0x00, 0xB0, 0x01, 0x01, 0xB1, 0x00 }, - [0x30] = { 0x2C, 0x2C, 0x2C, 0x00, 0x05, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x14, 0x01, 0x0D, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x08, 0x04, 0x06 }, - [0x31] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0B, 0x00, 0x01, 0x01, 0x05, 0x18, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0B }, - [0x32] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x07, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0D, 0x00, 0x00, 0x00, 0x00 }, - [0x33] = { 0x05, 0x00, 0x18, 0x15, 0x01, 0x0F, 0x05, 0x38, 0x55, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0D, 0x00, 0x00, 0x00, 0x18, 0x01, 0x01, 0x01, 0x01, 0x01 }, - [0x34] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x07, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x10, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0B }, - [0x35] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0A }, - [0x36] = { 0x00, 0x00, 0x04, 0x06, 0x2D, 0x02, 0x02, 0x2E, 0x0C, 0x01, 0x01, 0x08, 0x21, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05, 0x10, 0x10, 0x10, 0x56, 0x00, 0x00, 0x00, 0x00 }, - [0x37] = { 0x01, 0x11, 0x01, 0x01, 0x05, 0x01, 0x01, 0xB2, 0x01, 0x07, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x08 }, - [0x38] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x39] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x0A, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x3A] = { 0x01, 0x01, 0x01, 0x01, 0x00, 0x15, 0x01, 0x01, 0x01, 0x08, 0x01, 0x01, 0x01, 0x01, 0x01, 0x08, 0x01, 0x01, 0x01, 0x07, 0x01, 0x01, 0x01, 0x01, 0x0B, 0x01, 0x3B, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x3B] = { 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x07, 0x04, 0x06, 0x02, 0x02, 0x02, 0x02, 0x51, 0x01, 0x01, 0x01, 0x01, 0x0B }, - [0x3C] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0B, 0x00, 0x02, 0x57, 0x02, 0x57, 0xB3, 0x01, 0x17, 0x01, 0x17, 0x34, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0B, 0x00 }, - [0x3D] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05, 0x00, 0x01, 0x01, 0x07, 0x00, 0x01, 0x00, 0x00, 0x00, 0x12, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0F, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x3E] = { 0x07, 0x0F, 0x01, 0x01, 0x01, 0x01, 0x12, 0xB4, 0x01, 0x01, 0x07, 0x00, 0x01, 0x01, 0x05, 0x00, 0x01, 0x01, 0x01, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x36, 0x00 }, - [0x3F] = { 0x01, 0x01, 0x07, 0x00, 0x01, 0x01, 0x01, 0x0D, 0x01, 0x01, 0x01, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x40] = { 0x26, 0x1E, 0x11, 0x0C, 0x01, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x0A, 0x01, 0x01, 0x01, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0C, 0x01, 0x01, 0x0A, 0x00, 0x00, 0x00 }, - [0x41] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x07, 0x00, 0x01, 0x01, 0x07, 0x00, 0x01, 0x01, 0x08, 0x00, 0x01, 0x01, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x42] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x2E, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x08, 0x00 }, - [0x43] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x04, 0x06, 0x04, 0x22, 0x27, 0x27, 0xB5, 0xB6, 0x01, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x44] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x34, 0x0D, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x56 }, - [0x45] = { 0x01, 0x01, 0x01, 0x0A, 0x0E, 0x00, 0x01, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x0A, 0x00, 0x00, 0x00, 0x01, 0x01, 0x05, 0x00 }, - [0x46] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x07, 0x00, 0x00, 0x00, 0x24, 0x04, 0x3B, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x09, 0x1C, 0x00, 0x01, 0x01, 0x01, 0x09, 0x04, 0x06 }, - [0x47] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0xB7, 0x04, 0x1E, 0x00, 0x01, 0x01, 0x01, 0x01, 0xB8, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x48, 0x21, 0x04, 0xB9, 0x00, 0x00, 0x00, 0x00 }, - [0x48] = { 0x01, 0x01, 0x17, 0x01, 0x01, 0x01, 0x16, 0x21, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0xBA, 0x01, 0x12, 0x01, 0x09, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x09, 0x04, 0x06 }, - [0x49] = { 0x11, 0x16, 0x1F, 0x01, 0x01, 0x0F, 0x33, 0x20, 0x16, 0x32, 0x4A, 0x15, 0x0B, 0x00, 0x00, 0x00, 0x01, 0xBB, 0x01, 0x01, 0x01, 0x01, 0x12, 0x01, 0xBC, 0x36, 0x58, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x4A] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0xBD, 0x08, 0x04, 0xBE, 0x0D, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0xBF, 0x00, 0x04, 0x06, 0x00, 0x00, 0x00, 0x00 }, - [0x4B] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x07, 0x05, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00 }, - [0x4C] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05, 0xC0, 0x00, 0x04, 0x06, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x07, 0x09, 0x04, 0x06, 0x04, 0x04, 0xC1, 0x00, 0x00, 0x00 }, - [0x4D] = { 0x01, 0x01, 0x01, 0x37, 0x01, 0x08, 0x04, 0x06, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x4E] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x04, 0x06, 0x00, 0x0E }, - [0x4F] = { 0x05, 0xC2, 0x26, 0x01, 0x01, 0x01, 0x12, 0xC3, 0x08, 0x00, 0x04, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x01, 0x01, 0x01, 0x01, 0x01, 0x10, 0xC4, 0x00, 0x00, 0x00 }, - [0x50] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x37, 0x05, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x1D, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x09 }, - [0x51] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x09, 0x00, 0x04, 0x06 }, - [0x52] = { 0x01, 0x0F, 0x01, 0x01, 0x01, 0x01, 0x05, 0x05, 0x09, 0x00, 0x04, 0x06, 0x00, 0x00, 0x10, 0x01, 0x01, 0x01, 0x10, 0x01, 0x01, 0x0C, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x53] = { 0x05, 0x17, 0x01, 0x01, 0x01, 0x01, 0x05, 0xC5, 0xC6, 0x00, 0x04, 0x06, 0x12, 0x0F, 0x01, 0x01, 0x01, 0x05, 0xC7, 0x09, 0x04, 0x06, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0B, 0x04, 0x06, 0x00, 0x00 }, - [0x54] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x05, 0x00 }, - [0x55] = { 0x01, 0x01, 0x0F, 0x01, 0x01, 0x01, 0x01, 0x25, 0x09, 0x00, 0x04, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x56] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x57] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }, - [0x58] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x59] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x09, 0x00 }, - [0x5A] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x2C, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }, - [0x5B] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x08 }, - [0x5C] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x5D] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x05, 0x04, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x5E] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x09, 0x01, 0x01, 0x01, 0x05, 0x04, 0x06, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05, 0x04, 0x06, 0x01, 0x01, 0x01, 0x07, 0x00, 0x00 }, - [0x5F] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x0B, 0x00, 0x04, 0x06, 0x18, 0x01, 0x01, 0x15, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x60] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0A, 0x04, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x61] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x27, 0x27, 0x27, 0xC8, 0x01, 0x01, 0x0B, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x62] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x2B, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0E, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC9, 0x00, 0x05, 0x00 }, - [0x63] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x0E }, - [0x64] = { 0x01, 0x01, 0x01, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x08, 0x00 }, - [0x65] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x26 }, - [0x66] = { 0x01, 0x01, 0x01, 0x01, 0x08, 0x00, 0x1C, 0x00, 0x00, 0x00, 0xCA, 0x00, 0x1E, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }, - [0x67] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0B }, - [0x68] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x08, 0x01, 0x0A, 0x01, 0x09, 0x01, 0x52, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x69] = { 0x02, 0x02, 0x02, 0x1B, 0x01, 0x01, 0x28, 0x02, 0x02, 0x29, 0x13, 0x01, 0x01, 0x02, 0x02, 0x02, 0x1B, 0x01, 0x01, 0xCB, 0xCC, 0xCD, 0x29, 0xCE, 0x11, 0x01, 0x02, 0x02, 0x02, 0x1B, 0x01, 0x01 }, - [0x6A] = { 0xCF, 0x4F, 0xD0, 0x59, 0x01, 0x01, 0x01, 0xD1, 0xD2, 0xD3, 0x3C, 0x01, 0x01, 0x28, 0x02, 0x02, 0x29, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x1B, 0x01, 0x01, 0x28, 0x02, 0x02, 0x29, 0x01, 0x01 }, - [0x6B] = { 0x01, 0x02, 0x02, 0x02, 0x1B, 0x01, 0x01, 0x28, 0x02, 0x02, 0x29, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x1B, 0x01, 0x01, 0x07, 0x02, 0x02, 0x02, 0x3C, 0x01, 0x01, 0x14, 0xD4, 0x02, 0x02, 0xD5 }, - [0x6C] = { 0x01, 0x01, 0x13, 0x28, 0x02, 0x02, 0x59, 0x01, 0x01, 0x05, 0x53, 0x02, 0x02, 0x2F, 0x01, 0x01, 0x01, 0x0F, 0x02, 0x02, 0x02, 0x3C, 0x01, 0x01, 0x14, 0xD6, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04 }, - [0x6D] = { 0x01, 0x01, 0x01, 0x05, 0x15, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x6E] = { 0x05, 0x01, 0x01, 0x1F, 0x55, 0x08, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x07, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x6F] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x0A, 0x0E, 0x07, 0x04, 0xD7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x70] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x07, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0B, 0x04, 0x06 }, - [0x71] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x0B, 0x04, 0x06 }, - [0x72] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x07, 0xD8, 0xD9 }, - [0x73] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x05, 0x01, 0x01, 0x07, 0x21 }, - [0x74] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x26, 0x01, 0x05 }, - [0x75] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x76] = { 0x02, 0x02, 0x02, 0x02, 0x1B, 0x01, 0x01, 0x01, 0x54, 0xDA, 0x04, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x77] = { 0x11, 0x01, 0x01, 0x01, 0x3D, 0x0C, 0x14, 0x58, 0xDB, 0xDC, 0x3D, 0xDD, 0x3D, 0x14, 0x14, 0x47, 0x01, 0x17, 0x01, 0x0B, 0x23, 0x17, 0x01, 0x0B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x78] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x3E, 0x02, 0x02, 0x02, 0x3E, 0x02, 0x02, 0x02, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x79] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00 }, - [0x7A] = { 0x01, 0x01, 0x01, 0x07, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }, - [0x7B] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x07, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }, - [0x7C] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x09, 0x00, 0x01, 0x01 }, - [0x7D] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x7E] = { 0x01, 0x01, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - [0x7F] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x08, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }, - [0x80] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + [0x01] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x01, 0x01, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x0A, 0x0A, 0x00, 0x00, 0x00, 0x00 }, + [0x02] = { 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x0B, 0x0B, 0x0C, 0x02, 0x02, 0x02, 0x02, 0x02, 0x1E, 0x12, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x13, 0x26, 0x0B, 0x27, 0x02, 0x02, 0x12, 0x02 }, + [0x03] = { 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x10, 0x28, 0x29, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + [0x04] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x15, 0x16, 0x2A, 0x08, 0x01, 0x2B, 0x0D, 0x00, 0x00, 0x00, 0x15, 0x2C, 0x02, 0x02, 0x02, 0x2D, 0x2E }, + [0x05] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x02, 0x0E, 0x0C, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x2F, 0x30, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02 }, + [0x06] = { 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x08, 0x01, 0x01, 0x01, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + [0x07] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x31, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + [0x08] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x04, 0x00 }, + [0x09] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x01, 0x01, 0x01, 0x01, 0x01, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + [0x0A] = { 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x18, 0x16, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02 }, + [0x0B] = { 0x00, 0x01, 0x00, 0x04, 0x00, 0x01, 0x00, 0x01, 0x00, 0x04, 0x00, 0x0B, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x05, 0x00, 0x05, 0x00, 0x0D, 0x00, 0x05, 0x00, 0x05 }, + [0x0C] = { 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x0D, 0x0F, 0x11, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + [0x0D] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + [0x0E] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3A, 0x3B, 0x3C, 0x0F, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x10, 0x19, 0x1A, 0x00 }, + [0x0F] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x18, 0x00, 0x00, 0x02, 0x02, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + [0x10] = { 0x00, 0x00, 0x00, 0x00, 0x0C, 0x02, 0x0C, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x3D, 0x02, 0x19, 0x14, 0x02, 0x02, 0x3E, 0x1B, 0x02, 0x3F, 0x40, 0x41, 0x42, 0x00, 0x00, 0x11, 0x00 }, + [0x11] = { 0x00, 0x00, 0x00, 0x00, 0x08, 0x01, 0x01, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + [0x12] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00 }, + [0x13] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x1C, 0x01, 0x1C, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + [0x14] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + [0x15] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x06, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + [0x16] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + [0x17] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x06, 0x06, 0x45, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + [0x18] = { 0x01, 0x01, 0x01, 0x03, 0x00, 0x00, 0x07, 0x01, 0x01, 0x04, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x03, 0x00, 0x00, 0x46, 0x47, 0x48, 0x04, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x03, 0x00, 0x00 }, + [0x19] = { 0x13, 0x17, 0x49, 0x05, 0x00, 0x00, 0x00, 0x4A, 0x1B, 0x1D, 0x0E, 0x00, 0x00, 0x07, 0x01, 0x01, 0x04, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x03, 0x00, 0x00, 0x07, 0x01, 0x01, 0x04, 0x00, 0x00 }, + [0x1A] = { 0x00, 0x01, 0x01, 0x01, 0x03, 0x00, 0x00, 0x07, 0x01, 0x01, 0x04, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x03, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x0E, 0x00, 0x00, 0x00, 0x1D, 0x01, 0x01, 0x09 }, + [0x1B] = { 0x00, 0x00, 0x00, 0x07, 0x01, 0x01, 0x05, 0x00, 0x00, 0x00, 0x0F, 0x01, 0x01, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x0E, 0x00, 0x00, 0x00, 0x1A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + [0x1C] = { 0x01, 0x01, 0x01, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + [0x1D] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, }; /** @@ -225,249 +106,94 @@ static const uint8_t pm_unicode_middle[129][32] = { */ #define PM_UNICODE_15_NOT_UPPERCASE_BIT (1 << 3) -/* No properties. */ +/* Not uppercase. */ #define N 0 -/* A digit: alphanumeric but not alphabetic. */ -#define D (PRISM_ENCODING_ALPHANUMERIC_BIT) - -/* A letter that is not uppercase: alphabetic and alphanumeric. */ -#define A (PRISM_ENCODING_ALPHABETIC_BIT | PRISM_ENCODING_ALPHANUMERIC_BIT) - -/* An uppercase or titlecase letter: alphabetic, alphanumeric, and uppercase. */ -#define U (PRISM_ENCODING_ALPHABETIC_BIT | PRISM_ENCODING_ALPHANUMERIC_BIT | PRISM_ENCODING_UPPERCASE_BIT) +/* An uppercase or titlecase letter. */ +#define U (PRISM_ENCODING_UPPERCASE_BIT) /* An uppercase or titlecase letter that is not one in Unicode 15.0.0. */ -#define V (PRISM_ENCODING_ALPHABETIC_BIT | PRISM_ENCODING_ALPHANUMERIC_BIT | PRISM_ENCODING_UPPERCASE_BIT | PM_UNICODE_15_NOT_UPPERCASE_BIT) +#define V (PRISM_ENCODING_UPPERCASE_BIT | PM_UNICODE_15_NOT_UPPERCASE_BIT) -static const uint8_t pm_unicode_leaf[222][8] = { +static const uint8_t pm_unicode_leaf[75][8] = { [0x00] = { N, N, N, N, N, N, N, N }, - [0x01] = { A, A, A, A, A, A, A, A }, - [0x02] = { U, U, U, U, U, U, U, U }, - [0x03] = { U, A, U, A, U, A, U, A }, - [0x04] = { D, D, D, D, D, D, D, D }, - [0x05] = { A, A, A, A, A, A, A, N }, - [0x06] = { D, D, N, N, N, N, N, N }, - [0x07] = { A, A, A, A, A, A, N, N }, - [0x08] = { A, A, A, N, N, N, N, N }, - [0x09] = { A, N, N, N, N, N, N, N }, - [0x0A] = { A, A, A, A, A, N, N, N }, - [0x0B] = { A, A, A, A, N, N, N, N }, - [0x0C] = { N, A, A, A, A, A, A, A }, - [0x0D] = { A, A, N, N, N, N, N, N }, - [0x0E] = { N, N, N, N, N, N, N, A }, - [0x0F] = { A, N, A, A, A, A, A, A }, - [0x10] = { N, N, A, A, A, A, A, A }, - [0x11] = { A, A, A, A, N, A, A, A }, - [0x12] = { A, A, A, A, A, A, N, A }, - [0x13] = { A, A, A, A, A, N, A, A }, - [0x14] = { A, A, A, N, A, A, A, A }, - [0x15] = { N, N, N, N, N, A, A, A }, - [0x16] = { A, A, A, A, A, N, N, A }, - [0x17] = { A, A, N, A, A, A, A, A }, - [0x18] = { N, N, N, A, A, A, A, A }, - [0x19] = { A, A, A, A, N, N, D, D }, - [0x1A] = { A, N, A, A, A, A, N, N }, - [0x1B] = { U, U, A, A, A, A, A, A }, - [0x1C] = { N, N, A, N, N, N, N, N }, - [0x1D] = { N, N, N, N, N, A, N, N }, - [0x1E] = { N, N, N, N, A, A, A, A }, - [0x1F] = { A, N, N, A, A, A, A, A }, - [0x20] = { A, A, N, N, N, A, A, A }, - [0x21] = { N, N, N, N, N, N, A, A }, - [0x22] = { D, D, A, A, A, A, A, A }, - [0x23] = { N, A, A, A, N, A, A, A }, - [0x24] = { N, N, N, N, N, N, D, D }, - [0x25] = { A, A, A, N, N, N, A, A }, - [0x26] = { A, A, A, A, N, A, A, N }, - [0x27] = { V, V, V, V, V, V, V, V }, - [0x28] = { A, A, A, A, U, U, U, U }, - [0x29] = { U, U, U, U, U, U, A, A }, - [0x2A] = { N, A, N, N, N, N, N, N }, - [0x2B] = { A, A, A, N, N, N, N, A }, - [0x2C] = { N, A, A, A, A, A, A, N }, - [0x2D] = { N, U, U, U, U, U, U, U }, - [0x2E] = { U, U, U, N, N, N, N, N }, - [0x2F] = { U, U, U, U, U, U, U, N }, - [0x30] = { A, U, A, U, A, U, A, U }, - [0x31] = { A, A, N, N, N, N, A, A }, - [0x32] = { A, N, N, A, A, N, N, N }, - [0x33] = { A, N, A, A, N, A, A, A }, - [0x34] = { A, A, N, A, A, N, N, N }, - [0x35] = { A, N, A, A, A, N, N, N }, - [0x36] = { A, A, A, N, A, A, N, N }, - [0x37] = { A, A, A, N, N, A, A, A }, - [0x38] = { A, A, A, A, A, N, A, N }, - [0x39] = { U, U, U, U, U, U, N, N }, - [0x3A] = { U, U, U, U, U, N, N, N }, - [0x3B] = { N, A, A, A, A, A, N, N }, - [0x3C] = { U, N, A, A, A, A, A, A }, - [0x3D] = { N, A, A, N, A, N, N, A }, - [0x3E] = { U, U, N, N, N, N, N, N }, - [0x3F] = { A, A, U, A, U, A, U, A }, - [0x40] = { A, U, U, A, U, A, U, U }, - [0x41] = { U, A, U, A, A, A, A, A }, - [0x42] = { U, U, U, U, A, A, A, A }, - [0x43] = { N, N, U, A, U, A, U, A }, - [0x44] = { A, N, N, N, N, A, A, A }, - [0x45] = { N, N, N, N, A, A, N, A }, - [0x46] = { N, N, N, N, A, N, N, N }, - [0x47] = { N, A, A, A, A, N, A, N }, - [0x48] = { N, A, A, A, A, N, N, N }, - [0x49] = { N, A, A, N, A, N, A, A }, - [0x4A] = { A, N, N, N, N, N, N, A }, - [0x4B] = { N, N, N, N, N, A, A, N }, - [0x4C] = { N, N, N, N, A, A, A, N }, - [0x4D] = { A, A, A, A, N, A, N, N }, - [0x4E] = { A, A, A, A, N, N, A, A }, - [0x4F] = { U, U, U, N, N, U, U, U }, - [0x50] = { N, N, A, A, A, N, A, A }, - [0x51] = { U, U, U, U, N, N, N, N }, - [0x52] = { A, A, N, N, N, N, A, N }, - [0x53] = { A, A, A, A, A, A, U, U }, - [0x54] = { A, A, A, A, N, N, N, A }, - [0x55] = { A, A, N, A, A, N, A, A }, - [0x56] = { N, N, A, A, A, N, N, N }, - [0x57] = { U, U, U, N, U, U, U, U }, - [0x58] = { N, A, N, A, N, N, N, N }, - [0x59] = { U, U, U, U, U, N, A, A }, - [0x5A] = { U, U, U, U, U, U, U, A }, - [0x5B] = { U, U, A, U, A, U, A, A }, - [0x5C] = { A, U, U, U, A, A, U, U }, - [0x5D] = { U, U, A, U, U, A, U, U }, - [0x5E] = { U, A, A, A, U, U, A, U }, - [0x5F] = { U, A, U, A, U, A, U, U }, - [0x60] = { A, U, A, A, U, A, U, U }, - [0x61] = { A, U, U, U, A, U, A, U }, - [0x62] = { U, A, A, A, U, A, A, A }, - [0x63] = { A, A, A, A, U, U, A, U }, - [0x64] = { U, A, U, U, A, U, A, U }, - [0x65] = { A, U, A, U, A, A, U, A }, - [0x66] = { A, A, U, U, A, U, U, A }, - [0x67] = { A, U, A, U, U, U, U, A }, - [0x68] = { N, N, N, N, A, N, A, N }, - [0x69] = { U, A, U, A, A, N, U, A }, - [0x6A] = { N, N, A, A, A, A, N, U }, - [0x6B] = { N, N, N, N, N, N, U, N }, - [0x6C] = { U, U, U, N, U, N, U, U }, - [0x6D] = { A, U, U, U, U, U, U, U }, - [0x6E] = { U, U, N, U, U, U, U, U }, - [0x6F] = { A, A, A, A, A, A, A, U }, - [0x70] = { A, A, U, U, U, A, A, A }, - [0x71] = { A, A, A, A, U, A, N, U }, - [0x72] = { A, U, U, A, A, U, U, U }, - [0x73] = { U, A, N, N, N, N, N, N }, - [0x74] = { U, U, A, U, A, U, A, U }, - [0x75] = { A, U, A, U, A, U, A, A }, - [0x76] = { N, A, A, N, A, A, N, A }, - [0x77] = { D, D, N, N, N, N, A, A }, - [0x78] = { D, D, A, A, A, N, N, A }, - [0x79] = { N, N, N, N, A, A, N, N }, - [0x7A] = { A, N, A, N, N, N, A, A }, - [0x7B] = { A, N, N, A, A, N, A, N }, - [0x7C] = { A, N, A, A, N, A, A, N }, - [0x7D] = { N, N, A, A, N, A, A, A }, - [0x7E] = { N, N, N, A, A, N, N, N }, - [0x7F] = { N, A, A, A, N, N, N, N }, - [0x80] = { A, N, A, A, A, N, A, N }, - [0x81] = { N, N, A, A, N, N, N, N }, - [0x82] = { A, A, A, A, N, A, N, A }, - [0x83] = { A, A, N, A, A, A, N, N }, - [0x84] = { D, D, N, N, A, A, A, A }, - [0x85] = { D, D, A, A, A, A, N, N }, - [0x86] = { U, U, U, U, U, U, N, U }, - [0x87] = { N, N, N, N, N, U, N, N }, - [0x88] = { A, N, A, A, N, N, N, N }, - [0x89] = { A, A, N, N, A, A, A, A }, - [0x8A] = { D, D, N, N, N, A, A, A }, - [0x8B] = { A, V, A, N, N, N, N, N }, - [0x8C] = { N, A, A, A, A, N, A, A }, - [0x8D] = { U, A, U, A, U, A, A, A }, - [0x8E] = { A, A, A, A, A, A, U, A }, - [0x8F] = { N, U, N, U, N, U, N, U }, - [0x90] = { U, U, U, U, U, N, A, N }, - [0x91] = { N, N, U, N, N, N, N, U }, - [0x92] = { N, N, A, U, U, U, A, A }, - [0x93] = { U, U, U, A, N, U, N, N }, - [0x94] = { N, U, U, U, U, U, N, N }, - [0x95] = { N, N, N, N, U, N, U, N }, - [0x96] = { U, N, U, U, U, U, N, A }, - [0x97] = { A, A, N, N, A, A, U, U }, - [0x98] = { N, N, N, N, N, U, A, A }, - [0x99] = { A, A, A, U, A, A, A, A }, - [0x9A] = { N, N, N, N, N, N, U, U }, - [0x9B] = { U, A, U, U, U, A, A, U }, - [0x9C] = { A, U, A, U, A, U, U, U }, - [0x9D] = { U, A, U, A, A, U, A, A }, - [0x9E] = { U, A, U, A, A, N, N, N }, - [0x9F] = { N, N, N, U, A, U, A, N }, - [0xA0] = { N, N, U, A, N, N, N, N }, - [0xA1] = { D, D, A, A, N, N, N, N }, - [0xA2] = { U, A, U, A, U, A, A, N }, - [0xA3] = { A, U, A, U, A, U, U, A }, - [0xA4] = { A, N, N, U, A, U, A, A }, - [0xA5] = { U, A, U, A, A, A, U, A }, - [0xA6] = { U, A, U, U, U, U, U, A }, - [0xA7] = { U, U, U, U, U, A, U, A }, - [0xA8] = { U, A, U, A, U, U, U, U }, - [0xA9] = { A, U, A, V, V, A, V, A }, - [0xAA] = { U, A, V, A, V, A, U, A }, - [0xAB] = { U, A, V, A, V, N, N, N }, - [0xAC] = { N, A, A, A, A, U, A, A }, - [0xAD] = { N, N, N, A, N, A, A, A }, - [0xAE] = { D, D, A, A, A, A, A, N }, - [0xAF] = { A, N, A, N, N, N, N, N }, - [0xB0] = { N, N, N, A, A, A, N, N }, - [0xB1] = { N, N, A, A, A, A, N, N }, - [0xB2] = { A, A, A, N, A, A, N, A }, - [0xB3] = { U, U, U, N, U, U, N, A }, - [0xB4] = { A, N, N, N, A, N, N, A }, - [0xB5] = { V, V, V, V, V, V, N, N }, - [0xB6] = { N, A, N, N, N, N, N, A }, - [0xB7] = { A, A, A, N, N, N, D, D }, - [0xB8] = { A, A, A, N, N, N, A, N }, - [0xB9] = { D, D, A, N, A, N, N, N }, - [0xBA] = { A, N, A, A, A, A, N, A }, - [0xBB] = { A, A, N, A, N, N, A, N }, - [0xBC] = { A, N, A, N, N, A, N, A }, - [0xBD] = { A, A, N, A, A, A, N, A }, - [0xBE] = { D, D, N, N, N, N, N, A }, - [0xBF] = { A, A, N, N, A, A, N, A }, - [0xC0] = { A, N, N, N, A, N, N, N }, - [0xC1] = { D, D, D, D, N, N, N, N }, - [0xC2] = { N, A, N, N, A, A, A, A }, - [0xC3] = { A, N, N, A, A, N, N, A }, - [0xC4] = { N, A, N, A, A, N, N, N }, - [0xC5] = { N, N, A, N, A, A, N, A }, - [0xC6] = { A, A, N, A, N, N, A, A }, - [0xC7] = { A, A, N, A, A, A, A, N }, - [0xC8] = { V, N, N, A, A, A, A, A }, - [0xC9] = { A, A, N, A, N, N, N, N }, - [0xCA] = { A, A, A, N, N, A, N, N }, - [0xCB] = { A, A, A, A, U, N, U, U }, - [0xCC] = { N, N, U, N, N, U, U, N }, - [0xCD] = { N, U, U, U, U, N, U, U }, - [0xCE] = { A, A, N, A, N, A, A, A }, - [0xCF] = { A, A, A, A, U, U, N, U }, - [0xD0] = { U, U, U, U, U, N, U, U }, - [0xD1] = { U, U, N, U, U, U, U, N }, - [0xD2] = { U, U, U, U, U, N, U, N }, - [0xD3] = { N, N, U, U, U, U, U, U }, - [0xD4] = { A, A, U, U, U, U, U, U }, - [0xD5] = { U, U, U, N, A, A, A, A }, - [0xD6] = { A, A, U, A, N, N, D, D }, - [0xD7] = { D, D, N, N, N, N, A, N }, - [0xD8] = { A, D, D, D, D, D, D, D }, - [0xD9] = { D, D, D, N, N, N, N, N }, - [0xDA] = { N, N, N, A, N, N, N, N }, - [0xDB] = { N, N, A, N, N, N, N, A }, - [0xDC] = { N, A, N, A, N, A, A, A }, - [0xDD] = { N, A, N, A, N, A, N, A }, + [0x01] = { U, U, U, U, U, U, U, U }, + [0x02] = { U, N, U, N, U, N, U, N }, + [0x03] = { U, U, N, N, N, N, N, N }, + [0x04] = { U, U, U, U, U, U, N, N }, + [0x05] = { U, U, U, U, U, N, N, N }, + [0x06] = { V, V, V, V, V, V, V, V }, + [0x07] = { N, N, N, N, U, U, U, U }, + [0x08] = { N, U, U, U, U, U, U, U }, + [0x09] = { U, U, U, N, N, N, N, N }, + [0x0A] = { U, U, U, U, U, U, U, N }, + [0x0B] = { N, U, N, U, N, U, N, U }, + [0x0C] = { N, N, U, N, U, N, U, N }, + [0x0D] = { U, U, U, U, N, N, N, N }, + [0x0E] = { U, N, N, N, N, N, N, N }, + [0x0F] = { N, N, N, N, N, N, U, U }, + [0x10] = { U, N, U, N, N, N, N, N }, + [0x11] = { N, N, N, N, N, U, N, N }, + [0x12] = { N, U, U, N, U, N, U, U }, + [0x13] = { N, N, N, N, U, U, N, U }, + [0x14] = { U, N, U, N, N, N, U, N }, + [0x15] = { N, N, N, N, N, N, N, U }, + [0x16] = { N, N, N, N, N, N, U, N }, + [0x17] = { U, U, U, N, N, U, U, U }, + [0x18] = { U, N, U, N, U, N, N, N }, + [0x19] = { N, N, N, U, N, U, N, N }, + [0x1A] = { N, N, U, N, N, N, N, N }, + [0x1B] = { U, U, U, U, U, N, U, N }, + [0x1C] = { U, U, U, N, U, U, U, U }, + [0x1D] = { N, N, U, U, U, U, U, U }, + [0x1E] = { U, U, N, U, N, U, N, N }, + [0x1F] = { N, U, U, U, N, N, U, U }, + [0x20] = { U, U, N, U, U, N, U, U }, + [0x21] = { U, N, N, N, U, U, N, U }, + [0x22] = { U, N, U, N, U, N, U, U }, + [0x23] = { N, U, N, N, U, N, U, U }, + [0x24] = { N, U, U, U, N, U, N, U }, + [0x25] = { U, N, N, N, U, N, N, N }, + [0x26] = { U, N, U, U, N, U, N, U }, + [0x27] = { N, U, N, U, N, N, U, N }, + [0x28] = { N, N, U, U, N, U, U, N }, + [0x29] = { N, U, N, U, U, U, U, N }, + [0x2A] = { U, U, U, N, U, N, U, U }, + [0x2B] = { U, U, N, U, U, U, U, U }, + [0x2C] = { N, N, U, U, U, N, N, N }, + [0x2D] = { N, N, N, N, U, N, N, U }, + [0x2E] = { N, U, U, N, N, U, U, U }, + [0x2F] = { U, U, N, U, N, U, N, U }, + [0x30] = { N, U, N, U, N, U, N, N }, + [0x31] = { U, U, U, U, U, U, N, U }, + [0x32] = { N, V, N, N, N, N, N, N }, + [0x33] = { N, N, U, N, N, N, N, U }, + [0x34] = { N, N, N, U, U, U, N, N }, + [0x35] = { U, U, U, N, N, U, N, N }, + [0x36] = { N, U, U, U, U, U, N, N }, + [0x37] = { N, N, N, N, U, N, U, N }, + [0x38] = { U, N, U, U, U, U, N, N }, + [0x39] = { N, N, N, U, N, N, N, N }, + [0x3A] = { U, N, U, U, U, N, N, U }, + [0x3B] = { N, U, N, U, N, U, U, U }, + [0x3C] = { U, N, U, N, N, U, N, N }, + [0x3D] = { N, U, N, U, N, U, U, N }, + [0x3E] = { U, N, U, U, U, U, U, N }, + [0x3F] = { U, N, U, N, U, U, U, U }, + [0x40] = { N, U, N, V, V, N, V, N }, + [0x41] = { U, N, V, N, V, N, U, N }, + [0x42] = { U, N, V, N, V, N, N, N }, + [0x43] = { U, U, U, N, U, U, N, N }, + [0x44] = { V, V, V, V, V, V, N, N }, + [0x45] = { V, N, N, N, N, N, N, N }, + [0x46] = { N, N, N, N, U, N, U, U }, + [0x47] = { N, N, U, N, N, U, U, N }, + [0x48] = { N, U, U, U, U, N, U, U }, + [0x49] = { U, U, U, U, U, N, U, U }, + [0x4A] = { U, U, N, U, U, U, U, N }, }; #undef N -#undef D -#undef A #undef U #undef V From ba126a3a131b184d79893c85abeeca0d1dffbd2d Mon Sep 17 00:00:00 2001 From: Kevin Newton Date: Mon, 16 Nov 2026 20:52:47 -0500 Subject: [PATCH 12/20] Begin constant names the way Ruby does in encodings that are not Unicode --- CHANGELOG.md | 2 + bin/prism | 14 +++++- src/encoding.c | 22 +++++---- test/prism/encoding/encodings_test.rb | 67 ++++++++++++++++++--------- 4 files changed, 73 insertions(+), 32 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fbd4a5b731..948ca77c51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a - Whether a name is a constant follows the version of Unicode of the Ruby that is targeted: Unicode 15.0.0 for Ruby 3.3 and 3.4, and Unicode 17.0.0 for Ruby 4.0 and 4.1. A name that starts with a letter that became uppercase in Unicode 16.0.0 or 17.0.0, such as the Garay capital letters, is now a local variable name when targeting Ruby 3.3 or 3.4. - A `?` followed by two identifier characters is a ternary operator, even when the first one is not ASCII. For example, `a ?☃b : c` used to read `?☃` as a character literal. - A multiple assignment can write to an attribute whose name starts with a character that is not ASCII, as in `foo.☃, bar = 1, 2`. +- A name that starts with `€` (0xA4) in ISO-8859-16, or with `¯` (0xAF) in Windows-1252, is a constant name. In encodings that are not Unicode, a character that is neither uppercase nor lowercase begins a constant if case folding changes it. +- In Emacs-Mule, stateless-ISO-2022-JP, and stateless-ISO-2022-JP-KDDI, a name that starts with any character that is not ASCII is a constant name. ## [2.1.0] - 2026-10-28 diff --git a/bin/prism b/bin/prism index 4c2023fa01..42a0f12a6e 100755 --- a/bin/prism +++ b/bin/prism @@ -398,6 +398,18 @@ module Prism pp parser_tokens end + # Return true if a name that starts with the given character is a constant + # name. Object.const_defined? raises a NameError for a name that is not. + # This is more than [[:upper:]]: in an encoding that is not Unicode, a + # character that is neither uppercase nor lowercase begins a constant if + # case folding changes it, as Windows-1252 does to the multiplication sign. + def constant_start?(character) + Object.const_defined?(character) + true + rescue NameError + false + end + # Generate the list of values that will be used in a lookup table for a # given encoding. def lookup_table_values(encoding) @@ -408,7 +420,7 @@ module Prism values = 0 values |= (1 << 0) if character.match?(/[[:alpha:]]/) values |= (1 << 1) if character.match?(/[[:alnum:]]/) - values |= (1 << 2) if character.match?(/[[:upper:]]/) + values |= (1 << 2) if constant_start?(character) values rescue RangeError 0 diff --git a/src/encoding.c b/src/encoding.c index cf498183a1..0b234285e9 100644 --- a/src/encoding.c +++ b/src/encoding.c @@ -722,7 +722,7 @@ static const uint8_t pm_encoding_iso_8859_16_table[256] = { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x - 0, 7, 3, 7, 0, 0, 7, 0, 3, 0, 7, 0, 7, 0, 3, 7, // Ax + 0, 7, 3, 7, 4, 0, 7, 0, 3, 0, 7, 0, 7, 0, 3, 7, // Ax 0, 0, 7, 3, 7, 0, 0, 0, 3, 3, 3, 0, 7, 3, 7, 3, // Bx 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // Cx 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 3, // Dx @@ -797,7 +797,7 @@ static const uint8_t pm_encoding_windows_1250_table[256] = { 0, 0, 0, 7, 0, 7, 0, 0, 0, 0, 7, 0, 0, 0, 0, 7, // Ax 0, 0, 0, 3, 0, 3, 0, 0, 0, 3, 3, 0, 7, 0, 3, 3, // Bx 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // Cx - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 3, // Dx + 7, 7, 7, 7, 7, 7, 7, 4, 7, 7, 7, 7, 7, 7, 7, 3, // Dx 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Ex 3, 3, 3, 3, 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3, 0, // Fx }; @@ -842,10 +842,10 @@ static const uint8_t pm_encoding_windows_1252_table[256] = { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 7, 0, 7, 0, // 8x 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 3, 0, 3, 7, // 9x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, // Ax + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 4, // Ax 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, // Bx 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // Cx - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 3, // Dx + 7, 7, 7, 7, 7, 7, 7, 4, 7, 7, 7, 7, 7, 7, 7, 3, // Dx 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Ex 3, 3, 3, 3, 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3, 3, // Fx }; @@ -1112,14 +1112,16 @@ pm_encoding_cp949_property_char(uint8_t property, const uint8_t *b, ptrdiff_t n) } /** - * The forms of the characters in the Emacs-Mule encoding. + * The forms of the characters in the Emacs-Mule encoding. Ruby reads a name + * that starts with any character that is not ASCII as a constant name in this + * encoding, so every form is uppercase. */ #define PM_ENCODING_EMACS_MULE_FORMS(X) \ - X##_2(0, 0x81, 0x8F, 0xA0, 0xFF) \ - X##_3(0, 0x90, 0x99, 0xA0, 0xFF, 0xA0, 0xFF) \ - X##_3(0, 0x9A, 0x9B, 0xE0, 0xEF, 0xA0, 0xFF) \ - X##_4(0, 0x9C, 0x9C, 0xF0, 0xF4, 0xA0, 0xFF, 0xA0, 0xFF) \ - X##_4(0, 0x9D, 0x9D, 0xF5, 0xFE, 0xA0, 0xFF, 0xA0, 0xFF) + X##_2(PRISM_ENCODING_UPPERCASE_BIT, 0x81, 0x8F, 0xA0, 0xFF) \ + X##_3(PRISM_ENCODING_UPPERCASE_BIT, 0x90, 0x99, 0xA0, 0xFF, 0xA0, 0xFF) \ + X##_3(PRISM_ENCODING_UPPERCASE_BIT, 0x9A, 0x9B, 0xE0, 0xEF, 0xA0, 0xFF) \ + X##_4(PRISM_ENCODING_UPPERCASE_BIT, 0x9C, 0x9C, 0xF0, 0xF4, 0xA0, 0xFF, 0xA0, 0xFF) \ + X##_4(PRISM_ENCODING_UPPERCASE_BIT, 0x9D, 0x9D, 0xF5, 0xFE, 0xA0, 0xFF, 0xA0, 0xFF) /** * Return the width of the character at b in Emacs-Mule, or 0 if there is none. diff --git a/test/prism/encoding/encodings_test.rb b/test/prism/encoding/encodings_test.rb index 2e69fec544..aa07a7527c 100644 --- a/test/prism/encoding/encodings_test.rb +++ b/test/prism/encoding/encodings_test.rb @@ -6,12 +6,6 @@ module Prism class EncodingsTest < TestCase - class ConstantContext < BasicObject - def self.const_missing(const) - const - end - end - class IdentifierContext < BasicObject def method_missing(name, *) name @@ -36,8 +30,44 @@ def method_missing(name, *) end end + # In an encoding that is not Unicode, a character that is neither uppercase + # nor lowercase begins a constant if case folding changes it. Windows-1252 + # folds the multiplication sign to the division sign, for example. + if !ENV["PRISM_BUILD_MINIMAL"] + def test_case_folded_constants + { "ISO-8859-16" => [0xA4], "Windows-1250" => [0xD7], "Windows-1252" => [0xAF, 0xD7] }.each do |name, bytes| + bytes.each do |byte| + character = byte.chr(Encoding.find(name)) + assert constant_start?(character), "Expected Ruby to read #{character.inspect} in #{name} as a constant." + assert_encoding_constant(name, character) + end + end + end + + # In Emacs-Mule, and the encodings that share its characters, a name that + # starts with any character that is not ASCII is a constant name. + def test_emacs_mule_constants + ["Emacs-Mule", "stateless-ISO-2022-JP", "stateless-ISO-2022-JP-KDDI"].each do |name| + [0x81A0, 0x90A0A0, 0x9AE0A0, 0x9CF0A0A0, 0x9DF5A0A0].each do |codepoint| + character = codepoint.chr(Encoding.find(name)) + assert constant_start?(character), "Expected Ruby to read #{character.inspect} in #{name} as a constant." + assert_encoding_constant(name, character) + end + end + end + end + private + # Return true if a name that starts with the character is a constant name. + # Object.const_defined? raises a NameError for a name that is not one. + def constant_start?(character) + Object.const_defined?(character) + true + rescue NameError + false + end + # These identifiers are longer than the bytes that the lexer scans at once # for ASCII identifier characters. def assert_ascii_identifiers(encoding) @@ -55,7 +85,11 @@ def assert_ascii_identifiers(encoding) def assert_encoding_constant(name, character) source = "# encoding: #{name}\n#{character}" - expected = ConstantContext.new.instance_eval(source) + + # A name like UTF-8-MAC ends in an Emacs line ending, so Ruby reads the + # source as UTF-8 rather than UTF8-MAC. + encoding = eval("# encoding: #{name}\n__ENCODING__") + expected = character.b.force_encoding(encoding).to_sym result = Prism.parse(source) assert result.success? @@ -79,24 +113,15 @@ def assert_encoding_identifier(name, character) # Check that we can properly parse every codepoint in the given encoding. def assert_encoding(encoding, name, range) - unicode = false - - case encoding - when Encoding::UTF_8, Encoding::UTF_8_MAC, Encoding::UTF8_DoCoMo, Encoding::UTF8_KDDI, Encoding::UTF8_SoftBank, Encoding::CESU_8 - unicode = true - when Encoding::Windows_1253 - range = range.to_a - [0xb5] - end + range = range.to_a - [0xb5] if encoding == Encoding::Windows_1253 range.each do |codepoint| character = codepoint.chr(encoding) - if character.match?(/[[:alpha:]]/) - if character.match?(/[[:upper:]]/) || (unicode && character.match?(Regexp.new("\\p{Lt}".encode(encoding)))) - assert_encoding_constant(name, character) - else - assert_encoding_identifier(name, character) - end + if constant_start?(character) + assert_encoding_constant(name, character) + elsif character.match?(/[[:alpha:]]/) + assert_encoding_identifier(name, character) elsif character.match?(/[[:alnum:]]/) assert_encoding_identifier(name, "_#{character}") else From 50f11ec8aee14f7ff644e59f6c7c1c4d6edc9d67 Mon Sep 17 00:00:00 2001 From: Kevin Newton Date: Mon, 16 Nov 2026 21:07:29 -0500 Subject: [PATCH 13/20] Replace the single-byte tables with bitmaps of the constant-starting bytes --- bin/prism | 48 +- include/prism/internal/encoding.h | 9 +- src/encoding.c | 812 +++++++----------------------- 3 files changed, 237 insertions(+), 632 deletions(-) diff --git a/bin/prism b/bin/prism index 42a0f12a6e..1ff08f738a 100755 --- a/bin/prism +++ b/bin/prism @@ -147,8 +147,13 @@ module Prism exit(1) end - lookup_table(found) - unicode_lists if found == Encoding::UTF_8 || found == Encoding::UTF8_MAC + if found == Encoding::UTF_8 || found == Encoding::UTF8_MAC + unicode_lists + elsif found == Encoding::ASCII_8BIT + lookup_table(found) + else + uppercase_bitmap(found) + end end # bin/prism error [source] @@ -428,18 +433,39 @@ module Prism end end - # Generate a lookup table for a given encoding. + # Generate the lookup table of the ASCII characters. def lookup_table(encoding) - encoding_values = lookup_table_values(encoding) - if encoding_values == lookup_table_values(Encoding::US_ASCII) - puts "static const uint8_t pm_encoding_ascii_table[256] = {" - else - puts "static const uint8_t pm_encoding_#{encoding.name.downcase}_table[256] = {" + puts "const uint8_t pm_encoding_ascii_table[256] = {" + puts "/* #{(0...16).map { |value| value.to_s(16).upcase }.join(" ")} */" + lookup_table_values(encoding).each_with_index do |row, row_index| + puts " #{row.join(", ")}, /* #{row_index.to_s(16).upcase}x */" + end + puts "};" + end + + # Generate the bitmap of the bytes from 0x80 to 0xFF that begin a constant + # name in a single-byte encoding. The bit for a byte is bit (byte & 7) of + # element ((byte - 0x80) >> 3). The bytes below 0x80 are ASCII in every + # encoding that prism supports, so they need no bits. + def uppercase_bitmap(encoding) + bitmap = Array.new(16, 0) + + (0x80...0x100).each do |byte| + next unless constant_start?(byte.chr(encoding)) + bitmap[(byte - 0x80) >> 3] |= 1 << (byte & 7) + end + + if bitmap.all?(0) + puts "/* No byte from 0x80 up begins a constant name in #{encoding.name}, so it needs no bitmap. */" + return end - puts "// #{(0...16).map { |value| value.to_s(16).upcase }.join(" ")}" - encoding_values.each_with_index do |row, row_index| - puts " #{row.join(", ")}, // #{row_index.to_s(16).upcase}x" + puts "/**" + puts " * The bytes from 0x80 up that begin a constant name in #{encoding.name}." + puts " */" + puts "static const uint8_t pm_encoding_#{encoding.name.downcase.tr("-", "_")}_uppercase[16] = {" + bitmap.each_slice(8).with_index do |row, row_index| + puts " #{row.map { |value| "0x%02X" % value }.join(", ")}, /* 0x#{(0x80 + row_index * 64).to_s(16).upcase} */" end puts "};" end diff --git a/include/prism/internal/encoding.h b/include/prism/internal/encoding.h index 3af1d3f09d..6f1c860b21 100644 --- a/include/prism/internal/encoding.h +++ b/include/prism/internal/encoding.h @@ -15,7 +15,7 @@ * other characters take the forms listed for it in encoding.c. */ typedef enum { - /* Every byte is a character, with the properties in its table. */ + /* Every byte is a character. */ PM_ENCODING_KIND_SINGLE_BYTE, /* Every byte below 0x80 is a character, and every other byte is invalid. */ @@ -67,8 +67,11 @@ typedef struct { */ const char *name; - /* The PRISM_ENCODING_*_BIT properties of each byte as a character. */ - const uint8_t *table; + /* + * In a single-byte encoding, the bytes from 0x80 up that begin a constant + * name, one bit per byte, or NULL if none do. + */ + const uint8_t *uppercase; /* * How the encoding answers questions about its characters, as a diff --git a/src/encoding.c b/src/encoding.c index 0b234285e9..7d246a7fa0 100644 --- a/src/encoding.c +++ b/src/encoding.c @@ -199,10 +199,9 @@ static const uint8_t pm_unicode_leaf[75][8] = { /** * Each element of the following table contains a bitfield that indicates a - * piece of information about the corresponding US-ASCII character. It is also - * the table of every single-byte encoding whose bytes above 0x7F have none of - * these properties, and of every multibyte encoding, whose characters beyond - * ASCII take their properties from their code points or forms instead. + * piece of information about the corresponding US-ASCII character. Every + * encoding that prism supports is ASCII-compatible, so this table answers for + * the bytes below 0x80 in all of them. */ const uint8_t pm_encoding_ascii_table[256] = { /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */ @@ -395,507 +394,149 @@ pm_cesu_8_codepoint(const uint8_t *b, size_t width) { #ifndef PRISM_ENCODING_EXCLUDE_FULL /** - * The properties of the bytes in ISO-8859-1. ISO-8859-9 has the same letters and digits - * in the same cases, so it shares this table. - */ -static const uint8_t pm_encoding_iso_8859_1_table[256] = { -// 0 1 2 3 4 5 6 7 8 9 A B C D E F - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x - 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x - 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, // Ax - 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, // Bx - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // Cx - 7, 7, 7, 7, 7, 7, 7, 0, 7, 7, 7, 7, 7, 7, 7, 3, // Dx - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Ex - 3, 3, 3, 3, 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3, 3, // Fx -}; - -/** - * Each element of the following table contains a bitfield that indicates a - * piece of information about the corresponding ISO-8859-2 character. - */ -static const uint8_t pm_encoding_iso_8859_2_table[256] = { -// 0 1 2 3 4 5 6 7 8 9 A B C D E F - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x - 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x - 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x - 0, 7, 0, 7, 0, 7, 7, 0, 0, 7, 7, 7, 7, 0, 7, 7, // Ax - 0, 3, 0, 3, 0, 3, 3, 0, 0, 3, 3, 3, 3, 0, 3, 3, // Bx - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // Cx - 7, 7, 7, 7, 7, 7, 7, 0, 7, 7, 7, 7, 7, 7, 7, 3, // Dx - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Ex - 3, 3, 3, 3, 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3, 0, // Fx -}; - -/** - * Each element of the following table contains a bitfield that indicates a - * piece of information about the corresponding ISO-8859-3 character. - */ -static const uint8_t pm_encoding_iso_8859_3_table[256] = { -// 0 1 2 3 4 5 6 7 8 9 A B C D E F - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x - 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x - 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x - 0, 7, 0, 0, 0, 0, 7, 0, 0, 7, 7, 7, 7, 0, 0, 7, // Ax - 0, 3, 0, 0, 0, 3, 3, 0, 0, 3, 3, 3, 3, 0, 0, 3, // Bx - 7, 7, 7, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // Cx - 0, 7, 7, 7, 7, 7, 7, 0, 7, 7, 7, 7, 7, 7, 7, 3, // Dx - 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Ex - 0, 3, 3, 3, 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3, 0, // Fx -}; - -/** - * Each element of the following table contains a bitfield that indicates a - * piece of information about the corresponding ISO-8859-4 character. - */ -static const uint8_t pm_encoding_iso_8859_4_table[256] = { -// 0 1 2 3 4 5 6 7 8 9 A B C D E F - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x - 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x - 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x - 0, 7, 3, 7, 0, 7, 7, 0, 0, 7, 7, 7, 7, 0, 7, 0, // Ax - 0, 3, 0, 3, 0, 3, 3, 0, 0, 3, 3, 3, 3, 7, 3, 3, // Bx - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // Cx - 7, 7, 7, 7, 7, 7, 7, 0, 7, 7, 7, 7, 7, 7, 7, 3, // Dx - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Ex - 3, 3, 3, 3, 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3, 0, // Fx + * The bytes from 0x80 up that begin a constant name in ISO-8859-1. + * ISO-8859-9 has the same bytes, so it shares this bitmap. + */ +static const uint8_t pm_encoding_iso_8859_1_uppercase[16] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80 */ + 0xFF, 0xFF, 0x7F, 0x7F, 0x00, 0x00, 0x00, 0x00, /* 0xC0 */ }; /** - * Each element of the following table contains a bitfield that indicates a - * piece of information about the corresponding ISO-8859-5 character. - */ -static const uint8_t pm_encoding_iso_8859_5_table[256] = { -// 0 1 2 3 4 5 6 7 8 9 A B C D E F - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x - 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x - 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x - 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 7, 7, // Ax - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // Bx - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // Cx - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Dx - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Ex - 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 3, 3, // Fx + * The bytes from 0x80 up that begin a constant name in ISO-8859-2. + */ +static const uint8_t pm_encoding_iso_8859_2_uppercase[16] = { + 0x00, 0x00, 0x00, 0x00, 0x6A, 0xDE, 0x00, 0x00, /* 0x80 */ + 0xFF, 0xFF, 0x7F, 0x7F, 0x00, 0x00, 0x00, 0x00, /* 0xC0 */ }; /** - * The properties of the bytes in ISO-8859-6. Windows-1256 has the same letters and digits - * in the same cases, so it shares this table. - */ -static const uint8_t pm_encoding_iso_8859_6_table[256] = { -// 0 1 2 3 4 5 6 7 8 9 A B C D E F - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x - 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x - 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ax - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Bx - 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Cx - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // Dx - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Ex - 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Fx + * The bytes from 0x80 up that begin a constant name in ISO-8859-3. + */ +static const uint8_t pm_encoding_iso_8859_3_uppercase[16] = { + 0x00, 0x00, 0x00, 0x00, 0x42, 0x9E, 0x00, 0x00, /* 0x80 */ + 0xF7, 0xFF, 0x7E, 0x7F, 0x00, 0x00, 0x00, 0x00, /* 0xC0 */ }; /** - * Each element of the following table contains a bitfield that indicates a - * piece of information about the corresponding ISO-8859-7 character. - */ -static const uint8_t pm_encoding_iso_8859_7_table[256] = { -// 0 1 2 3 4 5 6 7 8 9 A B C D E F - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x - 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x - 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ax - 0, 0, 0, 0, 0, 0, 7, 0, 7, 7, 7, 0, 7, 0, 7, 7, // Bx - 3, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // Cx - 7, 7, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 3, 3, 3, 3, // Dx - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Ex - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, // Fx + * The bytes from 0x80 up that begin a constant name in ISO-8859-4. + */ +static const uint8_t pm_encoding_iso_8859_4_uppercase[16] = { + 0x00, 0x00, 0x00, 0x00, 0x6A, 0x5E, 0x00, 0x20, /* 0x80 */ + 0xFF, 0xFF, 0x7F, 0x7F, 0x00, 0x00, 0x00, 0x00, /* 0xC0 */ }; /** - * The properties of the bytes in ISO-8859-8. Windows-1255 has the same letters and digits - * in the same cases, so it shares this table. - */ -static const uint8_t pm_encoding_iso_8859_8_table[256] = { -// 0 1 2 3 4 5 6 7 8 9 A B C D E F - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x - 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x - 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ax - 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Bx - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Cx - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Dx - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Ex - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // Fx + * The bytes from 0x80 up that begin a constant name in ISO-8859-5. + */ +static const uint8_t pm_encoding_iso_8859_5_uppercase[16] = { + 0x00, 0x00, 0x00, 0x00, 0xFE, 0xDF, 0xFF, 0xFF, /* 0x80 */ + 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xC0 */ }; /** - * Each element of the following table contains a bitfield that indicates a - * piece of information about the corresponding ISO-8859-10 character. - */ -static const uint8_t pm_encoding_iso_8859_10_table[256] = { -// 0 1 2 3 4 5 6 7 8 9 A B C D E F - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x - 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x - 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x - 0, 7, 7, 7, 7, 7, 7, 0, 7, 7, 7, 7, 7, 0, 7, 7, // Ax - 0, 3, 3, 3, 3, 3, 3, 0, 3, 3, 3, 3, 3, 0, 3, 3, // Bx - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // Cx - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 3, // Dx - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Ex - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Fx + * The bytes from 0x80 up that begin a constant name in ISO-8859-7. + */ +static const uint8_t pm_encoding_iso_8859_7_uppercase[16] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0xD7, /* 0x80 */ + 0xFE, 0xFF, 0xFB, 0x0F, 0x00, 0x00, 0x00, 0x00, /* 0xC0 */ }; /** - * The properties of the bytes in ISO-8859-11. TIS-620 has the same letters and digits - * in the same cases, so it shares this table. - */ -static const uint8_t pm_encoding_iso_8859_11_table[256] = { -// 0 1 2 3 4 5 6 7 8 9 A B C D E F - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x - 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x - 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x - 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Ax - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Bx - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Cx - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 3, // Dx - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Ex - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, // Fx + * The bytes from 0x80 up that begin a constant name in ISO-8859-10. + */ +static const uint8_t pm_encoding_iso_8859_10_uppercase[16] = { + 0x00, 0x00, 0x00, 0x00, 0x7E, 0xDF, 0x00, 0x00, /* 0x80 */ + 0xFF, 0xFF, 0xFF, 0x7F, 0x00, 0x00, 0x00, 0x00, /* 0xC0 */ }; /** - * The properties of the bytes in ISO-8859-13. Windows-1257 has the same letters and digits - * in the same cases, so it shares this table. - */ -static const uint8_t pm_encoding_iso_8859_13_table[256] = { -// 0 1 2 3 4 5 6 7 8 9 A B C D E F - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x - 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x - 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x - 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 7, 0, 0, 0, 0, 7, // Ax - 0, 0, 0, 0, 0, 3, 0, 0, 3, 0, 3, 0, 0, 0, 0, 3, // Bx - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // Cx - 7, 7, 7, 7, 7, 7, 7, 0, 7, 7, 7, 7, 7, 7, 7, 3, // Dx - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Ex - 3, 3, 3, 3, 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3, 0, // Fx + * The bytes from 0x80 up that begin a constant name in ISO-8859-13. + * Windows-1257 has the same bytes, so it shares this bitmap. + */ +static const uint8_t pm_encoding_iso_8859_13_uppercase[16] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x85, 0x00, 0x00, /* 0x80 */ + 0xFF, 0xFF, 0x7F, 0x7F, 0x00, 0x00, 0x00, 0x00, /* 0xC0 */ }; /** - * Each element of the following table contains a bitfield that indicates a - * piece of information about the corresponding ISO-8859-14 character. - */ -static const uint8_t pm_encoding_iso_8859_14_table[256] = { -// 0 1 2 3 4 5 6 7 8 9 A B C D E F - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x - 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x - 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x - 0, 7, 3, 0, 7, 3, 7, 0, 7, 0, 7, 3, 7, 0, 0, 7, // Ax - 7, 3, 7, 3, 7, 3, 0, 7, 3, 3, 3, 7, 3, 7, 3, 3, // Bx - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // Cx - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 3, // Dx - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Ex - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Fx + * The bytes from 0x80 up that begin a constant name in ISO-8859-14. + */ +static const uint8_t pm_encoding_iso_8859_14_uppercase[16] = { + 0x00, 0x00, 0x00, 0x00, 0x52, 0x95, 0x95, 0x28, /* 0x80 */ + 0xFF, 0xFF, 0xFF, 0x7F, 0x00, 0x00, 0x00, 0x00, /* 0xC0 */ }; /** - * Each element of the following table contains a bitfield that indicates a - * piece of information about the corresponding ISO-8859-15 character. - */ -static const uint8_t pm_encoding_iso_8859_15_table[256] = { -// 0 1 2 3 4 5 6 7 8 9 A B C D E F - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x - 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x - 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x - 0, 0, 0, 0, 0, 0, 7, 0, 3, 0, 3, 0, 0, 0, 0, 0, // Ax - 0, 0, 0, 0, 7, 3, 0, 0, 3, 0, 3, 0, 7, 3, 7, 0, // Bx - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // Cx - 7, 7, 7, 7, 7, 7, 7, 0, 7, 7, 7, 7, 7, 7, 7, 3, // Dx - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Ex - 3, 3, 3, 3, 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3, 3, // Fx + * The bytes from 0x80 up that begin a constant name in ISO-8859-15. + */ +static const uint8_t pm_encoding_iso_8859_15_uppercase[16] = { + 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x10, 0x50, /* 0x80 */ + 0xFF, 0xFF, 0x7F, 0x7F, 0x00, 0x00, 0x00, 0x00, /* 0xC0 */ }; /** - * Each element of the following table contains a bitfield that indicates a - * piece of information about the corresponding ISO-8859-16 character. - */ -static const uint8_t pm_encoding_iso_8859_16_table[256] = { -// 0 1 2 3 4 5 6 7 8 9 A B C D E F - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x - 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x - 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x - 0, 7, 3, 7, 4, 0, 7, 0, 3, 0, 7, 0, 7, 0, 3, 7, // Ax - 0, 0, 7, 3, 7, 0, 0, 0, 3, 3, 3, 0, 7, 3, 7, 3, // Bx - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // Cx - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 3, // Dx - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Ex - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Fx + * The bytes from 0x80 up that begin a constant name in ISO-8859-16. + */ +static const uint8_t pm_encoding_iso_8859_16_uppercase[16] = { + 0x00, 0x00, 0x00, 0x00, 0x5A, 0x94, 0x14, 0x50, /* 0x80 */ + 0xFF, 0xFF, 0xFF, 0x7F, 0x00, 0x00, 0x00, 0x00, /* 0xC0 */ }; /** - * Each element of the following table contains a bitfield that indicates a - * piece of information about the corresponding KOI8-R character. - */ -static const uint8_t pm_encoding_koi8_r_table[256] = { -// 0 1 2 3 4 5 6 7 8 9 A B C D E F - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x - 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x - 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x - 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ax - 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Bx - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Cx - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Dx - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // Ex - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // Fx + * The bytes from 0x80 up that begin a constant name in KOI8-R. + */ +static const uint8_t pm_encoding_koi8_r_uppercase[16] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, /* 0x80 */ + 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, /* 0xC0 */ }; /** - * Each element of the following table contains a bitfield that indicates a - * piece of information about the corresponding KOI8-U character. - */ -static const uint8_t pm_encoding_koi8_u_table[256] = { -// 0 1 2 3 4 5 6 7 8 9 A B C D E F - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x - 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x - 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x - 0, 0, 0, 3, 3, 0, 3, 3, 0, 0, 0, 0, 0, 3, 0, 0, // Ax - 0, 0, 0, 7, 7, 0, 7, 7, 0, 0, 0, 0, 0, 7, 0, 0, // Bx - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Cx - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Dx - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // Ex - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // Fx + * The bytes from 0x80 up that begin a constant name in KOI8-U. + */ +static const uint8_t pm_encoding_koi8_u_uppercase[16] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD8, 0x20, /* 0x80 */ + 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, /* 0xC0 */ }; /** - * Each element of the following table contains a bitfield that indicates a - * piece of information about the corresponding windows-1250 character. - */ -static const uint8_t pm_encoding_windows_1250_table[256] = { -// 0 1 2 3 4 5 6 7 8 9 A B C D E F - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x - 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x - 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 7, 7, 7, 7, // 8x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 3, 3, 3, 3, // 9x - 0, 0, 0, 7, 0, 7, 0, 0, 0, 0, 7, 0, 0, 0, 0, 7, // Ax - 0, 0, 0, 3, 0, 3, 0, 0, 0, 3, 3, 0, 7, 0, 3, 3, // Bx - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // Cx - 7, 7, 7, 7, 7, 7, 7, 4, 7, 7, 7, 7, 7, 7, 7, 3, // Dx - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Ex - 3, 3, 3, 3, 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3, 0, // Fx + * The bytes from 0x80 up that begin a constant name in Windows-1250. + */ +static const uint8_t pm_encoding_windows_1250_uppercase[16] = { + 0x00, 0xF4, 0x00, 0x00, 0x28, 0x84, 0x00, 0x10, /* 0x80 */ + 0xFF, 0xFF, 0xFF, 0x7F, 0x00, 0x00, 0x00, 0x00, /* 0xC0 */ }; /** - * Each element of the following table contains a bitfield that indicates a - * piece of information about the corresponding windows-1251 character. - */ -static const uint8_t pm_encoding_windows_1251_table[256] = { -// 0 1 2 3 4 5 6 7 8 9 A B C D E F - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x - 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x - 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x - 7, 7, 0, 3, 0, 0, 0, 0, 0, 0, 7, 0, 7, 7, 7, 7, // 8x - 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 3, 3, 3, 3, // 9x - 0, 7, 3, 7, 0, 7, 0, 0, 7, 0, 7, 0, 0, 0, 0, 7, // Ax - 0, 0, 7, 3, 3, 3, 0, 0, 3, 0, 3, 0, 3, 7, 3, 3, // Bx - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // Cx - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // Dx - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Ex - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Fx + * The bytes from 0x80 up that begin a constant name in Windows-1251. + */ +static const uint8_t pm_encoding_windows_1251_uppercase[16] = { + 0x03, 0xF4, 0x00, 0x00, 0x2A, 0x85, 0x04, 0x20, /* 0x80 */ + 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, /* 0xC0 */ }; /** - * Each element of the following table contains a bitfield that indicates a - * piece of information about the corresponding windows-1252 character. - */ -static const uint8_t pm_encoding_windows_1252_table[256] = { -// 0 1 2 3 4 5 6 7 8 9 A B C D E F - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x - 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x - 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 7, 0, 7, 0, // 8x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 3, 0, 3, 7, // 9x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 4, // Ax - 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, // Bx - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // Cx - 7, 7, 7, 7, 7, 7, 7, 4, 7, 7, 7, 7, 7, 7, 7, 3, // Dx - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Ex - 3, 3, 3, 3, 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3, 3, // Fx + * The bytes from 0x80 up that begin a constant name in Windows-1252. + */ +static const uint8_t pm_encoding_windows_1252_uppercase[16] = { + 0x00, 0x54, 0x00, 0x80, 0x00, 0x80, 0x00, 0x00, /* 0x80 */ + 0xFF, 0xFF, 0xFF, 0x7F, 0x00, 0x00, 0x00, 0x00, /* 0xC0 */ }; /** - * Each element of the following table contains a bitfield that indicates a - * piece of information about the corresponding windows-1253 character. - */ -static const uint8_t pm_encoding_windows_1253_table[256] = { -// 0 1 2 3 4 5 6 7 8 9 A B C D E F - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x - 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x - 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x - 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ax - 0, 0, 0, 0, 0, 3, 7, 0, 7, 7, 7, 0, 7, 0, 7, 7, // Bx - 3, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // Cx - 7, 7, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 3, 3, 3, 3, // Dx - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Ex - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, // Fx + * The bytes from 0x80 up that begin a constant name in Windows-1253. + */ +static const uint8_t pm_encoding_windows_1253_uppercase[16] = { + 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x40, 0xD7, /* 0x80 */ + 0xFE, 0xFF, 0xFB, 0x0F, 0x00, 0x00, 0x00, 0x00, /* 0xC0 */ }; /** - * Each element of the following table contains a bitfield that indicates a - * piece of information about the corresponding windows-1254 character. - */ -static const uint8_t pm_encoding_windows_1254_table[256] = { -// 0 1 2 3 4 5 6 7 8 9 A B C D E F - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x - 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x - 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 7, 0, 0, 0, // 8x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 3, 0, 0, 7, // 9x - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, // Ax - 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, // Bx - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // Cx - 7, 7, 7, 7, 7, 7, 7, 0, 7, 7, 7, 7, 7, 7, 7, 3, // Dx - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // Ex - 3, 3, 3, 3, 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3, 3, // Fx + * The bytes from 0x80 up that begin a constant name in Windows-1254. + */ +static const uint8_t pm_encoding_windows_1254_uppercase[16] = { + 0x00, 0x14, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, /* 0x80 */ + 0xFF, 0xFF, 0x7F, 0x7F, 0x00, 0x00, 0x00, 0x00, /* 0xC0 */ }; #endif @@ -1294,14 +935,11 @@ pm_encoding_char_width(const pm_encoding_t *encoding, const uint8_t *b, ptrdiff_ /** * Return the number of bytes in the next character in the given encoding if it * has the given PRISM_ENCODING_*_BIT property, or 0 otherwise. The encoding is - * one whose characters are not Unicode code points, so not UTF-8 or CESU-8. + * multibyte, and its characters are not Unicode code points. */ static size_t pm_encoding_property_char(const pm_encoding_t *encoding, uint8_t property, const uint8_t *b, ptrdiff_t n) { switch (encoding->kind) { - case PM_ENCODING_KIND_ASCII: - case PM_ENCODING_KIND_SINGLE_BYTE: - return ((n > 0) && (encoding->table[*b] & property)) ? 1 : 0; case PM_ENCODING_KIND_EUC_JP: return pm_encoding_euc_jp_property_char(property, b, n); case PM_ENCODING_KIND_SHIFT_JIS: @@ -1336,6 +974,14 @@ pm_encoding_property_char(const pm_encoding_t *encoding, uint8_t property, const bool pm_encoding_isupper_char(const pm_encoding_t *encoding, const uint8_t *b, ptrdiff_t n, pm_options_version_t version) { switch (encoding->kind) { + case PM_ENCODING_KIND_ASCII: + case PM_ENCODING_KIND_SINGLE_BYTE: { + if (n <= 0) return false; + if (*b < 0x80) return (pm_encoding_ascii_table[*b] & PRISM_ENCODING_UPPERCASE_BIT) != 0; + + const uint8_t *uppercase = encoding->uppercase; + return uppercase != NULL && ((uppercase[(*b - 0x80) >> 3] >> (*b & 7)) & 1); + } case PM_ENCODING_KIND_UTF_8: return pm_encoding_utf_8_isupper_char(b, n, version); #ifndef PRISM_ENCODING_EXCLUDE_FULL @@ -1369,455 +1015,385 @@ pm_encoding_isupper_char(const pm_encoding_t *encoding, const uint8_t *b, ptrdif const pm_encoding_t pm_encodings[] = { [PM_ENCODING_UTF_8] = { .name = "UTF-8", - .kind = PM_ENCODING_KIND_UTF_8, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_UTF_8 }, [PM_ENCODING_US_ASCII] = { .name = "US-ASCII", - .kind = PM_ENCODING_KIND_ASCII, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_ASCII }, [PM_ENCODING_ASCII_8BIT] = { .name = "ASCII-8BIT", - .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_SINGLE_BYTE }, [PM_ENCODING_EUC_JP] = { .name = "EUC-JP", - .kind = PM_ENCODING_KIND_EUC_JP, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_EUC_JP }, [PM_ENCODING_WINDOWS_31J] = { .name = "Windows-31J", - .kind = PM_ENCODING_KIND_SHIFT_JIS, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_SHIFT_JIS }, #ifndef PRISM_ENCODING_EXCLUDE_FULL [PM_ENCODING_BIG5] = { .name = "Big5", - .kind = PM_ENCODING_KIND_BIG5, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_BIG5 }, [PM_ENCODING_BIG5_HKSCS] = { .name = "Big5-HKSCS", - .kind = PM_ENCODING_KIND_BIG5, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_BIG5 }, [PM_ENCODING_BIG5_UAO] = { .name = "Big5-UAO", - .kind = PM_ENCODING_KIND_BIG5, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_BIG5 }, [PM_ENCODING_CESU_8] = { .name = "CESU-8", - .kind = PM_ENCODING_KIND_CESU_8, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_CESU_8 }, [PM_ENCODING_CP51932] = { .name = "CP51932", - .kind = PM_ENCODING_KIND_EUC_JP, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_EUC_JP }, [PM_ENCODING_CP850] = { .name = "CP850", - .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_SINGLE_BYTE }, [PM_ENCODING_CP852] = { .name = "CP852", - .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_SINGLE_BYTE }, [PM_ENCODING_CP855] = { .name = "CP855", - .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_SINGLE_BYTE }, [PM_ENCODING_CP949] = { .name = "CP949", - .kind = PM_ENCODING_KIND_CP949, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_CP949 }, [PM_ENCODING_CP950] = { .name = "CP950", - .kind = PM_ENCODING_KIND_BIG5, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_BIG5 }, [PM_ENCODING_CP951] = { .name = "CP951", - .kind = PM_ENCODING_KIND_BIG5, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_BIG5 }, [PM_ENCODING_EMACS_MULE] = { .name = "Emacs-Mule", - .kind = PM_ENCODING_KIND_EMACS_MULE, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_EMACS_MULE }, [PM_ENCODING_EUC_JP_MS] = { .name = "eucJP-ms", - .kind = PM_ENCODING_KIND_EUC_JP, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_EUC_JP }, [PM_ENCODING_EUC_JIS_2004] = { .name = "EUC-JIS-2004", - .kind = PM_ENCODING_KIND_EUC_JP, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_EUC_JP }, [PM_ENCODING_EUC_KR] = { .name = "EUC-KR", - .kind = PM_ENCODING_KIND_EUC_KR, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_EUC_KR }, [PM_ENCODING_EUC_TW] = { .name = "EUC-TW", - .kind = PM_ENCODING_KIND_EUC_TW, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_EUC_TW }, [PM_ENCODING_GB12345] = { .name = "GB12345", - .kind = PM_ENCODING_KIND_EUC_KR, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_EUC_KR }, [PM_ENCODING_GB18030] = { .name = "GB18030", - .kind = PM_ENCODING_KIND_GB18030, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_GB18030 }, [PM_ENCODING_GB1988] = { .name = "GB1988", - .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_SINGLE_BYTE }, [PM_ENCODING_GB2312] = { .name = "GB2312", - .kind = PM_ENCODING_KIND_EUC_KR, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_EUC_KR }, [PM_ENCODING_GBK] = { .name = "GBK", - .kind = PM_ENCODING_KIND_GBK, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_GBK }, [PM_ENCODING_IBM437] = { .name = "IBM437", - .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_SINGLE_BYTE }, [PM_ENCODING_IBM720] = { .name = "IBM720", - .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_SINGLE_BYTE }, [PM_ENCODING_IBM737] = { .name = "IBM737", - .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_SINGLE_BYTE }, [PM_ENCODING_IBM775] = { .name = "IBM775", - .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_SINGLE_BYTE }, [PM_ENCODING_IBM852] = { .name = "IBM852", - .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_SINGLE_BYTE }, [PM_ENCODING_IBM855] = { .name = "IBM855", - .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_SINGLE_BYTE }, [PM_ENCODING_IBM857] = { .name = "IBM857", - .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_SINGLE_BYTE }, [PM_ENCODING_IBM860] = { .name = "IBM860", - .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_SINGLE_BYTE }, [PM_ENCODING_IBM861] = { .name = "IBM861", - .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_SINGLE_BYTE }, [PM_ENCODING_IBM862] = { .name = "IBM862", - .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_SINGLE_BYTE }, [PM_ENCODING_IBM863] = { .name = "IBM863", - .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_SINGLE_BYTE }, [PM_ENCODING_IBM864] = { .name = "IBM864", - .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_SINGLE_BYTE }, [PM_ENCODING_IBM865] = { .name = "IBM865", - .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_SINGLE_BYTE }, [PM_ENCODING_IBM866] = { .name = "IBM866", - .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_SINGLE_BYTE }, [PM_ENCODING_IBM869] = { .name = "IBM869", - .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_SINGLE_BYTE }, [PM_ENCODING_ISO_8859_1] = { .name = "ISO-8859-1", .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_iso_8859_1_table + .uppercase = pm_encoding_iso_8859_1_uppercase }, [PM_ENCODING_ISO_8859_2] = { .name = "ISO-8859-2", .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_iso_8859_2_table + .uppercase = pm_encoding_iso_8859_2_uppercase }, [PM_ENCODING_ISO_8859_3] = { .name = "ISO-8859-3", .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_iso_8859_3_table + .uppercase = pm_encoding_iso_8859_3_uppercase }, [PM_ENCODING_ISO_8859_4] = { .name = "ISO-8859-4", .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_iso_8859_4_table + .uppercase = pm_encoding_iso_8859_4_uppercase }, [PM_ENCODING_ISO_8859_5] = { .name = "ISO-8859-5", .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_iso_8859_5_table + .uppercase = pm_encoding_iso_8859_5_uppercase }, [PM_ENCODING_ISO_8859_6] = { .name = "ISO-8859-6", - .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_iso_8859_6_table + .kind = PM_ENCODING_KIND_SINGLE_BYTE }, [PM_ENCODING_ISO_8859_7] = { .name = "ISO-8859-7", .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_iso_8859_7_table + .uppercase = pm_encoding_iso_8859_7_uppercase }, [PM_ENCODING_ISO_8859_8] = { .name = "ISO-8859-8", - .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_iso_8859_8_table + .kind = PM_ENCODING_KIND_SINGLE_BYTE }, [PM_ENCODING_ISO_8859_9] = { .name = "ISO-8859-9", .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_iso_8859_1_table + .uppercase = pm_encoding_iso_8859_1_uppercase }, [PM_ENCODING_ISO_8859_10] = { .name = "ISO-8859-10", .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_iso_8859_10_table + .uppercase = pm_encoding_iso_8859_10_uppercase }, [PM_ENCODING_ISO_8859_11] = { .name = "ISO-8859-11", - .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_iso_8859_11_table + .kind = PM_ENCODING_KIND_SINGLE_BYTE }, [PM_ENCODING_ISO_8859_13] = { .name = "ISO-8859-13", .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_iso_8859_13_table + .uppercase = pm_encoding_iso_8859_13_uppercase }, [PM_ENCODING_ISO_8859_14] = { .name = "ISO-8859-14", .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_iso_8859_14_table + .uppercase = pm_encoding_iso_8859_14_uppercase }, [PM_ENCODING_ISO_8859_15] = { .name = "ISO-8859-15", .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_iso_8859_15_table + .uppercase = pm_encoding_iso_8859_15_uppercase }, [PM_ENCODING_ISO_8859_16] = { .name = "ISO-8859-16", .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_iso_8859_16_table + .uppercase = pm_encoding_iso_8859_16_uppercase }, [PM_ENCODING_KOI8_R] = { .name = "KOI8-R", .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_koi8_r_table + .uppercase = pm_encoding_koi8_r_uppercase }, [PM_ENCODING_KOI8_U] = { .name = "KOI8-U", .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_koi8_u_table + .uppercase = pm_encoding_koi8_u_uppercase }, [PM_ENCODING_MAC_CENT_EURO] = { .name = "macCentEuro", - .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_SINGLE_BYTE }, [PM_ENCODING_MAC_CROATIAN] = { .name = "macCroatian", - .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_SINGLE_BYTE }, [PM_ENCODING_MAC_CYRILLIC] = { .name = "macCyrillic", - .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_SINGLE_BYTE }, [PM_ENCODING_MAC_GREEK] = { .name = "macGreek", - .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_SINGLE_BYTE }, [PM_ENCODING_MAC_ICELAND] = { .name = "macIceland", - .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_SINGLE_BYTE }, [PM_ENCODING_MAC_JAPANESE] = { .name = "MacJapanese", - .kind = PM_ENCODING_KIND_SHIFT_JIS, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_SHIFT_JIS }, [PM_ENCODING_MAC_ROMAN] = { .name = "macRoman", - .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_SINGLE_BYTE }, [PM_ENCODING_MAC_ROMANIA] = { .name = "macRomania", - .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_SINGLE_BYTE }, [PM_ENCODING_MAC_THAI] = { .name = "macThai", - .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_SINGLE_BYTE }, [PM_ENCODING_MAC_TURKISH] = { .name = "macTurkish", - .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_SINGLE_BYTE }, [PM_ENCODING_MAC_UKRAINE] = { .name = "macUkraine", - .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_SINGLE_BYTE }, [PM_ENCODING_SHIFT_JIS] = { .name = "Shift_JIS", - .kind = PM_ENCODING_KIND_SHIFT_JIS, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_SHIFT_JIS }, [PM_ENCODING_SJIS_DOCOMO] = { .name = "SJIS-DoCoMo", - .kind = PM_ENCODING_KIND_SHIFT_JIS, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_SHIFT_JIS }, [PM_ENCODING_SJIS_KDDI] = { .name = "SJIS-KDDI", - .kind = PM_ENCODING_KIND_SHIFT_JIS, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_SHIFT_JIS }, [PM_ENCODING_SJIS_SOFTBANK] = { .name = "SJIS-SoftBank", - .kind = PM_ENCODING_KIND_SHIFT_JIS, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_SHIFT_JIS }, [PM_ENCODING_STATELESS_ISO_2022_JP] = { .name = "stateless-ISO-2022-JP", - .kind = PM_ENCODING_KIND_EMACS_MULE, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_EMACS_MULE }, [PM_ENCODING_STATELESS_ISO_2022_JP_KDDI] = { .name = "stateless-ISO-2022-JP-KDDI", - .kind = PM_ENCODING_KIND_EMACS_MULE, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_EMACS_MULE }, [PM_ENCODING_TIS_620] = { .name = "TIS-620", - .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_iso_8859_11_table + .kind = PM_ENCODING_KIND_SINGLE_BYTE }, [PM_ENCODING_UTF8_MAC] = { .name = "UTF8-MAC", - .kind = PM_ENCODING_KIND_UTF_8, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_UTF_8 }, [PM_ENCODING_UTF8_DOCOMO] = { .name = "UTF8-DoCoMo", - .kind = PM_ENCODING_KIND_UTF_8, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_UTF_8 }, [PM_ENCODING_UTF8_KDDI] = { .name = "UTF8-KDDI", - .kind = PM_ENCODING_KIND_UTF_8, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_UTF_8 }, [PM_ENCODING_UTF8_SOFTBANK] = { .name = "UTF8-SoftBank", - .kind = PM_ENCODING_KIND_UTF_8, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_UTF_8 }, [PM_ENCODING_WINDOWS_1250] = { .name = "Windows-1250", .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_windows_1250_table + .uppercase = pm_encoding_windows_1250_uppercase }, [PM_ENCODING_WINDOWS_1251] = { .name = "Windows-1251", .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_windows_1251_table + .uppercase = pm_encoding_windows_1251_uppercase }, [PM_ENCODING_WINDOWS_1252] = { .name = "Windows-1252", .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_windows_1252_table + .uppercase = pm_encoding_windows_1252_uppercase }, [PM_ENCODING_WINDOWS_1253] = { .name = "Windows-1253", .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_windows_1253_table + .uppercase = pm_encoding_windows_1253_uppercase }, [PM_ENCODING_WINDOWS_1254] = { .name = "Windows-1254", .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_windows_1254_table + .uppercase = pm_encoding_windows_1254_uppercase }, [PM_ENCODING_WINDOWS_1255] = { .name = "Windows-1255", - .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_iso_8859_8_table + .kind = PM_ENCODING_KIND_SINGLE_BYTE }, [PM_ENCODING_WINDOWS_1256] = { .name = "Windows-1256", - .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_iso_8859_6_table + .kind = PM_ENCODING_KIND_SINGLE_BYTE }, [PM_ENCODING_WINDOWS_1257] = { .name = "Windows-1257", .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_iso_8859_13_table + .uppercase = pm_encoding_iso_8859_13_uppercase }, [PM_ENCODING_WINDOWS_1258] = { .name = "Windows-1258", - .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_SINGLE_BYTE }, [PM_ENCODING_WINDOWS_874] = { .name = "Windows-874", - .kind = PM_ENCODING_KIND_SINGLE_BYTE, - .table = pm_encoding_ascii_table + .kind = PM_ENCODING_KIND_SINGLE_BYTE } #endif }; From 89ab616e02567f973fd77bfff586610f0a82a6c9 Mon Sep 17 00:00:00 2001 From: Kevin Newton Date: Mon, 16 Nov 2026 21:20:14 -0500 Subject: [PATCH 14/20] Check only uppercase in the multibyte encodings --- include/prism/internal/encoding.h | 9 ++ src/encoding.c | 205 +++++++++--------------------- 2 files changed, 71 insertions(+), 143 deletions(-) diff --git a/include/prism/internal/encoding.h b/include/prism/internal/encoding.h index 6f1c860b21..d9a2a1f61c 100644 --- a/include/prism/internal/encoding.h +++ b/include/prism/internal/encoding.h @@ -148,6 +148,15 @@ pm_encoding_ascii_alpha_p(uint8_t byte) { return pm_encoding_ascii_table[byte] & PRISM_ENCODING_ALPHABETIC_BIT; } +/* + * Return true if the byte is an ASCII uppercase letter. A byte that is not + * ASCII is not one, in every encoding. + */ +static PRISM_INLINE bool +pm_encoding_ascii_upper_p(uint8_t byte) { + return pm_encoding_ascii_table[byte] & PRISM_ENCODING_UPPERCASE_BIT; +} + /* * Return true if the byte is an ASCII letter or digit. A byte that is not ASCII * is neither, in every encoding. diff --git a/src/encoding.c b/src/encoding.c index 7d246a7fa0..c2754d7e28 100644 --- a/src/encoding.c +++ b/src/encoding.c @@ -355,7 +355,7 @@ pm_encoding_utf_8_isupper_char(const uint8_t *b, ptrdiff_t n, pm_options_version } if (*b < 0x80) { - return (pm_encoding_ascii_table[*b] & PRISM_ENCODING_UPPERCASE_BIT) ? true : false; + return pm_encoding_ascii_upper_p(*b); } size_t width; @@ -577,18 +577,18 @@ static const uint8_t pm_encoding_windows_1254_uppercase[16] = { if (n >= 6 && PM_ENCODING_BYTE_IN(b[0], s0_, e0_) && PM_ENCODING_BYTE_IN(b[1], s1_, e1_) && PM_ENCODING_BYTE_IN(b[2], s2_, e2_) && PM_ENCODING_BYTE_IN(b[3], s3_, e3_) && PM_ENCODING_BYTE_IN(b[4], s4_, e4_) && PM_ENCODING_BYTE_IN(b[5], s5_, e5_)) return 6; /* - * Return the width of the character at b if it takes the given form and the - * form has the property being asked about. Forms without properties never - * answer, so their checks fold away. - */ -#define PM_ENCODING_PROPERTY_1(properties_, s0_, e0_) \ - if (((properties_) & property) && n >= 1 && PM_ENCODING_BYTE_IN(b[0], s0_, e0_)) return 1; -#define PM_ENCODING_PROPERTY_2(properties_, s0_, e0_, s1_, e1_) \ - if (((properties_) & property) && n >= 2 && PM_ENCODING_BYTE_IN(b[0], s0_, e0_) && PM_ENCODING_BYTE_IN(b[1], s1_, e1_)) return 2; -#define PM_ENCODING_PROPERTY_3(properties_, s0_, e0_, s1_, e1_, s2_, e2_) \ - if (((properties_) & property) && n >= 3 && PM_ENCODING_BYTE_IN(b[0], s0_, e0_) && PM_ENCODING_BYTE_IN(b[1], s1_, e1_) && PM_ENCODING_BYTE_IN(b[2], s2_, e2_)) return 3; -#define PM_ENCODING_PROPERTY_4(properties_, s0_, e0_, s1_, e1_, s2_, e2_, s3_, e3_) \ - if (((properties_) & property) && n >= 4 && PM_ENCODING_BYTE_IN(b[0], s0_, e0_) && PM_ENCODING_BYTE_IN(b[1], s1_, e1_) && PM_ENCODING_BYTE_IN(b[2], s2_, e2_) && PM_ENCODING_BYTE_IN(b[3], s3_, e3_)) return 4; + * Return true if the character at b takes the given form and the form is + * uppercase. Forms that are not uppercase never answer, so their checks fold + * away. + */ +#define PM_ENCODING_UPPERCASE_1(properties_, s0_, e0_) \ + if (((properties_) & PRISM_ENCODING_UPPERCASE_BIT) && n >= 1 && PM_ENCODING_BYTE_IN(b[0], s0_, e0_)) return true; +#define PM_ENCODING_UPPERCASE_2(properties_, s0_, e0_, s1_, e1_) \ + if (((properties_) & PRISM_ENCODING_UPPERCASE_BIT) && n >= 2 && PM_ENCODING_BYTE_IN(b[0], s0_, e0_) && PM_ENCODING_BYTE_IN(b[1], s1_, e1_)) return true; +#define PM_ENCODING_UPPERCASE_3(properties_, s0_, e0_, s1_, e1_, s2_, e2_) \ + if (((properties_) & PRISM_ENCODING_UPPERCASE_BIT) && n >= 3 && PM_ENCODING_BYTE_IN(b[0], s0_, e0_) && PM_ENCODING_BYTE_IN(b[1], s1_, e1_) && PM_ENCODING_BYTE_IN(b[2], s2_, e2_)) return true; +#define PM_ENCODING_UPPERCASE_4(properties_, s0_, e0_, s1_, e1_, s2_, e2_, s3_, e3_) \ + if (((properties_) & PRISM_ENCODING_UPPERCASE_BIT) && n >= 4 && PM_ENCODING_BYTE_IN(b[0], s0_, e0_) && PM_ENCODING_BYTE_IN(b[1], s1_, e1_) && PM_ENCODING_BYTE_IN(b[2], s2_, e2_) && PM_ENCODING_BYTE_IN(b[3], s3_, e3_)) return true; /* * The body of the function that returns the width of the character at b in an @@ -602,18 +602,15 @@ static const uint8_t pm_encoding_windows_1254_uppercase[16] = { return 0; /* - * The body of the function that returns the width of the character at b in an - * encoding whose characters beyond ASCII take the given forms, if it has the - * given property, or 0 otherwise. + * The body of the function that returns true if the character at b begins a + * constant name in an encoding whose characters beyond ASCII take the given + * forms. */ -#define PM_ENCODING_FORMS_PROPERTY_CHAR(forms_) \ - if (n <= 0) return 0; \ - if (b[0] < 0x80) return (pm_encoding_ascii_table[b[0]] & property) ? 1 : 0; \ - forms_(PM_ENCODING_PROPERTY) \ - return 0; - -/* The properties of a form whose characters are all alphabetical. */ -#define PM_ENCODING_ALNUM (PRISM_ENCODING_ALPHABETIC_BIT | PRISM_ENCODING_ALPHANUMERIC_BIT) +#define PM_ENCODING_FORMS_ISUPPER_CHAR(forms_) \ + if (n <= 0) return false; \ + if (b[0] < 0x80) return pm_encoding_ascii_upper_p(b[0]); \ + forms_(PM_ENCODING_UPPERCASE) \ + return false; /** * The forms of the characters in the EUC-JP encoding. The full-width Latin, @@ -636,26 +633,24 @@ pm_encoding_euc_jp_char_width(const uint8_t *b, ptrdiff_t n) { } /** - * Return the width of the character at b in EUC-JP if it has the given - * property, or 0 otherwise. + * Return true if the character at b begins a constant name in EUC-JP. */ -static size_t -pm_encoding_euc_jp_property_char(uint8_t property, const uint8_t *b, ptrdiff_t n) { - PM_ENCODING_FORMS_PROPERTY_CHAR(PM_ENCODING_EUC_JP_FORMS) +static bool +pm_encoding_euc_jp_isupper_char(const uint8_t *b, ptrdiff_t n) { + PM_ENCODING_FORMS_ISUPPER_CHAR(PM_ENCODING_EUC_JP_FORMS) } /** * The forms of the characters in the Shift_JIS encoding, where the single - * bytes from 0xA1 to 0xDF are half-width katakana. Every character beyond ASCII - * is alphanumeric, and the full-width Latin, Greek, and Cyrillic capital - * letters are uppercase. + * bytes from 0xA1 to 0xDF are half-width katakana. The full-width Latin, Greek, + * and Cyrillic capital letters are uppercase. */ #define PM_ENCODING_SHIFT_JIS_FORMS(X) \ - X##_1(PM_ENCODING_ALNUM, 0xA1, 0xDF) \ - X##_2(PM_ENCODING_ALNUM, 0x81, 0x9F, 0x40, 0x7E) \ - X##_2(PM_ENCODING_ALNUM, 0x81, 0x9F, 0x80, 0xFC) \ - X##_2(PM_ENCODING_ALNUM, 0xE0, 0xFC, 0x40, 0x7E) \ - X##_2(PM_ENCODING_ALNUM, 0xE0, 0xFC, 0x80, 0xFC) \ + X##_1(0, 0xA1, 0xDF) \ + X##_2(0, 0x81, 0x9F, 0x40, 0x7E) \ + X##_2(0, 0x81, 0x9F, 0x80, 0xFC) \ + X##_2(0, 0xE0, 0xFC, 0x40, 0x7E) \ + X##_2(0, 0xE0, 0xFC, 0x80, 0xFC) \ X##_2(PRISM_ENCODING_UPPERCASE_BIT, 0x82, 0x82, 0x60, 0x79) \ X##_2(PRISM_ENCODING_UPPERCASE_BIT, 0x83, 0x83, 0x9F, 0xB6) \ X##_2(PRISM_ENCODING_UPPERCASE_BIT, 0x84, 0x84, 0x40, 0x60) @@ -669,12 +664,11 @@ pm_encoding_shift_jis_char_width(const uint8_t *b, ptrdiff_t n) { } /** - * Return the width of the character at b in Shift_JIS if it has the given - * property, or 0 otherwise. + * Return true if the character at b begins a constant name in Shift_JIS. */ -static size_t -pm_encoding_shift_jis_property_char(uint8_t property, const uint8_t *b, ptrdiff_t n) { - PM_ENCODING_FORMS_PROPERTY_CHAR(PM_ENCODING_SHIFT_JIS_FORMS) +static bool +pm_encoding_shift_jis_isupper_char(const uint8_t *b, ptrdiff_t n) { + PM_ENCODING_FORMS_ISUPPER_CHAR(PM_ENCODING_SHIFT_JIS_FORMS) } #ifndef PRISM_ENCODING_EXCLUDE_FULL @@ -695,15 +689,6 @@ pm_encoding_big5_char_width(const uint8_t *b, ptrdiff_t n) { PM_ENCODING_FORMS_CHAR_WIDTH(PM_ENCODING_BIG5_FORMS) } -/** - * Return the width of the character at b in Big5 if it has the given - * property, or 0 otherwise. - */ -static size_t -pm_encoding_big5_property_char(uint8_t property, const uint8_t *b, ptrdiff_t n) { - PM_ENCODING_FORMS_PROPERTY_CHAR(PM_ENCODING_BIG5_FORMS) -} - /** * The forms of the characters in the CESU-8 encoding: those of UTF-8, except * that a character beyond U+FFFF is a pair of surrogates. Its characters have @@ -743,15 +728,6 @@ pm_encoding_cp949_char_width(const uint8_t *b, ptrdiff_t n) { PM_ENCODING_FORMS_CHAR_WIDTH(PM_ENCODING_CP949_FORMS) } -/** - * Return the width of the character at b in CP949 if it has the given - * property, or 0 otherwise. - */ -static size_t -pm_encoding_cp949_property_char(uint8_t property, const uint8_t *b, ptrdiff_t n) { - PM_ENCODING_FORMS_PROPERTY_CHAR(PM_ENCODING_CP949_FORMS) -} - /** * The forms of the characters in the Emacs-Mule encoding. Ruby reads a name * that starts with any character that is not ASCII as a constant name in this @@ -773,12 +749,11 @@ pm_encoding_emacs_mule_char_width(const uint8_t *b, ptrdiff_t n) { } /** - * Return the width of the character at b in Emacs-Mule if it has the given - * property, or 0 otherwise. + * Return true if the character at b begins a constant name in Emacs-Mule. */ -static size_t -pm_encoding_emacs_mule_property_char(uint8_t property, const uint8_t *b, ptrdiff_t n) { - PM_ENCODING_FORMS_PROPERTY_CHAR(PM_ENCODING_EMACS_MULE_FORMS) +static bool +pm_encoding_emacs_mule_isupper_char(const uint8_t *b, ptrdiff_t n) { + PM_ENCODING_FORMS_ISUPPER_CHAR(PM_ENCODING_EMACS_MULE_FORMS) } /** @@ -795,15 +770,6 @@ pm_encoding_euc_kr_char_width(const uint8_t *b, ptrdiff_t n) { PM_ENCODING_FORMS_CHAR_WIDTH(PM_ENCODING_EUC_KR_FORMS) } -/** - * Return the width of the character at b in EUC-KR if it has the given - * property, or 0 otherwise. - */ -static size_t -pm_encoding_euc_kr_property_char(uint8_t property, const uint8_t *b, ptrdiff_t n) { - PM_ENCODING_FORMS_PROPERTY_CHAR(PM_ENCODING_EUC_KR_FORMS) -} - /** * The forms of the characters in the EUC-TW encoding. */ @@ -819,15 +785,6 @@ pm_encoding_euc_tw_char_width(const uint8_t *b, ptrdiff_t n) { PM_ENCODING_FORMS_CHAR_WIDTH(PM_ENCODING_EUC_TW_FORMS) } -/** - * Return the width of the character at b in EUC-TW if it has the given - * property, or 0 otherwise. - */ -static size_t -pm_encoding_euc_tw_property_char(uint8_t property, const uint8_t *b, ptrdiff_t n) { - PM_ENCODING_FORMS_PROPERTY_CHAR(PM_ENCODING_EUC_TW_FORMS) -} - /** * The forms of the characters in the GB18030 encoding. */ @@ -844,15 +801,6 @@ pm_encoding_gb18030_char_width(const uint8_t *b, ptrdiff_t n) { PM_ENCODING_FORMS_CHAR_WIDTH(PM_ENCODING_GB18030_FORMS) } -/** - * Return the width of the character at b in GB18030 if it has the given - * property, or 0 otherwise. - */ -static size_t -pm_encoding_gb18030_property_char(uint8_t property, const uint8_t *b, ptrdiff_t n) { - PM_ENCODING_FORMS_PROPERTY_CHAR(PM_ENCODING_GB18030_FORMS) -} - /** * The forms of the characters in the GBK encoding, where 0x80 is a character * of its own. @@ -880,15 +828,6 @@ pm_encoding_gbk_char_width(const uint8_t *b, ptrdiff_t n) { PM_ENCODING_FORMS_CHAR_WIDTH(PM_ENCODING_GBK_FORMS) } -/** - * Return the width of the character at b in GBK if it has the given property, - * or 0 otherwise. - */ -static size_t -pm_encoding_gbk_property_char(uint8_t property, const uint8_t *b, ptrdiff_t n) { - PM_ENCODING_FORMS_PROPERTY_CHAR(PM_ENCODING_GBK_FORMS) -} - #endif /** @@ -932,40 +871,6 @@ pm_encoding_char_width(const pm_encoding_t *encoding, const uint8_t *b, ptrdiff_ } } -/** - * Return the number of bytes in the next character in the given encoding if it - * has the given PRISM_ENCODING_*_BIT property, or 0 otherwise. The encoding is - * multibyte, and its characters are not Unicode code points. - */ -static size_t -pm_encoding_property_char(const pm_encoding_t *encoding, uint8_t property, const uint8_t *b, ptrdiff_t n) { - switch (encoding->kind) { - case PM_ENCODING_KIND_EUC_JP: - return pm_encoding_euc_jp_property_char(property, b, n); - case PM_ENCODING_KIND_SHIFT_JIS: - return pm_encoding_shift_jis_property_char(property, b, n); -#ifndef PRISM_ENCODING_EXCLUDE_FULL - case PM_ENCODING_KIND_BIG5: - return pm_encoding_big5_property_char(property, b, n); - case PM_ENCODING_KIND_CP949: - return pm_encoding_cp949_property_char(property, b, n); - case PM_ENCODING_KIND_EMACS_MULE: - return pm_encoding_emacs_mule_property_char(property, b, n); - case PM_ENCODING_KIND_EUC_KR: - return pm_encoding_euc_kr_property_char(property, b, n); - case PM_ENCODING_KIND_EUC_TW: - return pm_encoding_euc_tw_property_char(property, b, n); - case PM_ENCODING_KIND_GB18030: - return pm_encoding_gb18030_property_char(property, b, n); - case PM_ENCODING_KIND_GBK: - return pm_encoding_gbk_property_char(property, b, n); -#endif - default: - PRISM_ASSERT(false && "unreachable"); - return 0; - } -} - /** * Return true if the next character in the given encoding is uppercase, or * titlecase, in the given version of Ruby. The answer depends on the version @@ -977,31 +882,45 @@ pm_encoding_isupper_char(const pm_encoding_t *encoding, const uint8_t *b, ptrdif case PM_ENCODING_KIND_ASCII: case PM_ENCODING_KIND_SINGLE_BYTE: { if (n <= 0) return false; - if (*b < 0x80) return (pm_encoding_ascii_table[*b] & PRISM_ENCODING_UPPERCASE_BIT) != 0; + if (*b < 0x80) return pm_encoding_ascii_upper_p(*b); const uint8_t *uppercase = encoding->uppercase; return uppercase != NULL && ((uppercase[(*b - 0x80) >> 3] >> (*b & 7)) & 1); } case PM_ENCODING_KIND_UTF_8: return pm_encoding_utf_8_isupper_char(b, n, version); + case PM_ENCODING_KIND_EUC_JP: + return pm_encoding_euc_jp_isupper_char(b, n); + case PM_ENCODING_KIND_SHIFT_JIS: + return pm_encoding_shift_jis_isupper_char(b, n); #ifndef PRISM_ENCODING_EXCLUDE_FULL case PM_ENCODING_KIND_CESU_8: { size_t width = pm_encoding_cesu_8_char_width(b, n); return width != 0 && pm_unicode_uppercase_p(pm_cesu_8_codepoint(b, width), version); } + case PM_ENCODING_KIND_EMACS_MULE: + return pm_encoding_emacs_mule_isupper_char(b, n); + /* These encodings have no uppercase letters beyond ASCII. */ + case PM_ENCODING_KIND_BIG5: + case PM_ENCODING_KIND_CP949: + case PM_ENCODING_KIND_EUC_KR: + case PM_ENCODING_KIND_EUC_TW: + case PM_ENCODING_KIND_GB18030: + case PM_ENCODING_KIND_GBK: + return n > 0 && pm_encoding_ascii_upper_p(*b); #endif default: - return pm_encoding_property_char(encoding, PRISM_ENCODING_UPPERCASE_BIT, b, n) != 0; + PRISM_ASSERT(false && "unreachable"); + return false; } } -#undef PM_ENCODING_ALNUM -#undef PM_ENCODING_FORMS_PROPERTY_CHAR +#undef PM_ENCODING_FORMS_ISUPPER_CHAR #undef PM_ENCODING_FORMS_CHAR_WIDTH -#undef PM_ENCODING_PROPERTY_4 -#undef PM_ENCODING_PROPERTY_3 -#undef PM_ENCODING_PROPERTY_2 -#undef PM_ENCODING_PROPERTY_1 +#undef PM_ENCODING_UPPERCASE_4 +#undef PM_ENCODING_UPPERCASE_3 +#undef PM_ENCODING_UPPERCASE_2 +#undef PM_ENCODING_UPPERCASE_1 #undef PM_ENCODING_WIDTH_6 #undef PM_ENCODING_WIDTH_4 #undef PM_ENCODING_WIDTH_3 From fc1c8861dfdcb565589cf5f5872e80491e4cf49c Mon Sep 17 00:00:00 2001 From: Kevin Newton Date: Mon, 16 Nov 2026 21:42:36 -0500 Subject: [PATCH 15/20] Use pm_encoding_ascii_alpha_p and pm_encoding_ascii_alnum_p for identifier characters --- src/prism.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/prism.c b/src/prism.c index 9be3c2a83a..5191542939 100644 --- a/src/prism.c +++ b/src/prism.c @@ -1879,7 +1879,7 @@ char_is_identifier_start(const pm_parser_t *parser, const uint8_t *b, ptrdiff_t if (parser->encoding_changed && *b >= 0x80) { return pm_encoding_char_width(parser->encoding, b, n); } else if (*b < 0x80) { - return (pm_encoding_ascii_table[*b] & PRISM_ENCODING_ALPHABETIC_BIT ? 1 : 0) || (*b == '_'); + return pm_encoding_ascii_alpha_p(*b) || (*b == '_'); } else { return pm_encoding_utf_8_char_width(b, n); } @@ -1895,7 +1895,7 @@ char_is_identifier_utf8(const uint8_t *b, ptrdiff_t n) { if (n <= 0) { return 0; } else if (*b < 0x80) { - return (*b == '_') || (pm_encoding_ascii_table[*b] & PRISM_ENCODING_ALPHANUMERIC_BIT ? 1 : 0); + return (*b == '_') || pm_encoding_ascii_alnum_p(*b); } else { return pm_encoding_utf_8_char_width(b, n); } From ab06144e2db72b7971b2ab5d16bcaa8e41b0a1fc Mon Sep 17 00:00:00 2001 From: Kevin Newton Date: Mon, 16 Nov 2026 21:45:11 -0500 Subject: [PATCH 16/20] Update encoding documentation --- bin/prism | 6 ++++-- docs/encoding.md | 6 +++--- include/prism/internal/encoding.h | 21 +++++++-------------- src/encoding.c | 10 +++++----- 4 files changed, 19 insertions(+), 24 deletions(-) diff --git a/bin/prism b/bin/prism index 1ff08f738a..0472151cc2 100755 --- a/bin/prism +++ b/bin/prism @@ -415,8 +415,7 @@ module Prism false end - # Generate the list of values that will be used in a lookup table for a - # given encoding. + # Generate the list of values that will be used in the ASCII table. def lookup_table_values(encoding) (0...256).each_slice(16).map.with_index do |slice, row_index| slice.map do |codepoint| @@ -453,6 +452,9 @@ module Prism (0x80...0x100).each do |byte| next unless constant_start?(byte.chr(encoding)) bitmap[(byte - 0x80) >> 3] |= 1 << (byte & 7) + rescue RangeError + warn("Encoding `#{encoding.name}' is not a single-byte encoding. The forms of the multibyte encodings are written by hand in src/encoding.c.") + exit(1) end if bitmap.all?(0) diff --git a/docs/encoding.md b/docs/encoding.md index 8f2fd18d0a..2347debf96 100644 --- a/docs/encoding.md +++ b/docs/encoding.md @@ -1,8 +1,8 @@ # Encoding -When parsing a Ruby file, there are times when the parser must parse identifiers. Identifiers are names of variables, methods, classes, etc. To determine the start of an identifier, the parser must be able to tell if the subsequent bytes form an alphabetic character. To determine the rest of the identifier, the parser must look forward through all alphanumeric characters. +When parsing a Ruby file, there are times when the parser must parse identifiers. Identifiers are names of variables, methods, classes, etc. An identifier starts with an ASCII letter, an underscore, or any character that is not ASCII. The rest of it is ASCII letters, digits, and underscores, and any characters that are not ASCII. An identifier is a constant name if its first character is uppercase. -Determining if a set of bytes comprise an alphabetic or alphanumeric character is encoding-dependent. By default, the parser assumes that all source files are encoded UTF-8. If the file is not encoded in UTF-8, it must be encoded using an encoding that is "ASCII compatible" (i.e., all of the codepoints below 128 match the corresponding codepoints in ASCII and the minimum number of bytes required to represent a codepoint is 1 byte). +Which bytes form a character, and which characters begin a constant name, depends on the encoding. By default, the parser assumes that all source files are encoded UTF-8. If the file is not encoded in UTF-8, it must be encoded using an encoding that is "ASCII compatible" (i.e., all of the codepoints below 128 match the corresponding codepoints in ASCII and the minimum number of bytes required to represent a codepoint is 1 byte). If the file is not encoded in UTF-8, the user must specify the encoding in a "magic" comment at the top of the file. The comment looks like: @@ -103,7 +103,7 @@ The key of the comment can be either "encoding" or "coding". The value of the co * `Windows-31J` * `Windows-874` -For each of these encodings, prism provides functions for checking if the subsequent bytes can be interpreted as a character, and then if that character is alphabetic, alphanumeric, or uppercase. +For each of these encodings, prism provides functions for checking if the subsequent bytes can be interpreted as a character, and then if that character begins a constant name. In the encodings whose characters are Unicode code points, such as UTF-8 and CESU-8, that depends on the version of Unicode that the targeted version of Ruby uses. ## Getting notified when the encoding changes diff --git a/include/prism/internal/encoding.h b/include/prism/internal/encoding.h index d9a2a1f61c..28b8d7863e 100644 --- a/include/prism/internal/encoding.h +++ b/include/prism/internal/encoding.h @@ -89,21 +89,15 @@ pm_encoding_multibyte_p(const pm_encoding_t *encoding) { return encoding->kind != PM_ENCODING_KIND_SINGLE_BYTE && encoding->kind != PM_ENCODING_KIND_ASCII; } -/* - * All of the lookup tables use the first bit of each embedded byte to indicate - * whether the codepoint is alphabetical. - */ +/* The bit of the ASCII table that marks a letter. */ #define PRISM_ENCODING_ALPHABETIC_BIT (1 << 0) -/* - * All of the lookup tables use the second bit of each embedded byte to indicate - * whether the codepoint is alphanumeric. - */ +/* The bit of the ASCII table that marks a letter or a digit. */ #define PRISM_ENCODING_ALPHANUMERIC_BIT (1 << 1) /* - * All of the lookup tables use the third bit of each embedded byte to indicate - * whether the codepoint is uppercase. + * The bit that marks a character that begins a constant name, in the ASCII + * table, the unicode tables, and the forms of the multibyte encodings. */ #define PRISM_ENCODING_UPPERCASE_BIT (1 << 2) @@ -132,10 +126,9 @@ bool pm_encoding_utf_8_isupper_char(const uint8_t *b, ptrdiff_t n, pm_options_ve /* * This lookup table indicates whether a US-ASCII character is alphabetical, - * alphanumeric, or uppercase. It is referenced in both the UTF-8 encoding - * functions and the parser directly in order to speed up processing ASCII - * bytes in the default encoding, since every ASCII character is encoded as - * itself in UTF-8. + * alphanumeric, or uppercase. Every encoding that prism supports is + * ASCII-compatible, so this table answers for the bytes below 0x80 in all of + * them. */ extern const uint8_t pm_encoding_ascii_table[256]; diff --git a/src/encoding.c b/src/encoding.c index c2754d7e28..8257d268b5 100644 --- a/src/encoding.c +++ b/src/encoding.c @@ -11,11 +11,11 @@ typedef uint32_t pm_unicode_codepoint_t; * table, as described in section 5.1 of the unicode core specification. The * high bits of a codepoint index the root table, which gives a middle block. * The next five bits index that middle block, which gives a leaf block. The low - * three bits index that leaf block, which gives the same bitfield used by the - * single-byte lookup tables. Codepoints with identical blocks share a single - * copy, so the tables stay small, and every lookup is three loads with no - * searching. Codepoints at or above UNICODE_CODEPOINTS_MAXIMUM have no - * properties. + * three bits index that leaf block, which gives the properties of the + * codepoint, with the same uppercase bit as the ASCII table. Codepoints with + * identical blocks share a single copy, so the tables stay small, and every + * lookup is three loads with no searching. Codepoints at or above + * UNICODE_CODEPOINTS_MAXIMUM have no properties. * * The tables are Unicode 17.0.0. `bin/prism encoding UTF-8` generates them from * the Unicode Character Database at that version. From d5eaf0bd93ae987064f68f72f0acb85e6c9bb1cc Mon Sep 17 00:00:00 2001 From: Kevin Newton Date: Mon, 16 Nov 2026 21:47:36 -0500 Subject: [PATCH 17/20] Cover every four-byte Emacs-Mule character that starts with 0x9C --- test/prism/test_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/prism/test_helper.rb b/test/prism/test_helper.rb index 9fea36476b..4e5b2872f9 100644 --- a/test/prism/test_helper.rb +++ b/test/prism/test_helper.rb @@ -210,7 +210,7 @@ def self.each_encoding *(0...0x80), *((0x81...0x90).flat_map { |byte1| (0x90...0x100).map { |byte2| byte1 << 8 | byte2 } }), *((0x90...0x9C).flat_map { |byte1| (0xA0...0x100).flat_map { |byte2| (0xA0...0x100).flat_map { |byte3| byte1 << 16 | byte2 << 8 | byte3 } } }), - *((0xF0...0xF5).flat_map { |byte2| (0xA0...0x100).flat_map { |byte3| (0xA0...0x100).flat_map { |byte4| 0x9C << 24 | byte3 << 16 | byte3 << 8 | byte4 } } }), + *((0xF0...0xF5).flat_map { |byte2| (0xA0...0x100).flat_map { |byte3| (0xA0...0x100).flat_map { |byte4| 0x9C << 24 | byte2 << 16 | byte3 << 8 | byte4 } } }), ] yield Encoding::EMACS_MULE, codepoints_emacs_mule From 5916a5262c13f6b3d0ba6c5c3ffb8de6d70b4c06 Mon Sep 17 00:00:00 2001 From: Kevin Newton Date: Mon, 16 Nov 2026 22:03:52 -0500 Subject: [PATCH 18/20] Resolve string query versions in FFI the way the extension does --- lib/prism/ffi.rb | 58 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 42 insertions(+), 16 deletions(-) diff --git a/lib/prism/ffi.rb b/lib/prism/ffi.rb index 85215fa722..ac154ed9c1 100644 --- a/lib/prism/ffi.rb +++ b/lib/prism/ffi.rb @@ -119,6 +119,12 @@ def self.load_exported_functions_from(header, *functions, callbacks) [] ) + load_exported_functions_from( + "prism/options.h", + "pm_options_version_supported_p", + [] + ) + load_exported_functions_from( "prism/string_query.h", "pm_string_query_local", @@ -709,47 +715,67 @@ def dump_options(options) # Here we are going to patch StringQuery to put in the class-level methods so # that it can maintain a consistent interface class StringQuery # :nodoc: - # The version strings that the string queries take, by the number that the - # version option of the parse methods dumps for each version. The latest - # version is nil. - VERSIONS = { 0 => nil, 1 => "3.3", 2 => "3.4", 3 => "4.0", 4 => "4.1" }.freeze - private_constant :VERSIONS - class << self # Mirrors the C extension's StringQuery::local? method. def local?(string, version: nil) - query(LibRubyParser.pm_string_query_local(string, string.bytesize, string.encoding.name, query_version(version))) + version = query_version(version) + query(LibRubyParser.pm_string_query_local(string, string.bytesize, string.encoding.name, version), version) end # Mirrors the C extension's StringQuery::constant? method. def constant?(string, version: nil) - query(LibRubyParser.pm_string_query_constant(string, string.bytesize, string.encoding.name, query_version(version))) + version = query_version(version) + query(LibRubyParser.pm_string_query_constant(string, string.bytesize, string.encoding.name, version), version) end # Mirrors the C extension's StringQuery::method_name? method. def method_name?(string, version: nil) - query(LibRubyParser.pm_string_query_method_name(string, string.bytesize, string.encoding.name, query_version(version))) + version = query_version(version) + query(LibRubyParser.pm_string_query_method_name(string, string.bytesize, string.encoding.name, version), version) end # Mirrors the C extension's StringQuery::keyword? method. def keyword?(string, version: nil) - query(LibRubyParser.pm_string_query_keyword(string, string.bytesize, string.encoding.name, query_version(version))) + version = query_version(version) + query(LibRubyParser.pm_string_query_keyword(string, string.bytesize, string.encoding.name, version), version) end private - # Read the version option of a string query the same way that the version - # option of the parse methods is read, which raises for a version that is - # not valid, into the version string that the query takes. + # Read the version option of a string query the way the version option + # of the parse methods reads it. The nearest version is the running Ruby + # if prism supports it, 3.3 for an older Ruby, and otherwise the latest + # (nil). The current version is the running Ruby, which prism must + # support. Any other version is passed on as it is, and the query itself + # checks it. def query_version(version) - VERSIONS.fetch(Prism.__send__(:dump_options_version, version)) + case version + when nil, "nearest" + if running_version_supported? + RUBY_VERSION + elsif RUBY_VERSION < "3.3" + "3.3" + end + when "current" + raise CurrentVersionError, RUBY_VERSION unless running_version_supported? + RUBY_VERSION + else + version = String.try_convert(version) || raise(TypeError, "no implicit conversion of #{version.class} into String") + raise ArgumentError, "string contains null byte" if version.include?("\0") + version + end + end + + # Return true if prism supports the version of the running Ruby. + def running_version_supported? + LibRubyParser.pm_options_version_supported_p(RUBY_VERSION, RUBY_VERSION.bytesize) end # Parse the enum result and return an appropriate boolean. - def query(result) + def query(result, version) case result when :PM_STRING_QUERY_ERROR_VERSION - raise ArgumentError, "invalid version" + raise ArgumentError, "invalid version: #{version}" when :PM_STRING_QUERY_ERROR raise ArgumentError, "Invalid or non ascii-compatible encoding" when :PM_STRING_QUERY_FALSE From 80b45e39d85779361df03d0d396581c7d687456a Mon Sep 17 00:00:00 2001 From: Kevin Newton Date: Mon, 16 Nov 2026 22:24:45 -0500 Subject: [PATCH 19/20] Read non-ASCII Emacs-Mule characters as the start of a local name --- CHANGELOG.md | 1 - src/encoding.c | 25 ++++--------- test/prism/encoding/encodings_test.rb | 54 ++++++++++++++------------- 3 files changed, 35 insertions(+), 45 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 948ca77c51..6373b6531a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,7 +24,6 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a - A `?` followed by two identifier characters is a ternary operator, even when the first one is not ASCII. For example, `a ?☃b : c` used to read `?☃` as a character literal. - A multiple assignment can write to an attribute whose name starts with a character that is not ASCII, as in `foo.☃, bar = 1, 2`. - A name that starts with `€` (0xA4) in ISO-8859-16, or with `¯` (0xAF) in Windows-1252, is a constant name. In encodings that are not Unicode, a character that is neither uppercase nor lowercase begins a constant if case folding changes it. -- In Emacs-Mule, stateless-ISO-2022-JP, and stateless-ISO-2022-JP-KDDI, a name that starts with any character that is not ASCII is a constant name. ## [2.1.0] - 2026-10-28 diff --git a/src/encoding.c b/src/encoding.c index 8257d268b5..8534d1f2a6 100644 --- a/src/encoding.c +++ b/src/encoding.c @@ -729,16 +729,14 @@ pm_encoding_cp949_char_width(const uint8_t *b, ptrdiff_t n) { } /** - * The forms of the characters in the Emacs-Mule encoding. Ruby reads a name - * that starts with any character that is not ASCII as a constant name in this - * encoding, so every form is uppercase. + * The forms of the characters in the Emacs-Mule encoding. */ #define PM_ENCODING_EMACS_MULE_FORMS(X) \ - X##_2(PRISM_ENCODING_UPPERCASE_BIT, 0x81, 0x8F, 0xA0, 0xFF) \ - X##_3(PRISM_ENCODING_UPPERCASE_BIT, 0x90, 0x99, 0xA0, 0xFF, 0xA0, 0xFF) \ - X##_3(PRISM_ENCODING_UPPERCASE_BIT, 0x9A, 0x9B, 0xE0, 0xEF, 0xA0, 0xFF) \ - X##_4(PRISM_ENCODING_UPPERCASE_BIT, 0x9C, 0x9C, 0xF0, 0xF4, 0xA0, 0xFF, 0xA0, 0xFF) \ - X##_4(PRISM_ENCODING_UPPERCASE_BIT, 0x9D, 0x9D, 0xF5, 0xFE, 0xA0, 0xFF, 0xA0, 0xFF) + X##_2(0, 0x81, 0x8F, 0xA0, 0xFF) \ + X##_3(0, 0x90, 0x99, 0xA0, 0xFF, 0xA0, 0xFF) \ + X##_3(0, 0x9A, 0x9B, 0xE0, 0xEF, 0xA0, 0xFF) \ + X##_4(0, 0x9C, 0x9C, 0xF0, 0xF4, 0xA0, 0xFF, 0xA0, 0xFF) \ + X##_4(0, 0x9D, 0x9D, 0xF5, 0xFE, 0xA0, 0xFF, 0xA0, 0xFF) /** * Return the width of the character at b in Emacs-Mule, or 0 if there is none. @@ -748,14 +746,6 @@ pm_encoding_emacs_mule_char_width(const uint8_t *b, ptrdiff_t n) { PM_ENCODING_FORMS_CHAR_WIDTH(PM_ENCODING_EMACS_MULE_FORMS) } -/** - * Return true if the character at b begins a constant name in Emacs-Mule. - */ -static bool -pm_encoding_emacs_mule_isupper_char(const uint8_t *b, ptrdiff_t n) { - PM_ENCODING_FORMS_ISUPPER_CHAR(PM_ENCODING_EMACS_MULE_FORMS) -} - /** * The forms of the characters in the EUC-KR encoding. */ @@ -898,11 +888,10 @@ pm_encoding_isupper_char(const pm_encoding_t *encoding, const uint8_t *b, ptrdif size_t width = pm_encoding_cesu_8_char_width(b, n); return width != 0 && pm_unicode_uppercase_p(pm_cesu_8_codepoint(b, width), version); } - case PM_ENCODING_KIND_EMACS_MULE: - return pm_encoding_emacs_mule_isupper_char(b, n); /* These encodings have no uppercase letters beyond ASCII. */ case PM_ENCODING_KIND_BIG5: case PM_ENCODING_KIND_CP949: + case PM_ENCODING_KIND_EMACS_MULE: case PM_ENCODING_KIND_EUC_KR: case PM_ENCODING_KIND_EUC_TW: case PM_ENCODING_KIND_GB18030: diff --git a/test/prism/encoding/encodings_test.rb b/test/prism/encoding/encodings_test.rb index aa07a7527c..504dcbad77 100644 --- a/test/prism/encoding/encodings_test.rb +++ b/test/prism/encoding/encodings_test.rb @@ -6,11 +6,8 @@ module Prism class EncodingsTest < TestCase - class IdentifierContext < BasicObject - def method_missing(name, *) - name - end - end + # Emacs-Mule, and the encodings that share its characters. + EMACS_MULE_ENCODINGS = [Encoding::Emacs_Mule, Encoding::Stateless_ISO_2022_JP, Encoding::Stateless_ISO_2022_JP_KDDI] # These test that we're correctly parsing codepoints for each alias of each # encoding that prism supports. @@ -44,14 +41,13 @@ def test_case_folded_constants end end - # In Emacs-Mule, and the encodings that share its characters, a name that - # starts with any character that is not ASCII is a constant name. - def test_emacs_mule_constants - ["Emacs-Mule", "stateless-ISO-2022-JP", "stateless-ISO-2022-JP-KDDI"].each do |name| + # In Emacs-Mule, and the encodings that share its characters, no character + # that is not ASCII is uppercase, so a name that starts with one is a + # local name. + def test_emacs_mule_locals + EMACS_MULE_ENCODINGS.each do |encoding| [0x81A0, 0x90A0A0, 0x9AE0A0, 0x9CF0A0A0, 0x9DF5A0A0].each do |codepoint| - character = codepoint.chr(Encoding.find(name)) - assert constant_start?(character), "Expected Ruby to read #{character.inspect} in #{name} as a constant." - assert_encoding_constant(name, character) + assert_encoding_identifier(encoding.name, codepoint.chr(encoding)) end end end @@ -61,13 +57,29 @@ def test_emacs_mule_constants # Return true if a name that starts with the character is a constant name. # Object.const_defined? raises a NameError for a name that is not one. + # + # Ruby before 4.1 reads every character of Emacs-Mule that is not ASCII as + # uppercase, because of a bug in the character types of the encoding (Bug + # #22491). Prism reads those characters as Ruby 4.1 does, as the start of a + # local name. def constant_start?(character) + return false if EMACS_MULE_ENCODINGS.include?(character.encoding) && !character.ascii_only? + Object.const_defined?(character) true rescue NameError false end + # Return the symbol that a name made of the given characters is in a source + # file with the given encoding magic comment. A name like UTF-8-MAC ends in + # an Emacs line ending, so Ruby reads the source as UTF-8 rather than + # UTF8-MAC. + def expected_name(name, characters) + encoding = eval("# encoding: #{name}\n__ENCODING__") + characters.b.force_encoding(encoding).to_sym + end + # These identifiers are longer than the bytes that the lexer scans at once # for ASCII identifier characters. def assert_ascii_identifiers(encoding) @@ -84,31 +96,21 @@ def assert_ascii_identifiers(encoding) end def assert_encoding_constant(name, character) - source = "# encoding: #{name}\n#{character}" - - # A name like UTF-8-MAC ends in an Emacs line ending, so Ruby reads the - # source as UTF-8 rather than UTF8-MAC. - encoding = eval("# encoding: #{name}\n__ENCODING__") - expected = character.b.force_encoding(encoding).to_sym - - result = Prism.parse(source) + result = Prism.parse("# encoding: #{name}\n#{character}") assert result.success? actual = result.value.statements.body.last assert_kind_of ConstantReadNode, actual - assert_equal expected, actual.name + assert_equal expected_name(name, character), actual.name end def assert_encoding_identifier(name, character) - source = "# encoding: #{name}\n#{character}" - expected = IdentifierContext.new.instance_eval(source) - - result = Prism.parse(source) + result = Prism.parse("# encoding: #{name}\n#{character}") assert result.success? actual = result.value.statements.body.last assert_kind_of CallNode, actual - assert_equal expected, actual.name + assert_equal expected_name(name, character), actual.name end # Check that we can properly parse every codepoint in the given encoding. From 1613c441add6ebf7acec9f34a0f5a70643bb59d0 Mon Sep 17 00:00:00 2001 From: Kevin Newton Date: Mon, 16 Nov 2026 22:26:26 -0500 Subject: [PATCH 20/20] Skip the non-ASCII name snapshots on TruffleRuby --- test/prism/snapshots_test.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/prism/snapshots_test.rb b/test/prism/snapshots_test.rb index b63dfaa4eb..e3d4b60d01 100644 --- a/test/prism/snapshots_test.rb +++ b/test/prism/snapshots_test.rb @@ -31,6 +31,8 @@ def teardown if RUBY_ENGINE == "truffleruby" except.push( "emoji_method_calls.txt", + "multi_write_non_ascii.txt", + "ternary_operator_non_ascii.txt", ) end