2000-01-05 07:41:21 +03:00
|
|
|
/* This is a public domain general purpose hash table package written by Peter Moore @ UCB. */
|
1998-01-16 15:13:05 +03:00
|
|
|
|
2002-05-29 09:20:39 +04:00
|
|
|
/* static char sccsid[] = "@(#) st.c 5.1 89/12/14 Crucible"; */
|
1998-01-16 15:13:05 +03:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include <stdio.h>
|
2005-10-21 13:00:02 +04:00
|
|
|
#ifdef HAVE_STDLIB_H
|
2002-03-22 10:26:42 +03:00
|
|
|
#include <stdlib.h>
|
1999-08-13 09:45:20 +04:00
|
|
|
#endif
|
2005-10-21 13:00:02 +04:00
|
|
|
#include <string.h>
|
1999-08-13 09:45:20 +04:00
|
|
|
|
* ascii.c, euc_jp.c, hash.c, oniggnu.h, oniguruma.h, regcomp.c, regenc.c, regenc.h, regerror.c, regexec.c, reggnu.c, regint.h, regparse.c, regparse.h, sjis.c, st.c, st.h, utf8.c: imported Oni Guruma 3.5.4.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7846 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-01-28 18:21:48 +03:00
|
|
|
#ifdef NOT_RUBY
|
|
|
|
#include "regint.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "st.h"
|
|
|
|
|
1999-01-20 07:59:39 +03:00
|
|
|
typedef struct st_table_entry st_table_entry;
|
|
|
|
|
|
|
|
struct st_table_entry {
|
|
|
|
unsigned int hash;
|
* st.h, st.c: Introduce new conventional typedef's, st_data_t,
st_compare_func_t, st_hash_func_t and st_each_func_t.
* st.h, st.c: Do explicit function declarations and do not rely on
implicit declarations. On such platforms as IA64, int argument
values are NOT automatically promoted to long (64bit) values, so
explicit declarations are mandatory for those functions that
take long values or pointers. This fixes miniruby's coredump on
FreeBSD/IA64.
* class.c, eval.c, gc.c, hash.c, marshal.c, parse.y, variable.c:
Add proper casts to avoid warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3303 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-01-06 18:55:43 +03:00
|
|
|
st_data_t key;
|
|
|
|
st_data_t record;
|
1999-01-20 07:59:39 +03:00
|
|
|
st_table_entry *next;
|
|
|
|
};
|
|
|
|
|
1998-01-16 15:13:05 +03:00
|
|
|
#define ST_DEFAULT_MAX_DENSITY 5
|
|
|
|
#define ST_DEFAULT_INIT_TABLE_SIZE 11
|
|
|
|
|
|
|
|
/*
|
|
|
|
* DEFAULT_MAX_DENSITY is the default for the largest we allow the
|
|
|
|
* average number of items per bin before increasing the number of
|
|
|
|
* bins
|
|
|
|
*
|
|
|
|
* DEFAULT_INIT_TABLE_SIZE is the default for the number of bins
|
|
|
|
* allocated initially
|
|
|
|
*
|
|
|
|
*/
|
* ascii.c, euc_jp.c, hash.c, oniggnu.h, oniguruma.h, regcomp.c, regenc.c, regenc.h, regerror.c, regexec.c, reggnu.c, regint.h, regparse.c, regparse.h, sjis.c, st.c, st.h, utf8.c: imported Oni Guruma 3.5.4.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7846 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-01-28 18:21:48 +03:00
|
|
|
|
* st.h, st.c: Introduce new conventional typedef's, st_data_t,
st_compare_func_t, st_hash_func_t and st_each_func_t.
* st.h, st.c: Do explicit function declarations and do not rely on
implicit declarations. On such platforms as IA64, int argument
values are NOT automatically promoted to long (64bit) values, so
explicit declarations are mandatory for those functions that
take long values or pointers. This fixes miniruby's coredump on
FreeBSD/IA64.
* class.c, eval.c, gc.c, hash.c, marshal.c, parse.y, variable.c:
Add proper casts to avoid warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3303 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-01-06 18:55:43 +03:00
|
|
|
static int numcmp(long, long);
|
|
|
|
static int numhash(long);
|
1998-01-16 15:13:05 +03:00
|
|
|
static struct st_hash_type type_numhash = {
|
|
|
|
numcmp,
|
|
|
|
numhash,
|
|
|
|
};
|
|
|
|
|
* st.h, st.c: Introduce new conventional typedef's, st_data_t,
st_compare_func_t, st_hash_func_t and st_each_func_t.
* st.h, st.c: Do explicit function declarations and do not rely on
implicit declarations. On such platforms as IA64, int argument
values are NOT automatically promoted to long (64bit) values, so
explicit declarations are mandatory for those functions that
take long values or pointers. This fixes miniruby's coredump on
FreeBSD/IA64.
* class.c, eval.c, gc.c, hash.c, marshal.c, parse.y, variable.c:
Add proper casts to avoid warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3303 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-01-06 18:55:43 +03:00
|
|
|
/* extern int strcmp(const char *, const char *); */
|
|
|
|
static int strhash(const char *);
|
1998-01-16 15:13:05 +03:00
|
|
|
static struct st_hash_type type_strhash = {
|
2003-01-09 07:28:28 +03:00
|
|
|
strcmp,
|
|
|
|
strhash,
|
* ascii.c, euc_jp.c, hash.c, oniggnu.h, oniguruma.h, regcomp.c, regenc.c, regenc.h, regerror.c, regexec.c, reggnu.c, regint.h, regparse.c, regparse.h, sjis.c, st.c, st.h, utf8.c: imported Oni Guruma 3.5.4.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7846 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-01-28 18:21:48 +03:00
|
|
|
};
|
2000-05-16 06:46:57 +04:00
|
|
|
|
* st.h, st.c: Introduce new conventional typedef's, st_data_t,
st_compare_func_t, st_hash_func_t and st_each_func_t.
* st.h, st.c: Do explicit function declarations and do not rely on
implicit declarations. On such platforms as IA64, int argument
values are NOT automatically promoted to long (64bit) values, so
explicit declarations are mandatory for those functions that
take long values or pointers. This fixes miniruby's coredump on
FreeBSD/IA64.
* class.c, eval.c, gc.c, hash.c, marshal.c, parse.y, variable.c:
Add proper casts to avoid warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3303 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-01-06 18:55:43 +03:00
|
|
|
static void rehash(st_table *);
|
1998-01-16 15:13:05 +03:00
|
|
|
|
2005-12-19 17:10:36 +03:00
|
|
|
#define alloc(type) (type*)malloc((size_t)sizeof(type))
|
|
|
|
#define Calloc(n,s) (char*)calloc((n),(s))
|
1998-01-16 15:13:05 +03:00
|
|
|
|
2000-12-12 10:42:35 +03:00
|
|
|
#define EQUAL(table,x,y) ((x)==(y) || (*table->type->compare)((x),(y)) == 0)
|
1998-01-16 15:13:05 +03:00
|
|
|
|
2000-12-12 10:42:35 +03:00
|
|
|
#define do_hash(key,table) (unsigned int)(*(table)->type->hash)((key))
|
2001-06-22 13:12:24 +04:00
|
|
|
#define do_hash_bin(key,table) (do_hash(key, table)%(table)->num_bins)
|
1999-01-20 07:59:39 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* MINSIZE is the minimum size of a dictionary.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define MINSIZE 8
|
|
|
|
|
|
|
|
/*
|
|
|
|
Table of prime numbers 2^n+a, 2<=n<=30.
|
|
|
|
*/
|
|
|
|
static long primes[] = {
|
|
|
|
8 + 3,
|
|
|
|
16 + 3,
|
|
|
|
32 + 5,
|
|
|
|
64 + 3,
|
|
|
|
128 + 3,
|
1999-10-13 10:44:42 +04:00
|
|
|
256 + 27,
|
|
|
|
512 + 9,
|
1999-01-20 07:59:39 +03:00
|
|
|
1024 + 9,
|
|
|
|
2048 + 5,
|
2002-01-16 12:25:59 +03:00
|
|
|
4096 + 3,
|
1999-01-20 07:59:39 +03:00
|
|
|
8192 + 27,
|
|
|
|
16384 + 43,
|
|
|
|
32768 + 3,
|
|
|
|
65536 + 45,
|
2002-01-16 12:25:59 +03:00
|
|
|
131072 + 29,
|
|
|
|
262144 + 3,
|
|
|
|
524288 + 21,
|
|
|
|
1048576 + 7,
|
|
|
|
2097152 + 17,
|
|
|
|
4194304 + 15,
|
|
|
|
8388608 + 9,
|
|
|
|
16777216 + 43,
|
|
|
|
33554432 + 35,
|
|
|
|
67108864 + 15,
|
|
|
|
134217728 + 29,
|
|
|
|
268435456 + 3,
|
|
|
|
536870912 + 11,
|
|
|
|
1073741824 + 85,
|
1999-01-20 07:59:39 +03:00
|
|
|
0
|
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 14:44:21 +04:00
|
|
|
new_size(int size)
|
1999-01-20 07:59:39 +03:00
|
|
|
{
|
2001-05-16 13:05:54 +04:00
|
|
|
int i;
|
1999-01-20 07:59:39 +03:00
|
|
|
|
2001-06-22 13:12:24 +04:00
|
|
|
#if 0
|
2000-02-25 06:51:23 +03:00
|
|
|
for (i=3; i<31; i++) {
|
|
|
|
if ((1<<i) > size) return 1<<i;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
#else
|
2001-06-22 13:12:24 +04:00
|
|
|
int newsize;
|
|
|
|
|
1999-01-20 07:59:39 +03:00
|
|
|
for (i = 0, newsize = MINSIZE;
|
* ascii.c, euc_jp.c, hash.c, oniggnu.h, oniguruma.h, regcomp.c, regenc.c, regenc.h, regerror.c, regexec.c, reggnu.c, regint.h, regparse.c, regparse.h, sjis.c, st.c, st.h, utf8.c: imported Oni Guruma 3.5.4.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7846 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-01-28 18:21:48 +03:00
|
|
|
i < (int )(sizeof(primes)/sizeof(primes[0]));
|
1999-01-20 07:59:39 +03:00
|
|
|
i++, newsize <<= 1)
|
|
|
|
{
|
|
|
|
if (newsize > size) return primes[i];
|
|
|
|
}
|
|
|
|
/* Ran out of polynomials */
|
|
|
|
return -1; /* should raise exception */
|
2000-02-23 08:23:12 +03:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2000-02-25 06:51:23 +03:00
|
|
|
#ifdef HASH_LOG
|
2000-02-23 08:23:12 +03:00
|
|
|
static int collision = 0;
|
|
|
|
static int init_st = 0;
|
|
|
|
|
|
|
|
static void
|
|
|
|
stat_col()
|
|
|
|
{
|
|
|
|
FILE *f = fopen("/tmp/col", "w");
|
|
|
|
fprintf(f, "collision: %d\n", collision);
|
|
|
|
fclose(f);
|
1999-01-20 07:59:39 +03:00
|
|
|
}
|
2000-02-25 06:51:23 +03:00
|
|
|
#endif
|
1998-01-16 15:13:05 +03:00
|
|
|
|
|
|
|
st_table*
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 14:44:21 +04:00
|
|
|
st_init_table_with_size(struct st_hash_type *type, int size)
|
1998-01-16 15:13:05 +03:00
|
|
|
{
|
|
|
|
st_table *tbl;
|
|
|
|
|
2000-02-25 06:51:23 +03:00
|
|
|
#ifdef HASH_LOG
|
2000-02-23 08:23:12 +03:00
|
|
|
if (init_st == 0) {
|
|
|
|
init_st = 1;
|
|
|
|
atexit(stat_col);
|
|
|
|
}
|
2000-02-23 08:43:57 +03:00
|
|
|
#endif
|
2000-02-23 08:23:12 +03:00
|
|
|
|
1999-01-20 07:59:39 +03:00
|
|
|
size = new_size(size); /* round up to prime number */
|
1998-01-16 15:13:05 +03:00
|
|
|
|
|
|
|
tbl = alloc(st_table);
|
|
|
|
tbl->type = type;
|
|
|
|
tbl->num_entries = 0;
|
2002-02-28 09:53:33 +03:00
|
|
|
tbl->num_bins = size;
|
1998-01-16 15:13:05 +03:00
|
|
|
tbl->bins = (st_table_entry **)Calloc(size, sizeof(st_table_entry*));
|
1999-01-20 07:59:39 +03:00
|
|
|
|
1998-01-16 15:13:05 +03:00
|
|
|
return tbl;
|
|
|
|
}
|
|
|
|
|
|
|
|
st_table*
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 14:44:21 +04:00
|
|
|
st_init_table(struct st_hash_type *type)
|
1998-01-16 15:13:05 +03:00
|
|
|
{
|
|
|
|
return st_init_table_with_size(type, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
st_table*
|
* st.h, st.c: Introduce new conventional typedef's, st_data_t,
st_compare_func_t, st_hash_func_t and st_each_func_t.
* st.h, st.c: Do explicit function declarations and do not rely on
implicit declarations. On such platforms as IA64, int argument
values are NOT automatically promoted to long (64bit) values, so
explicit declarations are mandatory for those functions that
take long values or pointers. This fixes miniruby's coredump on
FreeBSD/IA64.
* class.c, eval.c, gc.c, hash.c, marshal.c, parse.y, variable.c:
Add proper casts to avoid warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3303 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-01-06 18:55:43 +03:00
|
|
|
st_init_numtable(void)
|
1998-01-16 15:13:05 +03:00
|
|
|
{
|
|
|
|
return st_init_table(&type_numhash);
|
|
|
|
}
|
|
|
|
|
1999-01-20 07:59:39 +03:00
|
|
|
st_table*
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 14:44:21 +04:00
|
|
|
st_init_numtable_with_size(int size)
|
1999-01-20 07:59:39 +03:00
|
|
|
{
|
|
|
|
return st_init_table_with_size(&type_numhash, size);
|
|
|
|
}
|
|
|
|
|
1998-01-16 15:13:05 +03:00
|
|
|
st_table*
|
* st.h, st.c: Introduce new conventional typedef's, st_data_t,
st_compare_func_t, st_hash_func_t and st_each_func_t.
* st.h, st.c: Do explicit function declarations and do not rely on
implicit declarations. On such platforms as IA64, int argument
values are NOT automatically promoted to long (64bit) values, so
explicit declarations are mandatory for those functions that
take long values or pointers. This fixes miniruby's coredump on
FreeBSD/IA64.
* class.c, eval.c, gc.c, hash.c, marshal.c, parse.y, variable.c:
Add proper casts to avoid warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3303 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-01-06 18:55:43 +03:00
|
|
|
st_init_strtable(void)
|
1998-01-16 15:13:05 +03:00
|
|
|
{
|
|
|
|
return st_init_table(&type_strhash);
|
|
|
|
}
|
|
|
|
|
1999-01-20 07:59:39 +03:00
|
|
|
st_table*
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 14:44:21 +04:00
|
|
|
st_init_strtable_with_size(int size)
|
1999-01-20 07:59:39 +03:00
|
|
|
{
|
|
|
|
return st_init_table_with_size(&type_strhash, size);
|
|
|
|
}
|
|
|
|
|
1998-01-16 15:13:05 +03:00
|
|
|
void
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 14:44:21 +04:00
|
|
|
st_free_table(st_table *table)
|
1998-01-16 15:13:05 +03:00
|
|
|
{
|
|
|
|
register st_table_entry *ptr, *next;
|
|
|
|
int i;
|
|
|
|
|
2002-02-28 09:53:33 +03:00
|
|
|
for(i = 0; i < table->num_bins; i++) {
|
1998-01-16 15:13:05 +03:00
|
|
|
ptr = table->bins[i];
|
1999-01-20 07:59:39 +03:00
|
|
|
while (ptr != 0) {
|
1998-01-16 15:13:05 +03:00
|
|
|
next = ptr->next;
|
2005-12-19 17:10:36 +03:00
|
|
|
free(ptr);
|
1998-01-16 15:13:05 +03:00
|
|
|
ptr = next;
|
|
|
|
}
|
|
|
|
}
|
2005-12-19 17:10:36 +03:00
|
|
|
free(table->bins);
|
|
|
|
free(table);
|
1998-01-16 15:13:05 +03:00
|
|
|
}
|
|
|
|
|
1999-01-20 07:59:39 +03:00
|
|
|
#define PTR_NOT_EQUAL(table, ptr, hash_val, key) \
|
1999-08-13 09:45:20 +04:00
|
|
|
((ptr) != 0 && (ptr->hash != (hash_val) || !EQUAL((table), (key), (ptr)->key)))
|
1998-01-16 15:13:05 +03:00
|
|
|
|
2000-02-25 06:51:23 +03:00
|
|
|
#ifdef HASH_LOG
|
|
|
|
#define COLLISION collision++
|
|
|
|
#else
|
|
|
|
#define COLLISION
|
|
|
|
#endif
|
|
|
|
|
2002-04-25 17:57:01 +04:00
|
|
|
#define FIND_ENTRY(table, ptr, hash_val, bin_pos) do {\
|
|
|
|
bin_pos = hash_val%(table)->num_bins;\
|
|
|
|
ptr = (table)->bins[bin_pos];\
|
|
|
|
if (PTR_NOT_EQUAL(table, ptr, hash_val, key)) {\
|
|
|
|
COLLISION;\
|
|
|
|
while (PTR_NOT_EQUAL(table, ptr->next, hash_val, key)) {\
|
|
|
|
ptr = ptr->next;\
|
|
|
|
}\
|
1998-01-16 15:13:05 +03:00
|
|
|
ptr = ptr->next;\
|
|
|
|
}\
|
2002-04-25 17:57:01 +04:00
|
|
|
} while (0)
|
1998-01-16 15:13:05 +03:00
|
|
|
|
|
|
|
int
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 14:44:21 +04:00
|
|
|
st_lookup(st_table *table, register st_data_t key, st_data_t *value)
|
1998-01-16 15:13:05 +03:00
|
|
|
{
|
1999-01-20 07:59:39 +03:00
|
|
|
unsigned int hash_val, bin_pos;
|
1998-01-16 15:13:05 +03:00
|
|
|
register st_table_entry *ptr;
|
|
|
|
|
|
|
|
hash_val = do_hash(key, table);
|
1999-01-20 07:59:39 +03:00
|
|
|
FIND_ENTRY(table, ptr, hash_val, bin_pos);
|
1998-01-16 15:13:05 +03:00
|
|
|
|
1999-01-20 07:59:39 +03:00
|
|
|
if (ptr == 0) {
|
1998-01-16 15:13:05 +03:00
|
|
|
return 0;
|
2001-05-02 08:22:21 +04:00
|
|
|
}
|
|
|
|
else {
|
1999-01-20 07:59:39 +03:00
|
|
|
if (value != 0) *value = ptr->record;
|
1998-01-16 15:13:05 +03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-01-20 07:59:39 +03:00
|
|
|
#define ADD_DIRECT(table, key, value, hash_val, bin_pos)\
|
2002-04-25 17:57:01 +04:00
|
|
|
do {\
|
1999-08-13 09:45:20 +04:00
|
|
|
st_table_entry *entry;\
|
2002-02-28 09:53:33 +03:00
|
|
|
if (table->num_entries/(table->num_bins) > ST_DEFAULT_MAX_DENSITY) {\
|
1998-01-16 15:13:05 +03:00
|
|
|
rehash(table);\
|
2001-06-22 13:12:24 +04:00
|
|
|
bin_pos = hash_val % table->num_bins;\
|
1998-01-16 15:13:05 +03:00
|
|
|
}\
|
|
|
|
\
|
1999-08-13 09:45:20 +04:00
|
|
|
entry = alloc(st_table_entry);\
|
1998-01-16 15:13:05 +03:00
|
|
|
\
|
1999-08-13 09:45:20 +04:00
|
|
|
entry->hash = hash_val;\
|
|
|
|
entry->key = key;\
|
|
|
|
entry->record = value;\
|
|
|
|
entry->next = table->bins[bin_pos];\
|
|
|
|
table->bins[bin_pos] = entry;\
|
1998-01-16 15:13:05 +03:00
|
|
|
table->num_entries++;\
|
2002-04-25 17:57:01 +04:00
|
|
|
} while (0)
|
1998-01-16 15:13:05 +03:00
|
|
|
|
|
|
|
int
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 14:44:21 +04:00
|
|
|
st_insert(register st_table *table, register st_data_t key, st_data_t value)
|
1998-01-16 15:13:05 +03:00
|
|
|
{
|
1999-01-20 07:59:39 +03:00
|
|
|
unsigned int hash_val, bin_pos;
|
1998-01-16 15:13:05 +03:00
|
|
|
register st_table_entry *ptr;
|
|
|
|
|
|
|
|
hash_val = do_hash(key, table);
|
1999-01-20 07:59:39 +03:00
|
|
|
FIND_ENTRY(table, ptr, hash_val, bin_pos);
|
1998-01-16 15:13:05 +03:00
|
|
|
|
1999-01-20 07:59:39 +03:00
|
|
|
if (ptr == 0) {
|
|
|
|
ADD_DIRECT(table, key, value, hash_val, bin_pos);
|
1998-01-16 15:13:05 +03:00
|
|
|
return 0;
|
2001-05-02 08:22:21 +04:00
|
|
|
}
|
|
|
|
else {
|
1998-01-16 15:13:05 +03:00
|
|
|
ptr->record = value;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 14:44:21 +04:00
|
|
|
st_add_direct(st_table *table, st_data_t key, st_data_t value)
|
1998-01-16 15:13:05 +03:00
|
|
|
{
|
1999-01-20 07:59:39 +03:00
|
|
|
unsigned int hash_val, bin_pos;
|
1998-01-16 15:13:05 +03:00
|
|
|
|
|
|
|
hash_val = do_hash(key, table);
|
2001-06-22 13:12:24 +04:00
|
|
|
bin_pos = hash_val % table->num_bins;
|
1999-01-20 07:59:39 +03:00
|
|
|
ADD_DIRECT(table, key, value, hash_val, bin_pos);
|
1998-01-16 15:13:05 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 14:44:21 +04:00
|
|
|
rehash(register st_table *table)
|
1998-01-16 15:13:05 +03:00
|
|
|
{
|
1999-01-20 07:59:39 +03:00
|
|
|
register st_table_entry *ptr, *next, **new_bins;
|
|
|
|
int i, old_num_bins = table->num_bins, new_num_bins;
|
|
|
|
unsigned int hash_val;
|
1998-01-16 15:13:05 +03:00
|
|
|
|
2000-02-25 06:51:23 +03:00
|
|
|
new_num_bins = new_size(old_num_bins+1);
|
1999-01-20 07:59:39 +03:00
|
|
|
new_bins = (st_table_entry**)Calloc(new_num_bins, sizeof(st_table_entry*));
|
1998-01-16 15:13:05 +03:00
|
|
|
|
2002-02-28 09:53:33 +03:00
|
|
|
for(i = 0; i < old_num_bins; i++) {
|
1999-01-20 07:59:39 +03:00
|
|
|
ptr = table->bins[i];
|
|
|
|
while (ptr != 0) {
|
1998-01-16 15:13:05 +03:00
|
|
|
next = ptr->next;
|
2001-06-22 13:12:24 +04:00
|
|
|
hash_val = ptr->hash % new_num_bins;
|
1999-01-20 07:59:39 +03:00
|
|
|
ptr->next = new_bins[hash_val];
|
|
|
|
new_bins[hash_val] = ptr;
|
1998-01-16 15:13:05 +03:00
|
|
|
ptr = next;
|
|
|
|
}
|
|
|
|
}
|
2005-12-19 17:10:36 +03:00
|
|
|
free(table->bins);
|
1999-01-20 07:59:39 +03:00
|
|
|
table->num_bins = new_num_bins;
|
|
|
|
table->bins = new_bins;
|
1998-01-16 15:13:05 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
st_table*
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 14:44:21 +04:00
|
|
|
st_copy(st_table *old_table)
|
1998-01-16 15:13:05 +03:00
|
|
|
{
|
|
|
|
st_table *new_table;
|
1999-08-13 09:45:20 +04:00
|
|
|
st_table_entry *ptr, *entry;
|
2002-02-28 09:53:33 +03:00
|
|
|
int i, num_bins = old_table->num_bins;
|
1998-01-16 15:13:05 +03:00
|
|
|
|
|
|
|
new_table = alloc(st_table);
|
1999-01-20 07:59:39 +03:00
|
|
|
if (new_table == 0) {
|
|
|
|
return 0;
|
1998-01-16 15:13:05 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
*new_table = *old_table;
|
|
|
|
new_table->bins = (st_table_entry**)
|
|
|
|
Calloc((unsigned)num_bins, sizeof(st_table_entry*));
|
|
|
|
|
1999-01-20 07:59:39 +03:00
|
|
|
if (new_table->bins == 0) {
|
2005-12-19 17:10:36 +03:00
|
|
|
free(new_table);
|
1999-01-20 07:59:39 +03:00
|
|
|
return 0;
|
1998-01-16 15:13:05 +03:00
|
|
|
}
|
|
|
|
|
1999-08-13 09:45:20 +04:00
|
|
|
for(i = 0; i < num_bins; i++) {
|
1999-01-20 07:59:39 +03:00
|
|
|
new_table->bins[i] = 0;
|
1998-01-16 15:13:05 +03:00
|
|
|
ptr = old_table->bins[i];
|
1999-01-20 07:59:39 +03:00
|
|
|
while (ptr != 0) {
|
1999-08-13 09:45:20 +04:00
|
|
|
entry = alloc(st_table_entry);
|
|
|
|
if (entry == 0) {
|
2005-12-19 17:10:36 +03:00
|
|
|
free(new_table->bins);
|
|
|
|
free(new_table);
|
1999-01-20 07:59:39 +03:00
|
|
|
return 0;
|
1998-01-16 15:13:05 +03:00
|
|
|
}
|
1999-08-13 09:45:20 +04:00
|
|
|
*entry = *ptr;
|
|
|
|
entry->next = new_table->bins[i];
|
|
|
|
new_table->bins[i] = entry;
|
1998-01-16 15:13:05 +03:00
|
|
|
ptr = ptr->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return new_table;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 14:44:21 +04:00
|
|
|
st_delete(register st_table *table, register st_data_t *key, st_data_t *value)
|
1998-01-16 15:13:05 +03:00
|
|
|
{
|
1999-01-20 07:59:39 +03:00
|
|
|
unsigned int hash_val;
|
1998-01-16 15:13:05 +03:00
|
|
|
st_table_entry *tmp;
|
|
|
|
register st_table_entry *ptr;
|
|
|
|
|
1999-01-20 07:59:39 +03:00
|
|
|
hash_val = do_hash_bin(*key, table);
|
1998-01-16 15:13:05 +03:00
|
|
|
ptr = table->bins[hash_val];
|
|
|
|
|
1999-01-20 07:59:39 +03:00
|
|
|
if (ptr == 0) {
|
|
|
|
if (value != 0) *value = 0;
|
1998-01-16 15:13:05 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (EQUAL(table, *key, ptr->key)) {
|
|
|
|
table->bins[hash_val] = ptr->next;
|
|
|
|
table->num_entries--;
|
1999-01-20 07:59:39 +03:00
|
|
|
if (value != 0) *value = ptr->record;
|
1998-01-16 15:13:05 +03:00
|
|
|
*key = ptr->key;
|
2005-12-19 17:10:36 +03:00
|
|
|
free(ptr);
|
1998-01-16 15:13:05 +03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
1999-01-20 07:59:39 +03:00
|
|
|
for(; ptr->next != 0; ptr = ptr->next) {
|
1998-01-16 15:13:05 +03:00
|
|
|
if (EQUAL(table, ptr->next->key, *key)) {
|
|
|
|
tmp = ptr->next;
|
|
|
|
ptr->next = ptr->next->next;
|
|
|
|
table->num_entries--;
|
1999-01-20 07:59:39 +03:00
|
|
|
if (value != 0) *value = tmp->record;
|
1998-01-16 15:13:05 +03:00
|
|
|
*key = tmp->key;
|
2005-12-19 17:10:36 +03:00
|
|
|
free(tmp);
|
1998-01-16 15:13:05 +03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 14:44:21 +04:00
|
|
|
st_delete_safe(register st_table *table, register st_data_t *key, st_data_t *value, st_data_t never)
|
1998-01-16 15:13:05 +03:00
|
|
|
{
|
1999-01-20 07:59:39 +03:00
|
|
|
unsigned int hash_val;
|
1998-01-16 15:13:05 +03:00
|
|
|
register st_table_entry *ptr;
|
|
|
|
|
1999-01-20 07:59:39 +03:00
|
|
|
hash_val = do_hash_bin(*key, table);
|
1998-01-16 15:13:05 +03:00
|
|
|
ptr = table->bins[hash_val];
|
|
|
|
|
1999-01-20 07:59:39 +03:00
|
|
|
if (ptr == 0) {
|
|
|
|
if (value != 0) *value = 0;
|
1998-01-16 15:13:05 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1999-08-13 09:45:20 +04:00
|
|
|
for(; ptr != 0; ptr = ptr->next) {
|
2000-03-23 11:37:35 +03:00
|
|
|
if ((ptr->key != never) && EQUAL(table, ptr->key, *key)) {
|
1998-01-16 15:13:05 +03:00
|
|
|
table->num_entries--;
|
|
|
|
*key = ptr->key;
|
1999-01-20 07:59:39 +03:00
|
|
|
if (value != 0) *value = ptr->record;
|
1998-01-16 15:13:05 +03:00
|
|
|
ptr->key = ptr->record = never;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1999-08-13 09:45:20 +04:00
|
|
|
static int
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 14:44:21 +04:00
|
|
|
delete_never(st_data_t key, st_data_t value, st_data_t never)
|
1999-08-13 09:45:20 +04:00
|
|
|
{
|
|
|
|
if (value == never) return ST_DELETE;
|
|
|
|
return ST_CONTINUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 14:44:21 +04:00
|
|
|
st_cleanup_safe(st_table *table, st_data_t never)
|
1999-08-13 09:45:20 +04:00
|
|
|
{
|
|
|
|
int num_entries = table->num_entries;
|
|
|
|
|
|
|
|
st_foreach(table, delete_never, never);
|
|
|
|
table->num_entries = num_entries;
|
|
|
|
}
|
|
|
|
|
* array.c: replace rb_protect_inspect() and rb_inspecting_p() by
rb_exec_recursive() in eval.c.
* eval.c (rb_exec_recursive): new function.
* array.c (rb_ary_join): use rb_exec_recursive().
* array.c (rb_ary_inspect, rb_ary_hash): ditto.
* file.c (rb_file_join): ditto.
* hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
* io.c (rb_io_puts): ditto.
* object.c (rb_obj_inspect): ditto
* struct.c (rb_struct_inspect): ditto.
* lib/set.rb (SortedSet::setup): a hack to shut up warning.
[ruby-talk:132866]
* lib/time.rb (Time::strptime): add new function. inspired by
[ruby-talk:132815].
* lib/parsedate.rb (ParseDate::strptime): ditto.
* regparse.c: move st_*_strend() functions from st.c. fixed some
potential memory leaks.
* exception error messages updated. [ruby-core:04497]
* ext/socket/socket.c (Init_socket): add bunch of Socket
constants. Patch from Sam Roberts <sroberts@uniserve.com>.
[ruby-core:04409]
* array.c (rb_ary_s_create): no need for negative argc check.
[ruby-core:04463]
* array.c (rb_ary_unshift_m): ditto.
* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
of StandardError class, not Exception class. [ruby-core:04429]
* parse.y (fcall_gen): lvar(arg) will be evaluated as
lvar.call(arg) when lvar is a defined local variable. [new]
* object.c (rb_class_initialize): call inherited method before
calling initializing block.
* eval.c (rb_thread_start_1): initialize newly pushed frame.
* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
fixed: [ruby-core:04444]
* eval.c (is_defined): NODE_IASGN is an assignment.
* ext/readline/readline.c (Readline.readline): use rl_outstream
and rl_instream. [ruby-dev:25699]
* ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
[ruby-dev:25675]
* misc/ruby-mode.el: [ruby-core:04415]
* lib/rdoc/generators/html_generator.rb: [ruby-core:04412]
* lib/rdoc/generators/ri_generator.rb: ditto.
* struct.c (make_struct): fixed: [ruby-core:04402]
* ext/curses/curses.c (window_color_set): [ruby-core:04393]
* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
[ruby-talk:130092]
* object.c: [ruby-doc:818]
* parse.y (open_args): fix too verbose warnings for the space
before argument parentheses. [ruby-dev:25492]
* parse.y (parser_yylex): ditto.
* parse.y (parser_yylex): the first expression in the parentheses
should not be a command. [ruby-dev:25492]
* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
* object.c (Init_Object): remove Object#type. [ruby-core:04335]
* st.c (st_foreach): report success/failure by return value.
[ruby-Bugs-1396]
* parse.y: forgot to initialize parser struct. [ruby-dev:25492]
* parse.y (parser_yylex): no tLABEL on EXPR_BEG.
[ruby-talk:127711]
* document updates - [ruby-core:04296], [ruby-core:04301],
[ruby-core:04302], [ruby-core:04307]
* dir.c (rb_push_glob): should work for NUL delimited patterns.
* dir.c (rb_glob2): should aware of offset in the pattern.
* string.c (rb_str_new4): should propagate taintedness.
* env.h: rename member names in struct FRAME; last_func -> callee,
orig_func -> this_func, last_class -> this_class.
* struct.c (rb_struct_set): use original method name, not callee
name, to retrieve member slot. [ruby-core:04268]
* time.c (time_strftime): protect from format modification from GC
finalizers.
* object.c (Init_Object): remove rb_obj_id_obsolete()
* eval.c (rb_mod_define_method): incomplete subclass check.
[ruby-dev:25464]
* gc.c (rb_data_object_alloc): klass may be NULL.
[ruby-list:40498]
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401]
* bignum.c (rb_big_rand): do not use rb_big_modulo to generate
random bignums. [ruby-dev:25396]
* variable.c (rb_autoload): [ruby-dev:25373]
* eval.c (svalue_to_avalue): [ruby-dev:25366]
* string.c (rb_str_justify): [ruby-dev:25367]
* io.c (rb_f_select): [ruby-dev:25312]
* ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
* struct.c (make_struct): [ruby-dev:25249]
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* io.c (rb_f_open): add type check for return value from to_open.
* lib/pstore.rb (PStore#transaction): Use the empty content when a
file is not found. [ruby-dev:24561]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-03-04 09:47:45 +03:00
|
|
|
int
|
2005-10-20 06:56:22 +04:00
|
|
|
st_foreach(st_table *table, int (*func)(ANYARGS), st_data_t arg)
|
1998-01-16 15:13:05 +03:00
|
|
|
{
|
|
|
|
st_table_entry *ptr, *last, *tmp;
|
|
|
|
enum st_retval retval;
|
|
|
|
int i;
|
|
|
|
|
2002-02-28 09:53:33 +03:00
|
|
|
for(i = 0; i < table->num_bins; i++) {
|
1999-01-20 07:59:39 +03:00
|
|
|
last = 0;
|
|
|
|
for(ptr = table->bins[i]; ptr != 0;) {
|
* array.c: replace rb_protect_inspect() and rb_inspecting_p() by
rb_exec_recursive() in eval.c.
* eval.c (rb_exec_recursive): new function.
* array.c (rb_ary_join): use rb_exec_recursive().
* array.c (rb_ary_inspect, rb_ary_hash): ditto.
* file.c (rb_file_join): ditto.
* hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
* io.c (rb_io_puts): ditto.
* object.c (rb_obj_inspect): ditto
* struct.c (rb_struct_inspect): ditto.
* lib/set.rb (SortedSet::setup): a hack to shut up warning.
[ruby-talk:132866]
* lib/time.rb (Time::strptime): add new function. inspired by
[ruby-talk:132815].
* lib/parsedate.rb (ParseDate::strptime): ditto.
* regparse.c: move st_*_strend() functions from st.c. fixed some
potential memory leaks.
* exception error messages updated. [ruby-core:04497]
* ext/socket/socket.c (Init_socket): add bunch of Socket
constants. Patch from Sam Roberts <sroberts@uniserve.com>.
[ruby-core:04409]
* array.c (rb_ary_s_create): no need for negative argc check.
[ruby-core:04463]
* array.c (rb_ary_unshift_m): ditto.
* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
of StandardError class, not Exception class. [ruby-core:04429]
* parse.y (fcall_gen): lvar(arg) will be evaluated as
lvar.call(arg) when lvar is a defined local variable. [new]
* object.c (rb_class_initialize): call inherited method before
calling initializing block.
* eval.c (rb_thread_start_1): initialize newly pushed frame.
* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
fixed: [ruby-core:04444]
* eval.c (is_defined): NODE_IASGN is an assignment.
* ext/readline/readline.c (Readline.readline): use rl_outstream
and rl_instream. [ruby-dev:25699]
* ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
[ruby-dev:25675]
* misc/ruby-mode.el: [ruby-core:04415]
* lib/rdoc/generators/html_generator.rb: [ruby-core:04412]
* lib/rdoc/generators/ri_generator.rb: ditto.
* struct.c (make_struct): fixed: [ruby-core:04402]
* ext/curses/curses.c (window_color_set): [ruby-core:04393]
* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
[ruby-talk:130092]
* object.c: [ruby-doc:818]
* parse.y (open_args): fix too verbose warnings for the space
before argument parentheses. [ruby-dev:25492]
* parse.y (parser_yylex): ditto.
* parse.y (parser_yylex): the first expression in the parentheses
should not be a command. [ruby-dev:25492]
* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
* object.c (Init_Object): remove Object#type. [ruby-core:04335]
* st.c (st_foreach): report success/failure by return value.
[ruby-Bugs-1396]
* parse.y: forgot to initialize parser struct. [ruby-dev:25492]
* parse.y (parser_yylex): no tLABEL on EXPR_BEG.
[ruby-talk:127711]
* document updates - [ruby-core:04296], [ruby-core:04301],
[ruby-core:04302], [ruby-core:04307]
* dir.c (rb_push_glob): should work for NUL delimited patterns.
* dir.c (rb_glob2): should aware of offset in the pattern.
* string.c (rb_str_new4): should propagate taintedness.
* env.h: rename member names in struct FRAME; last_func -> callee,
orig_func -> this_func, last_class -> this_class.
* struct.c (rb_struct_set): use original method name, not callee
name, to retrieve member slot. [ruby-core:04268]
* time.c (time_strftime): protect from format modification from GC
finalizers.
* object.c (Init_Object): remove rb_obj_id_obsolete()
* eval.c (rb_mod_define_method): incomplete subclass check.
[ruby-dev:25464]
* gc.c (rb_data_object_alloc): klass may be NULL.
[ruby-list:40498]
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401]
* bignum.c (rb_big_rand): do not use rb_big_modulo to generate
random bignums. [ruby-dev:25396]
* variable.c (rb_autoload): [ruby-dev:25373]
* eval.c (svalue_to_avalue): [ruby-dev:25366]
* string.c (rb_str_justify): [ruby-dev:25367]
* io.c (rb_f_select): [ruby-dev:25312]
* ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
* struct.c (make_struct): [ruby-dev:25249]
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* io.c (rb_f_open): add type check for return value from to_open.
* lib/pstore.rb (PStore#transaction): Use the empty content when a
file is not found. [ruby-dev:24561]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-03-04 09:47:45 +03:00
|
|
|
retval = (*func)(ptr->key, ptr->record, arg);
|
1998-01-16 15:13:05 +03:00
|
|
|
switch (retval) {
|
2004-09-22 08:48:52 +04:00
|
|
|
case ST_CHECK: /* check if hash is modified during iteration */
|
|
|
|
tmp = 0;
|
|
|
|
if (i < table->num_bins) {
|
|
|
|
for (tmp = table->bins[i]; tmp; tmp=tmp->next) {
|
|
|
|
if (tmp == ptr) break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!tmp) {
|
|
|
|
/* call func with error notice */
|
* array.c: replace rb_protect_inspect() and rb_inspecting_p() by
rb_exec_recursive() in eval.c.
* eval.c (rb_exec_recursive): new function.
* array.c (rb_ary_join): use rb_exec_recursive().
* array.c (rb_ary_inspect, rb_ary_hash): ditto.
* file.c (rb_file_join): ditto.
* hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
* io.c (rb_io_puts): ditto.
* object.c (rb_obj_inspect): ditto
* struct.c (rb_struct_inspect): ditto.
* lib/set.rb (SortedSet::setup): a hack to shut up warning.
[ruby-talk:132866]
* lib/time.rb (Time::strptime): add new function. inspired by
[ruby-talk:132815].
* lib/parsedate.rb (ParseDate::strptime): ditto.
* regparse.c: move st_*_strend() functions from st.c. fixed some
potential memory leaks.
* exception error messages updated. [ruby-core:04497]
* ext/socket/socket.c (Init_socket): add bunch of Socket
constants. Patch from Sam Roberts <sroberts@uniserve.com>.
[ruby-core:04409]
* array.c (rb_ary_s_create): no need for negative argc check.
[ruby-core:04463]
* array.c (rb_ary_unshift_m): ditto.
* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
of StandardError class, not Exception class. [ruby-core:04429]
* parse.y (fcall_gen): lvar(arg) will be evaluated as
lvar.call(arg) when lvar is a defined local variable. [new]
* object.c (rb_class_initialize): call inherited method before
calling initializing block.
* eval.c (rb_thread_start_1): initialize newly pushed frame.
* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
fixed: [ruby-core:04444]
* eval.c (is_defined): NODE_IASGN is an assignment.
* ext/readline/readline.c (Readline.readline): use rl_outstream
and rl_instream. [ruby-dev:25699]
* ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
[ruby-dev:25675]
* misc/ruby-mode.el: [ruby-core:04415]
* lib/rdoc/generators/html_generator.rb: [ruby-core:04412]
* lib/rdoc/generators/ri_generator.rb: ditto.
* struct.c (make_struct): fixed: [ruby-core:04402]
* ext/curses/curses.c (window_color_set): [ruby-core:04393]
* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
[ruby-talk:130092]
* object.c: [ruby-doc:818]
* parse.y (open_args): fix too verbose warnings for the space
before argument parentheses. [ruby-dev:25492]
* parse.y (parser_yylex): ditto.
* parse.y (parser_yylex): the first expression in the parentheses
should not be a command. [ruby-dev:25492]
* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
* object.c (Init_Object): remove Object#type. [ruby-core:04335]
* st.c (st_foreach): report success/failure by return value.
[ruby-Bugs-1396]
* parse.y: forgot to initialize parser struct. [ruby-dev:25492]
* parse.y (parser_yylex): no tLABEL on EXPR_BEG.
[ruby-talk:127711]
* document updates - [ruby-core:04296], [ruby-core:04301],
[ruby-core:04302], [ruby-core:04307]
* dir.c (rb_push_glob): should work for NUL delimited patterns.
* dir.c (rb_glob2): should aware of offset in the pattern.
* string.c (rb_str_new4): should propagate taintedness.
* env.h: rename member names in struct FRAME; last_func -> callee,
orig_func -> this_func, last_class -> this_class.
* struct.c (rb_struct_set): use original method name, not callee
name, to retrieve member slot. [ruby-core:04268]
* time.c (time_strftime): protect from format modification from GC
finalizers.
* object.c (Init_Object): remove rb_obj_id_obsolete()
* eval.c (rb_mod_define_method): incomplete subclass check.
[ruby-dev:25464]
* gc.c (rb_data_object_alloc): klass may be NULL.
[ruby-list:40498]
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401]
* bignum.c (rb_big_rand): do not use rb_big_modulo to generate
random bignums. [ruby-dev:25396]
* variable.c (rb_autoload): [ruby-dev:25373]
* eval.c (svalue_to_avalue): [ruby-dev:25366]
* string.c (rb_str_justify): [ruby-dev:25367]
* io.c (rb_f_select): [ruby-dev:25312]
* ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
* struct.c (make_struct): [ruby-dev:25249]
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* io.c (rb_f_open): add type check for return value from to_open.
* lib/pstore.rb (PStore#transaction): Use the empty content when a
file is not found. [ruby-dev:24561]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-03-04 09:47:45 +03:00
|
|
|
return 1;
|
2004-09-22 08:48:52 +04:00
|
|
|
}
|
|
|
|
/* fall through */
|
1998-01-16 15:13:05 +03:00
|
|
|
case ST_CONTINUE:
|
|
|
|
last = ptr;
|
|
|
|
ptr = ptr->next;
|
|
|
|
break;
|
|
|
|
case ST_STOP:
|
* array.c: replace rb_protect_inspect() and rb_inspecting_p() by
rb_exec_recursive() in eval.c.
* eval.c (rb_exec_recursive): new function.
* array.c (rb_ary_join): use rb_exec_recursive().
* array.c (rb_ary_inspect, rb_ary_hash): ditto.
* file.c (rb_file_join): ditto.
* hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
* io.c (rb_io_puts): ditto.
* object.c (rb_obj_inspect): ditto
* struct.c (rb_struct_inspect): ditto.
* lib/set.rb (SortedSet::setup): a hack to shut up warning.
[ruby-talk:132866]
* lib/time.rb (Time::strptime): add new function. inspired by
[ruby-talk:132815].
* lib/parsedate.rb (ParseDate::strptime): ditto.
* regparse.c: move st_*_strend() functions from st.c. fixed some
potential memory leaks.
* exception error messages updated. [ruby-core:04497]
* ext/socket/socket.c (Init_socket): add bunch of Socket
constants. Patch from Sam Roberts <sroberts@uniserve.com>.
[ruby-core:04409]
* array.c (rb_ary_s_create): no need for negative argc check.
[ruby-core:04463]
* array.c (rb_ary_unshift_m): ditto.
* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
of StandardError class, not Exception class. [ruby-core:04429]
* parse.y (fcall_gen): lvar(arg) will be evaluated as
lvar.call(arg) when lvar is a defined local variable. [new]
* object.c (rb_class_initialize): call inherited method before
calling initializing block.
* eval.c (rb_thread_start_1): initialize newly pushed frame.
* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
fixed: [ruby-core:04444]
* eval.c (is_defined): NODE_IASGN is an assignment.
* ext/readline/readline.c (Readline.readline): use rl_outstream
and rl_instream. [ruby-dev:25699]
* ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
[ruby-dev:25675]
* misc/ruby-mode.el: [ruby-core:04415]
* lib/rdoc/generators/html_generator.rb: [ruby-core:04412]
* lib/rdoc/generators/ri_generator.rb: ditto.
* struct.c (make_struct): fixed: [ruby-core:04402]
* ext/curses/curses.c (window_color_set): [ruby-core:04393]
* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
[ruby-talk:130092]
* object.c: [ruby-doc:818]
* parse.y (open_args): fix too verbose warnings for the space
before argument parentheses. [ruby-dev:25492]
* parse.y (parser_yylex): ditto.
* parse.y (parser_yylex): the first expression in the parentheses
should not be a command. [ruby-dev:25492]
* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
* object.c (Init_Object): remove Object#type. [ruby-core:04335]
* st.c (st_foreach): report success/failure by return value.
[ruby-Bugs-1396]
* parse.y: forgot to initialize parser struct. [ruby-dev:25492]
* parse.y (parser_yylex): no tLABEL on EXPR_BEG.
[ruby-talk:127711]
* document updates - [ruby-core:04296], [ruby-core:04301],
[ruby-core:04302], [ruby-core:04307]
* dir.c (rb_push_glob): should work for NUL delimited patterns.
* dir.c (rb_glob2): should aware of offset in the pattern.
* string.c (rb_str_new4): should propagate taintedness.
* env.h: rename member names in struct FRAME; last_func -> callee,
orig_func -> this_func, last_class -> this_class.
* struct.c (rb_struct_set): use original method name, not callee
name, to retrieve member slot. [ruby-core:04268]
* time.c (time_strftime): protect from format modification from GC
finalizers.
* object.c (Init_Object): remove rb_obj_id_obsolete()
* eval.c (rb_mod_define_method): incomplete subclass check.
[ruby-dev:25464]
* gc.c (rb_data_object_alloc): klass may be NULL.
[ruby-list:40498]
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401]
* bignum.c (rb_big_rand): do not use rb_big_modulo to generate
random bignums. [ruby-dev:25396]
* variable.c (rb_autoload): [ruby-dev:25373]
* eval.c (svalue_to_avalue): [ruby-dev:25366]
* string.c (rb_str_justify): [ruby-dev:25367]
* io.c (rb_f_select): [ruby-dev:25312]
* ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
* struct.c (make_struct): [ruby-dev:25249]
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* io.c (rb_f_open): add type check for return value from to_open.
* lib/pstore.rb (PStore#transaction): Use the empty content when a
file is not found. [ruby-dev:24561]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-03-04 09:47:45 +03:00
|
|
|
return 0;
|
1998-01-16 15:13:05 +03:00
|
|
|
case ST_DELETE:
|
|
|
|
tmp = ptr;
|
1999-01-20 07:59:39 +03:00
|
|
|
if (last == 0) {
|
1998-01-16 15:13:05 +03:00
|
|
|
table->bins[i] = ptr->next;
|
2001-05-02 08:22:21 +04:00
|
|
|
}
|
|
|
|
else {
|
1998-01-16 15:13:05 +03:00
|
|
|
last->next = ptr->next;
|
|
|
|
}
|
|
|
|
ptr = ptr->next;
|
2005-12-19 17:10:36 +03:00
|
|
|
free(tmp);
|
1998-01-16 15:13:05 +03:00
|
|
|
table->num_entries--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
* array.c: replace rb_protect_inspect() and rb_inspecting_p() by
rb_exec_recursive() in eval.c.
* eval.c (rb_exec_recursive): new function.
* array.c (rb_ary_join): use rb_exec_recursive().
* array.c (rb_ary_inspect, rb_ary_hash): ditto.
* file.c (rb_file_join): ditto.
* hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
* io.c (rb_io_puts): ditto.
* object.c (rb_obj_inspect): ditto
* struct.c (rb_struct_inspect): ditto.
* lib/set.rb (SortedSet::setup): a hack to shut up warning.
[ruby-talk:132866]
* lib/time.rb (Time::strptime): add new function. inspired by
[ruby-talk:132815].
* lib/parsedate.rb (ParseDate::strptime): ditto.
* regparse.c: move st_*_strend() functions from st.c. fixed some
potential memory leaks.
* exception error messages updated. [ruby-core:04497]
* ext/socket/socket.c (Init_socket): add bunch of Socket
constants. Patch from Sam Roberts <sroberts@uniserve.com>.
[ruby-core:04409]
* array.c (rb_ary_s_create): no need for negative argc check.
[ruby-core:04463]
* array.c (rb_ary_unshift_m): ditto.
* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
of StandardError class, not Exception class. [ruby-core:04429]
* parse.y (fcall_gen): lvar(arg) will be evaluated as
lvar.call(arg) when lvar is a defined local variable. [new]
* object.c (rb_class_initialize): call inherited method before
calling initializing block.
* eval.c (rb_thread_start_1): initialize newly pushed frame.
* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
fixed: [ruby-core:04444]
* eval.c (is_defined): NODE_IASGN is an assignment.
* ext/readline/readline.c (Readline.readline): use rl_outstream
and rl_instream. [ruby-dev:25699]
* ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
[ruby-dev:25675]
* misc/ruby-mode.el: [ruby-core:04415]
* lib/rdoc/generators/html_generator.rb: [ruby-core:04412]
* lib/rdoc/generators/ri_generator.rb: ditto.
* struct.c (make_struct): fixed: [ruby-core:04402]
* ext/curses/curses.c (window_color_set): [ruby-core:04393]
* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
[ruby-talk:130092]
* object.c: [ruby-doc:818]
* parse.y (open_args): fix too verbose warnings for the space
before argument parentheses. [ruby-dev:25492]
* parse.y (parser_yylex): ditto.
* parse.y (parser_yylex): the first expression in the parentheses
should not be a command. [ruby-dev:25492]
* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
* object.c (Init_Object): remove Object#type. [ruby-core:04335]
* st.c (st_foreach): report success/failure by return value.
[ruby-Bugs-1396]
* parse.y: forgot to initialize parser struct. [ruby-dev:25492]
* parse.y (parser_yylex): no tLABEL on EXPR_BEG.
[ruby-talk:127711]
* document updates - [ruby-core:04296], [ruby-core:04301],
[ruby-core:04302], [ruby-core:04307]
* dir.c (rb_push_glob): should work for NUL delimited patterns.
* dir.c (rb_glob2): should aware of offset in the pattern.
* string.c (rb_str_new4): should propagate taintedness.
* env.h: rename member names in struct FRAME; last_func -> callee,
orig_func -> this_func, last_class -> this_class.
* struct.c (rb_struct_set): use original method name, not callee
name, to retrieve member slot. [ruby-core:04268]
* time.c (time_strftime): protect from format modification from GC
finalizers.
* object.c (Init_Object): remove rb_obj_id_obsolete()
* eval.c (rb_mod_define_method): incomplete subclass check.
[ruby-dev:25464]
* gc.c (rb_data_object_alloc): klass may be NULL.
[ruby-list:40498]
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401]
* bignum.c (rb_big_rand): do not use rb_big_modulo to generate
random bignums. [ruby-dev:25396]
* variable.c (rb_autoload): [ruby-dev:25373]
* eval.c (svalue_to_avalue): [ruby-dev:25366]
* string.c (rb_str_justify): [ruby-dev:25367]
* io.c (rb_f_select): [ruby-dev:25312]
* ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
* struct.c (make_struct): [ruby-dev:25249]
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* io.c (rb_f_open): add type check for return value from to_open.
* lib/pstore.rb (PStore#transaction): Use the empty content when a
file is not found. [ruby-dev:24561]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-03-04 09:47:45 +03:00
|
|
|
return 0;
|
1998-01-16 15:13:05 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 14:44:21 +04:00
|
|
|
strhash(register const char *string)
|
1998-01-16 15:13:05 +03:00
|
|
|
{
|
|
|
|
register int c;
|
|
|
|
|
2000-02-25 06:51:23 +03:00
|
|
|
#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') {
|
2003-11-01 19:16:31 +03:00
|
|
|
val += c;
|
|
|
|
val += (val << 10);
|
|
|
|
val ^= (val >> 6);
|
2000-02-25 06:51:23 +03:00
|
|
|
}
|
2003-11-01 19:16:31 +03:00
|
|
|
val += (val << 3);
|
|
|
|
val ^= (val >> 11);
|
2000-02-25 06:51:23 +03:00
|
|
|
|
2003-11-01 19:16:31 +03:00
|
|
|
return val + (val << 15);
|
2000-02-25 06:51:23 +03:00
|
|
|
#else
|
|
|
|
register int val = 0;
|
|
|
|
|
1998-01-16 15:13:05 +03:00
|
|
|
while ((c = *string++) != '\0') {
|
|
|
|
val = val*997 + c;
|
|
|
|
}
|
|
|
|
|
2000-02-25 06:51:23 +03:00
|
|
|
return val + (val>>5);
|
|
|
|
#endif
|
1998-01-16 15:13:05 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 14:44:21 +04:00
|
|
|
numcmp(long x, long y)
|
1998-01-16 15:13:05 +03:00
|
|
|
{
|
|
|
|
return x != y;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 14:44:21 +04:00
|
|
|
numhash(long n)
|
1998-01-16 15:13:05 +03:00
|
|
|
{
|
2001-06-22 13:12:24 +04:00
|
|
|
return n;
|
1998-01-16 15:13:05 +03:00
|
|
|
}
|