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

* encoding.c (rb_ascii_encoding): renamed from previous

rb_default_encoding().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14443 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2007-12-21 18:55:30 +00:00
parent b36c642a85
commit d7cc14d436
8 changed files with 18 additions and 13 deletions

View file

@ -1,3 +1,8 @@
Sat Dec 22 03:54:18 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
* encoding.c (rb_ascii_encoding): renamed from previous
rb_default_encoding().
Sat Dec 22 02:49:02 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
* parse.y (command): block from cmd_brace_block was ignored.

View file

@ -236,7 +236,7 @@ rb_define_dummy_encoding(const char *name)
enc_check_duplication(name);
if (index < ENCODING_INLINE_MAX) index = ENCODING_INLINE_MAX;
if (enc_table_expand(index + 1) < 0) return -1;
encoding = rb_default_encoding();
encoding = rb_ascii_encoding();
enc_register_at(index, name, encoding);
enc = set_based_encoding(index, encoding);
FL_SET(enc, ENC_DUMMY);
@ -742,7 +742,7 @@ enc_load(VALUE klass, VALUE str)
}
rb_encoding *
rb_default_encoding(void)
rb_ascii_encoding(void)
{
if (!enc_table) {
rb_enc_init();

View file

@ -115,7 +115,7 @@ int rb_enc_str_coderange(VALUE);
int rb_enc_str_asciionly_p(VALUE);
#define rb_enc_str_asciicompat_p(str) rb_enc_asciicompat(rb_enc_get(str))
VALUE rb_enc_from_encoding(rb_encoding *enc);
rb_encoding *rb_default_encoding(void);
rb_encoding *rb_ascii_encoding(void);
rb_encoding *rb_utf8_encoding(void);
rb_encoding *rb_default_external_encoding(void);
VALUE rb_enc_default_external(void);

2
io.c
View file

@ -2862,7 +2862,7 @@ rb_io_binmode(VALUE io)
#endif
fptr->mode |= FMODE_BINMODE;
fptr->enc = rb_default_encoding();
fptr->enc = rb_ascii_encoding();
return io;
}

View file

@ -1860,7 +1860,7 @@ int_chr(int argc, VALUE *argv, VALUE num)
break;
}
enc = rb_to_encoding(argv[0]);
if (!enc) enc = rb_default_encoding();
if (!enc) enc = rb_ascii_encoding();
if (i < 0 || (n = rb_enc_codelen(i, enc)) <= 0) goto out_of_range;
str = rb_enc_str_new(0, n, enc);
rb_enc_mbcput(i, RSTRING_PTR(str), enc);

10
re.c
View file

@ -954,7 +954,7 @@ rb_reg_prepare_re(VALUE re, VALUE str)
need_recompile = 1;
}
if ((RBASIC(re)->flags & REG_ENCODING_NONE) &&
enc != rb_default_encoding() &&
enc != rb_ascii_encoding() &&
rb_enc_str_coderange(str) != ENC_CODERANGE_7BIT) {
rb_warn("none encoding regexp with non ASCII string (string encoding: %s)",
rb_enc_name(enc));
@ -1964,7 +1964,7 @@ rb_reg_initialize(VALUE obj, const char *s, int len, rb_encoding *enc,
struct RRegexp *re = RREGEXP(obj);
VALUE unescaped;
rb_encoding *fixed_enc = 0;
rb_encoding *d_enc = rb_default_encoding();
rb_encoding *a_enc = rb_ascii_encoding();
if (!OBJ_TAINTED(obj) && rb_safe_level() >= 4)
rb_raise(rb_eSecurityError, "Insecure: can't modify regexp");
@ -1982,17 +1982,17 @@ rb_reg_initialize(VALUE obj, const char *s, int len, rb_encoding *enc,
if (fixed_enc) {
if ((fixed_enc != enc && (options & ARG_ENCODING_FIXED)) ||
(fixed_enc != d_enc && (options & ARG_ENCODING_NONE))) {
(fixed_enc != a_enc && (options & ARG_ENCODING_NONE))) {
strcpy(err, "incompatible character encoding");
return -1;
}
if (fixed_enc != d_enc) {
if (fixed_enc != a_enc) {
options |= ARG_ENCODING_FIXED;
enc = fixed_enc;
}
}
else if (!(options & ARG_ENCODING_FIXED)) {
enc = d_enc;
enc = a_enc;
}
rb_enc_associate((VALUE)re, enc);

4
ruby.c
View file

@ -144,12 +144,12 @@ locale_encoding(void)
int idx;
if (codeset == Qnil)
return rb_default_encoding();
return rb_ascii_encoding();
name = StringValueCStr(codeset);
idx = rb_enc_find_index(name);
if (idx < 0)
return rb_default_encoding();
return rb_ascii_encoding();
return rb_enc_from_index(idx);
}

View file

@ -345,7 +345,7 @@ str_transcode(int argc, VALUE *argv, VALUE *self)
}
/* set encoding */
if (!to_enc) {
to_encidx = rb_enc_replicate(to_e, rb_default_encoding());
to_encidx = rb_enc_replicate(to_e, rb_ascii_encoding());
}
*self = dest;