mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	* complex.c: inpsect should not depend on to_s.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20546 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									8c07972702
								
							
						
					
					
						commit
						2d3f41d19f
					
				
					 2 changed files with 14 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -1,3 +1,7 @@
 | 
			
		|||
Fri Dec  5 21:42:44 2008  Tadayoshi Funaba  <tadf@dotrb.org>
 | 
			
		||||
 | 
			
		||||
	* complex.c: inpsect should not depend on to_s.
 | 
			
		||||
 | 
			
		||||
Fri Dec  5 19:06:04 2008  Tanaka Akira  <akr@fsij.org>
 | 
			
		||||
 | 
			
		||||
	* lib/open3.rb (Open3.pipeline_start): new method.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										14
									
								
								complex.c
									
										
									
									
									
								
							
							
						
						
									
										14
									
								
								complex.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -910,7 +910,7 @@ f_tpositive_p(VALUE x)
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
static VALUE
 | 
			
		||||
nucomp_to_s(VALUE self)
 | 
			
		||||
nucomp_format(VALUE self, VALUE (*func)(VALUE))
 | 
			
		||||
{
 | 
			
		||||
    VALUE s, impos;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -918,10 +918,10 @@ nucomp_to_s(VALUE self)
 | 
			
		|||
 | 
			
		||||
    impos = f_tpositive_p(dat->imag);
 | 
			
		||||
 | 
			
		||||
    s = f_to_s(dat->real);
 | 
			
		||||
    s = (*func)(dat->real);
 | 
			
		||||
    rb_str_cat2(s, !impos ? "-" : "+");
 | 
			
		||||
 | 
			
		||||
    rb_str_concat(s, f_to_s(f_abs(dat->imag)));
 | 
			
		||||
    rb_str_concat(s, (*func)(f_abs(dat->imag)));
 | 
			
		||||
    if (!rb_isdigit(RSTRING_PTR(s)[RSTRING_LEN(s) - 1]))
 | 
			
		||||
	rb_str_cat2(s, "*");
 | 
			
		||||
    rb_str_cat2(s, "i");
 | 
			
		||||
| 
						 | 
				
			
			@ -929,13 +929,19 @@ nucomp_to_s(VALUE self)
 | 
			
		|||
    return s;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static VALUE
 | 
			
		||||
nucomp_to_s(VALUE self)
 | 
			
		||||
{
 | 
			
		||||
    return nucomp_format(self, f_to_s);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static VALUE
 | 
			
		||||
nucomp_inspect(VALUE self)
 | 
			
		||||
{
 | 
			
		||||
    VALUE s;
 | 
			
		||||
 | 
			
		||||
    s = rb_str_new2("(");
 | 
			
		||||
    rb_str_concat(s, nucomp_to_s(self));
 | 
			
		||||
    rb_str_concat(s, nucomp_format(self, f_inspect));
 | 
			
		||||
    rb_str_cat2(s, ")");
 | 
			
		||||
 | 
			
		||||
    return s;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue