mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* include/ruby/intern.h (rb_str_buf_cat_ascii): declared.
* string.c (rb_str_buf_cat_ascii): defined. * re.c (rb_reg_s_union): use rb_str_buf_cat_ascii to support ASCII incompatible encoding. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15232 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
8020c2e676
commit
1e41069754
4 changed files with 34 additions and 1 deletions
|
@ -1,3 +1,12 @@
|
|||
Fri Jan 25 16:31:47 2008 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* include/ruby/intern.h (rb_str_buf_cat_ascii): declared.
|
||||
|
||||
* string.c (rb_str_buf_cat_ascii): defined.
|
||||
|
||||
* re.c (rb_reg_s_union): use rb_str_buf_cat_ascii to support ASCII
|
||||
incompatible encoding.
|
||||
|
||||
Fri Jan 25 16:11:16 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* ruby.c (process_options, load_file, rb_load_file): propagates script
|
||||
|
|
|
@ -504,6 +504,7 @@ void rb_str_shared_replace(VALUE, VALUE);
|
|||
VALUE rb_str_buf_append(VALUE, VALUE);
|
||||
VALUE rb_str_buf_cat(VALUE, const char*, long);
|
||||
VALUE rb_str_buf_cat2(VALUE, const char*);
|
||||
VALUE rb_str_buf_cat_ascii(VALUE, const char*);
|
||||
VALUE rb_obj_as_string(VALUE);
|
||||
VALUE rb_check_string_type(VALUE);
|
||||
VALUE rb_str_dup(VALUE);
|
||||
|
|
5
re.c
5
re.c
|
@ -2668,7 +2668,7 @@ rb_reg_s_union(VALUE self, VALUE args0)
|
|||
VALUE e = rb_ary_entry(args0, i);
|
||||
|
||||
if (0 < i)
|
||||
rb_str_buf_cat2(source, "|"); /* xxx: UTF-16 */
|
||||
rb_str_buf_cat_ascii(source, "|");
|
||||
|
||||
v = rb_check_regexp_type(e);
|
||||
if (!NIL_P(v)) {
|
||||
|
@ -2726,6 +2726,9 @@ rb_reg_s_union(VALUE self, VALUE args0)
|
|||
}
|
||||
}
|
||||
|
||||
if (i == 0) {
|
||||
rb_enc_copy(source, v);
|
||||
}
|
||||
rb_str_append(source, v);
|
||||
}
|
||||
|
||||
|
|
20
string.c
20
string.c
|
@ -1116,6 +1116,26 @@ rb_str_cat2(VALUE str, const char *ptr)
|
|||
return rb_str_cat(str, ptr, strlen(ptr));
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_str_buf_cat_ascii(VALUE str, const char *ptr)
|
||||
{
|
||||
rb_encoding *enc = rb_enc_get(str);
|
||||
if (rb_enc_asciicompat(enc)) {
|
||||
return rb_str_buf_cat(str, ptr, strlen(ptr));
|
||||
}
|
||||
else {
|
||||
char *buf = ALLOCA_N(char, rb_enc_mbmaxlen(enc));
|
||||
while (*ptr) {
|
||||
int c = (unsigned char)*ptr;
|
||||
int len = rb_enc_codelen(c, enc);
|
||||
rb_enc_mbcput(c, buf, enc);
|
||||
rb_str_buf_cat(str, buf, len);
|
||||
ptr++;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
static VALUE
|
||||
rb_enc_cr_str_buf_cat(VALUE str, const char *ptr, long len,
|
||||
int ptr_encindex, int ptr_cr, int *ptr_cr_ret)
|
||||
|
|
Loading…
Reference in a new issue