diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-11-05 01:54:22 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-11-05 01:54:22 +0000 |
commit | 3614f8bd1c813916054079055d13462e90808a96 (patch) | |
tree | 630977a8a3021123bf01dd0e3639f9b2215e1a8d /ext | |
parent | 6c41b73decf61254ac9c3bc3fc0e1d0169d5b524 (diff) | |
download | ruby-3614f8bd1c813916054079055d13462e90808a96.tar.gz |
string.c: wchar terminator
* string.c (rb_str_lstrip_bang, rb_str_rstrip_bang): terminate
wchar strings with wchar 0.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48275 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r-- | ext/-test-/string/cstr.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/ext/-test-/string/cstr.c b/ext/-test-/string/cstr.c index c2ed410b41..7759cbdcf0 100644 --- a/ext/-test-/string/cstr.c +++ b/ext/-test-/string/cstr.c @@ -19,8 +19,22 @@ bug_str_cstr_term(VALUE str) return INT2NUM(c); } +static VALUE +bug_str_cstr_term_char(VALUE str) +{ + long len; + char *s; + int c; + rb_encoding *enc = rb_enc_get(str); + + RSTRING_GETMEM(str, s, len); + c = rb_enc_codepoint(&s[len], &s[len+rb_enc_mbminlen(enc)], enc); + return c ? rb_enc_uint_chr((unsigned int)c, enc) : Qnil; +} + void Init_cstr(VALUE klass) { rb_define_method(klass, "cstr_term", bug_str_cstr_term, 0); + rb_define_method(klass, "cstr_term_char", bug_str_cstr_term_char, 0); } |