Re: -Wall
From:
nobu.nokada@...
Date:
2005-04-29 05:41:33 UTC
List:
ruby-core #4815
Hi,
At Thu, 28 Apr 2005 23:48:22 +0900,
Kirill A. Shutemov wrote in [ruby-core:04806]:
> Why does ruby build without -Wall in CFLAGS by default? -Wall can help to
> resolve some potential problem.
I confirmed many "parentheses around assignment" warnings and
"might be used uninitialized" except for time_mload() have no
problem, but "type-punned pointer" warnings seem a bit more
problematic. And also:
* dir.c:file_s_fnmatch() has comment leaders within its comment,
* hash.c:rb_hash_hash_i() should be static,
* re.c should include regint.h for declarations of oniguruma
functions.
Index: bignum.c
===================================================================
RCS file: /cvs/ruby/src/ruby/bignum.c,v
retrieving revision 1.110
diff -U2 -p -r1.110 bignum.c
--- bignum.c 4 Mar 2005 06:47:45 -0000 1.110
+++ bignum.c 28 Apr 2005 22:31:26 -0000
@@ -457,5 +457,5 @@ rb_cstr_to_inum(str, base, badcheck)
zds = BDIGITS(z);
for (i=len;i--;) zds[i]=0;
- while (c = *str++) {
+ while ((c = *str++) != '\0') {
if (c == '_') {
if (badcheck) {
Index: dir.c
===================================================================
RCS file: /cvs/ruby/src/ruby/dir.c,v
retrieving revision 1.138
diff -U2 -p -r1.138 dir.c
--- dir.c 11 Apr 2005 13:30:10 -0000 1.138
+++ dir.c 28 Apr 2005 22:35:30 -0000
@@ -260,5 +260,5 @@ fnmatch_helper(pcur, scur, flags)
if (ISEND(s))
RETURN(FNM_NOMATCH);
- if (t = bracket(p + 1, s, flags)) {
+ if ((t = bracket(p + 1, s, flags)) != 0) {
p = t;
Inc(s);
@@ -967,5 +967,5 @@ has_magic(s, flags)
register char c;
- while (c = *p++) {
+ while ((c = *p++) != '\0'){
switch (c) {
case '*':
@@ -998,5 +998,5 @@ find_dirsep(s, flags)
int open = 0;
- while (c = *p++) {
+ while ((c = *p++) != '\0') {
switch (c) {
case '[':
@@ -1211,16 +1211,19 @@ glob_helper(path, dirsep, exist, isdir,
}
switch (p->type) {
- case PLAIN:
+ case PLAIN:
plain = 1;
break;
- case MAGICAL:
+ case MAGICAL:
magical = 1;
break;
- case MATCH_ALL:
+ case MATCH_ALL:
match_all = 1;
break;
- case MATCH_DIR:
+ case MATCH_DIR:
match_dir = 1;
break;
+ case RECURSIVE:
+ /* not reached */
+ break;
}
}
@@ -1608,5 +1611,4 @@ dir_open_dir(path)
VALUE path;
{
- struct dir_data *dp;
VALUE dir = rb_funcall(rb_cDir, rb_intern("open"), 1, path);
@@ -1739,6 +1741,6 @@ dir_entries(io, dirname)
* File.fnmatch('*', 'dave/.profile') #=> true
*
- * File.fnmatch('* IGNORE /*', 'dave/.profile', File::FNM_PATHNAME) #=> false
- * File.fnmatch('* IGNORE /*', 'dave/.profile', File::FNM_PATHNAME | File::FNM_DOTMATCH) #=> true
+ * File.fnmatch('* IGNORE / IGNORE *', 'dave/.profile', File::FNM_PATHNAME) #=> false
+ * File.fnmatch('* IGNORE / IGNORE *', 'dave/.profile', File::FNM_PATHNAME | File::FNM_DOTMATCH) #=> true
*
* File.fnmatch('** IGNORE /foo', 'a/b/c/foo', File::FNM_PATHNAME) #=> true
Index: eval.c
===================================================================
RCS file: /cvs/ruby/src/ruby/eval.c,v
retrieving revision 1.775
diff -U2 -p -r1.775 eval.c
--- eval.c 23 Apr 2005 02:45:38 -0000 1.775
+++ eval.c 29 Apr 2005 01:19:21 -0000
@@ -375,8 +375,8 @@ search_method(klass, id, origin)
ID id;
{
- NODE *body;
+ st_data_t body;
if (!klass) return 0;
- while (!st_lookup(RCLASS(klass)->m_tbl, id, (st_data_t *)&body)) {
+ while (!st_lookup(RCLASS(klass)->m_tbl, id, &body)) {
klass = RCLASS(klass)->super;
if (!klass) return 0;
@@ -384,5 +384,5 @@ search_method(klass, id, origin)
if (origin) *origin = klass;
- return body;
+ return (NODE *)body;
}
@@ -469,5 +469,5 @@ remove_method(klass, mid)
ID mid;
{
- NODE *body;
+ st_data_t body;
if (klass == rb_cObject) {
@@ -481,6 +481,6 @@ remove_method(klass, mid)
rb_warn("removing `%s' may cause serious problem", rb_id2name(mid));
}
- if (!st_delete(RCLASS(klass)->m_tbl, &mid, (st_data_t *)&body) ||
- !body->nd_body) {
+ if (!st_delete(RCLASS(klass)->m_tbl, &mid, &body) ||
+ !((NODE *)body)->nd_body) {
rb_name_error(mid, "method `%s' not defined in %s",
rb_id2name(mid), rb_class2name(klass));
@@ -1202,5 +1202,5 @@ error_print()
if (RSTRING(epath)->ptr[0] == '#') epath = 0;
- if (tail = memchr(einfo, '\n', elen)) {
+ if ((tail = memchr(einfo, '\n', elen)) != 0) {
len = tail - einfo;
tail++; /* skip newline */
@@ -1516,5 +1516,7 @@ ruby_cleanup(ex)
extern NODE *ruby_eval_tree;
+#if 0
static void cont_call _((VALUE));
+#endif
static int
@@ -2058,5 +2060,6 @@ rb_alias(klass, name, def)
{
VALUE origin;
- NODE *orig, *body, *node;
+ NODE *orig, *body;
+ st_data_t data;
VALUE singleton = 0;
@@ -2087,5 +2090,6 @@ rb_alias(klass, name, def)
rb_clear_cache_by_id(name);
- if (RTEST(ruby_verbose) && st_lookup(RCLASS(klass)->m_tbl, name, (st_data_t *)&node)) {
+ if (RTEST(ruby_verbose) && st_lookup(RCLASS(klass)->m_tbl, name, &data)) {
+ NODE *node = (NODE *)data;
if (node->nd_cnt == 0 && node->nd_body) {
rb_warning("discarding old %s", rb_id2name(name));
@@ -3831,4 +3835,5 @@ rb_eval(self, n)
VALUE klass;
NODE *body = 0, *defn;
+ st_data_t data;
if (ruby_safe_level >= 4 && !OBJ_TAINTED(recv)) {
@@ -3844,5 +3849,6 @@ rb_eval(self, n)
if (OBJ_FROZEN(recv)) rb_error_frozen("object");
klass = rb_singleton_class(recv);
- if (st_lookup(RCLASS(klass)->m_tbl, node->nd_mid, (st_data_t *)&body)) {
+ if (st_lookup(RCLASS(klass)->m_tbl, node->nd_mid, &data)) {
+ body = (NODE *)data;
if (ruby_safe_level >= 4) {
rb_raise(rb_eSecurityError, "redefining method prohibited");
@@ -5266,5 +5272,5 @@ rb_rescue2(b_proc, data1, r_proc, data2,
va_init_list(args, data2);
- while (eclass = va_arg(args, VALUE)) {
+ while ((eclass = va_arg(args, VALUE)) != 0) {
if (rb_obj_is_kind_of(ruby_errinfo, eclass)) {
handle = Qtrue;
@@ -6020,5 +6026,5 @@ rb_call_super(argc, argv)
const VALUE *argv;
{
- VALUE result, self, klass, k;
+ VALUE result, self, klass;
if (ruby_frame->this_class == 0) {
@@ -6883,5 +6889,5 @@ search_required(fname, path)
if (strcmp(".rb", ext) == 0) {
if (rb_feature_p(ftptr, ext, Qtrue)) return 'r';
- if (tmp = rb_find_file(fname)) {
+ if ((tmp = rb_find_file(fname)) != 0) {
tmp = rb_file_expand_path(tmp, Qnil);
ext = strrchr(ftptr = RSTRING(tmp)->ptr, '.');
@@ -6907,5 +6913,5 @@ search_required(fname, path)
rb_str_cat2(tmp, DLEXT);
OBJ_FREEZE(tmp);
- if (tmp = rb_find_file(tmp)) {
+ if ((tmp = rb_find_file(tmp)) != 0) {
tmp = rb_file_expand_path(tmp, Qnil);
ext = strrchr(ftptr = RSTRING(tmp)->ptr, '.');
@@ -6918,5 +6924,5 @@ search_required(fname, path)
else if (IS_DLEXT(ext)) {
if (rb_feature_p(ftptr, ext, Qfalse)) return 's';
- if (tmp = rb_find_file(fname)) {
+ if ((tmp = rb_find_file(fname)) != 0) {
tmp = rb_file_expand_path(tmp, Qnil);
ext = strrchr(ftptr = RSTRING(tmp)->ptr, '.');
@@ -6927,5 +6933,5 @@ search_required(fname, path)
}
}
- else if (ext = rb_feature_p(ftptr, 0, Qfalse)) {
+ else if ((ext = rb_feature_p(ftptr, 0, Qfalse)) != 0) {
return (*ext && (IS_SOEXT(ext) || IS_DLEXT(ext))) ? 's' : 'r';
}
@@ -7029,5 +7035,6 @@ rb_require_safe(fname, safe)
ruby_safe_level = saved.safe;
if (ftptr) {
- if (st_delete(loading_tbl, (st_data_t *)&ftptr, 0)) { /* loading done */
+ st_data_t data = (st_data_t)ftptr;
+ if (st_delete(loading_tbl, &data, 0)) { /* loading done */
free(ftptr);
}
@@ -7739,7 +7746,7 @@ Init_eval()
__send__ = rb_intern("__send__");
- rb_global_variable((VALUE*)&top_scope);
- rb_global_variable((VALUE*)&ruby_eval_tree);
- rb_global_variable((VALUE*)&ruby_dyna_vars);
+ rb_global_variable((VALUE *)(void *)&top_scope);
+ rb_global_variable((VALUE *)(void *)&ruby_eval_tree);
+ rb_global_variable((VALUE *)(void *)&ruby_dyna_vars);
rb_define_virtual_variable("$@", errat_getter, errat_setter);
@@ -7755,5 +7762,5 @@ Init_eval()
respond_to = rb_intern("respond_to?");
basic_respond_to = rb_method_node(rb_cObject, respond_to);
- rb_global_variable((VALUE*)&basic_respond_to);
+ rb_global_variable((VALUE *)(void *)&basic_respond_to);
rb_define_global_function("raise", rb_f_raise, -1);
@@ -8671,5 +8678,4 @@ rb_block_pass(func, arg, proc)
{
VALUE b;
- struct BLOCK * volatile old_block;
struct BLOCK _block;
struct BLOCK *data;
@@ -11922,5 +11928,5 @@ rb_thread_create(fn, arg)
void *arg;
{
- Init_stack((VALUE*)&arg);
+ Init_stack((void *)&arg);
return rb_thread_start_0(fn, arg, rb_thread_alloc(rb_cThread));
}
@@ -12888,5 +12894,4 @@ thgroup_add(group, thread)
/* variables for recursive traversals */
static ID recursive_key;
-static VALUE recursive_tbl;
Index: gc.c
===================================================================
RCS file: /cvs/ruby/src/ruby/gc.c,v
retrieving revision 1.197
diff -U2 -p -r1.197 gc.c
--- gc.c 4 Mar 2005 06:47:43 -0000 1.197
+++ gc.c 28 Apr 2005 22:45:32 -0000
@@ -519,6 +519,10 @@ rb_source_filename(f)
{
char *name;
+ st_data_t data;
- if (!st_lookup(source_filenames, (st_data_t)f, (st_data_t *)&name)) {
+ if (st_lookup(source_filenames, (st_data_t)f, &data)) {
+ name = (char *)data;
+ }
+ else {
long len = strlen(f) + 1;
char *ptr = name = ALLOC_N(char, len + 1);
Index: hash.c
===================================================================
RCS file: /cvs/ruby/src/ruby/hash.c,v
retrieving revision 1.148
diff -U2 -p -r1.148 hash.c
--- hash.c 2 Apr 2005 04:23:56 -0000 1.148
+++ hash.c 28 Apr 2005 22:46:49 -0000
@@ -1497,5 +1497,5 @@ rb_hash_eql(hash1, hash2)
}
-
+static int
rb_hash_hash_i(key, value, hp)
VALUE key, value;
Index: marshal.c
===================================================================
RCS file: /cvs/ruby/src/ruby/marshal.c,v
retrieving revision 1.120
diff -U2 -p -r1.120 marshal.c
--- marshal.c 4 Mar 2005 06:47:42 -0000 1.120
+++ marshal.c 29 Apr 2005 00:28:18 -0000
@@ -375,5 +375,5 @@ w_extended(klass, arg, check)
if (FL_TEST(klass, FL_SINGLETON)) {
- if (check && RCLASS(klass)->m_tbl->num_entries ||
+ if ((check && RCLASS(klass)->m_tbl->num_entries) ||
(RCLASS(klass)->iv_tbl && RCLASS(klass)->iv_tbl->num_entries > 1)) {
rb_raise(rb_eTypeError, "singleton can't be dumped");
@@ -469,5 +469,5 @@ w_object(obj, arg, limit)
}
- if (ivtbl = rb_generic_ivar_table(obj)) {
+ if ((ivtbl = rb_generic_ivar_table(obj)) != 0) {
w_byte(TYPE_IVAR, arg);
}
Index: numeric.c
===================================================================
RCS file: /cvs/ruby/src/ruby/numeric.c,v
retrieving revision 1.119
diff -U2 -p -r1.119 numeric.c
--- numeric.c 18 Apr 2005 06:38:30 -0000 1.119
+++ numeric.c 28 Apr 2005 22:51:59 -0000
@@ -1518,5 +1518,5 @@ rb_num2long(val)
sprintf(buf, "%-.10g", RFLOAT(val)->value);
- if (s = strchr(buf, ' ')) *s = '\0';
+ if ((s = strchr(buf, ' ')) != 0) *s = '\0';
rb_raise(rb_eRangeError, "float %s out of range of integer", buf);
}
@@ -1669,5 +1669,5 @@ rb_num2ll(val)
sprintf(buf, "%-.10g", RFLOAT(val)->value);
- if (s = strchr(buf, ' ')) *s = '\0';
+ if ((s = strchr(buf, ' ')) != 0) *s = '\0';
rb_raise(rb_eRangeError, "float %s out of range of long long", buf);
}
Index: parse.y
===================================================================
RCS file: /cvs/ruby/src/ruby/parse.y,v
retrieving revision 1.377
diff -U2 -p -r1.377 parse.y
--- parse.y 14 Apr 2005 10:05:27 -0000 1.377
+++ parse.y 28 Apr 2005 22:56:33 -0000
@@ -49,6 +49,4 @@
((id)&ID_SCOPE_MASK) == ID_CLASS))
-static int is_valid_lvar _((ID id));
-
#ifndef RIPPER
char *ruby_sourcefile; /* current source file */
@@ -2465,9 +2463,8 @@ primary : literal
| tLPAREN_ARG expr {lex_state = EXPR_ENDARG;} rparen
{
+ rb_warning0("(...) interpreted as grouped expression");
/*%%%*/
- rb_warning("(...) interpreted as grouped expression");
$$ = $2;
/*%
- rb_warning0("(...) interpreted as grouped expression");
$$ = dispatch1(paren, $2);
%*/
@@ -8144,4 +8141,5 @@ rb_id2name(id)
{
char *name;
+ st_data_t data;
if (id < tLAST_TOKEN) {
@@ -8154,6 +8152,6 @@ rb_id2name(id)
}
- if (st_lookup(sym_rev_tbl, id, (st_data_t *)&name))
- return name;
+ if (st_lookup(sym_rev_tbl, id, &data))
+ return (char *)data;
if (is_attrset_id(id)) {
Index: process.c
===================================================================
RCS file: /cvs/ruby/src/ruby/process.c,v
retrieving revision 1.129
diff -U2 -p -r1.129 process.c
--- process.c 4 Mar 2005 06:47:41 -0000 1.129
+++ process.c 28 Apr 2005 23:02:59 -0000
@@ -22,4 +22,5 @@
#endif
#ifdef HAVE_UNISTD_H
+#define __USE_XOPEN_EXTENDED
#include <unistd.h>
#endif
@@ -1047,6 +1048,6 @@ rb_proc_exec(str)
}
if (*s != ' ' && !ISALPHA(*s) && strchr("*?{}[]<>()~&|\\$;'`\"\n",*s)) {
- int status;
#if defined(MSDOS)
+ int status;
before_exec();
status = system(str);
@@ -1056,5 +1057,5 @@ rb_proc_exec(str)
#elif defined(__human68k__) || defined(__CYGWIN32__) || defined(__EMX__)
char *shell = dln_find_exe("sh", 0);
- status = -1;
+ int status = -1;
before_exec();
if (shell)
@@ -1077,6 +1078,6 @@ rb_proc_exec(str)
memcpy(ss, str, s-str);
ss[s-str] = '\0';
- if (*a++ = strtok(ss, " \t")) {
- while (t = strtok(NULL, " \t")) {
+ if ((*a++ = strtok(ss, " \t")) != 0) {
+ while ((t = strtok(NULL, " \t")) != 0) {
*a++ = t;
}
Index: re.c
===================================================================
RCS file: /cvs/ruby/src/ruby/re.c,v
retrieving revision 1.139
diff -U2 -p -r1.139 re.c
--- re.c 16 Mar 2005 09:25:44 -0000 1.139
+++ re.c 28 Apr 2005 23:06:09 -0000
@@ -12,4 +12,5 @@
#include "ruby.h"
#include "re.h"
+#include "regint.h"
#include <ctype.h>
@@ -80,9 +81,7 @@ rb_memcicmp(p1, p2, len)
long len;
{
- int tmp;
-
while (len--) {
- if (tmp = casetable[(unsigned)*p1++] - casetable[(unsigned)*p2++])
- return tmp;
+ int tmp = casetable[(unsigned)*p1++] - casetable[(unsigned)*p2++];
+ if (tmp) return tmp;
}
return 0;
Index: regparse.c
===================================================================
RCS file: /cvs/ruby/src/ruby/regparse.c,v
retrieving revision 1.17
diff -U2 -p -r1.17 regparse.c
--- regparse.c 24 Apr 2005 16:23:15 -0000 1.17
+++ regparse.c 28 Apr 2005 23:08:34 -0000
@@ -3255,5 +3255,7 @@ fetch_token(OnigToken* tok, UChar** src,
case '.':
if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_DOT_ANYCHAR)) break;
+#ifdef USE_VARIABLE_META_CHARS
any_char:
+#endif
tok->type = TK_ANYCHAR;
break;
@@ -3261,5 +3263,7 @@ fetch_token(OnigToken* tok, UChar** src,
case '*':
if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ASTERISK_ZERO_INF)) break;
+#ifdef USE_VARIABLE_META_CHARS
anytime:
+#endif
tok->type = TK_OP_REPEAT;
tok->u.repeat.lower = 0;
@@ -3270,5 +3274,7 @@ fetch_token(OnigToken* tok, UChar** src,
case '+':
if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_PLUS_ONE_INF)) break;
+#ifdef USE_VARIABLE_META_CHARS
one_or_more_time:
+#endif
tok->type = TK_OP_REPEAT;
tok->u.repeat.lower = 1;
@@ -3279,5 +3285,7 @@ fetch_token(OnigToken* tok, UChar** src,
case '?':
if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_QMARK_ZERO_ONE)) break;
+#ifdef USE_VARIABLE_META_CHARS
zero_or_one_time:
+#endif
tok->type = TK_OP_REPEAT;
tok->u.repeat.lower = 0;
@@ -3382,5 +3390,7 @@ fetch_token(OnigToken* tok, UChar** src,
}
+#ifdef USE_VARIABLE_META_CHARS
out:
+#endif
*src = p;
return tok->type;
Index: ruby.c
===================================================================
RCS file: /cvs/ruby/src/ruby/ruby.c,v
retrieving revision 1.98
diff -U2 -p -r1.98 ruby.c
--- ruby.c 20 Apr 2005 21:44:20 -0000 1.98
+++ ruby.c 29 Apr 2005 00:21:40 -0000
@@ -200,5 +200,5 @@ ruby_push_include(path, filter)
while (*p) {
while (*p == sep) p++;
- if (s = strchr(p, sep)) {
+ if ((s = strchr(p, sep)) != 0) {
rb_ary_push(ary, (*filter)(rubylib_mangled_path(p, (int)(s-p))));
p = s + 1;
@@ -741,5 +741,5 @@ proc_options(argc, argv)
if (rb_safe_level() == 0 && (s = getenv("RUBYOPT"))) {
while (ISSPACE(*s)) s++;
- if (*s == 'T' || *s == '-' && *(s+1) == 'T') {
+ if (*s == 'T' || (*s == '-' && *(s+1) == 'T')) {
int numlen;
int v = 1;
@@ -885,5 +885,5 @@ load_file(fname, script)
&& RSTRING(line)->ptr[0] == '#'
&& RSTRING(line)->ptr[1] == '!') {
- if (p = strstr(RSTRING(line)->ptr, "ruby")) {
+ if ((p = strstr(RSTRING(line)->ptr, "ruby")) != 0) {
goto start_read;
}
@@ -937,5 +937,5 @@ load_file(fname, script)
if (RSTRING(line)->ptr[RSTRING(line)->len-2] == '\r')
RSTRING(line)->ptr[RSTRING(line)->len-2] = '\0';
- if (p = strstr(p, " -")) {
+ if ((p = strstr(p, " -")) != 0) {
p++; /* skip space before `-' */
while (*p == '-') {
Index: signal.c
===================================================================
RCS file: /cvs/ruby/src/ruby/signal.c,v
retrieving revision 1.59
diff -U2 -p -r1.59 signal.c
--- signal.c 4 Mar 2005 06:47:41 -0000 1.59
+++ signal.c 29 Apr 2005 00:30:30 -0000
@@ -437,4 +437,5 @@ signal_exec(sig)
}
+#if defined(HAVE_NATIVETHREAD) && defined(HAVE_NATIVETHREAD_KILL)
static void
sigsend_to_ruby_thread(sig)
@@ -459,4 +460,5 @@ sigsend_to_ruby_thread(sig)
#endif
}
+#endif
static RETSIGTYPE sighandler _((int));
Index: struct.c
===================================================================
RCS file: /cvs/ruby/src/ruby/struct.c,v
retrieving revision 1.63
diff -U2 -p -r1.63 struct.c
--- struct.c 18 Apr 2005 06:38:30 -0000 1.63
+++ struct.c 29 Apr 2005 00:30:52 -0000
@@ -251,5 +251,5 @@ rb_struct_define(name, va_alist)
va_init_list(ar, name);
- while (mem = va_arg(ar, char*)) {
+ while ((mem = va_arg(ar, char*)) != 0) {
ID slot = rb_intern(mem);
rb_ary_push(ary, ID2SYM(slot));
Index: time.c
===================================================================
RCS file: /cvs/ruby/src/ruby/time.c,v
retrieving revision 1.103
diff -U2 -p -r1.103 time.c
--- time.c 4 Mar 2005 06:47:41 -0000 1.103
+++ time.c 29 Apr 2005 00:43:22 -0000
@@ -1982,4 +1982,5 @@ time_mload(time, str)
sec = p;
usec = s;
+ gmt = 0; /* very old dump, assuming local time zone */
}
else {
Index: util.c
===================================================================
RCS file: /cvs/ruby/src/ruby/util.c,v
retrieving revision 1.46
diff -U2 -p -r1.46 util.c
--- util.c 21 Sep 2004 03:08:31 -0000 1.46
+++ util.c 29 Apr 2005 00:43:58 -0000
@@ -783,5 +783,5 @@ ruby_strtod(string, endPtr)
*/
- for ( ; c = *p; p += 1) {
+ for ( ; (c = *p) != '\0'; p += 1) {
if (!ISDIGIT(c)) {
if (c != '.' || hasPoint) {
Index: variable.c
===================================================================
RCS file: /cvs/ruby/src/ruby/variable.c,v
retrieving revision 1.120
diff -U2 -p -r1.120 variable.c
--- variable.c 4 Mar 2005 06:47:41 -0000 1.120
+++ variable.c 29 Apr 2005 01:11:35 -0000
@@ -341,6 +341,7 @@ rb_global_entry(id)
{
struct global_entry *entry;
+ st_data_t data;
- if (!st_lookup(rb_global_tbl, id, (st_data_t *)&entry)) {
+ if (!st_lookup(rb_global_tbl, id, &data)) {
struct global_variable *var;
entry = ALLOC(struct global_entry);
@@ -358,4 +359,7 @@ rb_global_entry(id)
st_add_direct(rb_global_tbl, id, (st_data_t)entry);
}
+ else {
+ entry = (struct global_entry *)data;
+ }
return entry;
}
@@ -633,10 +637,12 @@ rb_f_untrace_var(argc, argv)
struct global_entry *entry;
struct trace_var *trace;
+ st_data_t data;
rb_scan_args(argc, argv, "11", &var, &cmd);
id = rb_to_id(var);
- if (!st_lookup(rb_global_tbl, id, (st_data_t *)&entry)) {
+ if (!st_lookup(rb_global_tbl, id, &data)) {
rb_name_error(id, "undefined global variable %s", rb_id2name(id));
}
+ entry = (struct global_entry *)data;
trace = entry->var->trace;
@@ -794,4 +800,5 @@ rb_alias_variable(name1, name2)
{
struct global_entry *entry1, *entry2;
+ st_data_t data;
if (rb_safe_level() >= 4)
@@ -799,10 +806,10 @@ rb_alias_variable(name1, name2)
entry2 = rb_global_entry(name2);
- if (!st_lookup(rb_global_tbl, name1, (st_data_t *)&entry1)) {
+ if (!st_lookup(rb_global_tbl, name1, &data)) {
entry1 = ALLOC(struct global_entry);
entry1->id = name1;
st_add_direct(rb_global_tbl, name1, (st_data_t)entry1);
}
- else if (entry1->var != entry2->var) {
+ else if ((entry1 = (struct global_entry *)data)->var != entry2->var) {
struct global_variable *var = entry1->var;
if (var->block_trace) {
@@ -834,10 +841,10 @@ rb_generic_ivar_table(obj)
VALUE obj;
{
- st_table *tbl;
+ st_data_t tbl;
if (!FL_TEST(obj, FL_EXIVAR)) return 0;
if (!generic_iv_tbl) return 0;
- if (!st_lookup(generic_iv_tbl, obj, (st_data_t *)&tbl)) return 0;
- return tbl;
+ if (!st_lookup(generic_iv_tbl, obj, &tbl)) return 0;
+ return (st_table *)tbl;
}
@@ -847,13 +854,11 @@ generic_ivar_get(obj, id)
ID id;
{
- st_table *tbl;
- VALUE val;
-
if (generic_iv_tbl) {
- if (st_lookup(generic_iv_tbl, obj, (st_data_t *)&tbl)) {
- if (st_lookup(tbl, id, &val)) {
- return val;
+ st_data_t data;
+ if (st_lookup(generic_iv_tbl, (st_data_t)obj, &data)) {
+ if (st_lookup((st_table *)data, (st_data_t)id, &data)) {
+ return (VALUE)data;
+ }
}
- }
}
@@ -869,4 +874,5 @@ generic_ivar_set(obj, id, val)
{
st_table *tbl;
+ st_data_t data;
if (rb_special_const_p(obj)) {
@@ -877,5 +883,5 @@ generic_ivar_set(obj, id, val)
}
- if (!st_lookup(generic_iv_tbl, obj, (st_data_t *)&tbl)) {
+ if (!st_lookup(generic_iv_tbl, obj, &data)) {
FL_SET(obj, FL_EXIVAR);
tbl = st_init_numtable();
@@ -884,5 +890,5 @@ generic_ivar_set(obj, id, val)
return;
}
- st_insert(tbl, id, val);
+ st_insert((st_table *)data, id, val);
}
@@ -892,10 +898,9 @@ generic_ivar_defined(obj, id)
ID id;
{
- st_table *tbl;
- VALUE val;
+ st_data_t tbl, val;
if (!generic_iv_tbl) return Qfalse;
- if (!st_lookup(generic_iv_tbl, obj, (st_data_t *)&tbl)) return Qfalse;
- if (st_lookup(tbl, id, &val)) {
+ if (!st_lookup(generic_iv_tbl, obj, &tbl)) return Qfalse;
+ if (st_lookup((st_table *)tbl, id, &val)) {
return Qtrue;
}
@@ -910,11 +915,15 @@ generic_ivar_remove(obj, id, valp)
{
st_table *tbl;
+ st_data_t data;
int status;
if (!generic_iv_tbl) return 0;
- if (!st_lookup(generic_iv_tbl, obj, (st_data_t *)&tbl)) return 0;
- status = st_delete(tbl, &id, valp);
+ if (!st_lookup(generic_iv_tbl, obj, &data)) return 0;
+ tbl = (st_table *)data;
+ status = st_delete(tbl, &id, &data);
+ if (valp) *valp = (VALUE)data;
if (tbl->num_entries == 0) {
- st_delete(generic_iv_tbl, &obj, (st_data_t *)&tbl);
+ data = (st_data_t)obj;
+ st_delete(generic_iv_tbl, &data, 0);
st_free_table(tbl);
}
@@ -926,9 +935,9 @@ rb_mark_generic_ivar(obj)
VALUE obj;
{
- st_table *tbl;
+ st_data_t tbl;
if (!generic_iv_tbl) return;
- if (st_lookup(generic_iv_tbl, obj, (st_data_t *)&tbl)) {
- rb_mark_tbl(tbl);
+ if (st_lookup(generic_iv_tbl, obj, &tbl)) {
+ rb_mark_tbl((st_table *)tbl);
}
}
@@ -966,9 +975,9 @@ rb_free_generic_ivar(obj)
VALUE obj;
{
- st_table *tbl;
+ st_data_t tbl;
if (!generic_iv_tbl) return;
- if (st_delete(generic_iv_tbl, &obj, (st_data_t *)&tbl))
- st_free_table(tbl);
+ if (st_delete(generic_iv_tbl, &obj, &tbl))
+ st_free_table((st_table *)tbl);
}
@@ -977,13 +986,13 @@ rb_copy_generic_ivar(clone, obj)
VALUE clone, obj;
{
+ st_data_t data;
st_table *tbl;
if (!generic_iv_tbl) return;
if (!FL_TEST(obj, FL_EXIVAR)) return;
- if (st_lookup(generic_iv_tbl, obj, (st_data_t *)&tbl)) {
- st_table *old;
-
- if (st_lookup(generic_iv_tbl, clone, (st_data_t *)&old)) {
- st_free_table(old);
+ if (st_lookup(generic_iv_tbl, obj, &data)) {
+ tbl = (st_table *)data;
+ if (st_lookup(generic_iv_tbl, clone, &data)) {
+ st_free_table((st_table *)data);
st_insert(generic_iv_tbl, clone, (st_data_t)st_copy(tbl));
}
@@ -1128,8 +1137,8 @@ rb_obj_instance_variables(obj)
if (!generic_iv_tbl) break;
if (FL_TEST(obj, FL_EXIVAR) || rb_special_const_p(obj)) {
- st_table *tbl;
+ st_data_t tbl;
- if (st_lookup(generic_iv_tbl, obj, (st_data_t *)&tbl)) {
- st_foreach_safe(tbl, ivar_i, ary);
+ if (st_lookup(generic_iv_tbl, obj, &tbl)) {
+ st_foreach_safe((st_table *)tbl, ivar_i, ary);
}
}
@@ -1339,5 +1348,5 @@ rb_autoload_load(klass, id)
if (!load || !(file = load->nd_lit) || rb_provided(RSTRING(file)->ptr)) {
- const_missing(klass, id);
+ file = const_missing(klass, id);
}
rb_require_safe(file, load->nd_nth);
--
Nobu Nakada