u 0.5.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -1,19 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* contents: Standard includes for method definitions.
|
3
|
-
*
|
4
|
-
* Copyright © 2006 Nikolai Weibull <now@bitwi.se>
|
5
|
-
*/
|
6
|
-
|
7
|
-
#ifndef RB_INCLUDES_H
|
8
|
-
#define RB_INCLUDES_H
|
9
|
-
|
10
|
-
#include <ruby.h>
|
11
|
-
#include <stdbool.h>
|
12
|
-
#include <stddef.h>
|
13
|
-
#include <stdint.h>
|
14
|
-
#include "unicode.h"
|
15
|
-
#include "private.h"
|
16
|
-
#include "rb_private.h"
|
17
|
-
#include "rb_methods.h"
|
18
|
-
|
19
|
-
#endif /* RB_INCLUDES_H */
|
@@ -1,49 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* contents: Method declarations.
|
3
|
-
*
|
4
|
-
* Copyright © 2006 Nikolai Weibull <now@bitwi.se>
|
5
|
-
*/
|
6
|
-
|
7
|
-
#ifndef RB_METHODS_H
|
8
|
-
#define RB_METHODS_H
|
9
|
-
|
10
|
-
VALUE rb_utf_collate(UNUSED(VALUE self), VALUE str, VALUE other) HIDDEN;
|
11
|
-
VALUE rb_utf_downcase(UNUSED(VALUE self), VALUE str) HIDDEN;
|
12
|
-
VALUE rb_utf_length(UNUSED(VALUE self), VALUE str) HIDDEN;
|
13
|
-
VALUE rb_utf_reverse(UNUSED(VALUE self), VALUE str) HIDDEN;
|
14
|
-
VALUE rb_utf_upcase(UNUSED(VALUE self), VALUE str) HIDDEN;
|
15
|
-
VALUE rb_utf_aref_m(int argc, VALUE *argv, UNUSED(VALUE self)) HIDDEN;
|
16
|
-
VALUE rb_utf_aset_m(int argc, VALUE *argv, UNUSED(VALUE self)) HIDDEN;
|
17
|
-
VALUE rb_utf_casecmp(UNUSED(VALUE self), VALUE str1, VALUE str2) HIDDEN;
|
18
|
-
VALUE rb_utf_center(int argc, VALUE *argv, UNUSED(VALUE self)) HIDDEN;
|
19
|
-
VALUE rb_utf_ljust(int argc, VALUE *argv, UNUSED(VALUE self)) HIDDEN;
|
20
|
-
VALUE rb_utf_rjust(int argc, VALUE *argv, UNUSED(VALUE self)) HIDDEN;
|
21
|
-
VALUE rb_utf_chomp_bang(int argc, VALUE *argv, UNUSED(VALUE self)) HIDDEN;
|
22
|
-
VALUE rb_utf_chomp(int argc, VALUE *argv, VALUE self) HIDDEN;
|
23
|
-
VALUE rb_utf_chop_bang(UNUSED(VALUE self), VALUE str) HIDDEN;
|
24
|
-
VALUE rb_utf_chop(VALUE self, VALUE str) HIDDEN;
|
25
|
-
VALUE rb_utf_count(int argc, VALUE *argv, UNUSED(VALUE self)) HIDDEN;
|
26
|
-
VALUE rb_utf_delete_bang(int argc, VALUE *argv, UNUSED(VALUE self)) HIDDEN;
|
27
|
-
VALUE rb_utf_delete(int argc, VALUE *argv, VALUE self) HIDDEN;
|
28
|
-
VALUE rb_utf_each_char(UNUSED(VALUE self), VALUE str) HIDDEN;
|
29
|
-
VALUE rb_utf_index_m(int argc, VALUE *argv, UNUSED(VALUE self)) HIDDEN;
|
30
|
-
VALUE rb_utf_insert(UNUSED(VALUE self), VALUE str, VALUE index,
|
31
|
-
VALUE other) HIDDEN;
|
32
|
-
VALUE rb_utf_lstrip_bang(UNUSED(VALUE self), VALUE str) HIDDEN;
|
33
|
-
VALUE rb_utf_lstrip(VALUE self, VALUE str) HIDDEN;
|
34
|
-
VALUE rb_utf_rindex_m(int argc, VALUE *argv, UNUSED(VALUE self)) HIDDEN;
|
35
|
-
VALUE rb_utf_rstrip_bang(UNUSED(VALUE self), VALUE str) HIDDEN;
|
36
|
-
VALUE rb_utf_rstrip(VALUE self, VALUE str) HIDDEN;
|
37
|
-
VALUE rb_utf_squeeze_bang(int argc, VALUE *argv, UNUSED(VALUE self)) HIDDEN;
|
38
|
-
VALUE rb_utf_squeeze(int argc, VALUE *argv, VALUE self) HIDDEN;
|
39
|
-
VALUE rb_utf_strip_bang(VALUE self, VALUE str) HIDDEN;
|
40
|
-
VALUE rb_utf_strip(VALUE self, VALUE str) HIDDEN;
|
41
|
-
VALUE rb_utf_to_i(int argc, VALUE *argv, UNUSED(VALUE self)) HIDDEN;
|
42
|
-
VALUE rb_utf_hex(UNUSED(VALUE self), VALUE str) HIDDEN;
|
43
|
-
VALUE rb_utf_oct(UNUSED(VALUE self), VALUE str) HIDDEN;
|
44
|
-
VALUE rb_utf_tr(UNUSED(VALUE self), VALUE str, VALUE from, VALUE to) HIDDEN;
|
45
|
-
VALUE rb_utf_tr_s(UNUSED(VALUE self), VALUE str, VALUE from, VALUE to) HIDDEN;
|
46
|
-
VALUE rb_utf_foldcase(UNUSED(VALUE self), VALUE str) HIDDEN;
|
47
|
-
VALUE rb_utf_normalize(int argc, VALUE *argv, UNUSED(VALUE self)) HIDDEN;
|
48
|
-
|
49
|
-
#endif /* RB_METHODS_H */
|
@@ -1,52 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* contents: Private Ruby-related functions.
|
3
|
-
*
|
4
|
-
* Copyright © 2007 Nikolai Weibull <now@bitwi.se>
|
5
|
-
*/
|
6
|
-
|
7
|
-
#ifndef RB_PRIVATE_H
|
8
|
-
#define RB_PRIVATE_H
|
9
|
-
|
10
|
-
|
11
|
-
void need_at_least_n_arguments(int argc, int n) HIDDEN;
|
12
|
-
|
13
|
-
unichar _utf_char_validated(char const *const str,
|
14
|
-
char const *const str_end) HIDDEN;
|
15
|
-
char *_utf_offset_to_pointer_validated_impl(const char *str, long offset,
|
16
|
-
const char *limit, bool noisy) HIDDEN;
|
17
|
-
|
18
|
-
char *_utf_offset_to_pointer_validated(const char *str, long offset,
|
19
|
-
const char *end) HIDDEN;
|
20
|
-
|
21
|
-
char *_utf_offset_to_pointer_failable(const char *str, long offset,
|
22
|
-
const char *end) HIDDEN;
|
23
|
-
|
24
|
-
VALUE rb_utf_new(const char *str, long len) HIDDEN;
|
25
|
-
|
26
|
-
VALUE rb_utf_new2(const char *str) HIDDEN;
|
27
|
-
|
28
|
-
VALUE rb_utf_new5(VALUE obj, const char *str, long len) HIDDEN;
|
29
|
-
|
30
|
-
VALUE rb_utf_alloc_using(char *str) HIDDEN;
|
31
|
-
|
32
|
-
VALUE rb_utf_dup(VALUE str) HIDDEN;
|
33
|
-
|
34
|
-
long rb_utf_index(VALUE str, VALUE sub, long offset) HIDDEN;
|
35
|
-
|
36
|
-
bool rb_utf_begin_from_offset(VALUE str, long offset, char **begin,
|
37
|
-
char **limit) HIDDEN;
|
38
|
-
|
39
|
-
void rb_utf_begin_from_offset_validated(VALUE str, long offset, char **begin,
|
40
|
-
char **limit) HIDDEN;
|
41
|
-
|
42
|
-
char *rb_utf_prev_validated(const char *begin, const char *p) HIDDEN;
|
43
|
-
|
44
|
-
VALUE rb_utf_update(VALUE str, long offset, long len, VALUE replacement) HIDDEN;
|
45
|
-
|
46
|
-
char *rb_utf_next_validated(const char *p, const char *end) HIDDEN;
|
47
|
-
|
48
|
-
long rb_utf_index_regexp(VALUE str, const char *s, const char *end, VALUE sub,
|
49
|
-
long offset, bool reverse) HIDDEN;
|
50
|
-
|
51
|
-
|
52
|
-
#endif /* RB_PRIVATE_H */
|
@@ -1,111 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* contents: UTF8.aref module function.
|
3
|
-
*
|
4
|
-
* Copyright © 2006 Nikolai Weibull <now@bitwi.se>
|
5
|
-
*/
|
6
|
-
|
7
|
-
#include "rb_includes.h"
|
8
|
-
#include <re.h>
|
9
|
-
|
10
|
-
static VALUE
|
11
|
-
rb_utf_substr(VALUE str, long offset, long len)
|
12
|
-
{
|
13
|
-
if (len < 0)
|
14
|
-
return Qnil;
|
15
|
-
|
16
|
-
char *begin, *limit;
|
17
|
-
if (!rb_utf_begin_from_offset(str, offset, &begin, &limit))
|
18
|
-
return Qnil;
|
19
|
-
char *end = _utf_offset_to_pointer_failable(begin, len, limit);
|
20
|
-
if (end == NULL)
|
21
|
-
end = limit;
|
22
|
-
|
23
|
-
VALUE substr = (begin == end) ?
|
24
|
-
rb_utf_new5(str, NULL, 0) :
|
25
|
-
rb_utf_new5(str, begin, end - begin);
|
26
|
-
|
27
|
-
OBJ_INFECT(substr, str);
|
28
|
-
|
29
|
-
return substr;
|
30
|
-
}
|
31
|
-
|
32
|
-
static VALUE
|
33
|
-
rb_utf_substr_and_infect(VALUE str, long offset, long len, VALUE source)
|
34
|
-
{
|
35
|
-
VALUE substr = rb_utf_substr(str, offset, len);
|
36
|
-
OBJ_INFECT(substr, source);
|
37
|
-
return substr;
|
38
|
-
}
|
39
|
-
|
40
|
-
/* XXX: Stolen straight from string.c. */
|
41
|
-
static VALUE
|
42
|
-
rb_str_subpat(VALUE str, VALUE re, int nth)
|
43
|
-
{
|
44
|
-
if (rb_reg_search(re, str, 0, 0) >= 0)
|
45
|
-
return rb_reg_nth_match(nth, rb_backref_get());
|
46
|
-
|
47
|
-
return Qnil;
|
48
|
-
}
|
49
|
-
|
50
|
-
static VALUE
|
51
|
-
rb_utf_aref_num(VALUE str, long offset)
|
52
|
-
{
|
53
|
-
char *begin, *limit;
|
54
|
-
if (!rb_utf_begin_from_offset(str, offset, &begin, &limit))
|
55
|
-
return Qnil;
|
56
|
-
|
57
|
-
char *end = rb_utf_next_validated(begin, limit);
|
58
|
-
|
59
|
-
return rb_utf_new(begin, end - begin);
|
60
|
-
}
|
61
|
-
|
62
|
-
static VALUE
|
63
|
-
rb_utf_aref_default(VALUE str, VALUE index)
|
64
|
-
{
|
65
|
-
long n_chars = utf_length_n(RSTRING(str)->ptr, RSTRING(str)->len);
|
66
|
-
|
67
|
-
long begin, len;
|
68
|
-
switch (rb_range_beg_len(index, &begin, &len, n_chars, 0)) {
|
69
|
-
case Qfalse:
|
70
|
-
return rb_utf_aref_num(str, NUM2LONG(index));
|
71
|
-
case Qnil:
|
72
|
-
return Qnil;
|
73
|
-
default:
|
74
|
-
return rb_utf_substr_and_infect(str, begin, len, index);
|
75
|
-
}
|
76
|
-
}
|
77
|
-
|
78
|
-
static VALUE
|
79
|
-
rb_utf_aref(VALUE str, VALUE index)
|
80
|
-
{
|
81
|
-
switch (TYPE(index)) {
|
82
|
-
case T_FIXNUM:
|
83
|
-
return rb_utf_aref_num(str, FIX2LONG(index));
|
84
|
-
case T_REGEXP:
|
85
|
-
return rb_str_subpat(str, index, 0);
|
86
|
-
case T_STRING:
|
87
|
-
if (rb_utf_index(str, index, 0) != -1)
|
88
|
-
return rb_utf_dup(index);
|
89
|
-
return Qnil;
|
90
|
-
default:
|
91
|
-
return rb_utf_aref_default(str, index);
|
92
|
-
}
|
93
|
-
}
|
94
|
-
|
95
|
-
VALUE
|
96
|
-
rb_utf_aref_m(int argc, VALUE *argv, UNUSED(VALUE self))
|
97
|
-
{
|
98
|
-
StringValue(argv[0]);
|
99
|
-
|
100
|
-
if (argc > 3 || argc < 2)
|
101
|
-
rb_raise(rb_eArgError,
|
102
|
-
"wrong number of arguments (%d for 2)", argc);
|
103
|
-
|
104
|
-
if (argc == 2)
|
105
|
-
return rb_utf_aref(argv[0], argv[1]);
|
106
|
-
|
107
|
-
if (TYPE(argv[1]) == T_REGEXP)
|
108
|
-
return rb_str_subpat(argv[0], argv[1], NUM2INT(argv[2]));
|
109
|
-
|
110
|
-
return rb_utf_substr(argv[0], NUM2INT(argv[1]), NUM2INT(argv[2]));
|
111
|
-
}
|
@@ -1,105 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* contents: UTF8.aset module function.
|
3
|
-
*
|
4
|
-
* Copyright © 2006 Nikolai Weibull <now@bitwi.se>
|
5
|
-
*/
|
6
|
-
|
7
|
-
#include "rb_includes.h"
|
8
|
-
#include <re.h>
|
9
|
-
|
10
|
-
/* XXX: Stolen straight from string.c. */
|
11
|
-
#define BEG(no) regs->beg[no]
|
12
|
-
#define END(no) regs->end[no]
|
13
|
-
|
14
|
-
static VALUE
|
15
|
-
rb_str_subpat_set(VALUE str, VALUE re, int nth, VALUE val)
|
16
|
-
{
|
17
|
-
VALUE match;
|
18
|
-
long start, end, len;
|
19
|
-
|
20
|
-
if (rb_reg_search(re, str, 0, 0) < 0) {
|
21
|
-
rb_raise(rb_eIndexError, "regexp not matched");
|
22
|
-
}
|
23
|
-
match = rb_backref_get();
|
24
|
-
if (nth >= RMATCH(match)->regs->num_regs) {
|
25
|
-
out_of_range:
|
26
|
-
rb_raise(rb_eIndexError, "index %d out of regexp", nth);
|
27
|
-
}
|
28
|
-
if (nth < 0) {
|
29
|
-
if (-nth >= RMATCH(match)->regs->num_regs) {
|
30
|
-
goto out_of_range;
|
31
|
-
}
|
32
|
-
nth += RMATCH(match)->regs->num_regs;
|
33
|
-
}
|
34
|
-
|
35
|
-
start = RMATCH(match)->BEG(nth);
|
36
|
-
if (start == -1) {
|
37
|
-
rb_raise(rb_eIndexError, "regexp group %d not matched", nth);
|
38
|
-
}
|
39
|
-
end = RMATCH(match)->END(nth);
|
40
|
-
len = end - start;
|
41
|
-
rb_str_update(str, start, len, val);
|
42
|
-
|
43
|
-
return val;
|
44
|
-
}
|
45
|
-
|
46
|
-
static VALUE
|
47
|
-
rb_utf_aset_num(VALUE str, long offset, VALUE replacement)
|
48
|
-
{
|
49
|
-
return rb_utf_update(str, offset, 1, replacement);
|
50
|
-
}
|
51
|
-
|
52
|
-
static VALUE
|
53
|
-
rb_utf_aset_default(VALUE str, VALUE index, VALUE replacement)
|
54
|
-
{
|
55
|
-
long n_chars = utf_length_n(RSTRING(str)->ptr, RSTRING(str)->len);
|
56
|
-
|
57
|
-
long begin, len;
|
58
|
-
if (rb_range_beg_len(index, &begin, &len, n_chars, 2))
|
59
|
-
return rb_utf_update(str, begin, len, replacement);
|
60
|
-
|
61
|
-
return rb_utf_aset_num(str, NUM2LONG(index), replacement);
|
62
|
-
}
|
63
|
-
|
64
|
-
static VALUE
|
65
|
-
rb_utf_aset(VALUE str, VALUE index, VALUE replacement)
|
66
|
-
{
|
67
|
-
switch (TYPE(index)) {
|
68
|
-
case T_FIXNUM:
|
69
|
-
return rb_utf_aset_num(str, FIX2LONG(index), replacement);
|
70
|
-
case T_BIGNUM:
|
71
|
-
return rb_utf_aset_num(str, NUM2LONG(index), replacement);
|
72
|
-
case T_REGEXP:
|
73
|
-
return rb_str_subpat_set(str, index, 0, replacement);
|
74
|
-
case T_STRING: {
|
75
|
-
long begin = rb_utf_index(str, index, 0);
|
76
|
-
if (begin < 0)
|
77
|
-
rb_raise(rb_eIndexError, "string not matched");
|
78
|
-
return rb_utf_update(str,
|
79
|
-
begin,
|
80
|
-
utf_length_n(RSTRING(index)->ptr,
|
81
|
-
RSTRING(index)->len),
|
82
|
-
replacement);
|
83
|
-
}
|
84
|
-
default:
|
85
|
-
return rb_utf_aset_default(str, index, replacement);
|
86
|
-
}
|
87
|
-
}
|
88
|
-
|
89
|
-
VALUE
|
90
|
-
rb_utf_aset_m(int argc, VALUE *argv, UNUSED(VALUE self))
|
91
|
-
{
|
92
|
-
if (argc > 4 || argc < 3)
|
93
|
-
rb_raise(rb_eArgError,
|
94
|
-
"wrong number of arguments (%d for 3)", argc);
|
95
|
-
|
96
|
-
StringValue(argv[0]);
|
97
|
-
|
98
|
-
if (argc == 3)
|
99
|
-
return rb_utf_aset(argv[0], argv[1], argv[2]);
|
100
|
-
|
101
|
-
if (TYPE(argv[1]) == T_REGEXP)
|
102
|
-
return rb_str_subpat_set(argv[0], argv[1], NUM2INT(argv[2]), argv[3]);
|
103
|
-
|
104
|
-
return rb_utf_update(argv[0], NUM2LONG(argv[1]), NUM2LONG(argv[2]), argv[3]);
|
105
|
-
}
|
@@ -1,24 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* contents: UTF8.casecmp module function.
|
3
|
-
*
|
4
|
-
* Copyright © 2006 Nikolai Weibull <now@bitwi.se>
|
5
|
-
*/
|
6
|
-
|
7
|
-
#include "rb_includes.h"
|
8
|
-
|
9
|
-
VALUE
|
10
|
-
rb_utf_casecmp(UNUSED(VALUE self), VALUE str1, VALUE str2)
|
11
|
-
{
|
12
|
-
StringValue(str1);
|
13
|
-
StringValue(str2);
|
14
|
-
|
15
|
-
char *folded1 = utf_foldcase(RSTRING(str1)->ptr);
|
16
|
-
char *folded2 = utf_foldcase(RSTRING(str2)->ptr);
|
17
|
-
|
18
|
-
int result = utf_collate(folded1, folded2);
|
19
|
-
|
20
|
-
free(folded2);
|
21
|
-
free(folded1);
|
22
|
-
|
23
|
-
return INT2FIX(result);
|
24
|
-
}
|
@@ -1,114 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* contents: UTF8.chomp module function.
|
3
|
-
*
|
4
|
-
* Copyright © 2006 Nikolai Weibull <now@bitwi.se>
|
5
|
-
*/
|
6
|
-
|
7
|
-
#include "rb_includes.h"
|
8
|
-
|
9
|
-
static VALUE
|
10
|
-
rb_utf_chomp_default(VALUE str)
|
11
|
-
{
|
12
|
-
rb_str_modify(str);
|
13
|
-
|
14
|
-
const char *end = RSTRING(str)->ptr + RSTRING(str)->len;
|
15
|
-
|
16
|
-
char *last = utf_find_prev(RSTRING(str)->ptr, end);
|
17
|
-
if (last == NULL)
|
18
|
-
return Qnil;
|
19
|
-
|
20
|
-
if (_utf_char_validated(last, end) == '\n') {
|
21
|
-
char *last_but_one = utf_find_prev(RSTRING(str)->ptr, last);
|
22
|
-
|
23
|
-
if (last_but_one != NULL && utf_char(last_but_one) == '\r')
|
24
|
-
last = last_but_one;
|
25
|
-
} else if (!unichar_isnewline(utf_char(last))) {
|
26
|
-
return Qnil;
|
27
|
-
}
|
28
|
-
|
29
|
-
RSTRING(str)->len -= (RSTRING(str)->ptr + RSTRING(str)->len) - last;
|
30
|
-
*last = '\0';
|
31
|
-
|
32
|
-
return str;
|
33
|
-
}
|
34
|
-
|
35
|
-
static VALUE
|
36
|
-
rb_utf_chomp_newlines(VALUE str)
|
37
|
-
{
|
38
|
-
char *begin = RSTRING(str)->ptr;
|
39
|
-
char *end = begin + RSTRING(str)->len;
|
40
|
-
|
41
|
-
char *last = end;
|
42
|
-
while (last > begin) {
|
43
|
-
char *last_but_one = utf_find_prev(begin, last);
|
44
|
-
if (last == NULL || !unichar_isnewline(utf_char(last_but_one)))
|
45
|
-
break;
|
46
|
-
last = last_but_one;
|
47
|
-
}
|
48
|
-
|
49
|
-
if (last == end)
|
50
|
-
return Qnil;
|
51
|
-
|
52
|
-
rb_str_modify(str);
|
53
|
-
RSTRING(str)->len -= end - last;
|
54
|
-
*last = '\0';
|
55
|
-
|
56
|
-
return str;
|
57
|
-
}
|
58
|
-
|
59
|
-
VALUE
|
60
|
-
rb_utf_chomp_bang(int argc, VALUE *argv, UNUSED(VALUE self))
|
61
|
-
{
|
62
|
-
VALUE str, rs;
|
63
|
-
|
64
|
-
rb_scan_args(argc, argv, "11", &str, &rs);
|
65
|
-
|
66
|
-
if (RSTRING(str)->len == 0)
|
67
|
-
return Qnil;
|
68
|
-
|
69
|
-
if (argc == 1) {
|
70
|
-
rs = rb_rs;
|
71
|
-
if (rs == rb_default_rs)
|
72
|
-
rb_utf_chomp_default(str);
|
73
|
-
}
|
74
|
-
|
75
|
-
if (NIL_P(rs))
|
76
|
-
return Qnil;
|
77
|
-
|
78
|
-
StringValue(rs);
|
79
|
-
|
80
|
-
long rs_len = RSTRING(rs)->len;
|
81
|
-
if (rs_len == 0)
|
82
|
-
return rb_utf_chomp_newlines(str);
|
83
|
-
|
84
|
-
long len = RSTRING(str)->len;
|
85
|
-
if (rs_len > len)
|
86
|
-
return Qnil;
|
87
|
-
|
88
|
-
char last_char = RSTRING(rs)->ptr[rs_len - 1];
|
89
|
-
if (rs_len == 1 && last_char == '\n')
|
90
|
-
rb_utf_chomp_default(str);
|
91
|
-
|
92
|
-
char *p = RSTRING(str)->ptr;
|
93
|
-
|
94
|
-
if (p[len - 1] != last_char ||
|
95
|
-
(rs_len > 1 &&
|
96
|
-
rb_memcmp(RSTRING(rs)->ptr, p + len - rs_len, rs_len) != 0))
|
97
|
-
return Qnil;
|
98
|
-
|
99
|
-
rb_str_modify(str);
|
100
|
-
RSTRING(str)->len -= rs_len;
|
101
|
-
RSTRING(str)->ptr[RSTRING(str)->len] = '\0';
|
102
|
-
|
103
|
-
return str;
|
104
|
-
}
|
105
|
-
|
106
|
-
VALUE
|
107
|
-
rb_utf_chomp(int argc, VALUE *argv, VALUE self)
|
108
|
-
{
|
109
|
-
StringValue(argv[0]);
|
110
|
-
argv[0] = rb_utf_dup(argv[0]);
|
111
|
-
rb_utf_chomp_bang(argc, argv, self);
|
112
|
-
return argv[0];
|
113
|
-
}
|
114
|
-
|