Skip to content

Commit

Permalink
Merge pull request #9 from tjschuck/mongolian_vowel_separator
Browse files Browse the repository at this point in the history
"Mongolian Vowel Separator" is not considered whitespace after Ruby 2.2
  • Loading branch information
SamSaffron committed Aug 3, 2015
2 parents 535f566 + 9cf94b4 commit 90a826b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
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

0 comments on commit 90a826b

Please sign in to comment.