mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	* string.c (rb_str_check_dummy_enc): new function to check dummy
encoding. * string.c (rb_str_upcase_bang): case conversion functions should not be applicable to strings in dummy encoding. [ruby-dev:36985] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20046 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									86ade65104
								
							
						
					
					
						commit
						f27e4c045f
					
				
					 2 changed files with 22 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -12,6 +12,14 @@ Thu Oct 30 01:10:32 2008  Yusuke Endoh  <mame@tsg.ne.jp>
 | 
			
		|||
	* test/ruby/test_array (test_permutation): add a test that replaces
 | 
			
		||||
	  array during permutation.
 | 
			
		||||
 | 
			
		||||
Wed Oct 29 23:31:34 2008  Yukihiro Matsumoto  <matz@ruby-lang.org>
 | 
			
		||||
 | 
			
		||||
	* string.c (rb_str_check_dummy_enc): new function to check dummy
 | 
			
		||||
	  encoding.
 | 
			
		||||
 | 
			
		||||
	* string.c (rb_str_upcase_bang): case conversion functions should
 | 
			
		||||
	  not be applicable to strings in dummy encoding.  [ruby-dev:36985]
 | 
			
		||||
 | 
			
		||||
Wed Oct 29 23:57:29 2008  Yusuke Endoh  <mame@tsg.ne.jp>
 | 
			
		||||
 | 
			
		||||
	* array.c (rb_ary_sort_bang): replacing array during sort broke
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										17
									
								
								string.c
									
										
									
									
									
								
							
							
						
						
									
										17
									
								
								string.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -4220,6 +4220,15 @@ rb_str_dump(VALUE str)
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
rb_str_check_dummy_enc(rb_encoding *enc)
 | 
			
		||||
{
 | 
			
		||||
    if (rb_enc_dummy_p(enc)) {
 | 
			
		||||
	rb_raise(rb_eEncCompatError, "incompatible encoding with this operation: %s",
 | 
			
		||||
		 rb_enc_name(enc));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 *  call-seq:
 | 
			
		||||
 *     str.upcase!   => str or nil
 | 
			
		||||
| 
						 | 
				
			
			@ -4238,6 +4247,7 @@ rb_str_upcase_bang(VALUE str)
 | 
			
		|||
 | 
			
		||||
    str_modify_keep_cr(str);
 | 
			
		||||
    enc = STR_ENC_GET(str);
 | 
			
		||||
    rb_str_check_dummy_enc(enc);
 | 
			
		||||
    s = RSTRING_PTR(str); send = RSTRING_END(str);
 | 
			
		||||
    if (single_byte_optimizable(str)) {
 | 
			
		||||
	while (s < send) {
 | 
			
		||||
| 
						 | 
				
			
			@ -4319,6 +4329,7 @@ rb_str_downcase_bang(VALUE str)
 | 
			
		|||
 | 
			
		||||
    str_modify_keep_cr(str);
 | 
			
		||||
    enc = STR_ENC_GET(str);
 | 
			
		||||
    rb_str_check_dummy_enc(enc);
 | 
			
		||||
    s = RSTRING_PTR(str); send = RSTRING_END(str);
 | 
			
		||||
    if (single_byte_optimizable(str)) {
 | 
			
		||||
	while (s < send) {
 | 
			
		||||
| 
						 | 
				
			
			@ -4406,6 +4417,7 @@ rb_str_capitalize_bang(VALUE str)
 | 
			
		|||
 | 
			
		||||
    str_modify_keep_cr(str);
 | 
			
		||||
    enc = STR_ENC_GET(str);
 | 
			
		||||
    rb_str_check_dummy_enc(enc);
 | 
			
		||||
    if (RSTRING_LEN(str) == 0 || !RSTRING_PTR(str)) return Qnil;
 | 
			
		||||
    s = RSTRING_PTR(str); send = RSTRING_END(str);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -4469,6 +4481,7 @@ rb_str_swapcase_bang(VALUE str)
 | 
			
		|||
 | 
			
		||||
    str_modify_keep_cr(str);
 | 
			
		||||
    enc = STR_ENC_GET(str);
 | 
			
		||||
    rb_str_check_dummy_enc(enc);
 | 
			
		||||
    s = RSTRING_PTR(str); send = RSTRING_END(str);
 | 
			
		||||
    while (s < send) {
 | 
			
		||||
	unsigned int c = rb_enc_codepoint(s, send, enc);
 | 
			
		||||
| 
						 | 
				
			
			@ -5996,9 +6009,7 @@ rb_str_rstrip_bang(VALUE str)
 | 
			
		|||
    char *s, *t, *e;
 | 
			
		||||
 | 
			
		||||
    enc = STR_ENC_GET(str);
 | 
			
		||||
    if (rb_enc_dummy_p(enc)) {
 | 
			
		||||
	rb_raise(rb_eEncCompatError, "incompatible encoding with this operation: %s", rb_enc_name(enc));
 | 
			
		||||
    }
 | 
			
		||||
    rb_str_check_dummy_enc(enc);
 | 
			
		||||
    s = RSTRING_PTR(str);
 | 
			
		||||
    if (!s || RSTRING_LEN(str) == 0) return Qnil;
 | 
			
		||||
    t = e = RSTRING_END(str);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue