From 95698ff2a414f6c212377ab321225bdcebd11a9f Mon Sep 17 00:00:00 2001 From: naruse Date: Tue, 20 May 2008 16:37:13 +0000 Subject: [PATCH] * transcode.c, include/ruby/encodng.h (rb_str_transcode): C API of encoding conversion for Ruby object. VALUE rb_str_transcode(VALUE str, VALUE to). * transcode.c (str_encode, str_encode_bang): rename from rb_tr_transcode or rb_str_transcode_bang. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16496 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 9 +++++++++ include/ruby/encoding.h | 2 ++ transcode.c | 19 ++++++++++++++----- version.h | 6 +++--- 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3f739b9589..278426b33b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Wed May 21 01:28:47 2008 NARUSE, Yui + + * transcode.c, include/ruby/encodng.h (rb_str_transcode): + C API of encoding conversion for Ruby object. + VALUE rb_str_transcode(VALUE str, VALUE to). + + * transcode.c (str_encode, str_encode_bang): + rename from rb_tr_transcode or rb_str_transcode_bang. + Tue May 20 23:26:05 2008 Yusuke Endoh * test/ruby/test_array.rb: fix tests for 64bit CPU. diff --git a/include/ruby/encoding.h b/include/ruby/encoding.h index 0a6b7c18e2..e5820beb7c 100644 --- a/include/ruby/encoding.h +++ b/include/ruby/encoding.h @@ -193,4 +193,6 @@ rb_enc_dummy_p(rb_encoding *enc) return ENC_DUMMY_P(ENC_FROM_ENCODING(enc)); } +VALUE rb_str_transcode(VALUE str, VALUE to); + #endif /* RUBY_ENCODING_H */ diff --git a/transcode.c b/transcode.c index c6e6a3eded..60aee66d5d 100644 --- a/transcode.c +++ b/transcode.c @@ -397,7 +397,7 @@ str_transcode(int argc, VALUE *argv, VALUE *self) */ static VALUE -rb_str_transcode_bang(int argc, VALUE *argv, VALUE str) +str_encode_bang(int argc, VALUE *argv, VALUE str) { VALUE newstr = str; int encidx = str_transcode(argc, argv, &newstr); @@ -432,10 +432,19 @@ rb_str_transcode_bang(int argc, VALUE *argv, VALUE str) */ static VALUE -rb_str_transcode(int argc, VALUE *argv, VALUE str) +str_encode(int argc, VALUE *argv, VALUE str) { str = rb_str_dup(str); - return rb_str_transcode_bang(argc, argv, str); + return str_encode_bang(argc, argv, str); +} + +VALUE +rb_str_transcode(VALUE str, VALUE to) +{ + int argc = 1; + VALUE argv = rb_ary_new2(1); + rb_ary_push(argv, to); + return str_encode(argc, &argv, str); } void @@ -447,6 +456,6 @@ Init_transcode(void) sym_invalid = ID2SYM(rb_intern("invalid")); sym_ignore = ID2SYM(rb_intern("ignore")); - rb_define_method(rb_cString, "encode", rb_str_transcode, -1); - rb_define_method(rb_cString, "encode!", rb_str_transcode_bang, -1); + rb_define_method(rb_cString, "encode", str_encode, -1); + rb_define_method(rb_cString, "encode!", str_encode_bang, -1); } diff --git a/version.h b/version.h index 29ddf70ea9..f278b39eac 100644 --- a/version.h +++ b/version.h @@ -1,7 +1,7 @@ #define RUBY_VERSION "1.9.0" -#define RUBY_RELEASE_DATE "2008-05-20" +#define RUBY_RELEASE_DATE "2008-05-21" #define RUBY_VERSION_CODE 190 -#define RUBY_RELEASE_CODE 20080520 +#define RUBY_RELEASE_CODE 20080521 #define RUBY_PATCHLEVEL 0 #define RUBY_VERSION_MAJOR 1 @@ -9,7 +9,7 @@ #define RUBY_VERSION_TEENY 0 #define RUBY_RELEASE_YEAR 2008 #define RUBY_RELEASE_MONTH 5 -#define RUBY_RELEASE_DAY 20 +#define RUBY_RELEASE_DAY 21 #ifdef RUBY_EXTERN RUBY_EXTERN const char ruby_version[];