summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-11 11:17:59 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-11 11:17:59 +0000
commitb271a8c98d7301482d5b4eb2c7d79b7e1a1fc368 (patch)
tree1d8dafbbbfc506d1b562fc78984ccf42d18599c6 /ext
parentdb3ddad3a710de4f0c6ef5d47493c5f7ba9b7384 (diff)
string.c: multi-byte terminator
* string.c (rb_string_value_cstr): fill minimum length of the encoding as the terminator. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41919 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/-test-/string/cstr.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/ext/-test-/string/cstr.c b/ext/-test-/string/cstr.c
index d4ff360575..c2ed410b41 100644
--- a/ext/-test-/string/cstr.c
+++ b/ext/-test-/string/cstr.c
@@ -1,16 +1,22 @@
#include "ruby.h"
+#include "ruby/encoding.h"
static VALUE
bug_str_cstr_term(VALUE str)
{
long len;
char *s;
+ int c;
+ rb_encoding *enc;
+
rb_str_modify(str);
len = RSTRING_LEN(str);
RSTRING_PTR(str)[len] = 'x';
s = StringValueCStr(str);
rb_gc();
- return INT2NUM(s[len]);
+ enc = rb_enc_get(str);
+ c = rb_enc_codepoint(&s[len], &s[len+rb_enc_mbminlen(enc)], enc);
+ return INT2NUM(c);
}
void