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>
 | 
			
		||||
 | 
			
		||||
	* 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
 | 
			
		||||
	  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>
 | 
			
		||||
 | 
			
		||||
	* 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
 | 
			
		||||
	  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>
 | 
			
		||||
 | 
			
		||||
	* 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;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    RARRAY(ary)->len = i2;
 | 
			
		||||
    if (RARRAY(ary)->len > i2)
 | 
			
		||||
	RARRAY(ary)->len = i2;
 | 
			
		||||
    if (i2 * 2 < RARRAY(ary)->aux.capa &&
 | 
			
		||||
	    RARRAY(ary)->aux.capa > ARY_DEFAULT_SIZE) {
 | 
			
		||||
	REALLOC_N(RARRAY(ary)->ptr, VALUE, i2 * 2);
 | 
			
		||||
| 
						 | 
				
			
			@ -2467,17 +2468,15 @@ VALUE
 | 
			
		|||
rb_ary_assoc(ary, key)
 | 
			
		||||
    VALUE ary, key;
 | 
			
		||||
{
 | 
			
		||||
    VALUE *p, *pend;
 | 
			
		||||
    long i;
 | 
			
		||||
    VALUE v;
 | 
			
		||||
 | 
			
		||||
    p = RARRAY(ary)->ptr;
 | 
			
		||||
    pend = p + RARRAY(ary)->len;
 | 
			
		||||
    
 | 
			
		||||
    while (p < pend) {
 | 
			
		||||
	if (TYPE(*p) == T_ARRAY &&
 | 
			
		||||
		RARRAY(*p)->len > 0 &&
 | 
			
		||||
		rb_equal(RARRAY(*p)->ptr[0], key))
 | 
			
		||||
	    return *p;
 | 
			
		||||
	p++;
 | 
			
		||||
    for (i = 0; i < RARRAY(ary)->len; ++i) {
 | 
			
		||||
	v = RARRAY(ary)->ptr[i];
 | 
			
		||||
	if (TYPE(v) == T_ARRAY &&
 | 
			
		||||
	    RARRAY(v)->len > 0 &&
 | 
			
		||||
	    rb_equal(RARRAY(v)->ptr[0], key))
 | 
			
		||||
	    return v;
 | 
			
		||||
    }
 | 
			
		||||
    return Qnil;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -2500,17 +2499,15 @@ VALUE
 | 
			
		|||
rb_ary_rassoc(ary, value)
 | 
			
		||||
    VALUE ary, value;
 | 
			
		||||
{
 | 
			
		||||
    VALUE *p, *pend;
 | 
			
		||||
    long i;
 | 
			
		||||
    VALUE v;
 | 
			
		||||
 | 
			
		||||
    p = RARRAY(ary)->ptr;
 | 
			
		||||
    pend = p + RARRAY(ary)->len;
 | 
			
		||||
 | 
			
		||||
    while (p < pend) {
 | 
			
		||||
	if (TYPE(*p) == T_ARRAY
 | 
			
		||||
	    && RARRAY(*p)->len > 1
 | 
			
		||||
	    && rb_equal(RARRAY(*p)->ptr[1], value))
 | 
			
		||||
	    return *p;
 | 
			
		||||
	p++;
 | 
			
		||||
    for (i = 0; i < RARRAY(ary)->len; ++i) {
 | 
			
		||||
	v = RARRAY(ary)->ptr[i];
 | 
			
		||||
	if (TYPE(v) == T_ARRAY &&
 | 
			
		||||
	    RARRAY(v)->len > 1 &&
 | 
			
		||||
	    rb_equal(RARRAY(v)->ptr[1], value))
 | 
			
		||||
	    return v;
 | 
			
		||||
    }
 | 
			
		||||
    return Qnil;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										22
									
								
								dir.c
									
										
									
									
									
								
							
							
						
						
									
										22
									
								
								dir.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -1,4 +1,3 @@
 | 
			
		|||
 | 
			
		||||
/**********************************************************************
 | 
			
		||||
 | 
			
		||||
  dir.c -
 | 
			
		||||
| 
						 | 
				
			
			@ -687,6 +686,19 @@ dir_chdir(path)
 | 
			
		|||
static int chdir_blocking = 0;
 | 
			
		||||
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
 | 
			
		||||
chdir_restore(path)
 | 
			
		||||
    char *path;
 | 
			
		||||
| 
						 | 
				
			
			@ -695,7 +707,6 @@ chdir_restore(path)
 | 
			
		|||
    if (chdir_blocking == 0)
 | 
			
		||||
	chdir_thread = Qnil;
 | 
			
		||||
    dir_chdir(path);
 | 
			
		||||
    free(path);
 | 
			
		||||
    return Qnil;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -767,11 +778,14 @@ dir_s_chdir(argc, argv, obj)
 | 
			
		|||
 | 
			
		||||
    if (rb_block_given_p()) {
 | 
			
		||||
	char *cwd = my_getcwd();
 | 
			
		||||
	struct chdir_data args;
 | 
			
		||||
 | 
			
		||||
	chdir_blocking++;
 | 
			
		||||
	if (chdir_thread == Qnil)
 | 
			
		||||
	    chdir_thread = rb_thread_current();
 | 
			
		||||
	dir_chdir(dist);
 | 
			
		||||
	return rb_ensure(rb_yield, path, chdir_restore, (VALUE)cwd);
 | 
			
		||||
	args.dist = dist;
 | 
			
		||||
	args.path = path;
 | 
			
		||||
	return rb_ensure(chdir_yield, (VALUE)&args, chdir_restore, (VALUE)cwd);
 | 
			
		||||
    }
 | 
			
		||||
    dir_chdir(dist);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -149,8 +149,8 @@ rb_digest_base_copy(copy, obj)
 | 
			
		|||
 | 
			
		||||
    if (copy == obj) return copy;
 | 
			
		||||
    rb_check_frozen(copy);
 | 
			
		||||
    algo = get_digest_base_metadata(CLASS_OF(copy));
 | 
			
		||||
    if (algo != get_digest_base_metadata(CLASS_OF(obj))) {
 | 
			
		||||
    algo = get_digest_base_metadata(rb_obj_class(copy));
 | 
			
		||||
    if (algo != get_digest_base_metadata(rb_obj_class(obj))) {
 | 
			
		||||
	rb_raise(rb_eTypeError, "wrong argument class");
 | 
			
		||||
    }
 | 
			
		||||
    Data_Get_Struct(obj, void, pctx1);
 | 
			
		||||
| 
						 | 
				
			
			@ -168,7 +168,7 @@ rb_digest_base_update(self, str)
 | 
			
		|||
    void *pctx;
 | 
			
		||||
 | 
			
		||||
    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);
 | 
			
		||||
 | 
			
		||||
    algo->update_func(pctx, RSTRING(str)->ptr, RSTRING(str)->len);
 | 
			
		||||
| 
						 | 
				
			
			@ -201,7 +201,7 @@ rb_digest_base_digest(self)
 | 
			
		|||
    size_t len;
 | 
			
		||||
    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);
 | 
			
		||||
 | 
			
		||||
    len = algo->ctx_size;
 | 
			
		||||
| 
						 | 
				
			
			@ -232,7 +232,7 @@ rb_digest_base_hexdigest(self)
 | 
			
		|||
    size_t len;
 | 
			
		||||
    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);
 | 
			
		||||
 | 
			
		||||
    len = algo->ctx_size;
 | 
			
		||||
| 
						 | 
				
			
			@ -261,10 +261,10 @@ rb_digest_base_equal(self, other)
 | 
			
		|||
    VALUE klass;
 | 
			
		||||
    VALUE str1, str2;
 | 
			
		||||
 | 
			
		||||
    klass = CLASS_OF(self);
 | 
			
		||||
    klass = rb_obj_class(self);
 | 
			
		||||
    algo = get_digest_base_metadata(klass);
 | 
			
		||||
 | 
			
		||||
    if (CLASS_OF(other) == klass) {
 | 
			
		||||
    if (rb_obj_class(other) == klass) {
 | 
			
		||||
	void *pctx1, *pctx2;
 | 
			
		||||
 | 
			
		||||
	Data_Get_Struct(self, void, pctx1);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -22,7 +22,6 @@ void
 | 
			
		|||
Init_sha1()
 | 
			
		||||
{
 | 
			
		||||
    VALUE mDigest, cDigest_Base, cDigest_SHA1;
 | 
			
		||||
    ID id_metadata;
 | 
			
		||||
 | 
			
		||||
    rb_require("digest.so");
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -31,8 +30,6 @@ Init_sha1()
 | 
			
		|||
 | 
			
		||||
    cDigest_SHA1 = rb_define_class_under(mDigest, "SHA1", cDigest_Base);
 | 
			
		||||
 | 
			
		||||
    id_metadata = rb_intern("metadata");
 | 
			
		||||
 | 
			
		||||
    rb_cvar_set(cDigest_SHA1, id_metadata,
 | 
			
		||||
    rb_cvar_set(cDigest_SHA1, rb_intern("metadata"),
 | 
			
		||||
		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;
 | 
			
		||||
{
 | 
			
		||||
    OpenFile *fptr;
 | 
			
		||||
    FILE *f;
 | 
			
		||||
 | 
			
		||||
    rb_secure(2);
 | 
			
		||||
    GetOpenFile(obj, fptr);
 | 
			
		||||
    if (!(fptr->mode & FMODE_WRITABLE)) {
 | 
			
		||||
	rb_raise(rb_eIOError, "not opened for writing");
 | 
			
		||||
    }
 | 
			
		||||
    f = GetWriteFile(fptr);
 | 
			
		||||
    fflush(f);
 | 
			
		||||
#ifdef HAVE_TRUNCATE
 | 
			
		||||
    if (ftruncate(fileno(fptr->f), NUM2OFFT(len)) < 0)
 | 
			
		||||
    if (ftruncate(fileno(f), NUM2OFFT(len)) < 0)
 | 
			
		||||
	rb_sys_fail(fptr->path);
 | 
			
		||||
#else
 | 
			
		||||
# ifdef HAVE_CHSIZE
 | 
			
		||||
    if (chsize(fileno(fptr->f), NUM2OFFT(len)) < 0)
 | 
			
		||||
    if (chsize(fileno(f), NUM2OFFT(len)) < 0)
 | 
			
		||||
	rb_sys_fail(fptr->path);
 | 
			
		||||
# else
 | 
			
		||||
    rb_notimplement();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										1
									
								
								intern.h
									
										
									
									
									
								
							
							
						
						
									
										1
									
								
								intern.h
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -325,7 +325,6 @@ double rb_str_to_dbl _((VALUE, int));
 | 
			
		|||
/* parse.y */
 | 
			
		||||
RUBY_EXTERN int   ruby_sourceline;
 | 
			
		||||
RUBY_EXTERN char *ruby_sourcefile;
 | 
			
		||||
int ruby_yyparse _((void));
 | 
			
		||||
ID rb_id_attrset _((ID));
 | 
			
		||||
void rb_parser_append_print _((void));
 | 
			
		||||
void rb_parser_while_loop _((int, int));
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -458,5 +458,42 @@ class CGI
 | 
			
		|||
	GLOBAL_HASH_TABLE.delete(@session_id)
 | 
			
		||||
      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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -475,7 +475,7 @@ def checking_for(m)
 | 
			
		|||
  r
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
def have_library(lib, func = nil, &b)
 | 
			
		||||
def have_library(lib, func = nil, header=nil, &b)
 | 
			
		||||
  func = "main" if !func or func.empty?
 | 
			
		||||
  lib = with_config(lib+'lib', lib)
 | 
			
		||||
  checking_for "#{func}() in #{LIBARG%lib}" do
 | 
			
		||||
| 
						 | 
				
			
			@ -483,7 +483,7 @@ def have_library(lib, func = nil, &b)
 | 
			
		|||
      true
 | 
			
		||||
    else
 | 
			
		||||
      libs = append_library($libs, lib)
 | 
			
		||||
      if try_func(func, libs, &b)
 | 
			
		||||
      if try_func(func, libs, header, &b)
 | 
			
		||||
        $libs = libs
 | 
			
		||||
        true
 | 
			
		||||
      else
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										5
									
								
								string.c
									
										
									
									
									
								
							
							
						
						
									
										5
									
								
								string.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -4352,9 +4352,10 @@ rb_str_crypt(str, salt)
 | 
			
		|||
 */
 | 
			
		||||
 | 
			
		||||
VALUE
 | 
			
		||||
rb_str_intern(str)
 | 
			
		||||
    VALUE str;
 | 
			
		||||
rb_str_intern(s)
 | 
			
		||||
    VALUE s;
 | 
			
		||||
{
 | 
			
		||||
    volatile VALUE str = s;
 | 
			
		||||
    ID id;
 | 
			
		||||
 | 
			
		||||
    if (!RSTRING(str)->ptr || RSTRING(str)->len == 0) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -89,7 +89,7 @@ class TestDigest < Test::Unit::TestCase
 | 
			
		|||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_instance_eval # [ruby-dev:24202]
 | 
			
		||||
  def test_instance_eval
 | 
			
		||||
    assert_nothing_raised {
 | 
			
		||||
      Digest::SHA1.new.instance_eval { update "a" }
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue