u 0.5.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/build/ext/u/data/attributes.rb +39 -0
- data/build/ext/u/data/bidi-mirroring.rb +27 -0
- data/build/ext/u/data/canonical-combining-class.rb +15 -0
- data/build/ext/u/data/case-folding.rb +39 -0
- data/build/ext/u/data/cased.rb +19 -0
- data/build/ext/u/data/compose.rb +304 -0
- data/build/ext/u/data/constants.rb +31 -0
- data/build/ext/u/data/decompose.rb +85 -0
- data/build/ext/u/data/general-category.rb +61 -0
- data/build/ext/u/data/grapheme-word-break.rb +15 -0
- data/build/ext/u/data/marshalled.rb +5 -0
- data/build/ext/u/data/script.rb +91 -0
- data/build/ext/u/data/soft-dotted.rb +17 -0
- data/build/ext/u/data/title-table.rb +30 -0
- data/build/ext/u/data/wide.rb +17 -0
- data/build/lib/u/build.rb +8 -0
- data/build/lib/u/build/data.rb +16 -0
- data/build/lib/u/build/data/bidimirroring.rb +26 -0
- data/build/lib/u/build/data/break.rb +14 -0
- data/build/lib/u/build/data/casefolding.rb +77 -0
- data/build/lib/u/build/data/compositionexclusions.rb +14 -0
- data/build/lib/u/build/data/derivedeastasianwidth.rb +15 -0
- data/build/lib/u/build/data/file.rb +88 -0
- data/build/lib/u/build/data/linebreak.rb +14 -0
- data/build/lib/u/build/data/proplist.rb +18 -0
- data/build/lib/u/build/data/scripts.rb +22 -0
- data/build/lib/u/build/data/specialcasing.rb +106 -0
- data/build/lib/u/build/data/unicode.rb +41 -0
- data/build/lib/u/build/data/unicode/entry.rb +27 -0
- data/build/lib/u/build/data/unicode/entry/decomposition.rb +29 -0
- data/build/lib/u/build/data/unicode/points.rb +32 -0
- data/build/lib/u/build/header.rb +11 -0
- data/build/lib/u/build/header/table.rb +19 -0
- data/build/lib/u/build/header/table/row.rb +64 -0
- data/build/lib/u/build/header/tables.rb +6 -0
- data/build/lib/u/build/header/tables/intervals.rb +50 -0
- data/build/lib/u/build/header/tables/split.rb +20 -0
- data/build/lib/u/build/header/tables/split/data.rb +29 -0
- data/build/lib/u/build/header/tables/split/part1.rb +28 -0
- data/build/lib/u/build/header/tables/split/part2.rb +13 -0
- data/build/lib/u/build/header/tables/split/row.rb +34 -0
- data/build/lib/u/build/header/tables/split/rows.rb +22 -0
- data/build/test/unit/break.rb +45 -0
- data/build/test/unit/case.rb +178 -0
- data/build/test/unit/foldcase.rb +44 -0
- data/build/test/unit/normalize.rb +81 -0
- data/ext/u/attributes.c +62 -0
- data/ext/u/attributes.h +5 -0
- data/ext/u/case.h +41 -0
- data/ext/u/data/attributes.h +3070 -0
- data/ext/u/data/bidi-mirroring.h +373 -0
- data/ext/u/data/canonical-combining-class.h +2157 -0
- data/ext/u/data/case-folding.h +171 -0
- data/ext/u/data/cased.h +42 -0
- data/ext/u/data/compose.h +1714 -0
- data/ext/u/data/constants.h +17 -0
- data/ext/u/data/decompose.h +9356 -0
- data/ext/u/data/general-category.h +28959 -0
- data/ext/u/data/grapheme-break.h +13201 -0
- data/ext/u/data/line-break.h +26501 -0
- data/ext/u/data/normalization-quick-check.h +3002 -0
- data/ext/u/data/script.h +2928 -0
- data/ext/u/data/soft-dotted.h +55 -0
- data/ext/u/data/title-table.h +41 -0
- data/ext/u/data/types.h +11117 -0
- data/ext/u/data/wide-cjk.h +197 -0
- data/ext/u/data/wide.h +59 -0
- data/ext/u/data/word-break.h +10001 -0
- data/ext/u/depend +281 -0
- data/ext/u/extconf.rb +158 -0
- data/ext/u/output.h +51 -0
- data/ext/{encoding/character/utf-8 → u}/private.c +11 -15
- data/ext/u/private.h +58 -0
- data/ext/u/rb_includes.h +10 -0
- data/ext/u/rb_private.c +98 -0
- data/ext/u/rb_private.h +67 -0
- data/ext/u/rb_u.c +251 -0
- data/ext/u/rb_u_buffer.c +443 -0
- data/ext/u/rb_u_buffer.h +24 -0
- data/ext/u/rb_u_re.c +43 -0
- data/ext/u/rb_u_re.h +15 -0
- data/ext/u/rb_u_string.c +478 -0
- data/ext/u/rb_u_string.h +173 -0
- data/ext/u/rb_u_string_alnum.c +10 -0
- data/ext/u/rb_u_string_alpha.c +10 -0
- data/ext/u/rb_u_string_aref.c +142 -0
- data/ext/u/rb_u_string_ascii_only.c +13 -0
- data/ext/u/rb_u_string_assigned.c +10 -0
- data/ext/u/rb_u_string_b.c +18 -0
- data/ext/u/rb_u_string_bytesize.c +10 -0
- data/ext/u/rb_u_string_byteslice.c +103 -0
- data/ext/u/rb_u_string_canonical_combining_class.c +33 -0
- data/ext/u/rb_u_string_case_ignorable.c +25 -0
- data/ext/u/rb_u_string_casecmp.c +61 -0
- data/ext/u/rb_u_string_cased.c +17 -0
- data/ext/u/rb_u_string_chomp.c +107 -0
- data/ext/u/rb_u_string_chop.c +33 -0
- data/ext/u/rb_u_string_chr.c +9 -0
- data/ext/u/rb_u_string_cntrl.c +10 -0
- data/ext/u/rb_u_string_collate.c +46 -0
- data/ext/u/rb_u_string_collation_key.c +18 -0
- data/ext/u/rb_u_string_count.c +38 -0
- data/ext/u/rb_u_string_defined.c +10 -0
- data/ext/u/rb_u_string_delete.c +62 -0
- data/ext/u/rb_u_string_digit.c +10 -0
- data/ext/u/rb_u_string_downcase.c +13 -0
- data/ext/u/rb_u_string_dump.c +153 -0
- data/ext/u/rb_u_string_each_byte.c +46 -0
- data/ext/u/rb_u_string_each_char.c +49 -0
- data/ext/u/rb_u_string_each_codepoint.c +45 -0
- data/ext/u/rb_u_string_each_grapheme_cluster.c +36 -0
- data/ext/u/rb_u_string_each_line.c +142 -0
- data/ext/u/rb_u_string_each_word.c +34 -0
- data/ext/u/rb_u_string_empty.c +11 -0
- data/ext/u/rb_u_string_end_with.c +31 -0
- data/ext/u/rb_u_string_eql.c +30 -0
- data/ext/u/rb_u_string_equal.c +33 -0
- data/ext/u/rb_u_string_foldcase.c +12 -0
- data/ext/u/rb_u_string_folded.c +13 -0
- data/ext/u/rb_u_string_format.c +1745 -0
- data/ext/u/rb_u_string_general_category.c +109 -0
- data/ext/u/rb_u_string_getbyte.c +21 -0
- data/ext/u/rb_u_string_graph.c +21 -0
- data/ext/u/rb_u_string_grapheme_break.c +61 -0
- data/ext/u/rb_u_string_gsub.c +164 -0
- data/ext/u/rb_u_string_hash.c +10 -0
- data/ext/u/rb_u_string_hex.c +9 -0
- data/ext/u/rb_u_string_include.c +10 -0
- data/ext/u/rb_u_string_index.c +110 -0
- data/ext/u/rb_u_string_inspect.c +189 -0
- data/ext/u/rb_u_string_internal_tr.c +148 -0
- data/ext/u/rb_u_string_internal_tr.h +29 -0
- data/ext/u/rb_u_string_justify.c +169 -0
- data/ext/u/rb_u_string_length.c +10 -0
- data/ext/u/rb_u_string_line_break.c +115 -0
- data/ext/u/rb_u_string_lower.c +13 -0
- data/ext/u/rb_u_string_lstrip.c +24 -0
- data/ext/u/rb_u_string_match.c +65 -0
- data/ext/u/rb_u_string_mirror.c +16 -0
- data/ext/u/rb_u_string_newline.c +21 -0
- data/ext/u/rb_u_string_normalize.c +70 -0
- data/ext/u/rb_u_string_normalized.c +28 -0
- data/ext/u/rb_u_string_oct.c +11 -0
- data/ext/u/rb_u_string_ord.c +14 -0
- data/ext/u/rb_u_string_partition.c +80 -0
- data/ext/u/rb_u_string_plus.c +33 -0
- data/ext/u/rb_u_string_print.c +10 -0
- data/ext/u/rb_u_string_punct.c +10 -0
- data/ext/u/rb_u_string_reverse.c +13 -0
- data/ext/u/rb_u_string_rindex.c +104 -0
- data/ext/u/rb_u_string_rpartition.c +81 -0
- data/ext/u/rb_u_string_rstrip.c +29 -0
- data/ext/u/rb_u_string_scan.c +109 -0
- data/ext/u/rb_u_string_script.c +253 -0
- data/ext/u/rb_u_string_soft_dotted.c +13 -0
- data/ext/u/rb_u_string_space.c +24 -0
- data/ext/u/rb_u_string_split.c +245 -0
- data/ext/u/rb_u_string_squeeze.c +75 -0
- data/ext/u/rb_u_string_start_with.c +31 -0
- data/ext/u/rb_u_string_strip.c +36 -0
- data/ext/u/rb_u_string_sub.c +147 -0
- data/ext/u/rb_u_string_times.c +35 -0
- data/ext/u/rb_u_string_title.c +10 -0
- data/ext/u/rb_u_string_titlecase.c +13 -0
- data/ext/u/rb_u_string_to_i.c +45 -0
- data/ext/u/rb_u_string_to_inum.c +364 -0
- data/ext/u/rb_u_string_to_inum.h +1 -0
- data/ext/u/rb_u_string_to_str.c +17 -0
- data/ext/u/rb_u_string_to_sym.c +12 -0
- data/ext/u/rb_u_string_tr.c +290 -0
- data/ext/u/rb_u_string_upcase.c +12 -0
- data/ext/u/rb_u_string_upper.c +13 -0
- data/ext/u/rb_u_string_valid.c +10 -0
- data/ext/u/rb_u_string_valid_encoding.c +12 -0
- data/ext/u/rb_u_string_wide.c +21 -0
- data/ext/u/rb_u_string_wide_cjk.c +21 -0
- data/ext/u/rb_u_string_width.c +19 -0
- data/ext/u/rb_u_string_word_break.c +63 -0
- data/ext/u/rb_u_string_xdigit.c +22 -0
- data/ext/u/rb_u_string_zero_width.c +16 -0
- data/ext/u/titled.c +55 -0
- data/ext/u/titled.h +1 -0
- data/ext/u/u.c +23 -0
- data/ext/u/u.h +458 -0
- data/ext/u/u_char_canonical_combining_class.c +31 -0
- data/ext/u/u_char_digit_value.c +21 -0
- data/ext/u/u_char_downcase.c +27 -0
- data/ext/u/u_char_general_category.c +31 -0
- data/ext/u/u_char_grapheme_break.c +28 -0
- data/ext/u/u_char_isalnum.c +24 -0
- data/ext/u/u_char_isalpha.c +21 -0
- data/ext/u/u_char_isassigned.c +16 -0
- data/ext/u/u_char_iscased.c +22 -0
- data/ext/u/u_char_iscaseignorable.c +29 -0
- data/ext/u/u_char_iscntrl.c +17 -0
- data/ext/u/u_char_isdefined.c +15 -0
- data/ext/u/u_char_isdigit.c +16 -0
- data/ext/u/u_char_isgraph.c +22 -0
- data/ext/u/u_char_islower.c +16 -0
- data/ext/u/u_char_isnewline.c +24 -0
- data/ext/u/u_char_isprint.c +21 -0
- data/ext/u/u_char_ispunct.c +27 -0
- data/ext/u/u_char_issoftdotted.c +18 -0
- data/ext/u/u_char_isspace.c +28 -0
- data/ext/u/u_char_isupper.c +16 -0
- data/ext/u/u_char_isvalid.c +18 -0
- data/ext/u/u_char_iswide.c +18 -0
- data/ext/u/u_char_iswide_cjk.c +22 -0
- data/ext/u/u_char_isxdigit.c +27 -0
- data/ext/u/u_char_iszerowidth.c +29 -0
- data/ext/u/u_char_line_break.c +29 -0
- data/ext/u/u_char_mirror.c +16 -0
- data/ext/u/u_char_normalized.c +23 -0
- data/ext/u/u_char_script.c +41 -0
- data/ext/u/u_char_to_u.c +48 -0
- data/ext/u/u_char_upcase.c +24 -0
- data/ext/u/u_char_width.c +12 -0
- data/ext/u/u_char_word_break.c +28 -0
- data/ext/u/u_char_xdigit_value.c +31 -0
- data/ext/u/u_collate.c +83 -0
- data/ext/u/u_collation_key.c +132 -0
- data/ext/u/u_decode.c +156 -0
- data/ext/u/u_downcase.c +201 -0
- data/ext/u/u_foldcase.c +68 -0
- data/ext/u/u_grapheme_clusters.c +57 -0
- data/ext/u/u_has_prefix.c +27 -0
- data/ext/u/u_index.c +93 -0
- data/ext/u/u_is_ascii_only.c +33 -0
- data/ext/u/u_locale.c +40 -0
- data/ext/u/u_locale.h +14 -0
- data/ext/u/u_mirror.c +20 -0
- data/ext/u/u_n_bytes.c +16 -0
- data/ext/u/u_n_chars.c +43 -0
- data/ext/u/u_normalize.c +232 -0
- data/ext/u/u_normalized.c +28 -0
- data/ext/u/u_offset_to_pointer.c +62 -0
- data/ext/u/u_pointer_to_offset.c +23 -0
- data/ext/u/u_recode.c +73 -0
- data/ext/u/u_reverse.c +21 -0
- data/ext/u/u_rindex.c +132 -0
- data/ext/u/u_titlecase.c +68 -0
- data/ext/u/u_upcase.c +89 -0
- data/ext/u/u_width.c +35 -0
- data/ext/u/u_words.c +82 -0
- data/ext/u/yield.h +27 -0
- data/lib/u-1.0.rb +20 -0
- data/lib/u-1.0/buffer.rb +10 -0
- data/lib/u-1.0/string.rb +9 -0
- data/lib/u-1.0/version.rb +287 -0
- data/test/unit/case.rb +2080 -0
- data/test/unit/foldcase.rb +1136 -0
- data/test/unit/graphemebreak.rb +407 -0
- data/test/unit/normalize.rb +367545 -0
- data/test/unit/u-1.0.rb +10 -0
- data/test/unit/u-1.0/buffer.rb +52 -0
- data/test/unit/u-1.0/string.rb +1439 -0
- data/test/unit/{u.rb → u-1.0/version.rb} +0 -1
- data/test/unit/wordbreak.rb +1083 -0
- metadata +603 -148
- data/README +0 -38
- data/Rakefile +0 -64
- data/ext/encoding/character/utf-8/break.c +0 -25
- data/ext/encoding/character/utf-8/data/break.h +0 -22931
- data/ext/encoding/character/utf-8/data/character-tables.h +0 -14358
- data/ext/encoding/character/utf-8/data/compose.h +0 -1607
- data/ext/encoding/character/utf-8/data/decompose.h +0 -10926
- data/ext/encoding/character/utf-8/data/generate-unicode-data.rb +0 -1070
- data/ext/encoding/character/utf-8/decompose.c +0 -444
- data/ext/encoding/character/utf-8/depend +0 -65
- data/ext/encoding/character/utf-8/extconf.rb +0 -67
- data/ext/encoding/character/utf-8/private.h +0 -51
- data/ext/encoding/character/utf-8/properties.c +0 -1056
- data/ext/encoding/character/utf-8/rb_includes.h +0 -19
- data/ext/encoding/character/utf-8/rb_methods.h +0 -49
- data/ext/encoding/character/utf-8/rb_private.h +0 -52
- data/ext/encoding/character/utf-8/rb_utf_aref.c +0 -111
- data/ext/encoding/character/utf-8/rb_utf_aset.c +0 -105
- data/ext/encoding/character/utf-8/rb_utf_casecmp.c +0 -24
- data/ext/encoding/character/utf-8/rb_utf_chomp.c +0 -114
- data/ext/encoding/character/utf-8/rb_utf_chop.c +0 -44
- data/ext/encoding/character/utf-8/rb_utf_collate.c +0 -13
- data/ext/encoding/character/utf-8/rb_utf_count.c +0 -30
- data/ext/encoding/character/utf-8/rb_utf_delete.c +0 -60
- data/ext/encoding/character/utf-8/rb_utf_downcase.c +0 -13
- data/ext/encoding/character/utf-8/rb_utf_each_char.c +0 -27
- data/ext/encoding/character/utf-8/rb_utf_foldcase.c +0 -13
- data/ext/encoding/character/utf-8/rb_utf_hex.c +0 -14
- data/ext/encoding/character/utf-8/rb_utf_index.c +0 -50
- data/ext/encoding/character/utf-8/rb_utf_insert.c +0 -48
- data/ext/encoding/character/utf-8/rb_utf_internal_bignum.c +0 -332
- data/ext/encoding/character/utf-8/rb_utf_internal_bignum.h +0 -12
- data/ext/encoding/character/utf-8/rb_utf_internal_tr.c +0 -142
- data/ext/encoding/character/utf-8/rb_utf_internal_tr.h +0 -41
- data/ext/encoding/character/utf-8/rb_utf_justify.c +0 -96
- data/ext/encoding/character/utf-8/rb_utf_length.c +0 -14
- data/ext/encoding/character/utf-8/rb_utf_lstrip.c +0 -41
- data/ext/encoding/character/utf-8/rb_utf_normalize.c +0 -51
- data/ext/encoding/character/utf-8/rb_utf_oct.c +0 -14
- data/ext/encoding/character/utf-8/rb_utf_reverse.c +0 -13
- data/ext/encoding/character/utf-8/rb_utf_rindex.c +0 -88
- data/ext/encoding/character/utf-8/rb_utf_rstrip.c +0 -51
- data/ext/encoding/character/utf-8/rb_utf_squeeze.c +0 -70
- data/ext/encoding/character/utf-8/rb_utf_strip.c +0 -27
- data/ext/encoding/character/utf-8/rb_utf_to_i.c +0 -25
- data/ext/encoding/character/utf-8/rb_utf_tr.c +0 -250
- data/ext/encoding/character/utf-8/rb_utf_upcase.c +0 -13
- data/ext/encoding/character/utf-8/tables.h +0 -38
- data/ext/encoding/character/utf-8/unicode.c +0 -319
- data/ext/encoding/character/utf-8/unicode.h +0 -216
- data/ext/encoding/character/utf-8/utf.c +0 -1334
- data/lib/encoding/character/utf-8.rb +0 -201
- data/lib/u.rb +0 -16
- data/lib/u/string.rb +0 -185
- data/lib/u/version.rb +0 -5
- data/test/unit/u/string.rb +0 -91
data/ext/u/u_width.c
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#include <assert.h>
|
|
2
|
+
#include <stddef.h>
|
|
3
|
+
#include <stdint.h>
|
|
4
|
+
#include <stdbool.h>
|
|
5
|
+
|
|
6
|
+
#include "u.h"
|
|
7
|
+
#include "private.h"
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
static size_t
|
|
11
|
+
u_width_impl(const char *string, size_t n, bool use_n)
|
|
12
|
+
{
|
|
13
|
+
assert(string != NULL);
|
|
14
|
+
|
|
15
|
+
size_t width = 0;
|
|
16
|
+
|
|
17
|
+
const char *p = string;
|
|
18
|
+
const char *end = p + n;
|
|
19
|
+
while (P_WITHIN_STR(p, end, use_n))
|
|
20
|
+
width += u_char_width(u_decode(&p, p, end));
|
|
21
|
+
|
|
22
|
+
return width;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
size_t
|
|
26
|
+
u_width(const char *string)
|
|
27
|
+
{
|
|
28
|
+
return u_width_impl(string, 0, false);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
size_t
|
|
32
|
+
u_width_n(const char *string, size_t n)
|
|
33
|
+
{
|
|
34
|
+
return u_width_impl(string, n, true);
|
|
35
|
+
}
|
data/ext/u/u_words.c
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
#include <stdbool.h>
|
|
2
|
+
#include <stddef.h>
|
|
3
|
+
#include <stdint.h>
|
|
4
|
+
|
|
5
|
+
#include "u.h"
|
|
6
|
+
#include "private.h"
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
#define ROW(other, cr, lf, newline, aletter, numeric, katakana, extendnumlet, \
|
|
10
|
+
regional_indicator, midletter, midnumlet, midnum, format, extend) \
|
|
11
|
+
{ [U_WORD_BREAK_OTHER] = other, \
|
|
12
|
+
[U_WORD_BREAK_CR] = cr, \
|
|
13
|
+
[U_WORD_BREAK_LF] = lf, \
|
|
14
|
+
[U_WORD_BREAK_NEWLINE] = newline, \
|
|
15
|
+
[U_WORD_BREAK_FORMAT] = format, \
|
|
16
|
+
[U_WORD_BREAK_EXTEND] = extend, \
|
|
17
|
+
[U_WORD_BREAK_ALETTER] = aletter, \
|
|
18
|
+
[U_WORD_BREAK_NUMERIC] = numeric, \
|
|
19
|
+
[U_WORD_BREAK_KATAKANA] = katakana, \
|
|
20
|
+
[U_WORD_BREAK_EXTENDNUMLET] = extendnumlet, \
|
|
21
|
+
[U_WORD_BREAK_REGIONAL_INDICATOR] = regional_indicator, \
|
|
22
|
+
[U_WORD_BREAK_MIDLETTER] = midletter, \
|
|
23
|
+
[U_WORD_BREAK_MIDNUMLET] = midnumlet, \
|
|
24
|
+
[U_WORD_BREAK_MIDNUM] = midnum }
|
|
25
|
+
#define K(s) (s | (1 << 4))
|
|
26
|
+
#define S(s) (s | (2 << 4))
|
|
27
|
+
#define D(s) (s | (3 << 4))
|
|
28
|
+
static const uint8_t wb_dfa[][U_WORD_BREAK_REGIONAL_INDICATOR + 1] = {
|
|
29
|
+
ROW(0,1, 2 ,2, 3 , 4 , 5 , 6 , 7 , 0 , 0 , 0 ,K(0),K(0)), // Other
|
|
30
|
+
ROW(0,1,K(2),2, 3 , 4 , 5 , 6 , 7 , 0 , 0 , 0 , 0 , 0 ), // CR
|
|
31
|
+
ROW(0,1, 2 ,2, 3 , 4 , 5 , 6 , 7 , 0 , 0 , 0 , 0 , 0 ), // LF | Newline
|
|
32
|
+
ROW(0,1, 2 ,2,K(3),K(4), 5 ,K(6), 7 ,S(8),S(8), 0 ,K(3),K(3)), // ALetter
|
|
33
|
+
ROW(0,1, 2 ,2,K(3),K(4), 5 ,K(6), 7 , 0 ,S(9),S(9),K(4),K(4)), // Numeric
|
|
34
|
+
ROW(0,1, 2 ,2, 3 , 4 ,K(5),K(6), 7 , 0 , 0 , 0 ,K(5),K(5)), // Katakana
|
|
35
|
+
ROW(0,1, 2 ,2,K(3),K(4),K(5),K(6), 7 , 0 , 0 , 0 ,K(6),K(6)), // ExtendNumLet
|
|
36
|
+
ROW(0,1, 2 ,2, 3 , 4 , 5 , 6 ,K(7), 0 , 0 , 0 ,K(7),K(7)), // Regional_Indicator
|
|
37
|
+
ROW(0,1, 2 ,2,D(3), 4 , 5 , 6 , 7 , 0 , 0 , 0 ,K(8),K(8)), // ALetter (MidLetter | MidNumLet)
|
|
38
|
+
ROW(0,1, 2 ,2, 3 ,D(4), 5 , 6 , 7 , 0 , 0 , 0 ,K(9),K(9)), // Numeric (MidNum | MidNumLet)
|
|
39
|
+
};
|
|
40
|
+
#undef D
|
|
41
|
+
#undef S
|
|
42
|
+
#undef K
|
|
43
|
+
|
|
44
|
+
void
|
|
45
|
+
u_words(const char *string, size_t n, u_substring_fn fn, void *closure)
|
|
46
|
+
{
|
|
47
|
+
const char *p = string;
|
|
48
|
+
const char *q = p;
|
|
49
|
+
const char *end = p + n;
|
|
50
|
+
const char *s = NULL;
|
|
51
|
+
uint8_t state = 2;
|
|
52
|
+
while (q < end) {
|
|
53
|
+
const char *r;
|
|
54
|
+
state = wb_dfa[state & 0xf][u_char_word_break(u_decode(&r, q, end))];
|
|
55
|
+
switch (state >> 4) {
|
|
56
|
+
case 1:
|
|
57
|
+
break;
|
|
58
|
+
case 2:
|
|
59
|
+
s = q;
|
|
60
|
+
break;
|
|
61
|
+
case 3:
|
|
62
|
+
s = NULL;
|
|
63
|
+
break;
|
|
64
|
+
default:
|
|
65
|
+
if (s != NULL) {
|
|
66
|
+
fn(p, s - p, closure);
|
|
67
|
+
p = s;
|
|
68
|
+
s = NULL;
|
|
69
|
+
}
|
|
70
|
+
if (p < q)
|
|
71
|
+
fn(p, q - p, closure);
|
|
72
|
+
p = q;
|
|
73
|
+
}
|
|
74
|
+
q = r;
|
|
75
|
+
}
|
|
76
|
+
if (s != NULL) {
|
|
77
|
+
fn(p, s - p, closure);
|
|
78
|
+
p = s;
|
|
79
|
+
}
|
|
80
|
+
if (p < q)
|
|
81
|
+
fn(p, q - p, closure);
|
|
82
|
+
}
|
data/ext/u/yield.h
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
struct yield {
|
|
2
|
+
void (*call)(struct yield *, VALUE value);
|
|
3
|
+
};
|
|
4
|
+
|
|
5
|
+
#define YIELD_INIT { yield };
|
|
6
|
+
|
|
7
|
+
static void
|
|
8
|
+
yield(UNUSED(struct yield *yield), VALUE value)
|
|
9
|
+
{
|
|
10
|
+
rb_yield(value);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
struct yield_array {
|
|
14
|
+
struct yield yield;
|
|
15
|
+
VALUE array;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
#define YIELD_ARRAY_INIT { { yield_array }, rb_ary_new() }
|
|
19
|
+
|
|
20
|
+
static void
|
|
21
|
+
yield_array(struct yield *yield, VALUE value)
|
|
22
|
+
{
|
|
23
|
+
rb_ary_push(((struct yield_array *)yield)->array, value);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
#define yield_call(yield, value) \
|
|
27
|
+
(((struct yield *)(yield))->call((struct yield *)(yield), (value)))
|
data/lib/u-1.0.rb
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
# The U namespace contains a string builder in {U::Buffer} and a string
|
|
4
|
+
# representation in {U::String}.
|
|
5
|
+
module U
|
|
6
|
+
load File.expand_path('../u-1.0/version.rb', __FILE__)
|
|
7
|
+
require File.expand_path('../u-1.0/u', __FILE__)
|
|
8
|
+
Version.load
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# Ruby’s built-in String class.
|
|
12
|
+
class String
|
|
13
|
+
# @return [U::String] A wrapper around the receiver that provides proper
|
|
14
|
+
# Unicode handling of its content
|
|
15
|
+
# @note The receiver will receive #encode(Encoding::UTF_8)#freeze and you
|
|
16
|
+
# should thus probably not use the receiver after invoking #u on it.
|
|
17
|
+
def u
|
|
18
|
+
U::String.new(self)
|
|
19
|
+
end
|
|
20
|
+
end
|
data/lib/u-1.0/buffer.rb
ADDED
data/lib/u-1.0/string.rb
ADDED
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
require 'inventory-1.0'
|
|
4
|
+
|
|
5
|
+
module U
|
|
6
|
+
Version = Inventory.new(1, 0, 0){
|
|
7
|
+
def dependencies
|
|
8
|
+
super + Inventory::Dependencies.new{
|
|
9
|
+
development 'inventory-rake', 1, 5, 0
|
|
10
|
+
development 'inventory-rake-tasks-yard', 1, 3, 0
|
|
11
|
+
development 'lookout', 3, 0, 0
|
|
12
|
+
development 'lookout-rake', 3, 0, 0
|
|
13
|
+
development 'yard', 0, 8, 0
|
|
14
|
+
development 'yard-heuristics', 1, 1, 0
|
|
15
|
+
}
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def extensions
|
|
19
|
+
[Inventory::Extension.new('u'){
|
|
20
|
+
def sources
|
|
21
|
+
%w[attributes.c
|
|
22
|
+
attributes.h
|
|
23
|
+
case.h
|
|
24
|
+
output.h
|
|
25
|
+
private.c
|
|
26
|
+
private.h
|
|
27
|
+
rb_includes.h
|
|
28
|
+
rb_private.c
|
|
29
|
+
rb_private.h
|
|
30
|
+
rb_u.c
|
|
31
|
+
rb_u_buffer.c
|
|
32
|
+
rb_u_buffer.h
|
|
33
|
+
rb_u_re.c
|
|
34
|
+
rb_u_re.h
|
|
35
|
+
rb_u_string.c
|
|
36
|
+
rb_u_string.h
|
|
37
|
+
rb_u_string_alnum.c
|
|
38
|
+
rb_u_string_alpha.c
|
|
39
|
+
rb_u_string_aref.c
|
|
40
|
+
rb_u_string_ascii_only.c
|
|
41
|
+
rb_u_string_assigned.c
|
|
42
|
+
rb_u_string_b.c
|
|
43
|
+
rb_u_string_bytesize.c
|
|
44
|
+
rb_u_string_byteslice.c
|
|
45
|
+
rb_u_string_case_ignorable.c
|
|
46
|
+
rb_u_string_casecmp.c
|
|
47
|
+
rb_u_string_cased.c
|
|
48
|
+
rb_u_string_chomp.c
|
|
49
|
+
rb_u_string_chop.c
|
|
50
|
+
rb_u_string_chr.c
|
|
51
|
+
rb_u_string_cntrl.c
|
|
52
|
+
rb_u_string_collate.c
|
|
53
|
+
rb_u_string_collation_key.c
|
|
54
|
+
rb_u_string_canonical_combining_class.c
|
|
55
|
+
rb_u_string_count.c
|
|
56
|
+
rb_u_string_defined.c
|
|
57
|
+
rb_u_string_delete.c
|
|
58
|
+
rb_u_string_digit.c
|
|
59
|
+
rb_u_string_downcase.c
|
|
60
|
+
rb_u_string_dump.c
|
|
61
|
+
rb_u_string_each_byte.c
|
|
62
|
+
rb_u_string_each_char.c
|
|
63
|
+
rb_u_string_each_codepoint.c
|
|
64
|
+
rb_u_string_each_grapheme_cluster.c
|
|
65
|
+
rb_u_string_each_line.c
|
|
66
|
+
rb_u_string_each_word.c
|
|
67
|
+
rb_u_string_empty.c
|
|
68
|
+
rb_u_string_end_with.c
|
|
69
|
+
rb_u_string_eql.c
|
|
70
|
+
rb_u_string_equal.c
|
|
71
|
+
rb_u_string_foldcase.c
|
|
72
|
+
rb_u_string_folded.c
|
|
73
|
+
rb_u_string_format.c
|
|
74
|
+
rb_u_string_general_category.c
|
|
75
|
+
rb_u_string_getbyte.c
|
|
76
|
+
rb_u_string_graph.c
|
|
77
|
+
rb_u_string_grapheme_break.c
|
|
78
|
+
rb_u_string_gsub.c
|
|
79
|
+
rb_u_string_hash.c
|
|
80
|
+
rb_u_string_hex.c
|
|
81
|
+
rb_u_string_include.c
|
|
82
|
+
rb_u_string_index.c
|
|
83
|
+
rb_u_string_inspect.c
|
|
84
|
+
rb_u_string_internal_tr.c
|
|
85
|
+
rb_u_string_internal_tr.h
|
|
86
|
+
rb_u_string_justify.c
|
|
87
|
+
rb_u_string_length.c
|
|
88
|
+
rb_u_string_line_break.c
|
|
89
|
+
rb_u_string_lower.c
|
|
90
|
+
rb_u_string_lstrip.c
|
|
91
|
+
rb_u_string_match.c
|
|
92
|
+
rb_u_string_mirror.c
|
|
93
|
+
rb_u_string_newline.c
|
|
94
|
+
rb_u_string_normalize.c
|
|
95
|
+
rb_u_string_normalized.c
|
|
96
|
+
rb_u_string_oct.c
|
|
97
|
+
rb_u_string_ord.c
|
|
98
|
+
rb_u_string_partition.c
|
|
99
|
+
rb_u_string_plus.c
|
|
100
|
+
rb_u_string_print.c
|
|
101
|
+
rb_u_string_punct.c
|
|
102
|
+
rb_u_string_reverse.c
|
|
103
|
+
rb_u_string_rindex.c
|
|
104
|
+
rb_u_string_rpartition.c
|
|
105
|
+
rb_u_string_rstrip.c
|
|
106
|
+
rb_u_string_scan.c
|
|
107
|
+
rb_u_string_script.c
|
|
108
|
+
rb_u_string_soft_dotted.c
|
|
109
|
+
rb_u_string_space.c
|
|
110
|
+
rb_u_string_split.c
|
|
111
|
+
rb_u_string_squeeze.c
|
|
112
|
+
rb_u_string_start_with.c
|
|
113
|
+
rb_u_string_strip.c
|
|
114
|
+
rb_u_string_sub.c
|
|
115
|
+
rb_u_string_times.c
|
|
116
|
+
rb_u_string_title.c
|
|
117
|
+
rb_u_string_titlecase.c
|
|
118
|
+
rb_u_string_to_i.c
|
|
119
|
+
rb_u_string_to_inum.c
|
|
120
|
+
rb_u_string_to_inum.h
|
|
121
|
+
rb_u_string_to_str.c
|
|
122
|
+
rb_u_string_to_sym.c
|
|
123
|
+
rb_u_string_tr.c
|
|
124
|
+
rb_u_string_upcase.c
|
|
125
|
+
rb_u_string_upper.c
|
|
126
|
+
rb_u_string_valid.c
|
|
127
|
+
rb_u_string_valid_encoding.c
|
|
128
|
+
rb_u_string_wide.c
|
|
129
|
+
rb_u_string_wide_cjk.c
|
|
130
|
+
rb_u_string_width.c
|
|
131
|
+
rb_u_string_word_break.c
|
|
132
|
+
rb_u_string_xdigit.c
|
|
133
|
+
rb_u_string_zero_width.c
|
|
134
|
+
titled.c
|
|
135
|
+
titled.h
|
|
136
|
+
u.c
|
|
137
|
+
u.h
|
|
138
|
+
u_char_downcase.c
|
|
139
|
+
u_char_canonical_combining_class.c
|
|
140
|
+
u_char_digit_value.c
|
|
141
|
+
u_char_general_category.c
|
|
142
|
+
u_char_grapheme_break.c
|
|
143
|
+
u_char_isalnum.c
|
|
144
|
+
u_char_isalpha.c
|
|
145
|
+
u_char_isassigned.c
|
|
146
|
+
u_char_iscased.c
|
|
147
|
+
u_char_iscaseignorable.c
|
|
148
|
+
u_char_iscntrl.c
|
|
149
|
+
u_char_isdefined.c
|
|
150
|
+
u_char_isdigit.c
|
|
151
|
+
u_char_isgraph.c
|
|
152
|
+
u_char_islower.c
|
|
153
|
+
u_char_isnewline.c
|
|
154
|
+
u_char_isprint.c
|
|
155
|
+
u_char_ispunct.c
|
|
156
|
+
u_char_issoftdotted.c
|
|
157
|
+
u_char_isspace.c
|
|
158
|
+
u_char_isupper.c
|
|
159
|
+
u_char_isvalid.c
|
|
160
|
+
u_char_iswide.c
|
|
161
|
+
u_char_iswide_cjk.c
|
|
162
|
+
u_char_isxdigit.c
|
|
163
|
+
u_char_iszerowidth.c
|
|
164
|
+
u_char_line_break.c
|
|
165
|
+
u_char_mirror.c
|
|
166
|
+
u_char_normalized.c
|
|
167
|
+
u_char_script.c
|
|
168
|
+
u_char_to_u.c
|
|
169
|
+
u_char_upcase.c
|
|
170
|
+
u_char_xdigit_value.c
|
|
171
|
+
u_char_word_break.c
|
|
172
|
+
u_char_width.c
|
|
173
|
+
u_collate.c
|
|
174
|
+
u_collation_key.c
|
|
175
|
+
u_downcase.c
|
|
176
|
+
u_decode.c
|
|
177
|
+
u_foldcase.c
|
|
178
|
+
u_grapheme_clusters.c
|
|
179
|
+
u_has_prefix.c
|
|
180
|
+
u_index.c
|
|
181
|
+
u_is_ascii_only.c
|
|
182
|
+
u_locale.c
|
|
183
|
+
u_locale.h
|
|
184
|
+
u_mirror.c
|
|
185
|
+
u_n_bytes.c
|
|
186
|
+
u_n_chars.c
|
|
187
|
+
u_normalize.c
|
|
188
|
+
u_normalized.c
|
|
189
|
+
u_offset_to_pointer.c
|
|
190
|
+
u_pointer_to_offset.c
|
|
191
|
+
u_recode.c
|
|
192
|
+
u_reverse.c
|
|
193
|
+
u_rindex.c
|
|
194
|
+
u_titlecase.c
|
|
195
|
+
u_upcase.c
|
|
196
|
+
u_width.c
|
|
197
|
+
u_words.c
|
|
198
|
+
yield.h]
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
def additional_files
|
|
202
|
+
%w[build/ext/u/data/attributes.rb
|
|
203
|
+
build/ext/u/data/bidi-mirroring.rb
|
|
204
|
+
build/ext/u/data/case-folding.rb
|
|
205
|
+
build/ext/u/data/cased.rb
|
|
206
|
+
build/ext/u/data/canonical-combining-class.rb
|
|
207
|
+
build/ext/u/data/compose.rb
|
|
208
|
+
build/ext/u/data/constants.rb
|
|
209
|
+
build/ext/u/data/decompose.rb
|
|
210
|
+
build/ext/u/data/general-category.rb
|
|
211
|
+
build/ext/u/data/grapheme-word-break.rb
|
|
212
|
+
build/ext/u/data/marshalled.rb
|
|
213
|
+
build/ext/u/data/script.rb
|
|
214
|
+
build/ext/u/data/soft-dotted.rb
|
|
215
|
+
build/ext/u/data/title-table.rb
|
|
216
|
+
build/ext/u/data/wide.rb
|
|
217
|
+
build/lib/u/build.rb
|
|
218
|
+
build/lib/u/build/data.rb
|
|
219
|
+
build/lib/u/build/data/bidimirroring.rb
|
|
220
|
+
build/lib/u/build/data/break.rb
|
|
221
|
+
build/lib/u/build/data/casefolding.rb
|
|
222
|
+
build/lib/u/build/data/compositionexclusions.rb
|
|
223
|
+
build/lib/u/build/data/derivedeastasianwidth.rb
|
|
224
|
+
build/lib/u/build/data/file.rb
|
|
225
|
+
build/lib/u/build/data/linebreak.rb
|
|
226
|
+
build/lib/u/build/data/proplist.rb
|
|
227
|
+
build/lib/u/build/data/scripts.rb
|
|
228
|
+
build/lib/u/build/data/specialcasing.rb
|
|
229
|
+
build/lib/u/build/data/unicode.rb
|
|
230
|
+
build/lib/u/build/data/unicode/entry.rb
|
|
231
|
+
build/lib/u/build/data/unicode/entry/decomposition.rb
|
|
232
|
+
build/lib/u/build/data/unicode/points.rb
|
|
233
|
+
build/lib/u/build/header.rb
|
|
234
|
+
build/lib/u/build/header/table.rb
|
|
235
|
+
build/lib/u/build/header/table/row.rb
|
|
236
|
+
build/lib/u/build/header/tables.rb
|
|
237
|
+
build/lib/u/build/header/tables/intervals.rb
|
|
238
|
+
build/lib/u/build/header/tables/split.rb
|
|
239
|
+
build/lib/u/build/header/tables/split/data.rb
|
|
240
|
+
build/lib/u/build/header/tables/split/part1.rb
|
|
241
|
+
build/lib/u/build/header/tables/split/part2.rb
|
|
242
|
+
build/lib/u/build/header/tables/split/row.rb
|
|
243
|
+
build/lib/u/build/header/tables/split/rows.rb
|
|
244
|
+
ext/u/data/attributes.h
|
|
245
|
+
ext/u/data/bidi-mirroring.h
|
|
246
|
+
ext/u/data/case-folding.h
|
|
247
|
+
ext/u/data/cased.h
|
|
248
|
+
ext/u/data/canonical-combining-class.h
|
|
249
|
+
ext/u/data/compose.h
|
|
250
|
+
ext/u/data/constants.h
|
|
251
|
+
ext/u/data/decompose.h
|
|
252
|
+
ext/u/data/general-category.h
|
|
253
|
+
ext/u/data/grapheme-break.h
|
|
254
|
+
ext/u/data/line-break.h
|
|
255
|
+
ext/u/data/normalization-quick-check.h
|
|
256
|
+
ext/u/data/script.h
|
|
257
|
+
ext/u/data/soft-dotted.h
|
|
258
|
+
ext/u/data/title-table.h
|
|
259
|
+
ext/u/data/types.h
|
|
260
|
+
ext/u/data/wide-cjk.h
|
|
261
|
+
ext/u/data/wide.h
|
|
262
|
+
ext/u/data/word-break.h]
|
|
263
|
+
end
|
|
264
|
+
}]
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
def package_libs
|
|
268
|
+
%w[buffer.rb
|
|
269
|
+
string.rb]
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
def additional_unit_tests
|
|
273
|
+
%w[case.rb
|
|
274
|
+
foldcase.rb
|
|
275
|
+
graphemebreak.rb
|
|
276
|
+
wordbreak.rb]
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
def additional_files
|
|
280
|
+
%w[build/test/unit/break.rb
|
|
281
|
+
build/test/unit/case.rb
|
|
282
|
+
build/test/unit/foldcase.rb
|
|
283
|
+
build/test/unit/normalize.rb
|
|
284
|
+
test/unit/normalize.rb]
|
|
285
|
+
end
|
|
286
|
+
}
|
|
287
|
+
end
|