1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* encoding.c (rb_enc_default, rb_enc_primary): return pointers to

rb_encoding of default and primary respectively.  [ruby-core:12795]

* encoding.c (set_primary_encoding): removed primary_encoding setter.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13746 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2007-10-21 09:29:19 +00:00
parent 6c77d58356
commit b2c81746ac
4 changed files with 31 additions and 15 deletions

View file

@ -1,3 +1,10 @@
Sun Oct 21 18:29:17 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* encoding.c (rb_enc_default, rb_enc_primary): return pointers to
rb_encoding of default and primary respectively. [ruby-core:12795]
* encoding.c (set_primary_encoding): removed primary_encoding setter.
Sat Oct 20 11:49:20 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* file.c (rb_get_path): returns frozen string.

View file

@ -48,6 +48,7 @@ VALUE
rb_enc_from_encoding(rb_encoding *encoding)
{
VALUE enc;
if (!encoding) return 0;
if (enc_initialized_p(encoding))
return ENC_FROM_ENCODING(encoding);
enc = enc_new(encoding);
@ -524,12 +525,27 @@ enc_load(VALUE klass, VALUE str)
return enc_find(klass, str);
}
static VALUE rb_primary_encoding;
static int primary_encoding_index;
rb_encoding *
rb_enc_default(void)
{
if (!enc_table) {
rb_enc_init();
}
return enc_table[0].enc;
}
rb_encoding *
rb_enc_primary(void)
{
return rb_enc_from_index(primary_encoding_index);
}
VALUE
rb_get_primary_encoding(void)
{
return rb_primary_encoding;
return rb_enc_from_encoding(rb_enc_primary());
}
static VALUE
@ -542,14 +558,7 @@ void
rb_set_primary_encoding(VALUE encoding)
{
rb_to_encoding(encoding);
rb_primary_encoding = encoding;
}
static VALUE
set_primary_encoding(VALUE klass, VALUE enc)
{
rb_set_primary_encoding(enc);
return rb_primary_encoding;
primary_encoding_index = ENCODING_GET(encoding);
}
static void
@ -616,9 +625,7 @@ Init_Encoding(void)
rb_define_method(rb_cEncoding, "_dump", enc_dump, -1);
rb_define_singleton_method(rb_cEncoding, "_load", enc_load, 1);
rb_primary_encoding = rb_enc_from_encoding(rb_enc_from_index(0));
rb_define_singleton_method(rb_cEncoding, "primary_encoding", get_primary_encoding, 0);
rb_define_singleton_method(rb_cEncoding, "primary_encoding=", set_primary_encoding, 1);
for (i = 0; i < enc_table_size; ++i) {
rb_encoding *enc = enc_table[i].enc;

View file

@ -100,6 +100,8 @@ ID rb_intern3(const char*, long, rb_encoding*);
int rb_enc_symname_p(const char*, rb_encoding*);
int rb_enc_str_coderange(VALUE);
VALUE rb_enc_from_encoding(rb_encoding *enc);
rb_encoding *rb_enc_primary(void);
rb_encoding *rb_enc_default(void);
VALUE rb_get_primary_encoding(void);
void rb_set_primary_encoding(VALUE encoding);

View file

@ -1,7 +1,7 @@
#define RUBY_VERSION "1.9.0"
#define RUBY_RELEASE_DATE "2007-10-20"
#define RUBY_RELEASE_DATE "2007-10-21"
#define RUBY_VERSION_CODE 190
#define RUBY_RELEASE_CODE 20071020
#define RUBY_RELEASE_CODE 20071021
#define RUBY_PATCHLEVEL 0
#define RUBY_VERSION_MAJOR 1
@ -9,7 +9,7 @@
#define RUBY_VERSION_TEENY 0
#define RUBY_RELEASE_YEAR 2007
#define RUBY_RELEASE_MONTH 10
#define RUBY_RELEASE_DAY 20
#define RUBY_RELEASE_DAY 21
#ifdef RUBY_EXTERN
RUBY_EXTERN const char ruby_version[];