From dda5dc00cff334cac373096d444a0fd59e716124 Mon Sep 17 00:00:00 2001 From: ocean Date: Mon, 12 Sep 2005 10:44:21 +0000 Subject: * 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 --- hash.c | 375 +++++++++++++++++++++-------------------------------------------- 1 file changed, 120 insertions(+), 255 deletions(-) (limited to 'hash.c') diff --git a/hash.c b/hash.c index 7eb12ce286..3abd5f7f34 100644 --- a/hash.c +++ b/hash.c @@ -25,8 +25,7 @@ #define HASH_PROC_DEFAULT FL_USER2 VALUE -rb_hash_freeze(hash) - VALUE hash; +rb_hash_freeze(VALUE hash) { return rb_obj_freeze(hash); } @@ -37,15 +36,13 @@ static VALUE envtbl; static ID id_hash, id_call, id_default; static VALUE -eql(args) - VALUE *args; +eql(VALUE *args) { return (VALUE)rb_eql(args[0], args[1]); } static int -rb_any_cmp(a, b) - VALUE a, b; +rb_any_cmp(VALUE a, VALUE b) { VALUE args[2]; @@ -68,15 +65,13 @@ rb_any_cmp(a, b) } VALUE -rb_hash(obj) - VALUE obj; +rb_hash(VALUE obj) { return rb_funcall(obj, id_hash, 0); } static int -rb_any_hash(a) - VALUE a; +rb_any_hash(VALUE a) { VALUE hval; @@ -111,9 +106,7 @@ struct foreach_safe_arg { }; static int -foreach_safe_i(key, value, arg) - st_data_t key, value; - struct foreach_safe_arg *arg; +foreach_safe_i(st_data_t key, st_data_t value, struct foreach_safe_arg *arg) { int status; @@ -126,10 +119,7 @@ foreach_safe_i(key, value, arg) } void -st_foreach_safe(table, func, a) - st_table *table; - int (*func)(); - st_data_t a; +st_foreach_safe(st_table *table, int (*func) (/* ??? */), st_data_t a) { struct foreach_safe_arg arg; @@ -148,9 +138,7 @@ struct hash_foreach_arg { }; static int -hash_foreach_iter(key, value, arg) - VALUE key, value; - struct hash_foreach_arg *arg; +hash_foreach_iter(VALUE key, VALUE value, struct hash_foreach_arg *arg) { int status; st_table *tbl; @@ -174,8 +162,7 @@ hash_foreach_iter(key, value, arg) } static VALUE -hash_foreach_ensure(hash) - VALUE hash; +hash_foreach_ensure(VALUE hash) { RHASH(hash)->iter_lev--; @@ -189,8 +176,7 @@ hash_foreach_ensure(hash) } static VALUE -hash_foreach_call(arg) - struct hash_foreach_arg *arg; +hash_foreach_call(struct hash_foreach_arg *arg) { if (st_foreach(RHASH(arg->hash)->tbl, hash_foreach_iter, (st_data_t)arg)) { rb_raise(rb_eRuntimeError, "hash modified during iteration"); @@ -199,10 +185,7 @@ hash_foreach_call(arg) } void -rb_hash_foreach(hash, func, farg) - VALUE hash; - int (*func)(); - VALUE farg; +rb_hash_foreach(VALUE hash, int (*func) (/* ??? */), VALUE farg) { struct hash_foreach_arg arg; @@ -216,8 +199,7 @@ rb_hash_foreach(hash, func, farg) static VALUE hash_alloc _((VALUE)); static VALUE -hash_alloc(klass) - VALUE klass; +hash_alloc(VALUE klass) { NEWOBJ(hash, struct RHash); OBJSETUP(hash, klass, T_HASH); @@ -229,14 +211,13 @@ hash_alloc(klass) } VALUE -rb_hash_new() +rb_hash_new(void) { return hash_alloc(rb_cHash); } static void -rb_hash_modify(hash) - VALUE hash; +rb_hash_modify(VALUE hash) { if (!RHASH(hash)->tbl) rb_raise(rb_eTypeError, "uninitialized Hash"); if (OBJ_FROZEN(hash)) rb_error_frozen("hash"); @@ -280,10 +261,7 @@ rb_hash_modify(hash) */ static VALUE -rb_hash_initialize(argc, argv, hash) - int argc; - VALUE *argv; - VALUE hash; +rb_hash_initialize(int argc, VALUE *argv, VALUE hash) { VALUE ifnone; @@ -317,10 +295,7 @@ rb_hash_initialize(argc, argv, hash) */ static VALUE -rb_hash_s_create(argc, argv, klass) - int argc; - VALUE *argv; - VALUE klass; +rb_hash_s_create(int argc, VALUE *argv, VALUE klass) { VALUE hash; int i; @@ -347,16 +322,13 @@ rb_hash_s_create(argc, argv, klass) } static VALUE -to_hash(hash) - VALUE hash; +to_hash(VALUE hash) { return rb_convert_type(hash, T_HASH, "Hash", "to_hash"); } static int -rb_hash_rehash_i(key, value, tbl) - VALUE key, value; - st_table *tbl; +rb_hash_rehash_i(VALUE key, VALUE value, st_table *tbl) { if (key != Qundef) st_insert(tbl, key, value); return ST_CONTINUE; @@ -383,8 +355,7 @@ rb_hash_rehash_i(key, value, tbl) */ static VALUE -rb_hash_rehash(hash) - VALUE hash; +rb_hash_rehash(VALUE hash) { st_table *tbl; @@ -415,8 +386,7 @@ rb_hash_rehash(hash) */ VALUE -rb_hash_aref(hash, key) - VALUE hash, key; +rb_hash_aref(VALUE hash, VALUE key) { VALUE val; @@ -456,10 +426,7 @@ rb_hash_aref(hash, key) */ static VALUE -rb_hash_fetch(argc, argv, hash) - int argc; - VALUE *argv; - VALUE hash; +rb_hash_fetch(int argc, VALUE *argv, VALUE hash) { VALUE key, if_none; VALUE val; @@ -503,10 +470,7 @@ rb_hash_fetch(argc, argv, hash) */ static VALUE -rb_hash_default(argc, argv, hash) - int argc; - VALUE *argv; - VALUE hash; +rb_hash_default(int argc, VALUE *argv, VALUE hash) { VALUE key; @@ -538,8 +502,7 @@ rb_hash_default(argc, argv, hash) */ static VALUE -rb_hash_set_default(hash, ifnone) - VALUE hash, ifnone; +rb_hash_set_default(VALUE hash, VALUE ifnone) { rb_hash_modify(hash); RHASH(hash)->ifnone = ifnone; @@ -563,8 +526,7 @@ rb_hash_set_default(hash, ifnone) static VALUE -rb_hash_default_proc(hash) - VALUE hash; +rb_hash_default_proc(VALUE hash) { if (FL_TEST(hash, HASH_PROC_DEFAULT)) { return RHASH(hash)->ifnone; @@ -573,9 +535,7 @@ rb_hash_default_proc(hash) } static int -key_i(key, value, args) - VALUE key, value; - VALUE *args; +key_i(VALUE key, VALUE value, VALUE *args) { if (rb_equal(value, args[0])) { args[1] = key; @@ -597,8 +557,7 @@ key_i(key, value, args) */ static VALUE -rb_hash_key(hash, value) - VALUE hash, value; +rb_hash_key(VALUE hash, VALUE value) { VALUE args[2]; @@ -612,8 +571,7 @@ rb_hash_key(hash, value) /* :nodoc: */ static VALUE -rb_hash_index(hash, value) - VALUE hash, value; +rb_hash_index(VALUE hash, VALUE value) { rb_warn("Hash#index is deprecated; use Hash#key"); return rb_hash_key(hash, value); @@ -638,8 +596,7 @@ rb_hash_index(hash, value) */ VALUE -rb_hash_delete(hash, key) - VALUE hash, key; +rb_hash_delete(VALUE hash, VALUE key) { VALUE val; @@ -665,9 +622,7 @@ struct shift_var { }; static int -shift_i(key, value, var) - VALUE key, value; - struct shift_var *var; +shift_i(VALUE key, VALUE value, struct shift_var *var) { if (key == Qundef) return ST_CONTINUE; if (var->stop) return ST_STOP; @@ -691,8 +646,7 @@ shift_i(key, value, var) */ static VALUE -rb_hash_shift(hash) - VALUE hash; +rb_hash_shift(VALUE hash) { struct shift_var var; @@ -712,8 +666,7 @@ rb_hash_shift(hash) } static int -delete_if_i(key, value, hash) - VALUE key, value, hash; +delete_if_i(VALUE key, VALUE value, VALUE hash) { if (key == Qundef) return ST_CONTINUE; if (RTEST(rb_yield_values(2, key, value))) { @@ -735,8 +688,7 @@ delete_if_i(key, value, hash) */ VALUE -rb_hash_delete_if(hash) - VALUE hash; +rb_hash_delete_if(VALUE hash) { rb_hash_modify(hash); rb_hash_foreach(hash, delete_if_i, hash); @@ -752,8 +704,7 @@ rb_hash_delete_if(hash) */ VALUE -rb_hash_reject_bang(hash) - VALUE hash; +rb_hash_reject_bang(VALUE hash) { int n = RHASH(hash)->tbl->num_entries; rb_hash_delete_if(hash); @@ -772,15 +723,13 @@ rb_hash_reject_bang(hash) */ static VALUE -rb_hash_reject(hash) - VALUE hash; +rb_hash_reject(VALUE hash) { return rb_hash_delete_if(rb_obj_dup(hash)); } static int -select_i(key, value, result) - VALUE key, value, result; +select_i(VALUE key, VALUE value, VALUE result) { if (key == Qundef) return ST_CONTINUE; if (RTEST(rb_yield_values(2, key, value))) @@ -800,10 +749,7 @@ select_i(key, value, result) */ VALUE -rb_hash_values_at(argc, argv, hash) - int argc; - VALUE *argv; - VALUE hash; +rb_hash_values_at(int argc, VALUE *argv, VALUE hash) { VALUE result = rb_ary_new2(argc); long i; @@ -828,8 +774,7 @@ rb_hash_values_at(argc, argv, hash) */ VALUE -rb_hash_select(hash) - VALUE hash; +rb_hash_select(VALUE hash) { VALUE result; @@ -840,8 +785,7 @@ rb_hash_select(hash) } static int -clear_i(key, value, dummy) - VALUE key, value, dummy; +clear_i(VALUE key, VALUE value, VALUE dummy) { return ST_DELETE; } @@ -858,8 +802,7 @@ clear_i(key, value, dummy) */ static VALUE -rb_hash_clear(hash) - VALUE hash; +rb_hash_clear(VALUE hash) { rb_hash_modify(hash); if (RHASH(hash)->tbl->num_entries > 0) { @@ -888,8 +831,7 @@ rb_hash_clear(hash) */ VALUE -rb_hash_aset(hash, key, val) - VALUE hash, key, val; +rb_hash_aset(VALUE hash, VALUE key, VALUE val) { rb_hash_modify(hash); if (TYPE(key) != T_STRING || st_lookup(RHASH(hash)->tbl, key, 0)) { @@ -902,8 +844,7 @@ rb_hash_aset(hash, key, val) } static int -replace_i(key, val, hash) - VALUE key, val, hash; +replace_i(VALUE key, VALUE val, VALUE hash) { if (key != Qundef) { rb_hash_aset(hash, key, val); @@ -925,8 +866,7 @@ replace_i(key, val, hash) */ static VALUE -rb_hash_replace(hash, hash2) - VALUE hash, hash2; +rb_hash_replace(VALUE hash, VALUE hash2) { hash2 = to_hash(hash2); if (hash == hash2) return hash; @@ -957,8 +897,7 @@ rb_hash_replace(hash, hash2) */ static VALUE -rb_hash_size(hash) - VALUE hash; +rb_hash_size(VALUE hash) { return INT2FIX(RHASH(hash)->tbl->num_entries); } @@ -975,8 +914,7 @@ rb_hash_size(hash) */ static VALUE -rb_hash_empty_p(hash) - VALUE hash; +rb_hash_empty_p(VALUE hash) { if (RHASH(hash)->tbl->num_entries == 0) return Qtrue; @@ -984,8 +922,7 @@ rb_hash_empty_p(hash) } static int -each_value_i(key, value) - VALUE key, value; +each_value_i(VALUE key, VALUE value) { if (key == Qundef) return ST_CONTINUE; rb_yield(value); @@ -1009,8 +946,7 @@ each_value_i(key, value) */ static VALUE -rb_hash_each_value(hash) - VALUE hash; +rb_hash_each_value(VALUE hash) { RETURN_ENUMERATOR(hash, 0, 0); rb_hash_foreach(hash, each_value_i, 0); @@ -1018,8 +954,7 @@ rb_hash_each_value(hash) } static int -each_key_i(key, value) - VALUE key, value; +each_key_i(VALUE key, VALUE value) { if (key == Qundef) return ST_CONTINUE; rb_yield(key); @@ -1042,8 +977,7 @@ each_key_i(key, value) * b */ static VALUE -rb_hash_each_key(hash) - VALUE hash; +rb_hash_each_key(VALUE hash) { RETURN_ENUMERATOR(hash, 0, 0); rb_hash_foreach(hash, each_key_i, 0); @@ -1051,8 +985,7 @@ rb_hash_each_key(hash) } static int -each_pair_i(key, value) - VALUE key, value; +each_pair_i(VALUE key, VALUE value) { if (key == Qundef) return ST_CONTINUE; rb_yield_values(2, key, value); @@ -1077,8 +1010,7 @@ each_pair_i(key, value) */ static VALUE -rb_hash_each_pair(hash) - VALUE hash; +rb_hash_each_pair(VALUE hash) { RETURN_ENUMERATOR(hash, 0, 0); rb_hash_foreach(hash, each_pair_i, 0); @@ -1086,8 +1018,7 @@ rb_hash_each_pair(hash) } static int -each_i(key, value) - VALUE key, value; +each_i(VALUE key, VALUE value) { if (key == Qundef) return ST_CONTINUE; rb_yield(rb_assoc_new(key, value)); @@ -1115,8 +1046,7 @@ each_i(key, value) */ static VALUE -rb_hash_each(hash) - VALUE hash; +rb_hash_each(VALUE hash) { RETURN_ENUMERATOR(hash, 0, 0); rb_hash_foreach(hash, each_i, 0); @@ -1124,8 +1054,7 @@ rb_hash_each(hash) } static int -to_a_i(key, value, ary) - VALUE key, value, ary; +to_a_i(VALUE key, VALUE value, VALUE ary) { if (key == Qundef) return ST_CONTINUE; rb_ary_push(ary, rb_assoc_new(key, value)); @@ -1144,8 +1073,7 @@ to_a_i(key, value, ary) */ static VALUE -rb_hash_to_a(hash) - VALUE hash; +rb_hash_to_a(VALUE hash) { VALUE ary; @@ -1172,8 +1100,7 @@ rb_hash_to_a(hash) */ static VALUE -rb_hash_sort(hash) - VALUE hash; +rb_hash_sort(VALUE hash) { VALUE entries = rb_hash_to_a(hash); rb_ary_sort_bang(entries); @@ -1181,8 +1108,7 @@ rb_hash_sort(hash) } static int -inspect_i(key, value, str) - VALUE key, value, str; +inspect_i(VALUE key, VALUE value, VALUE str) { VALUE str2; @@ -1202,9 +1128,7 @@ inspect_i(key, value, str) } static VALUE -inspect_hash(hash, dummy, recur) - VALUE hash, dummy; - int recur; +inspect_hash(VALUE hash, VALUE dummy, int recur) { VALUE str; @@ -1225,8 +1149,7 @@ inspect_hash(hash, dummy, recur) */ static VALUE -rb_hash_inspect(hash) - VALUE hash; +rb_hash_inspect(VALUE hash) { if (RHASH(hash)->tbl == 0 || RHASH(hash)->tbl->num_entries == 0) return rb_str_new2("{}"); @@ -1234,9 +1157,7 @@ rb_hash_inspect(hash) } static VALUE -to_s_hash(hash, dummy, recur) - VALUE hash, dummy; - int recur; +to_s_hash(VALUE hash, VALUE dummy, int recur) { if (recur) return rb_str_new2("{...}"); return rb_ary_to_s(rb_hash_to_a(hash)); @@ -1256,8 +1177,7 @@ to_s_hash(hash, dummy, recur) */ static VALUE -rb_hash_to_s(hash) - VALUE hash; +rb_hash_to_s(VALUE hash) { return rb_exec_recursive(to_s_hash, hash, 0); } @@ -1270,15 +1190,13 @@ rb_hash_to_s(hash) */ static VALUE -rb_hash_to_hash(hash) - VALUE hash; +rb_hash_to_hash(VALUE hash) { return hash; } static int -keys_i(key, value, ary) - VALUE key, value, ary; +keys_i(VALUE key, VALUE value, VALUE ary) { if (key == Qundef) return ST_CONTINUE; rb_ary_push(ary, key); @@ -1298,8 +1216,7 @@ keys_i(key, value, ary) */ static VALUE -rb_hash_keys(hash) - VALUE hash; +rb_hash_keys(VALUE hash) { VALUE ary; @@ -1310,8 +1227,7 @@ rb_hash_keys(hash) } static int -values_i(key, value, ary) - VALUE key, value, ary; +values_i(VALUE key, VALUE value, VALUE ary) { if (key == Qundef) return ST_CONTINUE; rb_ary_push(ary, value); @@ -1331,8 +1247,7 @@ values_i(key, value, ary) */ static VALUE -rb_hash_values(hash) - VALUE hash; +rb_hash_values(VALUE hash) { VALUE ary; @@ -1358,9 +1273,7 @@ rb_hash_values(hash) */ static VALUE -rb_hash_has_key(hash, key) - VALUE hash; - VALUE key; +rb_hash_has_key(VALUE hash, VALUE key) { if (st_lookup(RHASH(hash)->tbl, key, 0)) { return Qtrue; @@ -1369,8 +1282,7 @@ rb_hash_has_key(hash, key) } static int -rb_hash_search_value(key, value, data) - VALUE key, value, *data; +rb_hash_search_value(VALUE key, VALUE value, VALUE *data) { if (key == Qundef) return ST_CONTINUE; if (rb_equal(value, data[1])) { @@ -1394,9 +1306,7 @@ rb_hash_search_value(key, value, data) */ static VALUE -rb_hash_has_value(hash, val) - VALUE hash; - VALUE val; +rb_hash_has_value(VALUE hash, VALUE val) { VALUE data[2]; @@ -1412,9 +1322,7 @@ struct equal_data { }; static int -equal_i(key, val1, data) - VALUE key, val1; - struct equal_data *data; +equal_i(VALUE key, VALUE val1, struct equal_data *data) { VALUE val2; @@ -1431,9 +1339,7 @@ equal_i(key, val1, data) } static VALUE -hash_equal(hash1, hash2, eql) - VALUE hash1, hash2; - int eql; /* compare default value if true */ +hash_equal(VALUE hash1, VALUE hash2, int eql /* compare default value if true */) { struct equal_data data; @@ -1479,16 +1385,13 @@ hash_equal(hash1, hash2, eql) */ static VALUE -rb_hash_equal(hash1, hash2) - VALUE hash1, hash2; +rb_hash_equal(VALUE hash1, VALUE hash2) { return hash_equal(hash1, hash2, Qfalse); } static int -rb_hash_invert_i(key, value, hash) - VALUE key, value; - VALUE hash; +rb_hash_invert_i(VALUE key, VALUE value, VALUE hash) { if (key == Qundef) return ST_CONTINUE; rb_hash_aset(hash, value, key); @@ -1508,8 +1411,7 @@ rb_hash_invert_i(key, value, hash) */ static VALUE -rb_hash_invert(hash) - VALUE hash; +rb_hash_invert(VALUE hash) { VALUE h = rb_hash_new(); @@ -1518,9 +1420,7 @@ rb_hash_invert(hash) } static int -rb_hash_update_i(key, value, hash) - VALUE key, value; - VALUE hash; +rb_hash_update_i(VALUE key, VALUE value, VALUE hash) { if (key == Qundef) return ST_CONTINUE; rb_hash_aset(hash, key, value); @@ -1528,9 +1428,7 @@ rb_hash_update_i(key, value, hash) } static int -rb_hash_update_block_i(key, value, hash) - VALUE key, value; - VALUE hash; +rb_hash_update_block_i(VALUE key, VALUE value, VALUE hash) { if (key == Qundef) return ST_CONTINUE; if (rb_hash_has_key(hash, key)) { @@ -1561,8 +1459,7 @@ rb_hash_update_block_i(key, value, hash) */ static VALUE -rb_hash_update(hash1, hash2) - VALUE hash1, hash2; +rb_hash_update(VALUE hash1, VALUE hash2) { hash2 = to_hash(hash2); if (rb_block_given_p()) { @@ -1591,8 +1488,7 @@ rb_hash_update(hash1, hash2) */ static VALUE -rb_hash_merge(hash1, hash2) - VALUE hash1, hash2; +rb_hash_merge(VALUE hash1, VALUE hash2) { return rb_hash_update(rb_obj_dup(hash1), hash2); } @@ -1618,9 +1514,7 @@ extern char **environ; #endif static VALUE -env_str_new(ptr, len) - const char *ptr; - long len; +env_str_new(const char *ptr, long len) { VALUE str = rb_tainted_str_new(ptr, len); @@ -1629,16 +1523,14 @@ env_str_new(ptr, len) } static VALUE -env_str_new2(ptr) - const char *ptr; +env_str_new2(const char *ptr) { if (!ptr) return Qnil; return env_str_new(ptr, strlen(ptr)); } static VALUE -env_delete(obj, name) - VALUE obj, name; +env_delete(VALUE obj, VALUE name) { char *nam, *val; @@ -1667,8 +1559,7 @@ env_delete(obj, name) } static VALUE -env_delete_m(obj, name) - VALUE obj, name; +env_delete_m(VALUE obj, VALUE name) { VALUE val; @@ -1678,8 +1569,7 @@ env_delete_m(obj, name) } static VALUE -rb_f_getenv(obj, name) - VALUE obj, name; +rb_f_getenv(VALUE obj, VALUE name) { char *nam, *env; @@ -1708,9 +1598,7 @@ rb_f_getenv(obj, name) } static VALUE -env_fetch(argc, argv) - int argc; - VALUE *argv; +env_fetch(int argc, VALUE *argv) { VALUE key, if_none; long block_given; @@ -1745,14 +1633,13 @@ env_fetch(argc, argv) } static void -path_tainted_p(path) - char *path; +path_tainted_p(char *path) { path_tainted = rb_path_check(path)?0:1; } int -rb_env_path_tainted() +rb_env_path_tainted(void) { if (path_tainted < 0) { path_tainted_p(getenv(PATH_ENV)); @@ -1761,8 +1648,7 @@ rb_env_path_tainted() } static int -envix(nam) - const char *nam; +envix(const char *nam) { register int i, len = strlen(nam); char **env; @@ -1783,9 +1669,7 @@ envix(nam) } void -ruby_setenv(name, value) - const char *name; - const char *value; +ruby_setenv(const char *name, const char *value) { #if defined(_WIN32) /* The sane way to deal with the environment. @@ -1865,15 +1749,13 @@ ruby_setenv(name, value) } void -ruby_unsetenv(name) - const char *name; +ruby_unsetenv(const char *name) { ruby_setenv(name, 0); } static VALUE -env_aset(obj, nm, val) - VALUE obj, nm, val; +env_aset(VALUE obj, VALUE nm, VALUE val) { char *name, *value; @@ -1909,7 +1791,7 @@ env_aset(obj, nm, val) } static VALUE -env_keys() +env_keys(void) { char **env; VALUE ary; @@ -1929,8 +1811,7 @@ env_keys() } static VALUE -env_each_key(ehash) - VALUE ehash; +env_each_key(VALUE ehash) { VALUE keys; long i; @@ -1945,7 +1826,7 @@ env_each_key(ehash) } static VALUE -env_values() +env_values(void) { VALUE ary; char **env; @@ -1965,8 +1846,7 @@ env_values() } static VALUE -env_each_value(ehash) - VALUE ehash; +env_each_value(VALUE ehash) { VALUE values = env_values(); long i; @@ -1981,9 +1861,7 @@ env_each_value(ehash) } static VALUE -env_each_i(ehash, values) - VALUE ehash; - int values; +env_each_i(VALUE ehash, int values) { char **env; VALUE ary; @@ -2014,23 +1892,21 @@ env_each_i(ehash, values) } static VALUE -env_each(ehash) - VALUE ehash; +env_each(VALUE ehash) { RETURN_ENUMERATOR(ehash, 0, 0); return env_each_i(ehash, Qfalse); } static VALUE -env_each_pair(ehash) - VALUE ehash; +env_each_pair(VALUE ehash) { RETURN_ENUMERATOR(ehash, 0, 0); return env_each_i(ehash, Qtrue); } static VALUE -env_reject_bang() +env_reject_bang(void) { volatile VALUE keys; long i; @@ -2053,16 +1929,14 @@ env_reject_bang() } static VALUE -env_delete_if() +env_delete_if(void) { env_reject_bang(); return envtbl; } static VALUE -env_values_at(argc, argv) - int argc; - VALUE *argv; +env_values_at(int argc, VALUE *argv) { VALUE result; long i; @@ -2076,8 +1950,7 @@ env_values_at(argc, argv) } static VALUE -env_select(ehash) - VALUE ehash; +env_select(VALUE ehash) { VALUE result; char **env; @@ -2103,7 +1976,7 @@ env_select(ehash) } static VALUE -env_clear() +env_clear(void) { volatile VALUE keys; long i; @@ -2120,13 +1993,13 @@ env_clear() } static VALUE -env_to_s() +env_to_s(void) { return rb_str_new2("ENV"); } static VALUE -env_inspect() +env_inspect(void) { char **env; VALUE str, i; @@ -2157,7 +2030,7 @@ env_inspect() } static VALUE -env_to_a() +env_to_a(void) { char **env; VALUE ary; @@ -2178,13 +2051,13 @@ env_to_a() } static VALUE -env_none() +env_none(void) { return Qnil; } static VALUE -env_size() +env_size(void) { int i; char **env; @@ -2198,7 +2071,7 @@ env_size() } static VALUE -env_empty_p() +env_empty_p(void) { char **env; @@ -2213,8 +2086,7 @@ env_empty_p() } static VALUE -env_has_key(env, key) - VALUE env, key; +env_has_key(VALUE env, VALUE key) { char *s; @@ -2227,8 +2099,7 @@ env_has_key(env, key) } static VALUE -env_has_value(dmy, value) - VALUE dmy, value; +env_has_value(VALUE dmy, VALUE value) { char **env; @@ -2251,8 +2122,7 @@ env_has_value(dmy, value) } static VALUE -env_key(dmy, value) - VALUE dmy, value; +env_key(VALUE dmy, VALUE value) { char **env; VALUE str; @@ -2277,15 +2147,14 @@ env_key(dmy, value) } static VALUE -env_index(dmy, value) - VALUE dmy, value; +env_index(VALUE dmy, VALUE value) { rb_warn("ENV.index is deprecated; use ENV.key"); return env_key(dmy, value); } static VALUE -env_to_hash() +env_to_hash(void) { char **env; VALUE hash; @@ -2306,13 +2175,13 @@ env_to_hash() } static VALUE -env_reject() +env_reject(void) { return rb_hash_delete_if(env_to_hash()); } static VALUE -env_shift() +env_shift(void) { char **env; @@ -2332,14 +2201,13 @@ env_shift() } static VALUE -env_invert() +env_invert(void) { return rb_hash_invert(env_to_hash()); } static int -env_replace_i(key, val, keys) - VALUE key, val, keys; +env_replace_i(VALUE key, VALUE val, VALUE keys) { if (key != Qundef) { env_aset(Qnil, key, val); @@ -2351,8 +2219,7 @@ env_replace_i(key, val, keys) } static VALUE -env_replace(env, hash) - VALUE env, hash; +env_replace(VALUE env, VALUE hash) { volatile VALUE keys; long i; @@ -2370,8 +2237,7 @@ env_replace(env, hash) } static int -env_update_i(key, val) - VALUE key, val; +env_update_i(VALUE key, VALUE val) { if (key != Qundef) { if (rb_block_given_p()) { @@ -2383,8 +2249,7 @@ env_update_i(key, val) } static VALUE -env_update(env, hash) - VALUE env, hash; +env_update(VALUE env, VALUE hash) { rb_secure(4); if (env == hash) return env; @@ -2407,7 +2272,7 @@ env_update(env, hash) */ void -Init_Hash() +Init_Hash(void) { id_hash = rb_intern("hash"); id_call = rb_intern("call"); -- cgit v1.2.3