зеркало из https://github.com/github/ruby.git
* encoding.c (ENC_CODERANGE_AND): added.
* string.c (rb_str_plus, srb_str_times): keep coderange. * parse.y (STR_NEW0) use rb_usascii_str_new. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15519 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
a906fce838
Коммит
7a257b0110
|
@ -1,3 +1,11 @@
|
|||
Sun Feb 17 15:25:08 2008 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* encoding.c (ENC_CODERANGE_AND): added.
|
||||
|
||||
* string.c (rb_str_plus, srb_str_times): keep coderange.
|
||||
|
||||
* parse.y (STR_NEW0) use rb_usascii_str_new.
|
||||
|
||||
Sun Feb 17 14:07:24 2008 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* string.c (str_strlen): rb_enc_strlen doesn't fail.
|
||||
|
|
|
@ -56,6 +56,13 @@
|
|||
#define ENC_CODERANGE_SET(obj,cr) (RBASIC(obj)->flags = \
|
||||
(RBASIC(obj)->flags & ~ENC_CODERANGE_MASK) | (cr))
|
||||
#define ENC_CODERANGE_CLEAR(obj) ENC_CODERANGE_SET(obj,0)
|
||||
#define ENC_CODERANGE_AND(a, b) (\
|
||||
(a == b) ? a : \
|
||||
(a == ENC_CODERANGE_BROKEN) ? ENC_CODERANGE_BROKEN : \
|
||||
(b == ENC_CODERANGE_BROKEN) ? ENC_CODERANGE_BROKEN : \
|
||||
(a == ENC_CODERANGE_UNKNOWN) ? ENC_CODERANGE_UNKNOWN : \
|
||||
(b == ENC_CODERANGE_UNKNOWN) ? ENC_CODERANGE_UNKNOWN : \
|
||||
ENC_CODERANGE_VALID)
|
||||
|
||||
#define ENCODING_CODERANGE_SET(obj, encindex, cr) \
|
||||
do { \
|
||||
|
|
2
parse.y
2
parse.y
|
@ -268,7 +268,7 @@ struct parser_params {
|
|||
#define UTF8_ENC() (parser->utf8 ? parser->utf8 : \
|
||||
(parser->utf8 = rb_utf8_encoding()))
|
||||
#define STR_NEW(p,n) rb_enc_str_new((p),(n),parser->enc)
|
||||
#define STR_NEW0() rb_enc_str_new(0,0,rb_usascii_encoding())
|
||||
#define STR_NEW0() rb_usascii_str_new(0,0)
|
||||
#define STR_NEW2(p) rb_enc_str_new((p),strlen(p),parser->enc)
|
||||
#define STR_NEW3(p,n,e,func) parser_str_new((p),(n),(e),(func),parser->enc)
|
||||
#define STR_ENC(m) ((m)?parser->enc:rb_usascii_encoding())
|
||||
|
|
5
string.c
5
string.c
|
@ -738,7 +738,8 @@ rb_str_plus(VALUE str1, VALUE str2)
|
|||
|
||||
if (OBJ_TAINTED(str1) || OBJ_TAINTED(str2))
|
||||
OBJ_TAINT(str3);
|
||||
rb_enc_associate(str3, enc);
|
||||
ENCODING_CODERANGE_SET(str3, rb_enc_to_index(enc),
|
||||
ENC_CODERANGE_AND(ENC_CODERANGE(str1), ENC_CODERANGE(str2)));
|
||||
return str3;
|
||||
}
|
||||
|
||||
|
@ -778,7 +779,7 @@ rb_str_times(VALUE str, VALUE times)
|
|||
}
|
||||
RSTRING_PTR(str2)[RSTRING_LEN(str2)] = '\0';
|
||||
OBJ_INFECT(str2, str);
|
||||
rb_enc_copy(str2, str);
|
||||
ENCODING_CODERANGE_SET(str2, rb_enc_get_index(str), ENC_CODERANGE(str));
|
||||
|
||||
return str2;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче