mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* encoding.c (rb_obj_encoding): returns encoding of the given object.
* re.c (Init_Regexp): new method Regexp#encoding. * string.c (str_encoding): moved to encoding.c git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13613 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
612b2ed6a7
commit
19dee8af57
5 changed files with 26 additions and 16 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
Thu Oct 4 15:57:16 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* encoding.c (rb_obj_encoding): returns encoding of the given object.
|
||||||
|
|
||||||
|
* re.c (Init_Regexp): new method Regexp#encoding.
|
||||||
|
|
||||||
|
* string.c (str_encoding): moved to encoding.c
|
||||||
|
|
||||||
Thu Oct 4 15:49:33 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
|
Thu Oct 4 15:49:33 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
* array.c (rb_ary_permutation): remove C99 dependency.
|
* array.c (rb_ary_permutation): remove C99 dependency.
|
||||||
|
|
14
encoding.c
14
encoding.c
|
@ -259,6 +259,20 @@ rb_enc_copy(VALUE obj1, VALUE obj2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* call-seq:
|
||||||
|
* obj.encoding => str
|
||||||
|
*
|
||||||
|
* Retruns the encoding name.
|
||||||
|
*/
|
||||||
|
|
||||||
|
VALUE
|
||||||
|
rb_obj_encoding(VALUE obj)
|
||||||
|
{
|
||||||
|
return rb_str_new2(rb_enc_name(rb_enc_get(obj)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
char*
|
char*
|
||||||
rb_enc_nth(const char *p, const char *e, int nth, rb_encoding *enc)
|
rb_enc_nth(const char *p, const char *e, int nth, rb_encoding *enc)
|
||||||
{
|
{
|
||||||
|
|
|
@ -50,6 +50,7 @@ void rb_enc_copy(VALUE, VALUE);
|
||||||
VALUE rb_enc_str_new(const char*, long len, rb_encoding*);
|
VALUE rb_enc_str_new(const char*, long len, rb_encoding*);
|
||||||
long rb_enc_strlen(const char*, const char*, rb_encoding*);
|
long rb_enc_strlen(const char*, const char*, rb_encoding*);
|
||||||
char* rb_enc_nth(const char*, const char*, int, rb_encoding*);
|
char* rb_enc_nth(const char*, const char*, int, rb_encoding*);
|
||||||
|
VALUE rb_obj_encoding(VALUE);
|
||||||
|
|
||||||
/* index -> rb_encoding */
|
/* index -> rb_encoding */
|
||||||
rb_encoding* rb_enc_from_index(int idx);
|
rb_encoding* rb_enc_from_index(int idx);
|
||||||
|
|
1
re.c
1
re.c
|
@ -2476,6 +2476,7 @@ Init_Regexp(void)
|
||||||
rb_define_method(rb_cRegexp, "casefold?", rb_reg_casefold_p, 0);
|
rb_define_method(rb_cRegexp, "casefold?", rb_reg_casefold_p, 0);
|
||||||
rb_define_method(rb_cRegexp, "options", rb_reg_options_m, 0);
|
rb_define_method(rb_cRegexp, "options", rb_reg_options_m, 0);
|
||||||
rb_define_method(rb_cRegexp, "kcode", rb_reg_kcode_m, 0);
|
rb_define_method(rb_cRegexp, "kcode", rb_reg_kcode_m, 0);
|
||||||
|
rb_define_method(rb_cRegexp, "encoding", rb_obj_encoding, 0); /* in encoding.c */
|
||||||
|
|
||||||
rb_define_const(rb_cRegexp, "IGNORECASE", INT2FIX(ONIG_OPTION_IGNORECASE));
|
rb_define_const(rb_cRegexp, "IGNORECASE", INT2FIX(ONIG_OPTION_IGNORECASE));
|
||||||
rb_define_const(rb_cRegexp, "EXTENDED", INT2FIX(ONIG_OPTION_EXTEND));
|
rb_define_const(rb_cRegexp, "EXTENDED", INT2FIX(ONIG_OPTION_EXTEND));
|
||||||
|
|
18
string.c
18
string.c
|
@ -5106,20 +5106,6 @@ rb_str_setter(VALUE val, ID id, VALUE *var)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* call-seq:
|
|
||||||
* str.encoding => str
|
|
||||||
*
|
|
||||||
* Retruns the encoding name.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static VALUE
|
|
||||||
str_encoding(VALUE str)
|
|
||||||
{
|
|
||||||
return rb_str_new2(rb_enc_name(rb_enc_get(str)));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* str.force_encoding(encoding) => str
|
* str.force_encoding(encoding) => str
|
||||||
|
@ -5388,7 +5374,7 @@ sym_swapcase(VALUE sym)
|
||||||
static VALUE
|
static VALUE
|
||||||
sym_encoding(VALUE sym)
|
sym_encoding(VALUE sym)
|
||||||
{
|
{
|
||||||
return str_encoding(rb_id2str(SYM2ID(sym)));
|
return rb_obj_encoding(rb_id2str(SYM2ID(sym)));
|
||||||
}
|
}
|
||||||
|
|
||||||
ID
|
ID
|
||||||
|
@ -5545,7 +5531,7 @@ Init_String(void)
|
||||||
rb_define_method(rb_cString, "partition", rb_str_partition, 1);
|
rb_define_method(rb_cString, "partition", rb_str_partition, 1);
|
||||||
rb_define_method(rb_cString, "rpartition", rb_str_rpartition, 1);
|
rb_define_method(rb_cString, "rpartition", rb_str_rpartition, 1);
|
||||||
|
|
||||||
rb_define_method(rb_cString, "encoding", str_encoding, 0);
|
rb_define_method(rb_cString, "encoding", rb_obj_encoding, 0); /* in encoding.c */
|
||||||
rb_define_method(rb_cString, "force_encoding", rb_str_force_encoding, 1);
|
rb_define_method(rb_cString, "force_encoding", rb_str_force_encoding, 1);
|
||||||
|
|
||||||
id_to_s = rb_intern("to_s");
|
id_to_s = rb_intern("to_s");
|
||||||
|
|
Loading…
Add table
Reference in a new issue