mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Update to ruby/spec@b6b7752
This commit is contained in:
parent
64d8c0815e
commit
b3fa158d1c
35 changed files with 652 additions and 56 deletions
|
@ -106,10 +106,27 @@ static VALUE encoding_spec_rb_enc_find_index(VALUE self, VALUE name) {
|
|||
return INT2NUM(rb_enc_find_index(RSTRING_PTR(name)));
|
||||
}
|
||||
|
||||
static VALUE encoding_spec_rb_enc_isalnum(VALUE self, VALUE chr, VALUE encoding) {
|
||||
rb_encoding *e = rb_to_encoding(encoding);
|
||||
return rb_enc_isalnum(FIX2INT(chr), e) ? Qtrue : Qfalse;
|
||||
}
|
||||
|
||||
static VALUE encoding_spec_rb_enc_isspace(VALUE self, VALUE chr, VALUE encoding) {
|
||||
rb_encoding *e = rb_to_encoding(encoding);
|
||||
return rb_enc_isspace(FIX2INT(chr), e) ? Qtrue : Qfalse;
|
||||
}
|
||||
|
||||
static VALUE encoding_spec_rb_enc_from_index(VALUE self, VALUE index) {
|
||||
return rb_str_new2(rb_enc_from_index(NUM2INT(index))->name);
|
||||
}
|
||||
|
||||
static VALUE encoding_spec_rb_enc_mbc_to_codepoint(VALUE self, VALUE str, VALUE offset) {
|
||||
int o = FIX2INT(offset);
|
||||
char *p = RSTRING_PTR(str);
|
||||
char *e = p + o;
|
||||
return INT2FIX(rb_enc_mbc_to_codepoint(p, e, rb_enc_get(str)));
|
||||
}
|
||||
|
||||
static VALUE encoding_spec_rb_enc_from_encoding(VALUE self, VALUE name) {
|
||||
return rb_enc_from_encoding(rb_enc_find(RSTRING_PTR(name)));
|
||||
}
|
||||
|
@ -284,7 +301,10 @@ void Init_encoding_spec(void) {
|
|||
rb_define_method(cls, "rb_enc_copy", encoding_spec_rb_enc_copy, 2);
|
||||
rb_define_method(cls, "rb_enc_find", encoding_spec_rb_enc_find, 1);
|
||||
rb_define_method(cls, "rb_enc_find_index", encoding_spec_rb_enc_find_index, 1);
|
||||
rb_define_method(cls, "rb_enc_isalnum", encoding_spec_rb_enc_isalnum, 2);
|
||||
rb_define_method(cls, "rb_enc_isspace", encoding_spec_rb_enc_isspace, 2);
|
||||
rb_define_method(cls, "rb_enc_from_index", encoding_spec_rb_enc_from_index, 1);
|
||||
rb_define_method(cls, "rb_enc_mbc_to_codepoint", encoding_spec_rb_enc_mbc_to_codepoint, 2);
|
||||
rb_define_method(cls, "rb_enc_from_encoding", encoding_spec_rb_enc_from_encoding, 1);
|
||||
rb_define_method(cls, "rb_enc_get", encoding_spec_rb_enc_get, 1);
|
||||
rb_define_method(cls, "rb_enc_precise_mbclen", encoding_spec_rb_enc_precise_mbclen, 2);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue