Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.DS_Store
.bundle
*.bundle
public/.DS_Store
.kdev4
.rspec
Expand Down
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
language: ruby
rvm:
- 2.1.2
- 2.2.2
- 2.1.6
- 2.0.0
- 1.9.3
- rbx-2
15 changes: 14 additions & 1 deletion ext/fast_blank/fast_blank.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <ruby.h>
#include <ruby/encoding.h>
#include <ruby/re.h>
#include <ruby/version.h>

#define STR_ENC_GET(str) rb_enc_from_index(ENCODING_GET(str))

Expand All @@ -13,6 +14,17 @@
#define RSTRING_LEN(s) (RSTRING(s)->len)
#endif

static int
ruby_version_before_2_2()
{
#ifdef RUBY_API_VERSION_MAJOR
if (RUBY_API_VERSION_MAJOR > 2 || (RUBY_API_VERSION_MAJOR == 2 && RUBY_API_VERSION_MINOR >= 2)) {
return 0;
}
#endif
return 1;
}

static VALUE
rb_str_blank_as(VALUE str)
{
Expand All @@ -38,7 +50,6 @@ rb_str_blank_as(VALUE str)
case 0x85:
case 0xa0:
case 0x1680:
case 0x180e:
case 0x2000:
case 0x2001:
case 0x2002:
Expand All @@ -57,6 +68,8 @@ rb_str_blank_as(VALUE str)
case 0x3000:
/* found */
break;
case 0x180e:
if (ruby_version_before_2_2()) break;
default:
return Qfalse;
}
Expand Down