Skip to content

Commit

Permalink
string.c: no terminator
Browse files Browse the repository at this point in the history
* string.c (rb_str_{,l,r}strip_bang): rb_str_subseq() will not
  NUL-terminate the result string, in the future, so it will not
  be needed in other cases.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48280 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nobu committed Nov 5, 2014
1 parent 7fecd1e commit a707ab4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Wed Nov 5 15:05:12 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>

* string.c (rb_str_{,l,r}strip_bang): rb_str_subseq() will not
NUL-terminate the result string, in the future, so it will not
be needed in other cases.

Wed Nov 5 14:11:30 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>

* common.mk (lib/unicode_normalize/tables.rb): do nothing unless
Expand Down
8 changes: 4 additions & 4 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,10 @@ with all sufficient information, see the ChangeLog file.

* rb_str_cat_cstr() added. This is same as `rb_str_cat2()`.

* `rb_str_substr()` and `rb_str_subseq()` now share middle of a string,
but not only the end of a string. Therefore, result strings may not
be NUL-terminated, `StringValueCStr()` is needed calling to obtain a
NUL-terminated C string.
* `rb_str_substr()` and `rb_str_subseq()` will share middle of a string,
but not only the end of a string, in the futre. Therefore, result
strings may not be NUL-terminated, `StringValueCStr()` is needed
calling to obtain a NUL-terminated C string.

* rb_tracepoint_new() supports new internal events accessible only from C:
* RUBY_INTERNAL_EVENT_GC_ENTER
Expand Down
11 changes: 10 additions & 1 deletion string.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ VALUE rb_cSymbol;

#define STR_ENC_GET(str) get_encoding(str)

#if 1
#if !defined SHARABLE_MIDDLE_SUBSTRING
# define SHARABLE_MIDDLE_SUBSTRING 0
#endif
#if !SHARABLE_MIDDLE_SUBSTRING
#define SHARABLE_SUBSTRING_P(beg, len, end) ((beg) + (len) == (end))
#else
#define SHARABLE_SUBSTRING_P(beg, len, end) 1
Expand Down Expand Up @@ -7227,7 +7230,9 @@ rb_str_lstrip_bang(VALUE str)
s = start + loffset;
memmove(start, s, len);
STR_SET_LEN(str, len);
#if !SHARABLE_MIDDLE_SUBSTRING
TERM_FILL(start+len, rb_enc_mbminlen(enc));
#endif
return str;
}
return Qnil;
Expand Down Expand Up @@ -7309,7 +7314,9 @@ rb_str_rstrip_bang(VALUE str)
long len = olen - roffset;

STR_SET_LEN(str, len);
#if !SHARABLE_MIDDLE_SUBSTRING
TERM_FILL(start+len, rb_enc_mbminlen(enc));
#endif
return str;
}
return Qnil;
Expand Down Expand Up @@ -7371,7 +7378,9 @@ rb_str_strip_bang(VALUE str)
memmove(start, start + loffset, len);
}
STR_SET_LEN(str, len);
#if !SHARABLE_MIDDLE_SUBSTRING
TERM_FILL(start+len, rb_enc_mbminlen(enc));
#endif
return str;
}
return Qnil;
Expand Down

0 comments on commit a707ab4

Please sign in to comment.