mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	2000-02-25
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@627 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									e13f96f413
								
							
						
					
					
						commit
						7ed66b9e1d
					
				
					 10 changed files with 114 additions and 80 deletions
				
			
		| 
						 | 
					@ -1,3 +1,12 @@
 | 
				
			||||||
 | 
					Fri Feb 25 12:50:20 2000  Yukihiro Matsumoto  <matz@netlab.co.jp>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						* eval.c (rb_thread_start_timer): interval made 10ms from 50ms.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Thu Feb 24 16:53:47 2000  Yukihiro Matsumoto  <matz@netlab.co.jp>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						* eval.c (rb_thread_schedule): priority check for sleep expired
 | 
				
			||||||
 | 
						  threads needed.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Wed Feb 23 14:22:32 2000  Yukihiro Matsumoto  <matz@netlab.co.jp>
 | 
					Wed Feb 23 14:22:32 2000  Yukihiro Matsumoto  <matz@netlab.co.jp>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	* array.c (rb_ary_join): forgot to initialize a local variable
 | 
						* array.c (rb_ary_join): forgot to initialize a local variable
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										1
									
								
								ToDo
									
										
									
									
									
								
							
							
						
						
									
										1
									
								
								ToDo
									
										
									
									
									
								
							| 
						 | 
					@ -66,6 +66,7 @@ Standard Libraries
 | 
				
			||||||
* String#{pred,prev}, String#downto
 | 
					* String#{pred,prev}, String#downto
 | 
				
			||||||
* optional stepsize argument for succ()
 | 
					* optional stepsize argument for succ()
 | 
				
			||||||
* performance tune for String's non-bang methods.
 | 
					* performance tune for String's non-bang methods.
 | 
				
			||||||
 | 
					* Ruby module -- Ruby::Version, Ruby::Interpreter
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Extension Libraries
 | 
					Extension Libraries
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										3
									
								
								class.c
									
										
									
									
									
								
							
							
						
						
									
										3
									
								
								class.c
									
										
									
									
									
								
							| 
						 | 
					@ -605,6 +605,8 @@ rb_scan_args(argc, argv, fmt, va_alist)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    va_init_list(vargs, fmt);
 | 
					    va_init_list(vargs, fmt);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (*p == '*') goto rest_arg;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (ISDIGIT(*p)) {
 | 
					    if (ISDIGIT(*p)) {
 | 
				
			||||||
	n = *p - '0';
 | 
						n = *p - '0';
 | 
				
			||||||
	if (n > argc)
 | 
						if (n > argc)
 | 
				
			||||||
| 
						 | 
					@ -634,6 +636,7 @@ rb_scan_args(argc, argv, fmt, va_alist)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if(*p == '*') {
 | 
					    if(*p == '*') {
 | 
				
			||||||
 | 
					      rest_arg:
 | 
				
			||||||
	var = va_arg(vargs, VALUE*);
 | 
						var = va_arg(vargs, VALUE*);
 | 
				
			||||||
	if (argc > i) {
 | 
						if (argc > i) {
 | 
				
			||||||
	    if (var) *var = rb_ary_new4(argc-i, argv+i);
 | 
						    if (var) *var = rb_ary_new4(argc-i, argv+i);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										5
									
								
								eval.c
									
										
									
									
									
								
							
							
						
						
									
										5
									
								
								eval.c
									
										
									
									
									
								
							| 
						 | 
					@ -6603,7 +6603,8 @@ rb_thread_schedule()
 | 
				
			||||||
			    th->wait_for &= ~WAIT_TIME;
 | 
								    th->wait_for &= ~WAIT_TIME;
 | 
				
			||||||
			    th->status = THREAD_RUNNABLE;
 | 
								    th->status = THREAD_RUNNABLE;
 | 
				
			||||||
			    num_waiting_on_timer--;
 | 
								    num_waiting_on_timer--;
 | 
				
			||||||
			    next = th;
 | 
								    if (!next || next->priority < th->priority)
 | 
				
			||||||
 | 
									next = th;
 | 
				
			||||||
			} else if (th->delay < delay) {
 | 
								} else if (th->delay < delay) {
 | 
				
			||||||
			    delay = th->delay;
 | 
								    delay = th->delay;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
| 
						 | 
					@ -7216,7 +7217,7 @@ rb_thread_start_timer()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!thread_init) return;
 | 
					    if (!thread_init) return;
 | 
				
			||||||
    tval.it_interval.tv_sec = 0;
 | 
					    tval.it_interval.tv_sec = 0;
 | 
				
			||||||
    tval.it_interval.tv_usec = 50000;
 | 
					    tval.it_interval.tv_usec = 10000;
 | 
				
			||||||
    tval.it_value = tval.it_interval;
 | 
					    tval.it_value = tval.it_interval;
 | 
				
			||||||
    setitimer(ITIMER_VIRTUAL, &tval, NULL);
 | 
					    setitimer(ITIMER_VIRTUAL, &tval, NULL);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										16
									
								
								hash.c
									
										
									
									
									
								
							
							
						
						
									
										16
									
								
								hash.c
									
										
									
									
									
								
							| 
						 | 
					@ -89,23 +89,7 @@ rb_any_hash(a)
 | 
				
			||||||
	break;
 | 
						break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      case T_STRING:
 | 
					      case T_STRING:
 | 
				
			||||||
#if 0
 | 
					 | 
				
			||||||
	hval = rb_str_hash(a);
 | 
						hval = rb_str_hash(a);
 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
	    register const char *p = RSTRING(a)->ptr;
 | 
					 | 
				
			||||||
	    register int len = RSTRING(a)->len;
 | 
					 | 
				
			||||||
	    register unsigned int h = 0, g;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	    while (len--) {
 | 
					 | 
				
			||||||
		h = ( h << 4 ) + *p++;
 | 
					 | 
				
			||||||
		if ( g = h & 0xF0000000 )
 | 
					 | 
				
			||||||
		    h ^= g >> 24;
 | 
					 | 
				
			||||||
		h &= ~g;
 | 
					 | 
				
			||||||
	    }
 | 
					 | 
				
			||||||
	    hval = h;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
	break;
 | 
						break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      default:
 | 
					      default:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -9,25 +9,25 @@ class Mail
 | 
				
			||||||
    @header = {}
 | 
					    @header = {}
 | 
				
			||||||
    @body = []
 | 
					    @body = []
 | 
				
			||||||
    begin
 | 
					    begin
 | 
				
			||||||
      while f.gets()
 | 
					      while line = f.gets()
 | 
				
			||||||
	$_.chop!
 | 
						line.chop!
 | 
				
			||||||
	next if /^From /	# skip From-line
 | 
						next if /^From /=~line	# skip From-line
 | 
				
			||||||
	break if /^$/		# end of header
 | 
						break if /^$/=~line	# end of header
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if /^(\S+):\s*(.*)/
 | 
						if /^(\S+):\s*(.*)/=~line
 | 
				
			||||||
	  (attr = $1).capitalize!
 | 
						  (attr = $1).capitalize!
 | 
				
			||||||
	  @header[attr] = $2
 | 
						  @header[attr] = $2
 | 
				
			||||||
	elsif attr
 | 
						elsif attr
 | 
				
			||||||
	  sub!(/^\s*/, '')
 | 
						  line.sub!(/^\s*/, '')
 | 
				
			||||||
	  @header[attr] += "\n" + $_
 | 
						  @header[attr] += "\n" + line
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
      return unless $_
 | 
					      return unless line
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      while f.gets()
 | 
					      while line = f.gets()
 | 
				
			||||||
	break if /^From /
 | 
						break if /^From /=~line
 | 
				
			||||||
	@body.push($_)
 | 
						@body.push(line)
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
    ensure
 | 
					    ensure
 | 
				
			||||||
      f.close if opened
 | 
					      f.close if opened
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -43,13 +43,12 @@ end
 | 
				
			||||||
if $0 == __FILE__
 | 
					if $0 == __FILE__
 | 
				
			||||||
  a = Open3.popen3("nroff -man")
 | 
					  a = Open3.popen3("nroff -man")
 | 
				
			||||||
  Thread.start do
 | 
					  Thread.start do
 | 
				
			||||||
    while gets
 | 
					    while line = gets
 | 
				
			||||||
      a[0].print $_
 | 
					      a[0].print line
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
    a[0].close
 | 
					    a[0].close
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
  while a[1].gets
 | 
					  while line = a[1].gets
 | 
				
			||||||
    print ":", $_
 | 
					    print ":", line
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										72
									
								
								st.c
									
										
									
									
									
								
							
							
						
						
									
										72
									
								
								st.c
									
										
									
									
									
								
							| 
						 | 
					@ -62,7 +62,7 @@ static void rehash();
 | 
				
			||||||
#define EQUAL(table, x, y) ((*table->type->compare)(x, y) == 0)
 | 
					#define EQUAL(table, x, y) ((*table->type->compare)(x, y) == 0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define do_hash(key, table) (unsigned int)(*(table)->type->hash)((key))
 | 
					#define do_hash(key, table) (unsigned int)(*(table)->type->hash)((key))
 | 
				
			||||||
#define do_hash_bin(key, table) (do_hash(key, table)%(table)->num_bins)
 | 
					#define do_hash_bin(key, table) (do_hash(key, table)&(table)->num_bins)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * MINSIZE is the minimum size of a dictionary.
 | 
					 * MINSIZE is the minimum size of a dictionary.
 | 
				
			||||||
| 
						 | 
					@ -112,6 +112,11 @@ new_size(size)
 | 
				
			||||||
    int i, newsize;
 | 
					    int i, newsize;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if 1
 | 
					#if 1
 | 
				
			||||||
 | 
					    for (i=3; i<31; i++) {
 | 
				
			||||||
 | 
						if ((1<<i) > size) return 1<<i;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    return -1;
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
    for (i = 0, newsize = MINSIZE;
 | 
					    for (i = 0, newsize = MINSIZE;
 | 
				
			||||||
	 i < sizeof(primes)/sizeof(primes[0]);
 | 
						 i < sizeof(primes)/sizeof(primes[0]);
 | 
				
			||||||
	 i++, newsize <<= 1)
 | 
						 i++, newsize <<= 1)
 | 
				
			||||||
| 
						 | 
					@ -120,14 +125,10 @@ new_size(size)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    /* Ran out of polynomials */
 | 
					    /* Ran out of polynomials */
 | 
				
			||||||
    return -1;			/* should raise exception */
 | 
					    return -1;			/* should raise exception */
 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
    for (i=3; i<31; i++) {
 | 
					 | 
				
			||||||
	if ((1<<i) > size) return 1<<i;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    return -1;
 | 
					 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef HASH_LOG
 | 
				
			||||||
static int collision = 0;
 | 
					static int collision = 0;
 | 
				
			||||||
static int init_st = 0;
 | 
					static int init_st = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -138,6 +139,7 @@ stat_col()
 | 
				
			||||||
    fprintf(f, "collision: %d\n", collision);
 | 
					    fprintf(f, "collision: %d\n", collision);
 | 
				
			||||||
    fclose(f);
 | 
					    fclose(f);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
st_table*
 | 
					st_table*
 | 
				
			||||||
st_init_table_with_size(type, size)
 | 
					st_init_table_with_size(type, size)
 | 
				
			||||||
| 
						 | 
					@ -146,7 +148,7 @@ st_init_table_with_size(type, size)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    st_table *tbl;
 | 
					    st_table *tbl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if 0
 | 
					#ifdef HASH_LOG
 | 
				
			||||||
    if (init_st == 0) {
 | 
					    if (init_st == 0) {
 | 
				
			||||||
	init_st = 1;
 | 
						init_st = 1;
 | 
				
			||||||
	atexit(stat_col);
 | 
						atexit(stat_col);
 | 
				
			||||||
| 
						 | 
					@ -158,7 +160,7 @@ st_init_table_with_size(type, size)
 | 
				
			||||||
    tbl = alloc(st_table);
 | 
					    tbl = alloc(st_table);
 | 
				
			||||||
    tbl->type = type;
 | 
					    tbl->type = type;
 | 
				
			||||||
    tbl->num_entries = 0;
 | 
					    tbl->num_entries = 0;
 | 
				
			||||||
    tbl->num_bins = size;
 | 
					    tbl->num_bins = size-1;
 | 
				
			||||||
    tbl->bins = (st_table_entry **)Calloc(size, sizeof(st_table_entry*));
 | 
					    tbl->bins = (st_table_entry **)Calloc(size, sizeof(st_table_entry*));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return tbl;
 | 
					    return tbl;
 | 
				
			||||||
| 
						 | 
					@ -204,7 +206,7 @@ st_free_table(table)
 | 
				
			||||||
    register st_table_entry *ptr, *next;
 | 
					    register st_table_entry *ptr, *next;
 | 
				
			||||||
    int i;
 | 
					    int i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for(i = 0; i < table->num_bins; i++) {
 | 
					    for(i = 0; i <= table->num_bins; i++) {
 | 
				
			||||||
	ptr = table->bins[i];
 | 
						ptr = table->bins[i];
 | 
				
			||||||
	while (ptr != 0) {
 | 
						while (ptr != 0) {
 | 
				
			||||||
	    next = ptr->next;
 | 
						    next = ptr->next;
 | 
				
			||||||
| 
						 | 
					@ -219,11 +221,17 @@ st_free_table(table)
 | 
				
			||||||
#define PTR_NOT_EQUAL(table, ptr, hash_val, key) \
 | 
					#define PTR_NOT_EQUAL(table, ptr, hash_val, key) \
 | 
				
			||||||
((ptr) != 0 && (ptr->hash != (hash_val) || !EQUAL((table), (key), (ptr)->key)))
 | 
					((ptr) != 0 && (ptr->hash != (hash_val) || !EQUAL((table), (key), (ptr)->key)))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef HASH_LOG
 | 
				
			||||||
 | 
					#define COLLISION collision++
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					#define COLLISION
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define FIND_ENTRY(table, ptr, hash_val, bin_pos) \
 | 
					#define FIND_ENTRY(table, ptr, hash_val, bin_pos) \
 | 
				
			||||||
bin_pos = hash_val%(table)->num_bins;\
 | 
					bin_pos = hash_val&(table)->num_bins;\
 | 
				
			||||||
ptr = (table)->bins[bin_pos];\
 | 
					ptr = (table)->bins[bin_pos];\
 | 
				
			||||||
if (PTR_NOT_EQUAL(table, ptr, hash_val, key)) {\
 | 
					if (PTR_NOT_EQUAL(table, ptr, hash_val, key)) {\
 | 
				
			||||||
    collision++;\
 | 
					    COLLISION;\
 | 
				
			||||||
    while (PTR_NOT_EQUAL(table, ptr->next, hash_val, key)) {\
 | 
					    while (PTR_NOT_EQUAL(table, ptr->next, hash_val, key)) {\
 | 
				
			||||||
	ptr = ptr->next;\
 | 
						ptr = ptr->next;\
 | 
				
			||||||
    }\
 | 
					    }\
 | 
				
			||||||
| 
						 | 
					@ -253,9 +261,9 @@ st_lookup(table, key, value)
 | 
				
			||||||
#define ADD_DIRECT(table, key, value, hash_val, bin_pos)\
 | 
					#define ADD_DIRECT(table, key, value, hash_val, bin_pos)\
 | 
				
			||||||
{\
 | 
					{\
 | 
				
			||||||
    st_table_entry *entry;\
 | 
					    st_table_entry *entry;\
 | 
				
			||||||
    if (table->num_entries/table->num_bins > ST_DEFAULT_MAX_DENSITY) {\
 | 
					    if (table->num_entries/(table->num_bins+1) > ST_DEFAULT_MAX_DENSITY) {\
 | 
				
			||||||
	rehash(table);\
 | 
						rehash(table);\
 | 
				
			||||||
        bin_pos = hash_val % table->num_bins;\
 | 
					        bin_pos = hash_val & table->num_bins;\
 | 
				
			||||||
    }\
 | 
					    }\
 | 
				
			||||||
    \
 | 
					    \
 | 
				
			||||||
    entry = alloc(st_table_entry);\
 | 
					    entry = alloc(st_table_entry);\
 | 
				
			||||||
| 
						 | 
					@ -298,7 +306,7 @@ st_add_direct(table, key, value)
 | 
				
			||||||
    unsigned int hash_val, bin_pos;
 | 
					    unsigned int hash_val, bin_pos;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    hash_val = do_hash(key, table);
 | 
					    hash_val = do_hash(key, table);
 | 
				
			||||||
    bin_pos = hash_val % table->num_bins;
 | 
					    bin_pos = hash_val & table->num_bins;
 | 
				
			||||||
    ADD_DIRECT(table, key, value, hash_val, bin_pos);
 | 
					    ADD_DIRECT(table, key, value, hash_val, bin_pos);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -310,14 +318,15 @@ rehash(table)
 | 
				
			||||||
    int i, old_num_bins = table->num_bins, new_num_bins;
 | 
					    int i, old_num_bins = table->num_bins, new_num_bins;
 | 
				
			||||||
    unsigned int hash_val;
 | 
					    unsigned int hash_val;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    new_num_bins = new_size(old_num_bins);
 | 
					    new_num_bins = new_size(old_num_bins+1);
 | 
				
			||||||
    new_bins = (st_table_entry**)Calloc(new_num_bins, sizeof(st_table_entry*));
 | 
					    new_bins = (st_table_entry**)Calloc(new_num_bins, sizeof(st_table_entry*));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for(i = 0; i < old_num_bins; i++) {
 | 
					    new_num_bins--;
 | 
				
			||||||
 | 
					    for(i = 0; i <= old_num_bins; i++) {
 | 
				
			||||||
	ptr = table->bins[i];
 | 
						ptr = table->bins[i];
 | 
				
			||||||
	while (ptr != 0) {
 | 
						while (ptr != 0) {
 | 
				
			||||||
	    next = ptr->next;
 | 
						    next = ptr->next;
 | 
				
			||||||
	    hash_val = ptr->hash % new_num_bins;
 | 
						    hash_val = ptr->hash & new_num_bins;
 | 
				
			||||||
	    ptr->next = new_bins[hash_val];
 | 
						    ptr->next = new_bins[hash_val];
 | 
				
			||||||
	    new_bins[hash_val] = ptr;
 | 
						    new_bins[hash_val] = ptr;
 | 
				
			||||||
	    ptr = next;
 | 
						    ptr = next;
 | 
				
			||||||
| 
						 | 
					@ -334,7 +343,7 @@ st_copy(old_table)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    st_table *new_table;
 | 
					    st_table *new_table;
 | 
				
			||||||
    st_table_entry *ptr, *entry;
 | 
					    st_table_entry *ptr, *entry;
 | 
				
			||||||
    int i, num_bins = old_table->num_bins;
 | 
					    int i, num_bins = old_table->num_bins+1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    new_table = alloc(st_table);
 | 
					    new_table = alloc(st_table);
 | 
				
			||||||
    if (new_table == 0) {
 | 
					    if (new_table == 0) {
 | 
				
			||||||
| 
						 | 
					@ -471,7 +480,7 @@ st_foreach(table, func, arg)
 | 
				
			||||||
    enum st_retval retval;
 | 
					    enum st_retval retval;
 | 
				
			||||||
    int i;
 | 
					    int i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for(i = 0; i < table->num_bins; i++) {
 | 
					    for(i = 0; i <= table->num_bins; i++) {
 | 
				
			||||||
	last = 0;
 | 
						last = 0;
 | 
				
			||||||
	for(ptr = table->bins[i]; ptr != 0;) {
 | 
						for(ptr = table->bins[i]; ptr != 0;) {
 | 
				
			||||||
	    retval = (*func)(ptr->key, ptr->record, arg);
 | 
						    retval = (*func)(ptr->key, ptr->record, arg);
 | 
				
			||||||
| 
						 | 
					@ -501,14 +510,35 @@ static int
 | 
				
			||||||
strhash(string)
 | 
					strhash(string)
 | 
				
			||||||
    register char *string;
 | 
					    register char *string;
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    register int val = 0;
 | 
					 | 
				
			||||||
    register int c;
 | 
					    register int c;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef HASH_ELFHASH
 | 
				
			||||||
 | 
					    register unsigned int h = 0, g;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    while ((c = *string++) != '\0') {
 | 
				
			||||||
 | 
						h = ( h << 4 ) + c;
 | 
				
			||||||
 | 
						if ( g = h & 0xF0000000 )
 | 
				
			||||||
 | 
						    h ^= g >> 24;
 | 
				
			||||||
 | 
						h &= ~g;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    return h;
 | 
				
			||||||
 | 
					#elif HASH_PERL
 | 
				
			||||||
 | 
					    register int val = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    while ((c = *string++) != '\0') {
 | 
				
			||||||
 | 
						val = val*33 + c;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return val + (val>>5);
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					    register int val = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    while ((c = *string++) != '\0') {
 | 
					    while ((c = *string++) != '\0') {
 | 
				
			||||||
	val = val*997 + c;
 | 
						val = val*997 + c;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return val;
 | 
					    return val + (val>>5);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int
 | 
					static int
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										53
									
								
								string.c
									
										
									
									
									
								
							
							
						
						
									
										53
									
								
								string.c
									
										
									
									
									
								
							| 
						 | 
					@ -421,7 +421,29 @@ rb_str_hash(str)
 | 
				
			||||||
    register char *p = RSTRING(str)->ptr;
 | 
					    register char *p = RSTRING(str)->ptr;
 | 
				
			||||||
    register int key = 0;
 | 
					    register int key = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if 0
 | 
					#ifdef HASH_ELFHASH
 | 
				
			||||||
 | 
					    register unsigned int g;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    while (len--) {
 | 
				
			||||||
 | 
						key = (key << 4) + *p++;
 | 
				
			||||||
 | 
						if (g = key & 0xF0000000)
 | 
				
			||||||
 | 
						    key ^= g >> 24;
 | 
				
			||||||
 | 
						key &= ~g;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					#elif HASH_PERL
 | 
				
			||||||
 | 
					    if (ruby_ignorecase) {
 | 
				
			||||||
 | 
						while (len--) {
 | 
				
			||||||
 | 
						    key = key*33 + toupper(*p);
 | 
				
			||||||
 | 
						    p++;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    else {
 | 
				
			||||||
 | 
						while (len--) {
 | 
				
			||||||
 | 
						    key = key*33 + *p++;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    key = key + (key>>5);
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
    if (ruby_ignorecase) {
 | 
					    if (ruby_ignorecase) {
 | 
				
			||||||
	while (len--) {
 | 
						while (len--) {
 | 
				
			||||||
	    key = key*65599 + toupper(*p);
 | 
						    key = key*65599 + toupper(*p);
 | 
				
			||||||
| 
						 | 
					@ -434,18 +456,6 @@ rb_str_hash(str)
 | 
				
			||||||
	    p++;
 | 
						    p++;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
    if (ruby_ignorecase) {
 | 
					 | 
				
			||||||
	while (len--) {
 | 
					 | 
				
			||||||
	    key = key*33 + toupper(*p);
 | 
					 | 
				
			||||||
	    p++;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    else {
 | 
					 | 
				
			||||||
	while (len--) {
 | 
					 | 
				
			||||||
	    key = key*33 + *p++;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    key = key + (key>>5);
 | 
					    key = key + (key>>5);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
    return key;
 | 
					    return key;
 | 
				
			||||||
| 
						 | 
					@ -943,16 +953,13 @@ rb_str_aset_m(argc, argv, str)
 | 
				
			||||||
    VALUE *argv;
 | 
					    VALUE *argv;
 | 
				
			||||||
    VALUE str;
 | 
					    VALUE str;
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    VALUE arg1, arg2, arg3;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    rb_str_modify(str);
 | 
					    rb_str_modify(str);
 | 
				
			||||||
 | 
					    if (argc == 3) {
 | 
				
			||||||
    if (rb_scan_args(argc, argv, "21", &arg1, &arg2, &arg3) == 3) {
 | 
					 | 
				
			||||||
	int beg, len;
 | 
						int beg, len;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (TYPE(arg3) != T_STRING) arg3 = rb_str_to_str(arg3);
 | 
						if (TYPE(argv[2]) != T_STRING) argv[2] = rb_str_to_str(argv[2]);
 | 
				
			||||||
	beg = NUM2INT(arg1);
 | 
						beg = NUM2INT(argv[0]);
 | 
				
			||||||
	len = NUM2INT(arg2);
 | 
						len = NUM2INT(argv[1]);
 | 
				
			||||||
	if (len < 0) rb_raise(rb_eIndexError, "negative length %d", len);
 | 
						if (len < 0) rb_raise(rb_eIndexError, "negative length %d", len);
 | 
				
			||||||
	if (beg < 0) {
 | 
						if (beg < 0) {
 | 
				
			||||||
	    beg += RSTRING(str)->len;
 | 
						    beg += RSTRING(str)->len;
 | 
				
			||||||
| 
						 | 
					@ -966,10 +973,10 @@ rb_str_aset_m(argc, argv, str)
 | 
				
			||||||
	if (beg + len > RSTRING(str)->len) {
 | 
						if (beg + len > RSTRING(str)->len) {
 | 
				
			||||||
	    len = RSTRING(str)->len - beg;
 | 
						    len = RSTRING(str)->len - beg;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	rb_str_replace(str, beg, len, arg3);
 | 
						rb_str_replace(str, beg, len, argv[2]);
 | 
				
			||||||
	return arg3;
 | 
						return argv[2];
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return rb_str_aset(str, arg1, arg2);
 | 
					    return rb_str_aset(str, argv[0], argv[1]);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static VALUE
 | 
					static VALUE
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,4 @@
 | 
				
			||||||
#define RUBY_VERSION "1.5.2"
 | 
					#define RUBY_VERSION "1.5.2"
 | 
				
			||||||
#define RUBY_RELEASE_DATE "2000-02-23"
 | 
					#define RUBY_RELEASE_DATE "2000-02-25"
 | 
				
			||||||
#define RUBY_VERSION_CODE 152
 | 
					#define RUBY_VERSION_CODE 152
 | 
				
			||||||
#define RUBY_RELEASE_CODE 20000223
 | 
					#define RUBY_RELEASE_CODE 20000225
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue