1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
This commit is contained in:
Benoit Daloze 2020-03-28 00:22:51 +01:00
parent 296f68816c
commit f234d51eab
50 changed files with 739 additions and 377 deletions

View file

@ -69,6 +69,16 @@ VALUE string_spec_rb_str_buf_new2(VALUE self) {
return rb_str_buf_new2("hello\0invisible");
}
VALUE string_spec_rb_str_tmp_new(VALUE self, VALUE len) {
VALUE str = rb_str_tmp_new(NUM2LONG(len));
rb_obj_reveal(str, rb_cString);
return str;
}
VALUE string_spec_rb_str_tmp_new_klass(VALUE self, VALUE len) {
return RBASIC_CLASS(rb_str_tmp_new(NUM2LONG(len)));
}
VALUE string_spec_rb_str_buf_cat(VALUE self, VALUE str) {
const char *question_mark = "?";
rb_str_buf_cat(str, question_mark, strlen(question_mark));
@ -296,7 +306,7 @@ VALUE string_spec_RSTRING_PTR_iterate_uint32(VALUE self, VALUE str) {
}
VALUE string_spec_RSTRING_PTR_short_memcpy(VALUE self, VALUE str) {
// Short memcpy operations may be optimised by the compiler to a single write.
/* Short memcpy operations may be optimised by the compiler to a single write. */
if (RSTRING_LEN(str) >= 8) {
memcpy(RSTRING_PTR(str), "Infinity", 8);
}
@ -451,6 +461,8 @@ void Init_string_spec(void) {
rb_define_method(cls, "rb_str_buf_new", string_spec_rb_str_buf_new, 2);
rb_define_method(cls, "rb_str_capacity", string_spec_rb_str_capacity, 1);
rb_define_method(cls, "rb_str_buf_new2", string_spec_rb_str_buf_new2, 0);
rb_define_method(cls, "rb_str_tmp_new", string_spec_rb_str_tmp_new, 1);
rb_define_method(cls, "rb_str_tmp_new_klass", string_spec_rb_str_tmp_new_klass, 1);
rb_define_method(cls, "rb_str_buf_cat", string_spec_rb_str_buf_cat, 1);
rb_define_method(cls, "rb_str_cat", string_spec_rb_str_cat, 1);
rb_define_method(cls, "rb_str_cat2", string_spec_rb_str_cat2, 1);