sin_fast_blank 2.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 8b4a78098b2393805254ae0a8e23992958108b73a613458ee0d54bdc758dc57d
4
+ data.tar.gz: a8618c73bba6105e2727ee54aac621cc80d063de22414a192a4bc827750e8dd8
5
+ SHA512:
6
+ metadata.gz: 5e2aef38289aba766565cc552a91e85212db1554cd4e8485e1904814af075cfa223552b4a3d480247ad24083c4ab50b37877a7f69aaccee8e0134473b0828ade
7
+ data.tar.gz: 2b13bd11630bfbf83e00ca1ee1c394e5134afdbe1e9db045ef220bf5135a4260166193661485564d8fc2577d3f55d903b9414e62792a46c68507a66c58731b26
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'mkmf'
4
+
5
+ create_makefile 'sin_fast_blank'
@@ -0,0 +1,75 @@
1
+ #include <ruby.h>
2
+ #include <ruby/encoding.h>
3
+
4
+ #define STR_ENC_GET(str) rb_enc_from_index(ENCODING_GET(str))
5
+
6
+ static VALUE rb_str_blank_as(VALUE str) {
7
+ char *ptr = RSTRING_PTR(str);
8
+ if (!ptr || RSTRING_LEN(str) == 0) return Qtrue;
9
+
10
+ char *end = RSTRING_END(str);
11
+ rb_encoding *enc = STR_ENC_GET(str);
12
+
13
+ while (ptr < end) {
14
+ int len;
15
+ unsigned int codepoint = rb_enc_codepoint_len(ptr, end, &len, enc);
16
+
17
+ switch (codepoint) {
18
+ case 9:
19
+ case 0xa:
20
+ case 0xb:
21
+ case 0xc:
22
+ case 0xd:
23
+ case 0x20:
24
+ case 0x85:
25
+ case 0xa0:
26
+ case 0x1680:
27
+ case 0x2000:
28
+ case 0x2001:
29
+ case 0x2002:
30
+ case 0x2003:
31
+ case 0x2004:
32
+ case 0x2005:
33
+ case 0x2006:
34
+ case 0x2007:
35
+ case 0x2008:
36
+ case 0x2009:
37
+ case 0x200a:
38
+ case 0x2028:
39
+ case 0x2029:
40
+ case 0x202f:
41
+ case 0x205f:
42
+ case 0x3000:
43
+ break;
44
+ default:
45
+ return Qfalse;
46
+ }
47
+
48
+ ptr += len;
49
+ }
50
+
51
+ return Qtrue;
52
+ }
53
+
54
+ static VALUE rb_str_blank(VALUE str) {
55
+ char *ptr = RSTRING_PTR(str);
56
+ if (!ptr || RSTRING_LEN(str) == 0) return Qtrue;
57
+
58
+ char *end = RSTRING_END(str);
59
+ rb_encoding *enc = STR_ENC_GET(str);
60
+ while (ptr < end) {
61
+ int len;
62
+ unsigned int codepoint = rb_enc_codepoint_len(ptr, end, &len, enc);
63
+
64
+ if (!rb_isspace(codepoint) && codepoint != 0) return Qfalse;
65
+
66
+ ptr += len;
67
+ }
68
+
69
+ return Qtrue;
70
+ }
71
+
72
+ void Init_sin_fast_blank(void) {
73
+ rb_define_method(rb_cString, "blank?", rb_str_blank, 0);
74
+ rb_define_method(rb_cString, "blank_as?", rb_str_blank_as, 0);
75
+ }
metadata ADDED
@@ -0,0 +1,55 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sin_fast_blank
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Masahiro
8
+ bindir: exe
9
+ cert_chain: []
10
+ date: 2025-01-06 00:00:00.000000000 Z
11
+ dependencies: []
12
+ description: |
13
+ Ruby extension library for fast blank string checking.
14
+ Forked from FastBlank.
15
+ email:
16
+ - watanabe@cadenza-tech.com
17
+ executables: []
18
+ extensions:
19
+ - ext/sin_fast_blank/extconf.rb
20
+ extra_rdoc_files: []
21
+ files:
22
+ - ext/sin_fast_blank/extconf.rb
23
+ - ext/sin_fast_blank/sin_fast_blank.c
24
+ homepage: https://github.com/cadenza-tech/sin_fast_blank/tree/v2.0.0
25
+ licenses:
26
+ - MIT
27
+ metadata:
28
+ homepage_uri: https://github.com/cadenza-tech/sin_fast_blank/tree/v2.0.0
29
+ source_code_uri: https://github.com/cadenza-tech/sin_fast_blank/tree/v2.0.0
30
+ changelog_uri: https://github.com/cadenza-tech/sin_fast_blank/blob/v2.0.0/CHANGELOG.md
31
+ bug_tracker_uri: https://github.com/cadenza-tech/sin_fast_blank/issues
32
+ documentation_uri: https://rubydoc.info/gems/sin_fast_blank/2.0.0
33
+ funding_uri: https://patreon.com/CadenzaTech
34
+ rubygems_mfa_required: 'true'
35
+ required_jruby_version: ">= 9.3.0.0"
36
+ required_truffleruby_version: ">= 22.0.0"
37
+ required_truffleruby+graalvm_version: ">= 22.0.0"
38
+ rdoc_options: []
39
+ require_paths:
40
+ - lib
41
+ required_ruby_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: 2.3.0
46
+ required_rubygems_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ requirements: []
52
+ rubygems_version: 3.6.2
53
+ specification_version: 4
54
+ summary: Ruby extension library for fast blank string checking.
55
+ test_files: []