Project

General

Profile

Feature #13252 ยป out.diff

tenderlovemaking (Aaron Patterson), 02/25/2017 12:19 AM

View differences:

string.c
800 800
}
801 801

  
802 802
static VALUE
803
str_new_static(VALUE klass, const char *ptr, long len, int encindex)
803
str_new_with_buf(VALUE klass, const char *ptr, long len, int encindex)
804 804
{
805 805
    VALUE str;
806 806

  
......
819 819
	RSTRING(str)->as.heap.ptr = (char *)ptr;
820 820
	RSTRING(str)->as.heap.aux.capa = len;
821 821
	STR_SET_NOEMBED(str);
822
	RBASIC(str)->flags |= STR_NOFREE;
823 822
    }
824 823
    rb_enc_associate_index(str, encindex);
825 824
    return str;
826 825
}
827 826

  
827
static VALUE
828
str_new_static(VALUE klass, const char *ptr, long len, int encindex)
829
{
830
    VALUE str = str_new_with_buf(klass, ptr, len, encindex);
831

  
832
    if (ptr) {
833
	RBASIC(str)->flags |= STR_NOFREE;
834
    }
835

  
836
    return str;
837
}
838

  
828 839
VALUE
829 840
rb_str_new_static(const char *ptr, long len)
830 841
{
......
850 861
}
851 862

  
852 863
VALUE
864
rb_str_new_with_buf(const char *ptr, long len)
865
{
866
    return str_new_with_buf(rb_cString, ptr, len, 0);
867
}
868

  
869
VALUE
870
rb_usascii_str_new_with_buf(const char *ptr, long len)
871
{
872
    return str_new_with_buf(rb_cString, ptr, len, ENCINDEX_US_ASCII);
873
}
874

  
875
VALUE
876
rb_utf8_str_new_with_buf(const char *ptr, long len)
877
{
878
    return str_new_with_buf(rb_cString, ptr, len, ENCINDEX_UTF_8);
879
}
880

  
881
VALUE
882
rb_enc_str_new_with_buf(const char *ptr, long len, rb_encoding *enc)
883
{
884
    return str_new_with_buf(rb_cString, ptr, len, rb_enc_to_index(enc));
885
}
886

  
887
VALUE
853 888
rb_tainted_str_new(const char *ptr, long len)
854 889
{
855 890
    VALUE str = rb_str_new(ptr, len);