西山和広です。 ruby_1_8のwarning: unused variableと warning: suggest parentheses around assignment used as truth value を減らすパッチを作ってみました。 Index: bignum.c =================================================================== RCS file: /src/ruby/bignum.c,v retrieving revision 1.100.2.14 diff -u -p -r1.100.2.14 bignum.c --- bignum.c 8 Jun 2005 03:20:09 -0000 1.100.2.14 +++ bignum.c 27 Jun 2005 10:30:43 -0000 @@ -455,7 +455,7 @@ rb_cstr_to_inum(str, base, badcheck) z = bignew(len, sign); zds = BDIGITS(z); for (i=len;i--;) zds[i]=0; - while (c = *str++) { + while ((c = *str++)) { if (c == '_') { if (badcheck) { if (nondigit) goto bad; Index: dir.c =================================================================== RCS file: /src/ruby/dir.c,v retrieving revision 1.92.2.26 diff -u -p -r1.92.2.26 dir.c --- dir.c 18 May 2005 14:39:22 -0000 1.92.2.26 +++ dir.c 27 Jun 2005 10:30:43 -0000 @@ -145,7 +145,7 @@ fnmatch(pat, string, flags) int period = !(flags & FNM_DOTMATCH); int nocase = flags & FNM_CASEFOLD; - while (c = *pat++) { + while ((c = *pat++)) { switch (c) { case '?': if (!*s || ISDIRSEP(*s) || PERIOD(s)) @@ -1332,7 +1332,6 @@ static VALUE dir_open_dir(path) VALUE path; { - struct dir_data *dp; VALUE dir = rb_funcall(rb_cDir, rb_intern("open"), 1, path); if (TYPE(dir) != T_DATA || Index: eval.c =================================================================== RCS file: /src/ruby/eval.c,v retrieving revision 1.616.2.102 diff -u -p -r1.616.2.102 eval.c --- eval.c 20 Jun 2005 10:00:23 -0000 1.616.2.102 +++ eval.c 27 Jun 2005 10:30:43 -0000 @@ -1223,7 +1223,7 @@ error_print() long len = elen; if (RSTRING(epath)->ptr[0] == '#') epath = 0; - if (tail = memchr(einfo, '\n', elen)) { + if ((tail = memchr(einfo, '\n', elen))) { len = tail - einfo; tail++; /* skip newline */ } @@ -5247,7 +5247,7 @@ rb_rescue2(b_proc, data1, r_proc, data2, VALUE eclass; va_init_list(args, data2); - while (eclass = va_arg(args, VALUE)) { + while ((eclass = va_arg(args, VALUE))) { if (rb_obj_is_kind_of(ruby_errinfo, eclass)) { handle = Qtrue; break; @@ -6035,7 +6035,7 @@ rb_call_super(argc, argv) int argc; const VALUE *argv; { - VALUE result, self, klass, k; + VALUE result, self, klass; if (ruby_frame->last_class == 0) { rb_name_error(ruby_frame->last_func, "calling `super' from `%s' is prohibited", @@ -6886,7 +6886,7 @@ search_required(fname, featurep, path) if (ext && !strchr(ext, '/')) { if (strcmp(".rb", ext) == 0) { if (rb_feature_p(ftptr, ext, Qtrue)) return 'r'; - if (*path = rb_find_file(fname)) return 'r'; + if ((*path = rb_find_file(fname))) return 'r'; return 0; } else if (IS_SOEXT(ext)) { @@ -6903,14 +6903,14 @@ search_required(fname, featurep, path) #else rb_str_cat2(tmp, DLEXT); OBJ_FREEZE(tmp); - if (*path = rb_find_file(tmp)) { + if ((*path = rb_find_file(tmp))) { return 's'; } #endif } else if (IS_DLEXT(ext)) { if (rb_feature_p(ftptr, ext, Qfalse)) return 's'; - if (*path = rb_find_file(fname)) return 's'; + if ((*path = rb_find_file(fname))) return 's'; } } tmp = fname; @@ -10648,7 +10648,9 @@ rb_thread_select(max, read, write, excep fd_set *read, *write, *except; struct timeval *timeout; { +#ifndef linux double limit; +#endif int n; if (!read && !write && !except) { @@ -10660,10 +10662,12 @@ rb_thread_select(max, read, write, excep return 0; } +#ifndef linux if (timeout) { limit = timeofday()+ (double)timeout->tv_sec+(double)timeout->tv_usec*1e-6; } +#endif if (rb_thread_critical || curr_thread == curr_thread->next || @@ -11509,7 +11513,7 @@ rb_thread_start_0(fn, arg, th) { volatile rb_thread_t th_save = th; volatile VALUE thread = th->thread; - struct BLOCK *volatile saved_block = 0, *block; + struct BLOCK *volatile saved_block = 0; enum thread_status status; int state; @@ -12353,7 +12357,6 @@ rb_callcc(self) volatile rb_thread_t th_save; struct tag *tag; struct RVarmap *vars; - struct BLOCK *blk; THREAD_ALLOC(th); cont = Data_Wrap_Struct(rb_cCont, thread_mark, thread_free, th); Index: hash.c =================================================================== RCS file: /src/ruby/hash.c,v retrieving revision 1.128.2.12 diff -u -p -r1.128.2.12 hash.c --- hash.c 13 Jun 2005 04:04:33 -0000 1.128.2.12 +++ hash.c 27 Jun 2005 10:30:43 -0000 @@ -880,8 +880,6 @@ static VALUE rb_hash_clear(hash) VALUE hash; { - void *tmp; - rb_hash_modify(hash); if (RHASH(hash)->tbl->num_entries > 0) { rb_hash_foreach(hash, clear_i, 0); Index: marshal.c =================================================================== RCS file: /src/ruby/marshal.c,v retrieving revision 1.109.2.6 diff -u -p -r1.109.2.6 marshal.c --- marshal.c 28 Feb 2005 02:45:19 -0000 1.109.2.6 +++ marshal.c 27 Jun 2005 10:30:43 -0000 @@ -374,8 +374,8 @@ w_extended(klass, arg, check) char *path; if (FL_TEST(klass, FL_SINGLETON)) { - if (check && RCLASS(klass)->m_tbl->num_entries || - (RCLASS(klass)->iv_tbl && RCLASS(klass)->iv_tbl->num_entries > 1)) { + 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"); } klass = RCLASS(klass)->super; @@ -468,7 +468,7 @@ w_object(obj, arg, limit) return; } - if (ivtbl = rb_generic_ivar_table(obj)) { + if ((ivtbl = rb_generic_ivar_table(obj))) { w_byte(TYPE_IVAR, arg); } if (obj == Qnil) { Index: numeric.c =================================================================== RCS file: /src/ruby/numeric.c,v retrieving revision 1.101.2.17 diff -u -p -r1.101.2.17 numeric.c --- numeric.c 24 May 2005 14:52:04 -0000 1.101.2.17 +++ numeric.c 27 Jun 2005 10:30:43 -0000 @@ -1516,7 +1516,7 @@ rb_num2long(val) char *s; sprintf(buf, "%-.10g", RFLOAT(val)->value); - if (s = strchr(buf, ' ')) *s = '\0'; + if ((s = strchr(buf, ' '))) *s = '\0'; rb_raise(rb_eRangeError, "float %s out of range of integer", buf); } @@ -1667,7 +1667,7 @@ rb_num2ll(val) char *s; sprintf(buf, "%-.10g", RFLOAT(val)->value); - if (s = strchr(buf, ' ')) *s = '\0'; + if ((s = strchr(buf, ' '))) *s = '\0'; rb_raise(rb_eRangeError, "float %s out of range of long long", buf); } Index: process.c =================================================================== RCS file: /src/ruby/process.c,v retrieving revision 1.92.2.19 diff -u -p -r1.92.2.19 process.c --- process.c 14 May 2005 14:57:48 -0000 1.92.2.19 +++ process.c 27 Jun 2005 10:30:43 -0000 @@ -1061,8 +1061,8 @@ rb_proc_exec(str) a = argv = ALLOCA_N(char*, (s-str)/2+2); ss = ALLOCA_N(char, s-str+1); strcpy(ss, str); - if (*a++ = strtok(ss, " \t")) { - while (t = strtok(NULL, " \t")) { + if ((*a++ = strtok(ss, " \t"))) { + while ((t = strtok(NULL, " \t"))) { *a++ = t; } *a = NULL; @@ -1351,7 +1351,13 @@ rb_syswait(pid) int pid; { static int overriding; - RETSIGTYPE (*hfunc)_((int)), (*qfunc)_((int)), (*ifunc)_((int)); +#ifdef SIGHUP + RETSIGTYPE (*hfunc)_((int)); +#endif +#ifdef SIGQUIT + RETSIGTYPE (*qfunc)_((int)); +#endif + RETSIGTYPE (*ifunc)_((int)); int status; int i, hooked = Qfalse; Index: re.c =================================================================== RCS file: /src/ruby/re.c,v retrieving revision 1.114.2.14 diff -u -p -r1.114.2.14 re.c --- re.c 23 May 2005 03:24:28 -0000 1.114.2.14 +++ re.c 27 Jun 2005 10:30:44 -0000 @@ -77,7 +77,7 @@ rb_memcicmp(p1, p2, len) int tmp; while (len--) { - if (tmp = casetable[(unsigned)*p1++] - casetable[(unsigned)*p2++]) + if ((tmp = casetable[(unsigned)*p1++] - casetable[(unsigned)*p2++])) return tmp; } return 0; Index: ruby.c =================================================================== RCS file: /src/ruby/ruby.c,v retrieving revision 1.83.2.10 diff -u -p -r1.83.2.10 ruby.c --- ruby.c 24 May 2005 14:52:04 -0000 1.83.2.10 +++ ruby.c 27 Jun 2005 10:30:44 -0000 @@ -1005,7 +1005,9 @@ set_arg0(val, id) { char *s; long i; +#if !defined(PSTAT_SETCMD) && !defined(HAVE_SETPROCTITLE) static int len; +#endif if (origargv == 0) rb_raise(rb_eRuntimeError, "$0 not initialized"); StringValue(val); Index: struct.c =================================================================== RCS file: /src/ruby/struct.c,v retrieving revision 1.51.2.10 diff -u -p -r1.51.2.10 struct.c --- struct.c 11 May 2005 01:11:48 -0000 1.51.2.10 +++ struct.c 27 Jun 2005 10:30:44 -0000 @@ -252,7 +252,7 @@ rb_struct_define(name, va_alist) ary = rb_ary_new(); va_init_list(ar, name); - while (mem = va_arg(ar, char*)) { + while ((mem = va_arg(ar, char*))) { ID slot = rb_intern(mem); rb_ary_push(ary, ID2SYM(slot)); } Index: util.c =================================================================== RCS file: /src/ruby/util.c,v retrieving revision 1.38.2.6 diff -u -p -r1.38.2.6 util.c --- util.c 21 Sep 2004 09:35:28 -0000 1.38.2.6 +++ util.c 27 Jun 2005 10:30:47 -0000 @@ -782,7 +782,7 @@ ruby_strtod(string, endPtr) * and also locate the decimal point. */ - for ( ; c = *p; p += 1) { + for ( ; (c = *p); p += 1) { if (!ISDIGIT(c)) { if (c != '.' || hasPoint) { break; -- |ZnZ(ゼット エヌ ゼット) |西山和広(Kazuhiro NISHIYAMA)