mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	* transcode.c (encoded_dup): extract.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30788 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									780678dafb
								
							
						
					
					
						commit
						e9cc518446
					
				
					 2 changed files with 12 additions and 9 deletions
				
			
		| 
						 | 
				
			
			@ -1,3 +1,7 @@
 | 
			
		|||
Sat Feb  5 09:38:08 2011  Nobuyoshi Nakada  <nobu@ruby-lang.org>
 | 
			
		||||
 | 
			
		||||
	* transcode.c (encoded_dup): extract.
 | 
			
		||||
 | 
			
		||||
Sat Feb  5 03:37:47 2011  Nobuyoshi Nakada  <nobu@ruby-lang.org>
 | 
			
		||||
 | 
			
		||||
	* lib/fileutils.rb (FileUtils::LowMethods): make low level methods
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										17
									
								
								transcode.c
									
										
									
									
									
								
							
							
						
						
									
										17
									
								
								transcode.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -2757,6 +2757,8 @@ str_encode_bang(int argc, VALUE *argv, VALUE str)
 | 
			
		|||
    return str_encode_associate(str, encidx);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static VALUE encoded_dup(VALUE newstr, VALUE str, int encidx);
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 *  call-seq:
 | 
			
		||||
 *     str.encode(encoding [, options] )   -> str
 | 
			
		||||
| 
						 | 
				
			
			@ -2816,15 +2818,7 @@ str_encode(int argc, VALUE *argv, VALUE str)
 | 
			
		|||
{
 | 
			
		||||
    VALUE newstr = str;
 | 
			
		||||
    int encidx = str_transcode(argc, argv, &newstr);
 | 
			
		||||
 | 
			
		||||
    if (encidx < 0) return rb_str_dup(str);
 | 
			
		||||
    if (newstr == str) {
 | 
			
		||||
	newstr = rb_str_dup(str);
 | 
			
		||||
    }
 | 
			
		||||
    else {
 | 
			
		||||
	RBASIC(newstr)->klass = rb_obj_class(str);
 | 
			
		||||
    }
 | 
			
		||||
    return str_encode_associate(newstr, encidx);
 | 
			
		||||
    return encoded_dup(newstr, str, encidx);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
VALUE
 | 
			
		||||
| 
						 | 
				
			
			@ -2834,7 +2828,12 @@ rb_str_encode(VALUE str, VALUE to, int ecflags, VALUE ecopts)
 | 
			
		|||
    VALUE *argv = &to;
 | 
			
		||||
    VALUE newstr = str;
 | 
			
		||||
    int encidx = str_transcode0(argc, argv, &newstr, ecflags, ecopts);
 | 
			
		||||
    return encoded_dup(newstr, str, encidx);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static VALUE
 | 
			
		||||
encoded_dup(VALUE newstr, VALUE str, int encidx)
 | 
			
		||||
{
 | 
			
		||||
    if (encidx < 0) return rb_str_dup(str);
 | 
			
		||||
    if (newstr == str) {
 | 
			
		||||
	newstr = rb_str_dup(str);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue