mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	* object.c (convert_type): [ruby-core:03845]
* eval.c (rb_funcall_rescue): new function. * object.c (rb_Array): avoid using rb_respond_to(). * object.c (rb_Integer): ditto. * eval.c (get_backtrace): no conversion for nil. * parse.y (reduce_nodes): empty body should return nil. * lib/cgi/session.rb (CGI::Session::initialize): [ruby-core:03832] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7414 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									c56fa330b2
								
							
						
					
					
						commit
						f6348ca0ea
					
				
					 9 changed files with 99 additions and 40 deletions
				
			
		
							
								
								
									
										18
									
								
								ChangeLog
									
										
									
									
									
								
							
							
						
						
									
										18
									
								
								ChangeLog
									
										
									
									
									
								
							|  | @ -1,3 +1,17 @@ | |||
| Mon Nov 29 03:08:30 2004  Yukihiro Matsumoto  <matz@ruby-lang.org> | ||||
| 
 | ||||
| 	* object.c (convert_type): [ruby-core:03845] | ||||
| 
 | ||||
| 	* eval.c (rb_funcall_rescue): new function. | ||||
| 
 | ||||
| 	* object.c (rb_Array): avoid using rb_respond_to(). | ||||
| 
 | ||||
| 	* object.c (rb_Integer): ditto. | ||||
| 
 | ||||
| 	* parse.y (reduce_nodes): empty body should return nil. | ||||
| 
 | ||||
| 	* string.c (rb_str_aset): [ruby-dev:24981] | ||||
| 
 | ||||
| Mon Nov 29 13:57:38 2004  NAKAMURA Usaku  <usa@ruby-lang.org> | ||||
| 
 | ||||
| 	* win32/win32.c (CreateChild): search executable file if no program | ||||
|  | @ -28,6 +42,10 @@ Sat Nov 27 21:43:39 2004  Tanaka Akira  <akr@m17n.org> | |||
| 	  (rb_io_fwrite): wrapper for io_fwrite now. | ||||
| 	  (io_write): call io_fwrite instead of rb_io_fwrite. | ||||
| 
 | ||||
| Sat Nov 27 14:44:15 2004  Kent Sibilev  <ksibilev@bellsouth.net>	 | ||||
| 
 | ||||
| 	* lib/cgi/session.rb (CGI::Session::initialize): [ruby-core:03832] | ||||
| 
 | ||||
| Sat Nov 27 09:41:21 2004  Yukihiro Matsumoto  <matz@ruby-lang.org> | ||||
| 
 | ||||
| 	* io.c (io_fread): old rb_io_fread with file closing checking. | ||||
|  |  | |||
							
								
								
									
										73
									
								
								eval.c
									
										
									
									
									
								
							
							
						
						
									
										73
									
								
								eval.c
									
										
									
									
									
								
							|  | @ -1077,7 +1077,9 @@ get_backtrace(info) | |||
|     VALUE info; | ||||
| { | ||||
|     if (NIL_P(info)) return Qnil; | ||||
|     return rb_check_array_type(rb_funcall(info, rb_intern("backtrace"), 0)); | ||||
|     info = rb_funcall(info, rb_intern("backtrace"), 0); | ||||
|     if (NIL_P(info)) return Qnil; | ||||
|     return rb_check_array_type(info); | ||||
| } | ||||
| 
 | ||||
| static void | ||||
|  | @ -5789,6 +5791,32 @@ rb_f_send(argc, argv, recv) | |||
|     return vid; | ||||
| } | ||||
| 
 | ||||
| static VALUE | ||||
| vafuncall(recv, mid, n, ar) | ||||
|     VALUE recv; | ||||
|     ID mid; | ||||
|     int n; | ||||
|     va_list *ar; | ||||
| { | ||||
|     VALUE *argv; | ||||
| 
 | ||||
|     if (n > 0) { | ||||
| 	long i; | ||||
| 
 | ||||
| 	argv = ALLOCA_N(VALUE, n); | ||||
| 
 | ||||
| 	for (i=0;i<n;i++) { | ||||
| 	    argv[i] = va_arg(*ar, VALUE); | ||||
| 	} | ||||
| 	va_end(*ar); | ||||
|     } | ||||
|     else { | ||||
| 	argv = 0; | ||||
|     } | ||||
| 
 | ||||
|     return rb_call(CLASS_OF(recv), recv, mid, n, argv, 1); | ||||
| } | ||||
| 
 | ||||
| VALUE | ||||
| #ifdef HAVE_STDARG_PROTOTYPES | ||||
| rb_funcall(VALUE recv, ID mid, int n, ...) | ||||
|  | @ -5801,24 +5829,41 @@ rb_funcall(recv, mid, n, va_alist) | |||
| #endif | ||||
| { | ||||
|     va_list ar; | ||||
|     VALUE *argv; | ||||
|     va_init_list(ar, n); | ||||
| 
 | ||||
|     if (n > 0) { | ||||
| 	long i; | ||||
|     return vafuncall(recv, mid, n, &ar); | ||||
| } | ||||
| 
 | ||||
| 	argv = ALLOCA_N(VALUE, n); | ||||
| VALUE | ||||
| #ifdef HAVE_STDARG_PROTOTYPES | ||||
| rb_funcall_rescue(VALUE recv, ID mid, int n, ...) | ||||
| #else | ||||
| rb_funcall_rescue(recv, mid, n, va_alist) | ||||
|     VALUE recv; | ||||
|     ID mid; | ||||
|     int n; | ||||
|     va_dcl | ||||
| #endif | ||||
| { | ||||
|     VALUE result = Qnil;	/* OK */ | ||||
|     int status; | ||||
|     va_list ar; | ||||
| 
 | ||||
| 	va_init_list(ar, n); | ||||
| 	for (i=0;i<n;i++) { | ||||
| 	    argv[i] = va_arg(ar, VALUE); | ||||
| 	} | ||||
| 	va_end(ar); | ||||
|     va_init_list(ar, n); | ||||
| 
 | ||||
|     PUSH_TAG(PROT_NONE); | ||||
|     if ((status = EXEC_TAG()) == 0) { | ||||
| 	result = vafuncall(recv, mid, n, &ar); | ||||
|     } | ||||
|     else { | ||||
| 	argv = 0; | ||||
|     POP_TAG(); | ||||
|     switch (status) { | ||||
|       case 0: | ||||
| 	return result; | ||||
|       case TAG_RAISE: | ||||
| 	return Qundef; | ||||
|       default: | ||||
| 	JUMP_TAG(status); | ||||
|     } | ||||
| 
 | ||||
|     return rb_call(CLASS_OF(recv), recv, mid, n, argv, 1); | ||||
| } | ||||
| 
 | ||||
| VALUE | ||||
|  |  | |||
							
								
								
									
										1
									
								
								intern.h
									
										
									
									
									
								
							
							
						
						
									
										1
									
								
								intern.h
									
										
									
									
									
								
							|  | @ -217,6 +217,7 @@ VALUE rb_thread_main _((void)); | |||
| VALUE rb_thread_local_aref _((VALUE, ID)); | ||||
| VALUE rb_thread_local_aset _((VALUE, ID, VALUE)); | ||||
| void rb_thread_atfork _((void)); | ||||
| VALUE rb_funcall_rescue __((VALUE, ID, int, ...)); | ||||
| /* file.c */ | ||||
| int eaccess _((const char*, int)); | ||||
| VALUE rb_file_s_expand_path _((int, VALUE *)); | ||||
|  |  | |||
|  | @ -246,7 +246,7 @@ class CGI | |||
|       id = option['session_id'] | ||||
|       unless id | ||||
| 	if option['new_session'] | ||||
| 	  id = Session::create_new_id | ||||
| 	  id = create_new_id | ||||
| 	end | ||||
|       end | ||||
|       unless id | ||||
|  | @ -261,7 +261,7 @@ class CGI | |||
| 	  if option.key?('new_session') and not option['new_session'] | ||||
| 	    raise ArgumentError, "session_key `%s' should be supplied"%session_key | ||||
| 	  end | ||||
| 	  id = Session::create_new_id | ||||
| 	  id = create_new_id | ||||
| 	end | ||||
|       end | ||||
|       @session_id = id | ||||
|  |  | |||
|  | @ -90,7 +90,10 @@ class String | |||
|   end | ||||
| 
 | ||||
|   def succ | ||||
|     (str = self.dup).succ! or str | ||||
|     str = self.dup | ||||
|     p [self.object_id, str.object_id] | ||||
|     str.succ! or str | ||||
| #    (str = self.dup).succ! or str | ||||
|   end | ||||
| 
 | ||||
|   private | ||||
|  |  | |||
							
								
								
									
										29
									
								
								object.c
									
										
									
									
									
								
							
							
						
						
									
										29
									
								
								object.c
									
										
									
									
									
								
							|  | @ -2036,10 +2036,9 @@ convert_type(val, tname, method, raise) | |||
|     const char *tname, *method; | ||||
|     int raise; | ||||
| { | ||||
|     ID m; | ||||
|     VALUE result = rb_funcall_rescue(val, rb_intern(method), 0); | ||||
| 
 | ||||
|     m = rb_intern(method); | ||||
|     if (!rb_respond_to(val, m)) { | ||||
|     if (result == Qundef) { | ||||
| 	if (raise) { | ||||
| 	    rb_raise(rb_eTypeError, "cannot convert %s into %s", | ||||
| 		     NIL_P(val) ? "nil" : | ||||
|  | @ -2049,10 +2048,11 @@ convert_type(val, tname, method, raise) | |||
| 		     tname); | ||||
| 	} | ||||
| 	else { | ||||
| 	    ruby_errinfo = Qnil; | ||||
| 	    return Qnil; | ||||
| 	} | ||||
|     } | ||||
|     return rb_funcall(val, m, 0); | ||||
|     return result; | ||||
| } | ||||
| 
 | ||||
| VALUE | ||||
|  | @ -2116,6 +2116,8 @@ VALUE | |||
| rb_Integer(val) | ||||
|     VALUE val; | ||||
| { | ||||
|     VALUE tmp; | ||||
| 
 | ||||
|     switch (TYPE(val)) { | ||||
|       case T_FLOAT: | ||||
| 	if (RFLOAT(val)->value <= (double)FIXNUM_MAX | ||||
|  | @ -2134,10 +2136,11 @@ rb_Integer(val) | |||
|       default: | ||||
| 	break; | ||||
|     } | ||||
|     if (rb_respond_to(val, rb_intern("to_int"))) { | ||||
| 	return rb_to_integer(val, "to_int"); | ||||
|     tmp = convert_type(val, "Integer", "to_int", Qfalse); | ||||
|     if (NIL_P(tmp)) { | ||||
| 	return rb_to_integer(val, "to_i"); | ||||
|     } | ||||
|     return rb_to_integer(val, "to_i"); | ||||
|     return tmp; | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|  | @ -2379,18 +2382,10 @@ rb_Array(val) | |||
|     VALUE val; | ||||
| { | ||||
|     VALUE tmp = rb_check_array_type(val); | ||||
|     ID to_a; | ||||
| 
 | ||||
|     if (NIL_P(tmp)) { | ||||
| 	to_a = rb_intern("to_a"); | ||||
| 	if (rb_respond_to(val, to_a)) { | ||||
| 	    val = rb_funcall(val, to_a, 0); | ||||
| 	    if (TYPE(val) != T_ARRAY) { | ||||
| 		rb_raise(rb_eTypeError, "`to_a' did not return Array"); | ||||
| 	    } | ||||
| 	    return val; | ||||
| 	} | ||||
| 	else { | ||||
| 	tmp = rb_check_convert_type(val, T_ARRAY, "Array", "to_a"); | ||||
| 	if (NIL_P(tmp)) { | ||||
| 	    return rb_ary_new3(1, val); | ||||
| 	} | ||||
|     } | ||||
|  |  | |||
							
								
								
									
										1
									
								
								parse.y
									
										
									
									
									
								
							
							
						
						
									
										1
									
								
								parse.y
									
										
									
									
									
								
							|  | @ -1651,6 +1651,7 @@ primary		: literal | |||
| 		  bodystmt | ||||
| 		  kEND | ||||
| 		    { | ||||
| 			if (!$5) $5 = NEW_NIL(); | ||||
| 			$$ = NEW_DEFN($2, $4, $5, NOEX_PRIVATE); | ||||
| 		        fixpos($$, $4); | ||||
| 		        local_pop(); | ||||
|  |  | |||
							
								
								
									
										3
									
								
								string.c
									
										
									
									
									
								
							
							
						
						
									
										3
									
								
								string.c
									
										
									
									
									
								
							|  | @ -1386,7 +1386,7 @@ rb_str_succ(orig) | |||
|     int c = -1; | ||||
|     long n = 0; | ||||
| 
 | ||||
|     str = rb_str_new5(orig,RSTRING(orig)->ptr, RSTRING(orig)->len); | ||||
|     str = rb_str_new5(orig, RSTRING(orig)->ptr, RSTRING(orig)->len); | ||||
|     OBJ_INFECT(str, orig); | ||||
|     if (RSTRING(str)->len == 0) return str; | ||||
| 
 | ||||
|  | @ -1729,6 +1729,7 @@ rb_str_aset(str, indx, val) | |||
| 	    idx += RSTRING(str)->len; | ||||
| 	} | ||||
| 	if (FIXNUM_P(val)) { | ||||
| 	    rb_str_modify(str); | ||||
| 	    if (RSTRING(str)->len == idx) { | ||||
| 		RSTRING(str)->len += 1; | ||||
| 		RESIZE_CAPA(str, RSTRING(str)->len); | ||||
|  |  | |||
|  | @ -28,11 +28,6 @@ END { | |||
|   puts local_for_end2	# e2 | ||||
| } | ||||
| 
 | ||||
| END { | ||||
|   raise | ||||
|   puts "should not be dumped" | ||||
| } | ||||
| 
 | ||||
| eval <<EOE | ||||
|   BEGIN { | ||||
|     puts "b3" | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 matz
						matz