mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	* array.c (rb_ary_delete): element comparison might change array
size. [ruby-dev:24273] * parse.y: make ruby parser reentrant. merge ripper parser to the real one. this change makes ruby require bison. * file.c (rb_file_truncate): clear stdio buffer before truncating the file. [ruby-dev:24191] * ext/digest/digest.c: use rb_obj_class() instead of CLASS_OF which might return singleton class. [ruby-dev:24202] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6919 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									7b66963f61
								
							
						
					
					
						commit
						e77ddaf0d1
					
				
					 12 changed files with 568 additions and 586 deletions
				
			
		
							
								
								
									
										25
									
								
								ChangeLog
									
										
									
									
									
								
							
							
						
						
									
										25
									
								
								ChangeLog
									
										
									
									
									
								
							|  | @ -1,3 +1,17 @@ | ||||||
|  | Fri Sep 17 17:11:08 2004  Yukihiro Matsumoto  <matz@ruby-lang.org> | ||||||
|  | 
 | ||||||
|  | 	* array.c (rb_ary_delete): element comparison might change array | ||||||
|  | 	  size. [ruby-dev:24273] | ||||||
|  | 
 | ||||||
|  | 	* parse.y: make ruby parser reentrant. merge ripper parser to the | ||||||
|  | 	  real one.  this change makes ruby require bison. | ||||||
|  | 
 | ||||||
|  | 	* file.c (rb_file_truncate): clear stdio buffer before truncating | ||||||
|  | 	  the file.  [ruby-dev:24191] | ||||||
|  | 
 | ||||||
|  | 	* ext/digest/digest.c: use rb_obj_class() instead of CLASS_OF | ||||||
|  | 	  which might return singleton class.  [ruby-dev:24202] | ||||||
|  | 
 | ||||||
| Fri Sep 17 16:07:09 2004  Hidetoshi NAGAI  <nagai@ai.kyutech.ac.jp> | Fri Sep 17 16:07:09 2004  Hidetoshi NAGAI  <nagai@ai.kyutech.ac.jp> | ||||||
| 
 | 
 | ||||||
| 	* ext/tk/lib/multi-tk.rb: improve exit operation | 	* ext/tk/lib/multi-tk.rb: improve exit operation | ||||||
|  | @ -28,6 +42,11 @@ Thu Sep 16 18:12:13 2004  GOTOU Yuuzou  <gotoyuzo@notwork.org> | ||||||
| 	  (WEBrick::HTTPServlet::FileHandler#initialize): should expand | 	  (WEBrick::HTTPServlet::FileHandler#initialize): should expand | ||||||
| 	  the pathname of document root directory. | 	  the pathname of document root directory. | ||||||
| 
 | 
 | ||||||
|  | Thu Sep 16 15:49:28 2004  Yukihiro Matsumoto  <matz@ruby-lang.org> | ||||||
|  | 
 | ||||||
|  | 	* string.c (rb_str_intern): protect string argument from GC. | ||||||
|  | 	  [ruby-core:03411] | ||||||
|  | 
 | ||||||
| Wed Sep 15 20:22:23 2004  Hidetoshi NAGAI  <nagai@ai.kyutech.ac.jp> | Wed Sep 15 20:22:23 2004  Hidetoshi NAGAI  <nagai@ai.kyutech.ac.jp> | ||||||
| 
 | 
 | ||||||
| 	* ext/tk/sample/tkoptdb-safeTk.rb: fix a bug depend on the changes | 	* ext/tk/sample/tkoptdb-safeTk.rb: fix a bug depend on the changes | ||||||
|  | @ -321,6 +340,12 @@ Tue Sep  7 12:48:22 2004  NAKAMURA Usaku  <usa@ruby-lang.org> | ||||||
| 	* ext/socket/socket.c (wait_connectable, ruby_connect): support | 	* ext/socket/socket.c (wait_connectable, ruby_connect): support | ||||||
| 	  nonblocking connect on various platforms. | 	  nonblocking connect on various platforms. | ||||||
| 
 | 
 | ||||||
|  | Mon Sep  6 11:00:47 2004  Yukihiro Matsumoto  <matz@ruby-lang.org> | ||||||
|  | 
 | ||||||
|  | 	* dir.c (dir_s_chdir): the patch to shut up false warning when | ||||||
|  | 	  exception occurred within a block.  a patch was given from Johan | ||||||
|  | 	  Holmberg <holmberg@iar.se>.  [ruby-core:03292] | ||||||
|  | 
 | ||||||
| Mon Sep  6 10:57:40 2004  Hirokazu Yamamoto  <ocean@m2.ccsnet.ne.jp> | Mon Sep  6 10:57:40 2004  Hirokazu Yamamoto  <ocean@m2.ccsnet.ne.jp> | ||||||
| 
 | 
 | ||||||
| 	* ext/tk/lib/tk/menu.rb(TkOptionMenubutton#insert): call correct method | 	* ext/tk/lib/tk/menu.rb(TkOptionMenubutton#insert): call correct method | ||||||
|  |  | ||||||
							
								
								
									
										39
									
								
								array.c
									
										
									
									
									
								
							
							
						
						
									
										39
									
								
								array.c
									
										
									
									
									
								
							|  | @ -1923,7 +1923,8 @@ rb_ary_delete(ary, item) | ||||||
| 	return Qnil; | 	return Qnil; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     RARRAY(ary)->len = i2; |     if (RARRAY(ary)->len > i2) | ||||||
|  | 	RARRAY(ary)->len = i2; | ||||||
|     if (i2 * 2 < RARRAY(ary)->aux.capa && |     if (i2 * 2 < RARRAY(ary)->aux.capa && | ||||||
| 	    RARRAY(ary)->aux.capa > ARY_DEFAULT_SIZE) { | 	    RARRAY(ary)->aux.capa > ARY_DEFAULT_SIZE) { | ||||||
| 	REALLOC_N(RARRAY(ary)->ptr, VALUE, i2 * 2); | 	REALLOC_N(RARRAY(ary)->ptr, VALUE, i2 * 2); | ||||||
|  | @ -2467,17 +2468,15 @@ VALUE | ||||||
| rb_ary_assoc(ary, key) | rb_ary_assoc(ary, key) | ||||||
|     VALUE ary, key; |     VALUE ary, key; | ||||||
| { | { | ||||||
|     VALUE *p, *pend; |     long i; | ||||||
|  |     VALUE v; | ||||||
| 
 | 
 | ||||||
|     p = RARRAY(ary)->ptr; |     for (i = 0; i < RARRAY(ary)->len; ++i) { | ||||||
|     pend = p + RARRAY(ary)->len; | 	v = RARRAY(ary)->ptr[i]; | ||||||
|      | 	if (TYPE(v) == T_ARRAY && | ||||||
|     while (p < pend) { | 	    RARRAY(v)->len > 0 && | ||||||
| 	if (TYPE(*p) == T_ARRAY && | 	    rb_equal(RARRAY(v)->ptr[0], key)) | ||||||
| 		RARRAY(*p)->len > 0 && | 	    return v; | ||||||
| 		rb_equal(RARRAY(*p)->ptr[0], key)) |  | ||||||
| 	    return *p; |  | ||||||
| 	p++; |  | ||||||
|     } |     } | ||||||
|     return Qnil; |     return Qnil; | ||||||
| } | } | ||||||
|  | @ -2500,17 +2499,15 @@ VALUE | ||||||
| rb_ary_rassoc(ary, value) | rb_ary_rassoc(ary, value) | ||||||
|     VALUE ary, value; |     VALUE ary, value; | ||||||
| { | { | ||||||
|     VALUE *p, *pend; |     long i; | ||||||
|  |     VALUE v; | ||||||
| 
 | 
 | ||||||
|     p = RARRAY(ary)->ptr; |     for (i = 0; i < RARRAY(ary)->len; ++i) { | ||||||
|     pend = p + RARRAY(ary)->len; | 	v = RARRAY(ary)->ptr[i]; | ||||||
| 
 | 	if (TYPE(v) == T_ARRAY && | ||||||
|     while (p < pend) { | 	    RARRAY(v)->len > 1 && | ||||||
| 	if (TYPE(*p) == T_ARRAY | 	    rb_equal(RARRAY(v)->ptr[1], value)) | ||||||
| 	    && RARRAY(*p)->len > 1 | 	    return v; | ||||||
| 	    && rb_equal(RARRAY(*p)->ptr[1], value)) |  | ||||||
| 	    return *p; |  | ||||||
| 	p++; |  | ||||||
|     } |     } | ||||||
|     return Qnil; |     return Qnil; | ||||||
| } | } | ||||||
|  |  | ||||||
							
								
								
									
										22
									
								
								dir.c
									
										
									
									
									
								
							
							
						
						
									
										22
									
								
								dir.c
									
										
									
									
									
								
							|  | @ -1,4 +1,3 @@ | ||||||
| 
 |  | ||||||
| /**********************************************************************
 | /**********************************************************************
 | ||||||
| 
 | 
 | ||||||
|   dir.c - |   dir.c - | ||||||
|  | @ -687,6 +686,19 @@ dir_chdir(path) | ||||||
| static int chdir_blocking = 0; | static int chdir_blocking = 0; | ||||||
| static VALUE chdir_thread = Qnil; | static VALUE chdir_thread = Qnil; | ||||||
| 
 | 
 | ||||||
|  | struct chdir_data { | ||||||
|  |     char *dist; | ||||||
|  |     VALUE path; | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | static VALUE | ||||||
|  | chdir_yield(args) | ||||||
|  |     struct chdir_data *args; | ||||||
|  | { | ||||||
|  |     dir_chdir(args->dist); | ||||||
|  |     return rb_yield(args->path); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| static VALUE | static VALUE | ||||||
| chdir_restore(path) | chdir_restore(path) | ||||||
|     char *path; |     char *path; | ||||||
|  | @ -695,7 +707,6 @@ chdir_restore(path) | ||||||
|     if (chdir_blocking == 0) |     if (chdir_blocking == 0) | ||||||
| 	chdir_thread = Qnil; | 	chdir_thread = Qnil; | ||||||
|     dir_chdir(path); |     dir_chdir(path); | ||||||
|     free(path); |  | ||||||
|     return Qnil; |     return Qnil; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -767,11 +778,14 @@ dir_s_chdir(argc, argv, obj) | ||||||
| 
 | 
 | ||||||
|     if (rb_block_given_p()) { |     if (rb_block_given_p()) { | ||||||
| 	char *cwd = my_getcwd(); | 	char *cwd = my_getcwd(); | ||||||
|  | 	struct chdir_data args; | ||||||
|  | 
 | ||||||
| 	chdir_blocking++; | 	chdir_blocking++; | ||||||
| 	if (chdir_thread == Qnil) | 	if (chdir_thread == Qnil) | ||||||
| 	    chdir_thread = rb_thread_current(); | 	    chdir_thread = rb_thread_current(); | ||||||
| 	dir_chdir(dist); | 	args.dist = dist; | ||||||
| 	return rb_ensure(rb_yield, path, chdir_restore, (VALUE)cwd); | 	args.path = path; | ||||||
|  | 	return rb_ensure(chdir_yield, (VALUE)&args, chdir_restore, (VALUE)cwd); | ||||||
|     } |     } | ||||||
|     dir_chdir(dist); |     dir_chdir(dist); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -149,8 +149,8 @@ rb_digest_base_copy(copy, obj) | ||||||
| 
 | 
 | ||||||
|     if (copy == obj) return copy; |     if (copy == obj) return copy; | ||||||
|     rb_check_frozen(copy); |     rb_check_frozen(copy); | ||||||
|     algo = get_digest_base_metadata(CLASS_OF(copy)); |     algo = get_digest_base_metadata(rb_obj_class(copy)); | ||||||
|     if (algo != get_digest_base_metadata(CLASS_OF(obj))) { |     if (algo != get_digest_base_metadata(rb_obj_class(obj))) { | ||||||
| 	rb_raise(rb_eTypeError, "wrong argument class"); | 	rb_raise(rb_eTypeError, "wrong argument class"); | ||||||
|     } |     } | ||||||
|     Data_Get_Struct(obj, void, pctx1); |     Data_Get_Struct(obj, void, pctx1); | ||||||
|  | @ -168,7 +168,7 @@ rb_digest_base_update(self, str) | ||||||
|     void *pctx; |     void *pctx; | ||||||
| 
 | 
 | ||||||
|     StringValue(str); |     StringValue(str); | ||||||
|     algo = get_digest_base_metadata(CLASS_OF(self)); |     algo = get_digest_base_metadata(rb_obj_class(self)); | ||||||
|     Data_Get_Struct(self, void, pctx); |     Data_Get_Struct(self, void, pctx); | ||||||
| 
 | 
 | ||||||
|     algo->update_func(pctx, RSTRING(str)->ptr, RSTRING(str)->len); |     algo->update_func(pctx, RSTRING(str)->ptr, RSTRING(str)->len); | ||||||
|  | @ -201,7 +201,7 @@ rb_digest_base_digest(self) | ||||||
|     size_t len; |     size_t len; | ||||||
|     VALUE str; |     VALUE str; | ||||||
| 
 | 
 | ||||||
|     algo = get_digest_base_metadata(CLASS_OF(self)); |     algo = get_digest_base_metadata(rb_obj_class(self)); | ||||||
|     Data_Get_Struct(self, void, pctx1); |     Data_Get_Struct(self, void, pctx1); | ||||||
| 
 | 
 | ||||||
|     len = algo->ctx_size; |     len = algo->ctx_size; | ||||||
|  | @ -232,7 +232,7 @@ rb_digest_base_hexdigest(self) | ||||||
|     size_t len; |     size_t len; | ||||||
|     VALUE str; |     VALUE str; | ||||||
| 
 | 
 | ||||||
|     algo = get_digest_base_metadata(CLASS_OF(self)); |     algo = get_digest_base_metadata(rb_obj_class(self)); | ||||||
|     Data_Get_Struct(self, void, pctx1); |     Data_Get_Struct(self, void, pctx1); | ||||||
| 
 | 
 | ||||||
|     len = algo->ctx_size; |     len = algo->ctx_size; | ||||||
|  | @ -261,10 +261,10 @@ rb_digest_base_equal(self, other) | ||||||
|     VALUE klass; |     VALUE klass; | ||||||
|     VALUE str1, str2; |     VALUE str1, str2; | ||||||
| 
 | 
 | ||||||
|     klass = CLASS_OF(self); |     klass = rb_obj_class(self); | ||||||
|     algo = get_digest_base_metadata(klass); |     algo = get_digest_base_metadata(klass); | ||||||
| 
 | 
 | ||||||
|     if (CLASS_OF(other) == klass) { |     if (rb_obj_class(other) == klass) { | ||||||
| 	void *pctx1, *pctx2; | 	void *pctx1, *pctx2; | ||||||
| 
 | 
 | ||||||
| 	Data_Get_Struct(self, void, pctx1); | 	Data_Get_Struct(self, void, pctx1); | ||||||
|  |  | ||||||
|  | @ -22,7 +22,6 @@ void | ||||||
| Init_sha1() | Init_sha1() | ||||||
| { | { | ||||||
|     VALUE mDigest, cDigest_Base, cDigest_SHA1; |     VALUE mDigest, cDigest_Base, cDigest_SHA1; | ||||||
|     ID id_metadata; |  | ||||||
| 
 | 
 | ||||||
|     rb_require("digest.so"); |     rb_require("digest.so"); | ||||||
| 
 | 
 | ||||||
|  | @ -31,8 +30,6 @@ Init_sha1() | ||||||
| 
 | 
 | ||||||
|     cDigest_SHA1 = rb_define_class_under(mDigest, "SHA1", cDigest_Base); |     cDigest_SHA1 = rb_define_class_under(mDigest, "SHA1", cDigest_Base); | ||||||
| 
 | 
 | ||||||
|     id_metadata = rb_intern("metadata"); |     rb_cvar_set(cDigest_SHA1, rb_intern("metadata"), | ||||||
| 
 |  | ||||||
|     rb_cvar_set(cDigest_SHA1, id_metadata, |  | ||||||
| 		Data_Wrap_Struct(rb_cObject, 0, 0, &sha1), Qtrue); | 		Data_Wrap_Struct(rb_cObject, 0, 0, &sha1), Qtrue); | ||||||
| } | } | ||||||
|  |  | ||||||
							
								
								
									
										7
									
								
								file.c
									
										
									
									
									
								
							
							
						
						
									
										7
									
								
								file.c
									
										
									
									
									
								
							|  | @ -2965,18 +2965,21 @@ rb_file_truncate(obj, len) | ||||||
|     VALUE obj, len; |     VALUE obj, len; | ||||||
| { | { | ||||||
|     OpenFile *fptr; |     OpenFile *fptr; | ||||||
|  |     FILE *f; | ||||||
| 
 | 
 | ||||||
|     rb_secure(2); |     rb_secure(2); | ||||||
|     GetOpenFile(obj, fptr); |     GetOpenFile(obj, fptr); | ||||||
|     if (!(fptr->mode & FMODE_WRITABLE)) { |     if (!(fptr->mode & FMODE_WRITABLE)) { | ||||||
| 	rb_raise(rb_eIOError, "not opened for writing"); | 	rb_raise(rb_eIOError, "not opened for writing"); | ||||||
|     } |     } | ||||||
|  |     f = GetWriteFile(fptr); | ||||||
|  |     fflush(f); | ||||||
| #ifdef HAVE_TRUNCATE | #ifdef HAVE_TRUNCATE | ||||||
|     if (ftruncate(fileno(fptr->f), NUM2OFFT(len)) < 0) |     if (ftruncate(fileno(f), NUM2OFFT(len)) < 0) | ||||||
| 	rb_sys_fail(fptr->path); | 	rb_sys_fail(fptr->path); | ||||||
| #else | #else | ||||||
| # ifdef HAVE_CHSIZE | # ifdef HAVE_CHSIZE | ||||||
|     if (chsize(fileno(fptr->f), NUM2OFFT(len)) < 0) |     if (chsize(fileno(f), NUM2OFFT(len)) < 0) | ||||||
| 	rb_sys_fail(fptr->path); | 	rb_sys_fail(fptr->path); | ||||||
| # else | # else | ||||||
|     rb_notimplement(); |     rb_notimplement(); | ||||||
|  |  | ||||||
							
								
								
									
										1
									
								
								intern.h
									
										
									
									
									
								
							
							
						
						
									
										1
									
								
								intern.h
									
										
									
									
									
								
							|  | @ -325,7 +325,6 @@ double rb_str_to_dbl _((VALUE, int)); | ||||||
| /* parse.y */ | /* parse.y */ | ||||||
| RUBY_EXTERN int   ruby_sourceline; | RUBY_EXTERN int   ruby_sourceline; | ||||||
| RUBY_EXTERN char *ruby_sourcefile; | RUBY_EXTERN char *ruby_sourcefile; | ||||||
| int ruby_yyparse _((void)); |  | ||||||
| ID rb_id_attrset _((ID)); | ID rb_id_attrset _((ID)); | ||||||
| void rb_parser_append_print _((void)); | void rb_parser_append_print _((void)); | ||||||
| void rb_parser_while_loop _((int, int)); | void rb_parser_while_loop _((int, int)); | ||||||
|  |  | ||||||
|  | @ -458,5 +458,42 @@ class CGI | ||||||
| 	GLOBAL_HASH_TABLE.delete(@session_id) | 	GLOBAL_HASH_TABLE.delete(@session_id) | ||||||
|       end |       end | ||||||
|     end |     end | ||||||
|  | 
 | ||||||
|  |     # Dummy session storage class. | ||||||
|  |     # | ||||||
|  |     # Implements session storage place holder.  No actual storage | ||||||
|  |     # will be done. | ||||||
|  |     class NullStore | ||||||
|  |       # Create a new NullStore instance. | ||||||
|  |       # | ||||||
|  |       # +session+ is the session this instance is associated with. | ||||||
|  |       # +option+ is a list of initialisation options.  None are | ||||||
|  |       # currently recognised. | ||||||
|  |       def initialize(session, option=nil) | ||||||
|  |       end | ||||||
|  | 
 | ||||||
|  |       # Restore (empty) session state. | ||||||
|  |       def restore | ||||||
|  |         {} | ||||||
|  |       end | ||||||
|  | 
 | ||||||
|  |       # Update session state. | ||||||
|  |       # | ||||||
|  |       # A no-op. | ||||||
|  |       def update | ||||||
|  |       end | ||||||
|  | 
 | ||||||
|  |       # Close session storage. | ||||||
|  |       # | ||||||
|  |       # A no-op. | ||||||
|  |       def close | ||||||
|  |       end | ||||||
|  | 
 | ||||||
|  |       # Delete the session state. | ||||||
|  |       # | ||||||
|  |       # A no-op. | ||||||
|  |       def delete | ||||||
|  |       end | ||||||
|  |     end | ||||||
|   end |   end | ||||||
| end | end | ||||||
|  |  | ||||||
|  | @ -475,7 +475,7 @@ def checking_for(m) | ||||||
|   r |   r | ||||||
| end | end | ||||||
| 
 | 
 | ||||||
| def have_library(lib, func = nil, &b) | def have_library(lib, func = nil, header=nil, &b) | ||||||
|   func = "main" if !func or func.empty? |   func = "main" if !func or func.empty? | ||||||
|   lib = with_config(lib+'lib', lib) |   lib = with_config(lib+'lib', lib) | ||||||
|   checking_for "#{func}() in #{LIBARG%lib}" do |   checking_for "#{func}() in #{LIBARG%lib}" do | ||||||
|  | @ -483,7 +483,7 @@ def have_library(lib, func = nil, &b) | ||||||
|       true |       true | ||||||
|     else |     else | ||||||
|       libs = append_library($libs, lib) |       libs = append_library($libs, lib) | ||||||
|       if try_func(func, libs, &b) |       if try_func(func, libs, header, &b) | ||||||
|         $libs = libs |         $libs = libs | ||||||
|         true |         true | ||||||
|       else |       else | ||||||
|  |  | ||||||
							
								
								
									
										5
									
								
								string.c
									
										
									
									
									
								
							
							
						
						
									
										5
									
								
								string.c
									
										
									
									
									
								
							|  | @ -4352,9 +4352,10 @@ rb_str_crypt(str, salt) | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| VALUE | VALUE | ||||||
| rb_str_intern(str) | rb_str_intern(s) | ||||||
|     VALUE str; |     VALUE s; | ||||||
| { | { | ||||||
|  |     volatile VALUE str = s; | ||||||
|     ID id; |     ID id; | ||||||
| 
 | 
 | ||||||
|     if (!RSTRING(str)->ptr || RSTRING(str)->len == 0) { |     if (!RSTRING(str)->ptr || RSTRING(str)->len == 0) { | ||||||
|  |  | ||||||
|  | @ -89,7 +89,7 @@ class TestDigest < Test::Unit::TestCase | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
| 
 | 
 | ||||||
|   def test_instance_eval # [ruby-dev:24202] |   def test_instance_eval | ||||||
|     assert_nothing_raised { |     assert_nothing_raised { | ||||||
|       Digest::SHA1.new.instance_eval { update "a" } |       Digest::SHA1.new.instance_eval { update "a" } | ||||||
|     } |     } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 matz
						matz