diff options
| author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-01-25 07:35:27 +0000 |
|---|---|---|
| committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-01-25 07:35:27 +0000 |
| commit | 2c2e6ee432bcbdb2e28005021ea2eb42c871c440 (patch) | |
| tree | 76efd4714a4e19398186edd80c46763bce7a4a0d /string.c | |
| parent | c730ae2525228ad54447508980b2f187bc7a3a9b (diff) | |
| download | ruby-2c2e6ee432bcbdb2e28005021ea2eb42c871c440.tar.gz ruby-2c2e6ee432bcbdb2e28005021ea2eb42c871c440.tar.xz ruby-2c2e6ee432bcbdb2e28005021ea2eb42c871c440.zip | |
* 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: http://svn.ruby-lang.org/repos/ruby/trunk@15232 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
| -rw-r--r-- | string.c | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -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) |
