Vendor dependencies for 0.3.0 release

This commit is contained in:
2025-09-27 10:29:08 -05:00
parent 0c8d39d483
commit 82ab7f317b
26803 changed files with 16134934 additions and 0 deletions

View File

@@ -0,0 +1 @@
{"files":{"COPYRIGHT":"23860c2a7b5d96b21569afedf033469bab9fe14a1b24a35068b8641c578ce24d","Cargo.toml":"a19304f0364a6b4d62e6624295d7a62892683abfdb64b1a02bf0a56f5a73ad4e","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"7b63ecd5f1902af1b63729947373683c32745c16a10e8e6292e2e2dcd7e90ae0","README.md":"ac1fb7340d99dce9ab7a59051a7bf1239ae83540066b7f209c12ac06e3c2fda6","scripts/unicode.py":"5f7db3635c482a2e1e78fbe44b8ba6e59864c675cd3ff0e48a0aad3b49b372f3","src/lib.rs":"8420eb2f6741246706a3a8bae92b21e8ce7599e8f5d7a66a438ecc0b395927a9","src/tables.rs":"d108073889dd497264866c54ea88d13540377d716ac6ee618e7c0550390eed48","tests/emoji.rs":"3a7401584ae30ca7662cb0b4eed1c65e38268926dc110a9a74061efeabdb12ae","tests/general_category.rs":"b4230f259b7d8395000398722dbd6077f9feb27dfdb78f113f19371320476738"},"package":"e70f2a8b45122e719eb623c01822704c4e0907e7e426a05927e1a1cfff5b75d0"}

7
vendor/unicode-properties/COPYRIGHT vendored Normal file
View File

@@ -0,0 +1,7 @@
Licensed under the Apache License, Version 2.0
<LICENSE-APACHE or
http://www.apache.org/licenses/LICENSE-2.0> or the MIT
license <LICENSE-MIT or http://opensource.org/licenses/MIT>,
at your option. All files in the project carrying such
notice may not be copied, modified, or distributed except
according to those terms.

64
vendor/unicode-properties/Cargo.toml vendored Normal file
View File

@@ -0,0 +1,64 @@
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
#
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g., crates.io) dependencies.
#
# If you are reading this file be aware that the original Cargo.toml
# will likely look very different (and much more reasonable).
# See Cargo.toml.orig for the original contents.
[package]
edition = "2021"
name = "unicode-properties"
version = "0.1.3"
authors = [
"Charles Lew <crlf0710@gmail.com>",
"Manish Goregaokar <manishsmail@gmail.com>",
]
build = false
exclude = [
"target/*",
"Cargo.lock",
]
autobins = false
autoexamples = false
autotests = false
autobenches = false
description = """
Query character Unicode properties according to
UAX #44 and UTR #51.
"""
homepage = "https://github.com/unicode-rs/unicode-properties"
documentation = "https://docs.rs/unicode-properties"
readme = "README.md"
keywords = [
"text",
"unicode",
]
categories = ["no-std::no-alloc"]
license = "MIT/Apache-2.0"
repository = "https://github.com/unicode-rs/unicode-properties"
[lib]
name = "unicode_properties"
path = "src/lib.rs"
[[test]]
name = "emoji"
path = "tests/emoji.rs"
[[test]]
name = "general_category"
path = "tests/general_category.rs"
[dependencies]
[features]
default = [
"general-category",
"emoji",
]
emoji = []
general-category = []

201
vendor/unicode-properties/LICENSE-APACHE vendored Normal file
View File

@@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

25
vendor/unicode-properties/LICENSE-MIT vendored Normal file
View File

@@ -0,0 +1,25 @@
Copyright (c) 2015 The Rust Project Developers
Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

5
vendor/unicode-properties/README.md vendored Normal file
View File

@@ -0,0 +1,5 @@
# unicode-properties
[![Build Status](https://github.com/unicode-rs/unicode-properties/workflows/Tests/badge.svg)](https://github.com/unicode-rs/unicode-properties/actions)
[![Current Version](https://img.shields.io/crates/v/unicode-properties.svg)](https://crates.io/crates/unicode-properties)
[![License: MIT/Apache-2.0](https://img.shields.io/crates/l/unicode-properties.svg)](#license)

View File

@@ -0,0 +1,538 @@
#!/usr/bin/env python3
#
# Copyright 2011-2015 The Rust Project Developers. See the COPYRIGHT
# file at the top-level directory of this distribution and at
# http://rust-lang.org/COPYRIGHT.
#
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
# option. This file may not be copied, modified, or distributed
# except according to those terms.
# This script uses the following Unicode UCD data:
# - emoji/emoji-data.txt
#
# Since this should not require frequent updates, we just store this
# out-of-line and check the tables.rs file into git.
import fileinput, re, os, sys, operator
preamble = '''// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// NOTE: The following code was generated by "scripts/unicode.py", do not edit directly
#![allow(missing_docs, non_upper_case_globals, non_snake_case)]
'''
UNICODE_VERSION = (16, 0, 0)
UNICODE_VERSION_NUMBER = "%s.%s.%s" %UNICODE_VERSION
# Download a UCD table file
def fetch_unidata(f):
if not os.path.exists(os.path.basename(f)):
os.system("curl -O https://www.unicode.org/Public/%s/ucd/%s"
% (UNICODE_VERSION_NUMBER, f))
if not os.path.exists(os.path.basename(f)):
sys.stderr.write("cannot load %s" % f)
exit(1)
# Loads code point data from emoji-data.txt
# Implementation from unicode-segmentation
def load_emoji_properties(f):
fetch_unidata(f)
kinds = {}
re1 = re.compile(r"^ *([0-9A-F]+) *; *(\w+)")
re2 = re.compile(r"^ *([0-9A-F]+)\.\.([0-9A-F]+) *; *(\w+) *#")
for line in fileinput.input(os.path.basename(f), openhook=fileinput.hook_encoded("utf-8")):
kind = None
d_lo = 0
d_hi = 0
m = re1.match(line)
if m:
d_lo = m.group(1)
d_hi = m.group(1)
kind = m.group(2).strip()
else:
m = re2.match(line)
if m:
d_lo = m.group(1)
d_hi = m.group(2)
kind = m.group(3).strip()
else:
continue
d_lo = int(d_lo, 16)
d_hi = int(d_hi, 16)
if kind not in kinds:
kinds[kind] = []
kinds[kind].append((d_lo, d_hi))
return kinds
def load_general_category_properties(f):
fetch_unidata(f)
general_category_list = []
re1 = re.compile(r"^([0-9A-F]+);([^;]+);([A-Za-z]+);.*$")
re2 = re.compile(r"^<(.*), First>$")
re3 = re.compile(r"^<(.*), Last>$")
re4 = re.compile(r"^<(.*)>$")
special_group_lo = 0
special_group_text = ''
special_group_gc = ''
for line in fileinput.input(os.path.basename(f), openhook=fileinput.hook_encoded("utf-8")):
d_ch = 0
d_name = ''
d_gc = ''
d_lo = 0
d_hi = 0
m = re1.match(line)
if not m:
continue
d_ch = m.group(1)
d_name = m.group(2).strip()
d_gc = m.group(3).strip()
if not d_name.startswith('<'):
d_lo = int(d_ch, 16)
d_hi = d_lo
general_category_list.append((d_lo, d_hi, d_gc))
continue
m2 = re2.match(d_name)
if m2:
special_group_lo = int(d_ch, 16)
special_group_text = m2.group(1)
special_group_gc = d_gc
continue
m3 = re3.match(d_name)
if m3:
assert(special_group_text == m3.group(1))
assert(special_group_gc == d_gc)
d_lo = special_group_lo
d_hi = int(d_ch, 16)
general_category_list.append((d_lo, d_hi, d_gc))
continue
m4 = re4.match(d_name)
if m4:
d_lo = int(d_ch, 16)
d_hi = d_lo
general_category_list.append((d_lo, d_hi, d_gc))
continue
raise ValueError("unreachable")
return general_category_list
def format_table_content(f, content, indent):
line = " "*indent
first = True
for chunk in content.split(","):
if len(line) + len(chunk) < 98:
if first:
line += chunk
else:
line += ", " + chunk
first = False
else:
f.write(line + ",\n")
line = " "*indent + chunk
f.write(line)
def escape_char(c):
if c == 'multi':
return "\"<multiple code points>\""
return "'\\u{%x}'" % c
def escape_char_list(l):
line = "["
first = True
for c in l:
if first:
line += escape_char(c)
else:
line += ", " + escape_char(c)
first = False
line += "]"
return line
def emit_table(f, name, t_data, t_type = "&'static [(char, char)]", is_pub=True,
pfun=lambda x: "(%s,%s)" % (escape_char(x[0]), escape_char(x[1])), is_const=True):
pub_string = "const"
if not is_const:
pub_string = "let"
if is_pub:
pub_string = "pub " + pub_string
f.write(" %s %s: %s = &[\n" % (pub_string, name, t_type))
data = ""
first = True
for dat in t_data:
if not first:
data += ","
first = False
data += pfun(dat)
format_table_content(f, data, 8)
f.write("\n ];\n\n")
def emit_general_category_module(f):
f.write("""#[cfg(feature = \"general-category\")]
pub mod general_category {""")
f.write("""
#[derive(Copy, Clone, Hash, Eq, PartialEq, Ord, PartialOrd, Debug)]
/// The most general classification of a character.
pub enum GeneralCategory {
/// `Lu`, an uppercase letter
UppercaseLetter,
/// `Ll`, a lowercase letter
LowercaseLetter,
/// `Lt`, a digraphic character, with first part uppercase
TitlecaseLetter,
/// `Lm`, a modifier letter
ModifierLetter,
/// `Lo`, other letters, including syllables and ideographs
OtherLetter,
/// `Mn`, a nonspacing combining mark (zero advance width)
NonspacingMark,
/// `Mc`, a spacing combining mark (positive advance width)
SpacingMark,
/// `Me`, an enclosing combining mark
EnclosingMark,
/// `Nd`, a decimal digit
DecimalNumber,
/// `Nl`, a letterlike numeric character
LetterNumber,
/// `No`, a numeric character of other type
OtherNumber,
/// `Pc`, a connecting punctuation mark, like a tie
ConnectorPunctuation,
/// `Pd`, a dash or hyphen punctuation mark
DashPunctuation,
/// `Ps`, an opening punctuation mark (of a pair)
OpenPunctuation,
/// `Pe`, a closing punctuation mark (of a pair)
ClosePunctuation,
/// `Pi`, an initial quotation mark
InitialPunctuation,
/// `Pf`, a final quotation mark
FinalPunctuation,
/// `Po`, a punctuation mark of other type
OtherPunctuation,
/// `Sm`, a symbol of mathematical use
MathSymbol,
/// `Sc`, a currency sign
CurrencySymbol,
/// `Sk`, a non-letterlike modifier symbol
ModifierSymbol,
/// `So`, a symbol of other type
OtherSymbol,
/// `Zs`, a space character (of various non-zero widths)
SpaceSeparator,
/// `Zl`, U+2028 LINE SEPARATOR only
LineSeparator,
/// `Zp`, U+2029 PARAGRAPH SEPARATOR only
ParagraphSeparator,
/// `Cc`, a C0 or C1 control code
Control,
/// `Cf`, a format control character
Format,
/// `Cs`, a surrogate code point
Surrogate,
/// `Co`, a private-use character
PrivateUse,
/// `Cn`, a reserved unassigned code point or a noncharacter
Unassigned,
}
#[derive(Copy, Clone, Hash, Eq, PartialEq, Ord, PartialOrd, Debug)]
/// Groupings of the most general classification of a character.
pub enum GeneralCategoryGroup {
/// Lu | Ll | Lt | Lm | Lo
Letter,
/// Mn | Mc | Me
Mark,
/// Nd | Nl | No
Number,
/// Pc | Pd | Ps | Pe | Pi | Pf | Po
Punctuation,
/// Sm | Sc | Sk | So
Symbol,
/// Zs | Zl | Zp
Separator,
/// Cc | Cf | Cs | Co | Cn
Other,
}
#[inline]
pub(crate) fn general_category_of_char(c: char) -> GeneralCategory {
super::util::bsearch_range_value_table(c, GENERAL_CATEGORY).unwrap_or(GeneralCategory::Unassigned)
}
#[inline]
pub(crate) fn general_category_is_letter_cased(gc: GeneralCategory) -> bool {
matches!(gc, GeneralCategory::UppercaseLetter | GeneralCategory::LowercaseLetter | GeneralCategory::TitlecaseLetter)
}
#[inline]
pub(crate) fn general_category_group(gc: GeneralCategory) -> GeneralCategoryGroup {
match gc {
GeneralCategory::UppercaseLetter |
GeneralCategory::LowercaseLetter |
GeneralCategory::TitlecaseLetter |
GeneralCategory::ModifierLetter |
GeneralCategory::OtherLetter => GeneralCategoryGroup::Letter,
GeneralCategory::NonspacingMark |
GeneralCategory::SpacingMark |
GeneralCategory::EnclosingMark => GeneralCategoryGroup::Mark,
GeneralCategory::DecimalNumber |
GeneralCategory::LetterNumber |
GeneralCategory::OtherNumber => GeneralCategoryGroup::Number,
GeneralCategory::ConnectorPunctuation |
GeneralCategory::DashPunctuation |
GeneralCategory::OpenPunctuation |
GeneralCategory::ClosePunctuation |
GeneralCategory::InitialPunctuation |
GeneralCategory::FinalPunctuation |
GeneralCategory::OtherPunctuation => GeneralCategoryGroup::Punctuation,
GeneralCategory::MathSymbol |
GeneralCategory::CurrencySymbol |
GeneralCategory::ModifierSymbol |
GeneralCategory::OtherSymbol => GeneralCategoryGroup::Symbol,
GeneralCategory::SpaceSeparator |
GeneralCategory::LineSeparator |
GeneralCategory::ParagraphSeparator => GeneralCategoryGroup::Separator,
GeneralCategory::Control |
GeneralCategory::Format |
GeneralCategory::Surrogate |
GeneralCategory::PrivateUse |
GeneralCategory::Unassigned => GeneralCategoryGroup::Other,
}
}
""")
gc_variants = {
"Lu": "GeneralCategory::UppercaseLetter",
"Ll": "GeneralCategory::LowercaseLetter" ,
"Lt": "GeneralCategory::TitlecaseLetter" ,
"Lm": "GeneralCategory::ModifierLetter" ,
"Lo": "GeneralCategory::OtherLetter",
"Mn": "GeneralCategory::NonspacingMark",
"Mc": "GeneralCategory::SpacingMark" ,
"Me": "GeneralCategory::EnclosingMark",
"Nd": "GeneralCategory::DecimalNumber",
"Nl": "GeneralCategory::LetterNumber" ,
"No": "GeneralCategory::OtherNumber",
"Pc": "GeneralCategory::ConnectorPunctuation",
"Pd": "GeneralCategory::DashPunctuation" ,
"Ps": "GeneralCategory::OpenPunctuation" ,
"Pe": "GeneralCategory::ClosePunctuation" ,
"Pi": "GeneralCategory::InitialPunctuation" ,
"Pf": "GeneralCategory::FinalPunctuation" ,
"Po": "GeneralCategory::OtherPunctuation",
"Sm": "GeneralCategory::MathSymbol",
"Sc": "GeneralCategory::CurrencySymbol" ,
"Sk": "GeneralCategory::ModifierSymbol" ,
"So": "GeneralCategory::OtherSymbol",
"Zs": "GeneralCategory::SpaceSeparator",
"Zl": "GeneralCategory::LineSeparator" ,
"Zp": "GeneralCategory::ParagraphSeparator",
"Cc": "GeneralCategory::Control",
"Cf": "GeneralCategory::Format" ,
"Cs": "GeneralCategory::Surrogate" ,
"Co": "GeneralCategory::PrivateUse" ,
"Cn": "GeneralCategory::Unassigned",
}
f.write(" // General category table:\n")
general_category_char_table = load_general_category_properties("UnicodeData.txt")
general_category_group_table = []
for input_idx in range(len(general_category_char_table)):
if general_category_char_table[input_idx][2] == "Cs":
continue
existing_group_count = len(general_category_group_table)
if existing_group_count == 0:
general_category_group_table.append(general_category_char_table[input_idx])
elif (general_category_group_table[existing_group_count - 1][1] + 1 == general_category_char_table[input_idx][0] and
general_category_group_table[existing_group_count - 1][2] == general_category_char_table[input_idx][2]):
general_category_group_table[existing_group_count - 1] = (general_category_group_table[existing_group_count - 1][0],
general_category_char_table[input_idx][1], general_category_group_table[existing_group_count - 1][2])
else:
general_category_group_table.append(general_category_char_table[input_idx])
emit_table(f, "GENERAL_CATEGORY", general_category_group_table, "&[(char, char, GeneralCategory)]", is_pub=False,
pfun=lambda x: "(%s,%s,%s)" % (escape_char(x[0]), escape_char(x[1]), gc_variants[x[2]]))
f.write("}\n\n")
def emit_emoji_module(f):
f.write("""#[cfg(feature = \"emoji\")]
pub mod emoji {""")
f.write("""
#[derive(Copy, Clone, Hash, Eq, PartialEq, Ord, PartialOrd, Debug)]
#[non_exhaustive]
/// The emoji character properties of a character.
pub enum EmojiStatus {
/// `Emoji=NO`, `Emoji_Component=NO`
NonEmoji,
/// `Emoji=NO`, `Emoji_Component=YES`
NonEmojiButEmojiComponent,
/// `Emoji=YES`, `Emoji_Component=NO`;`Emoji_Presentation=YES`
EmojiPresentation,
/// `Emoji=YES`, `Emoji_Component=NO`;`Emoji_Modifier_Base=YES`
EmojiModifierBase,
/// `Emoji=YES`, `Emoji_Component=NO`;`Emoji_Presentation=YES`, `Emoji_Modifier_Base=YES`
EmojiPresentationAndModifierBase,
/// `Emoji=YES`, `Emoji_Component=NO`
EmojiOther,
/// `Emoji=YES`, `Emoji_Component=YES`;`Emoji_Presentation=YES`
EmojiPresentationAndEmojiComponent,
/// `Emoji=YES`, `Emoji_Component=YES`;`Emoji_Presentation=YES`, `Emoji_Modifier=YES`
EmojiPresentationAndModifierAndEmojiComponent,
/// `Emoji=YES`, `Emoji_Component=YES`
EmojiOtherAndEmojiComponent,
}
#[inline]
pub(crate) fn emoji_status(c: char) -> EmojiStatus {
// FIXME: do we want to special case ASCII here?
super::util::bsearch_range_value_table(c, EMOJI_STATUS).unwrap()
}
#[inline]
pub(crate) fn is_emoji_status_for_emoji_char_or_emoji_component(s: EmojiStatus) -> bool {
!matches!(s, EmojiStatus::NonEmoji)
}
#[inline]
pub(crate) fn is_emoji_status_for_emoji_char(s: EmojiStatus) -> bool {
!matches!(s, EmojiStatus::NonEmoji | EmojiStatus::NonEmojiButEmojiComponent)
}
#[inline]
pub(crate) fn is_emoji_status_for_emoji_component(s: EmojiStatus) -> bool {
matches!(s, EmojiStatus::EmojiPresentationAndEmojiComponent |
EmojiStatus::EmojiPresentationAndModifierAndEmojiComponent |
EmojiStatus::EmojiOtherAndEmojiComponent)
}
""")
f.write(" // Emoji status table:\n")
emoji_status_table = load_emoji_properties("emoji/emoji-data.txt")
# we combine things together here.
# `Extended_Pictographic`` is only for future proof usages, we ignore it here.
# emoji_prop_list = ["Emoji", "Emoji_Presentation", "Emoji_Modifier", "Emoji_Modifier_Base", "Emoji_Component", "Extended_Pictographic"]
emoji_prop_list = ["Emoji", "Emoji_Presentation", "Emoji_Modifier", "Emoji_Modifier_Base", "Emoji_Component"]
# need to skip surrogates because they're not representable by rust `char`s
emoji_status_table["Surrogate"] = [(0xD800, 0xDFFF)]
emoji_prop_list.append("Surrogate")
emoji_prop_list_len = [len(emoji_status_table[x]) for x in emoji_prop_list]
emoji_prop_count = len(emoji_prop_list)
code_point_first = 0
code_point_last = 0x10FFFF
emoji_prop_list_pos = [0 for _ in emoji_prop_list]
cur_group_first = code_point_first
emoji_table = []
def group_text(s):
if s == "Surrogate":
return "<Surrogate>"
elif s == "":
return "EmojiStatus::NonEmoji"
elif s == "Emoji_Component":
return "EmojiStatus::NonEmojiButEmojiComponent"
elif s == "Emoji;Emoji_Presentation":
return "EmojiStatus::EmojiPresentation"
elif s == "Emoji;Emoji_Presentation;Emoji_Modifier_Base":
return "EmojiStatus::EmojiPresentationAndModifierBase"
elif s == "Emoji;Emoji_Modifier_Base":
return "EmojiStatus::EmojiModifierBase"
elif s == "Emoji":
return "EmojiStatus::EmojiOther"
elif s == "Emoji;Emoji_Presentation;Emoji_Component":
return "EmojiStatus::EmojiPresentationAndEmojiComponent"
elif s == "Emoji;Emoji_Presentation;Emoji_Modifier;Emoji_Component":
return "EmojiStatus::EmojiPresentationAndModifierAndEmojiComponent"
elif s == "Emoji;Emoji_Component":
return "EmojiStatus::EmojiOtherAndEmojiComponent"
else:
return "EmojiStatus::NewCombination(\"" + s + "\")"
while cur_group_first <= code_point_last:
cur_group_props = []
cur_group_last = code_point_last
for prop_list_idx in range(emoji_prop_count):
if emoji_prop_list_pos[prop_list_idx] >= emoji_prop_list_len[prop_list_idx]:
continue
elif emoji_status_table[emoji_prop_list[prop_list_idx]][emoji_prop_list_pos[prop_list_idx]][0] > cur_group_first:
cur_group_last = min(cur_group_last, emoji_status_table[emoji_prop_list[prop_list_idx]][emoji_prop_list_pos[prop_list_idx]][0] - 1)
else:
cur_group_props.append(emoji_prop_list[prop_list_idx])
cur_group_last = min(cur_group_last, emoji_status_table[emoji_prop_list[prop_list_idx]][emoji_prop_list_pos[prop_list_idx]][1])
cur_group_text = group_text(";".join(cur_group_props))
if cur_group_text != "<Surrogate>":
emoji_table.append((cur_group_first, cur_group_last, cur_group_text))
for prop_list_idx in range(emoji_prop_count):
if emoji_prop_list_pos[prop_list_idx] >= emoji_prop_list_len[prop_list_idx]:
continue
elif emoji_status_table[emoji_prop_list[prop_list_idx]][emoji_prop_list_pos[prop_list_idx]][0] > cur_group_first:
continue
else:
if cur_group_last == emoji_status_table[emoji_prop_list[prop_list_idx]][emoji_prop_list_pos[prop_list_idx]][1]:
emoji_prop_list_pos[prop_list_idx] += 1
cur_group_first = cur_group_last + 1
emit_table(f, "EMOJI_STATUS", emoji_table, "&[(char, char, EmojiStatus)]", is_pub=False,
pfun=lambda x: "(%s,%s,%s)" % (escape_char(x[0]), escape_char(x[1]), x[2]))
f.write("}\n\n")
def emit_util_mod(f):
f.write("""
#[allow(dead_code)]
pub mod util {
use core::result::Result::{Ok, Err};
pub fn bsearch_range_value_table<T: Copy>(c: char, r: &'static [(char, char, T)]) -> Option<T> {
use core::cmp::Ordering::{Equal, Less, Greater};
match r.binary_search_by(|&(lo, hi, _)| {
if lo <= c && c <= hi { Equal }
else if hi < c { Less }
else { Greater }
}) {
Ok(idx) => {
let (_, _, cat) = r[idx];
Some(cat)
}
Err(_) => None
}
}
}
""")
if __name__ == "__main__":
r = "tables.rs"
if os.path.exists(r):
os.remove(r)
with open(r, "w") as rf:
# write the file's preamble
rf.write(preamble)
rf.write("""
/// The version of [Unicode](http://www.unicode.org/)
/// that this version of unicode-security is based on.
pub const UNICODE_VERSION: (u64, u64, u64) = (%s, %s, %s);
""" % UNICODE_VERSION)
emit_util_mod(rf)
### general category module
emit_general_category_module(rf)
### emoji module
emit_emoji_module(rf)

183
vendor/unicode-properties/src/lib.rs vendored Normal file
View File

@@ -0,0 +1,183 @@
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
//! Query character Unicode properties according to
//! [Unicode Standard Annex #44](https://www.unicode.org/reports/tr44/)
//! and [Unicode Technical Standard #51](https://www.unicode.org/reports/tr51/)
//! rules.
//!
//! Currently we support the `General_Category` property as well as `Emoji` and `Emoji_Component`.
//!
//! Future properties can be added as requested.
//!
//! ```rust
//! use unicode_properties::UnicodeEmoji;
//! use unicode_properties::UnicodeGeneralCategory;
//!
//! let ch = '🦀'; // U+1F980 CRAB
//! let is_emoji = ch.is_emoji_char();
//! let group = ch.general_category_group();
//! println!("{}({:?})", ch, group);
//! println!("The above char {} for use as emoji char.",
//! if is_emoji { "is recommended" } else { "is not recommended" });
//! ```
//!
//! # Features
//!
//! ## `general-category`
//!
//! Provides the most general classification of a character,
//! based on its primary characteristic.
//!
//! ## `emoji`
//!
//! Provides the emoji character properties of a character.
//!
#![no_std]
#![deny(missing_docs)]
#[rustfmt::skip]
mod tables;
#[cfg(feature = "emoji")]
/// Query the emoji character properties of a character.
pub mod emoji {
pub use crate::tables::emoji::EmojiStatus;
/// Query the emoji character properties of a character.
pub trait UnicodeEmoji: Sized {
/// Returns the emoji character properties in a status enum.
fn emoji_status(self) -> EmojiStatus;
/// Checks whether this character is recommended for use as emoji, i.e. `Emoji=YES`.
#[allow(clippy::wrong_self_convention)]
fn is_emoji_char(self) -> bool {
crate::tables::emoji::is_emoji_status_for_emoji_char(self.emoji_status())
}
/// Checks whether this character are used in emoji sequences where they're not
/// intended for independent, direct input, i.e. `Emoji_Component=YES`.
#[allow(clippy::wrong_self_convention)]
fn is_emoji_component(self) -> bool {
crate::tables::emoji::is_emoji_status_for_emoji_component(self.emoji_status())
}
/// Checks whether this character occurs in emoji sequences, i.e. `Emoji=YES | Emoji_Component=YES`
#[allow(clippy::wrong_self_convention)]
fn is_emoji_char_or_emoji_component(self) -> bool {
crate::tables::emoji::is_emoji_status_for_emoji_char_or_emoji_component(
self.emoji_status(),
)
}
}
impl UnicodeEmoji for char {
fn emoji_status(self) -> EmojiStatus {
crate::tables::emoji::emoji_status(self)
}
}
#[inline]
/// Checks whether this character is the U+200D ZERO WIDTH JOINER (ZWJ) character.
///
/// It can be used between the elements of a sequence of characters to indicate that
/// a single glyph should be presented if available.
pub fn is_zwj(c: char) -> bool {
c == '\u{200D}'
}
#[inline]
/// Checks whether this character is the U+FE0F VARIATION SELECTOR-16 (VS16) character, used to
/// request an emoji presentation for an emoji character.
pub fn is_emoji_presentation_selector(c: char) -> bool {
c == '\u{FE0F}'
}
#[inline]
/// Checks whether this character is the U+FE0E VARIATION SELECTOR-15 (VS15) character, used to
/// request a text presentation for an emoji character.
pub fn is_text_presentation_selector(c: char) -> bool {
c == '\u{FE0E}'
}
#[inline]
/// Checks whether this character is one of the Regional Indicator characters.
///
/// A pair of REGIONAL INDICATOR symbols is referred to as an emoji_flag_sequence.
pub fn is_regional_indicator(c: char) -> bool {
matches!(c, '\u{1F1E6}'..='\u{1F1FF}')
}
#[inline]
/// Checks whether this character is one of the Tag Characters.
///
/// These can be used in indicating variants or extensions of emoji characters.
pub fn is_tag_character(c: char) -> bool {
matches!(c, '\u{E0020}'..='\u{E007F}')
}
}
#[cfg(feature = "general-category")]
/// Query the general category property of a character.
pub mod general_category {
pub use crate::tables::general_category::{GeneralCategory, GeneralCategoryGroup};
/// Query the general category property of a character.
///
/// See [General Category Values](https://www.unicode.org/reports/tr44/#General_Category_Values) for more info.
pub trait UnicodeGeneralCategory: Sized {
/// Queries the most general classification of a character.
fn general_category(self) -> GeneralCategory;
/// Queries the grouping of the most general classification of a character.
fn general_category_group(self) -> GeneralCategoryGroup {
crate::tables::general_category::general_category_group(self.general_category())
}
/// Queries whether the most general classification of a character belongs to the `LetterCased` group
///
/// The `LetterCased` group includes `LetterUppercase`, `LetterLowercase`, and `LetterTitlecase`
/// categories, and is a subset of the `Letter` group.
#[allow(clippy::wrong_self_convention)]
fn is_letter_cased(self) -> bool {
crate::tables::general_category::general_category_is_letter_cased(
self.general_category(),
)
}
}
impl UnicodeGeneralCategory for char {
fn general_category(self) -> GeneralCategory {
crate::tables::general_category::general_category_of_char(self)
}
}
}
pub use tables::UNICODE_VERSION;
#[cfg(feature = "emoji")]
#[doc(inline)]
pub use emoji::UnicodeEmoji;
#[cfg(feature = "emoji")]
#[doc(inline)]
pub use emoji::EmojiStatus;
#[cfg(feature = "general-category")]
#[doc(inline)]
pub use general_category::GeneralCategory;
#[cfg(feature = "general-category")]
#[doc(inline)]
pub use general_category::GeneralCategoryGroup;
#[cfg(feature = "general-category")]
#[doc(inline)]
pub use general_category::UnicodeGeneralCategory;

3240
vendor/unicode-properties/src/tables.rs vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,28 @@
#![cfg(feature = "emoji")]
#[test]
fn all_ascii_are_either_nonemoji_or_emojiother() {
use unicode_properties::EmojiStatus;
use unicode_properties::UnicodeEmoji;
for i in 0u8..=255u8 {
let c = i as char;
let s = c.emoji_status();
assert!(matches!(
s,
EmojiStatus::NonEmoji
| EmojiStatus::EmojiOther
| EmojiStatus::EmojiOtherAndEmojiComponent
))
}
}
#[test]
fn emoji_test() {
use std::ops::Not;
use unicode_properties::EmojiStatus;
use unicode_properties::UnicodeEmoji;
assert_eq!('🦀'.emoji_status(), EmojiStatus::EmojiPresentation);
assert!('🦀'.is_emoji_char());
assert!('🦀'.is_emoji_component().not());
assert!('🦀'.is_emoji_char_or_emoji_component());
}

View File

@@ -0,0 +1,23 @@
#![cfg(feature = "general-category")]
#[test]
fn general_category_test() {
use std::ops::Not;
use unicode_properties::UnicodeGeneralCategory;
use unicode_properties::{GeneralCategory, GeneralCategoryGroup};
assert_eq!('A'.general_category(), GeneralCategory::UppercaseLetter);
assert_eq!('A'.general_category_group(), GeneralCategoryGroup::Letter);
assert!('A'.is_letter_cased());
assert_eq!(' '.general_category(), GeneralCategory::SpaceSeparator);
assert_eq!(
' '.general_category_group(),
GeneralCategoryGroup::Separator
);
assert!(' '.is_letter_cased().not());
assert_eq!('一'.general_category(), GeneralCategory::OtherLetter);
assert_eq!('一'.general_category_group(), GeneralCategoryGroup::Letter);
assert!('一'.is_letter_cased().not());
assert_eq!('🦀'.general_category(), GeneralCategory::OtherSymbol);
assert_eq!('🦀'.general_category_group(), GeneralCategoryGroup::Symbol);
assert!('🦀'.is_letter_cased().not());
}