mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
transcode.c: fill terminator
* transcode.c (str_encode_associate): fill terminator after conversion. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41921 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
1549894a06
commit
18030d18cf
4 changed files with 15 additions and 1 deletions
|
@ -1,4 +1,6 @@
|
|||
Thu Jul 11 20:18:03 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
Thu Jul 11 20:18:08 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* transcode.c (str_encode_associate): fill terminator after conversion.
|
||||
|
||||
* string.c (rb_enc_str_new, rb_str_set_len, rb_str_resize): fill
|
||||
minimum length of the encoding as the terminator.
|
||||
|
|
|
@ -441,6 +441,7 @@ VALUE rb_str_quote_unprintable(VALUE);
|
|||
VALUE rb_id_quote_unprintable(ID);
|
||||
#define QUOTE(str) rb_str_quote_unprintable(str)
|
||||
#define QUOTE_ID(id) rb_id_quote_unprintable(id)
|
||||
void rb_str_fill_terminator(VALUE str);
|
||||
|
||||
/* struct.c */
|
||||
VALUE rb_struct_init_copy(VALUE copy, VALUE s);
|
||||
|
|
10
string.c
10
string.c
|
@ -1539,6 +1539,16 @@ rb_string_value_cstr(volatile VALUE *ptr)
|
|||
return s;
|
||||
}
|
||||
|
||||
void
|
||||
rb_str_fill_terminator(VALUE str)
|
||||
{
|
||||
char *s = RSTRING_PTR(str);
|
||||
long len = RSTRING_LEN(str);
|
||||
rb_encoding *enc = rb_enc_get(str);
|
||||
const int minlen = rb_enc_mbminlen(enc);
|
||||
str_fill_term(str, s, len, minlen, enc);
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_check_string_type(VALUE str)
|
||||
{
|
||||
|
|
|
@ -2760,6 +2760,7 @@ str_encode_associate(VALUE str, int encidx)
|
|||
int cr = 0;
|
||||
|
||||
rb_enc_associate_index(str, encidx);
|
||||
rb_str_fill_terminator(str);
|
||||
|
||||
/* transcoded string never be broken. */
|
||||
if (rb_enc_asciicompat(rb_enc_from_index(encidx))) {
|
||||
|
|
Loading…
Add table
Reference in a new issue