зеркало из https://github.com/github/ruby.git
* ext/socket/socket.c (tcp_s_gethostbyname): was using
uninitialized size_t value. [ruby-talk:76946] * Minor cleanups. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
43601a1d17
Коммит
85911c410a
|
@ -1,3 +1,8 @@
|
|||
Fri Jul 25 14:34:55 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* ext/socket/socket.c (tcp_s_gethostbyname): was using
|
||||
uninitialized size_t value. [ruby-talk:76946]
|
||||
|
||||
Fri Jul 25 13:38:38 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
|
||||
|
||||
* re.c (rb_reg_options_m): use rb_reg_options() to mask internal
|
||||
|
|
8
array.c
8
array.c
|
@ -1817,7 +1817,7 @@ rb_ary_and(ary1, ary2)
|
|||
|
||||
for (i=0; i<RARRAY(ary1)->len; i++) {
|
||||
VALUE v = RARRAY(ary1)->ptr[i];
|
||||
if (st_delete(RHASH(hash)->tbl, &v, 0)) {
|
||||
if (st_delete(RHASH(hash)->tbl, (st_data_t*)&v, 0)) {
|
||||
rb_ary_push(ary3, RARRAY(ary1)->ptr[i]);
|
||||
}
|
||||
}
|
||||
|
@ -1839,13 +1839,13 @@ rb_ary_or(ary1, ary2)
|
|||
|
||||
for (i=0; i<RARRAY(ary1)->len; i++) {
|
||||
v = RARRAY(ary1)->ptr[i];
|
||||
if (st_delete(RHASH(hash)->tbl, &v, 0)) {
|
||||
if (st_delete(RHASH(hash)->tbl, (st_data_t*)&v, 0)) {
|
||||
rb_ary_push(ary3, RARRAY(ary1)->ptr[i]);
|
||||
}
|
||||
}
|
||||
for (i=0; i<RARRAY(ary2)->len; i++) {
|
||||
v = RARRAY(ary2)->ptr[i];
|
||||
if (st_delete(RHASH(hash)->tbl, &v, 0)) {
|
||||
if (st_delete(RHASH(hash)->tbl, (st_data_t*)&v, 0)) {
|
||||
rb_ary_push(ary3, RARRAY(ary2)->ptr[i]);
|
||||
}
|
||||
}
|
||||
|
@ -1870,7 +1870,7 @@ rb_ary_uniq_bang(ary)
|
|||
end = p + RARRAY(ary)->len;
|
||||
while (p < end) {
|
||||
VALUE v = *p;
|
||||
if (st_delete(RHASH(hash)->tbl, &v, 0)) {
|
||||
if (st_delete(RHASH(hash)->tbl, (st_data_t*)&v, 0)) {
|
||||
*q++ = *p;
|
||||
}
|
||||
p++;
|
||||
|
|
4
class.c
4
class.c
|
@ -72,9 +72,9 @@ rb_mod_clone(module)
|
|||
|
||||
RCLASS(clone)->iv_tbl = st_copy(RCLASS(module)->iv_tbl);
|
||||
id = rb_intern("__classpath__");
|
||||
st_delete(RCLASS(clone)->iv_tbl, &id, 0);
|
||||
st_delete(RCLASS(clone)->iv_tbl, (st_data_t*)&id, 0);
|
||||
id = rb_intern("__classid__");
|
||||
st_delete(RCLASS(clone)->iv_tbl, &id, 0);
|
||||
st_delete(RCLASS(clone)->iv_tbl, (st_data_t*)&id, 0);
|
||||
}
|
||||
if (RCLASS(module)->m_tbl) {
|
||||
RCLASS(clone)->m_tbl = st_init_numtable();
|
||||
|
|
6
dln.c
6
dln.c
|
@ -675,7 +675,7 @@ load_1(fd, disp, need_init)
|
|||
char *key = sym->n_un.n_name;
|
||||
|
||||
if (st_lookup(sym_tbl, sym[1].n_un.n_name, &old_sym)) {
|
||||
if (st_delete(undef_tbl, &key, NULL)) {
|
||||
if (st_delete(undef_tbl, (st_data_t*)&key, NULL)) {
|
||||
unlink_undef(key, old_sym->n_value);
|
||||
free(key);
|
||||
}
|
||||
|
@ -688,7 +688,7 @@ load_1(fd, disp, need_init)
|
|||
st_foreach(reloc_tbl, reloc_repl, &data);
|
||||
|
||||
st_insert(undef_tbl, strdup(sym[1].n_un.n_name), NULL);
|
||||
if (st_delete(undef_tbl, &key, NULL)) {
|
||||
if (st_delete(undef_tbl, (st_data_t*)&key, NULL)) {
|
||||
free(key);
|
||||
}
|
||||
}
|
||||
|
@ -756,7 +756,7 @@ load_1(fd, disp, need_init)
|
|||
}
|
||||
|
||||
key = sym->n_un.n_name;
|
||||
if (st_delete(undef_tbl, &key, NULL) != 0) {
|
||||
if (st_delete(undef_tbl, (st_data_t*)&key, NULL) != 0) {
|
||||
unlink_undef(key, sym->n_value);
|
||||
free(key);
|
||||
}
|
||||
|
|
14
eval.c
14
eval.c
|
@ -8206,7 +8206,7 @@ rb_thread_save_context(th)
|
|||
}
|
||||
|
||||
static int
|
||||
thread_switch(n)
|
||||
rb_thread_switch(n)
|
||||
int n;
|
||||
{
|
||||
rb_trap_immediate = (curr_thread->flags&0x100)?1:0;
|
||||
|
@ -8239,7 +8239,7 @@ thread_switch(n)
|
|||
|
||||
#define THREAD_SAVE_CONTEXT(th) \
|
||||
(rb_thread_save_context(th),\
|
||||
thread_switch((FLUSH_REGISTER_WINDOWS, setjmp((th)->context))))
|
||||
rb_thread_switch((FLUSH_REGISTER_WINDOWS, setjmp((th)->context))))
|
||||
|
||||
static void rb_thread_restore_context _((rb_thread_t,int));
|
||||
|
||||
|
@ -9137,13 +9137,13 @@ rb_thread_safe_level(thread)
|
|||
return INT2NUM(th->safe);
|
||||
}
|
||||
|
||||
static int thread_abort;
|
||||
static int ruby_thread_abort;
|
||||
static VALUE thgroup_default;
|
||||
|
||||
static VALUE
|
||||
rb_thread_s_abort_exc()
|
||||
{
|
||||
return thread_abort?Qtrue:Qfalse;
|
||||
return ruby_thread_abort?Qtrue:Qfalse;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
|
@ -9151,7 +9151,7 @@ rb_thread_s_abort_exc_set(self, val)
|
|||
VALUE self, val;
|
||||
{
|
||||
rb_secure(4);
|
||||
thread_abort = RTEST(val);
|
||||
ruby_thread_abort = RTEST(val);
|
||||
return val;
|
||||
}
|
||||
|
||||
|
@ -9380,7 +9380,7 @@ rb_thread_start_0(fn, arg, th_arg)
|
|||
rb_thread_raise(1, &ruby_errinfo, main_thread);
|
||||
}
|
||||
}
|
||||
else if (th->safe < 4 && (thread_abort || th->abort || RTEST(ruby_debug))) {
|
||||
else if (th->safe < 4 && (ruby_thread_abort || th->abort || RTEST(ruby_debug))) {
|
||||
VALUE err = system_exit(1, 0, 0);
|
||||
error_print();
|
||||
/* exit on main_thread */
|
||||
|
@ -9733,7 +9733,7 @@ rb_thread_local_aset(thread, id, val)
|
|||
th->locals = st_init_numtable();
|
||||
}
|
||||
if (NIL_P(val)) {
|
||||
st_delete(th->locals, &id, 0);
|
||||
st_delete(th->locals, (st_data_t*)&id, 0);
|
||||
return Qnil;
|
||||
}
|
||||
st_insert(th->locals, id, val);
|
||||
|
|
|
@ -1092,7 +1092,6 @@ tcp_s_gethostbyname(obj, host)
|
|||
struct hostent *h = sock_hostbyname(host);
|
||||
VALUE ary, names;
|
||||
char **pch;
|
||||
size_t size;
|
||||
|
||||
ary = rb_ary_new();
|
||||
rb_ary_push(ary, rb_str_new2(h->h_name));
|
||||
|
@ -1124,7 +1123,7 @@ tcp_s_gethostbyname(obj, host)
|
|||
#ifdef SIN6_LEN
|
||||
sin6.sin6_len = sizeof(sin6);
|
||||
#endif
|
||||
memcpy((char*)&sin6.sin6_addr, *pch, size);
|
||||
memcpy((char*)&sin6.sin6_addr, *pch, h->h_length);
|
||||
rb_ary_push(ary, mkipaddr((struct sockaddr*)&sin6));
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -192,7 +192,7 @@ syck_emitter_flush( SyckEmitter *e, long check_room )
|
|||
{
|
||||
char *header = S_ALLOC_N( char, 64 );
|
||||
S_MEMZERO( header, char, 64 );
|
||||
sprintf( header, "--- %YAML:%d.%d ", SYCK_YAML_MAJOR, SYCK_YAML_MINOR );
|
||||
sprintf( header, "--- %%YAML:%d.%d ", SYCK_YAML_MAJOR, SYCK_YAML_MINOR );
|
||||
(e->handler)( e, header, strlen( header ) );
|
||||
S_FREE( header );
|
||||
}
|
||||
|
|
1
file.c
1
file.c
|
@ -1051,6 +1051,7 @@ rb_file_s_lchmod(argc, argv)
|
|||
VALUE *argv;
|
||||
{
|
||||
rb_notimplement();
|
||||
return Qnil; /* not reached */
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
4
gc.c
4
gc.c
|
@ -1459,7 +1459,7 @@ undefine_final(os, obj)
|
|||
VALUE os, obj;
|
||||
{
|
||||
if (finalizer_table) {
|
||||
st_delete(finalizer_table, &obj, 0);
|
||||
st_delete(finalizer_table, (st_data_t*)&obj, 0);
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
@ -1533,7 +1533,7 @@ run_final(obj)
|
|||
args[0] = RARRAY(finalizers)->ptr[i];
|
||||
rb_protect((VALUE(*)_((VALUE)))run_single_final, (VALUE)args, &status);
|
||||
}
|
||||
if (finalizer_table && st_delete(finalizer_table, &obj, &table)) {
|
||||
if (finalizer_table && st_delete(finalizer_table, (st_data_t*)&obj, &table)) {
|
||||
for (i=0; i<RARRAY(table)->len; i++) {
|
||||
args[0] = RARRAY(table)->ptr[i];
|
||||
rb_protect((VALUE(*)_((VALUE)))run_single_final, (VALUE)args, &status);
|
||||
|
|
4
hash.c
4
hash.c
|
@ -407,12 +407,12 @@ rb_hash_delete(hash, key)
|
|||
|
||||
rb_hash_modify(hash);
|
||||
if (RHASH(hash)->iter_lev > 0) {
|
||||
if (st_delete_safe(RHASH(hash)->tbl, &key, &val, Qundef)) {
|
||||
if (st_delete_safe(RHASH(hash)->tbl, (st_data_t*)&key, &val, Qundef)) {
|
||||
FL_SET(hash, HASH_DELETED);
|
||||
return val;
|
||||
}
|
||||
}
|
||||
else if (st_delete(RHASH(hash)->tbl, &key, &val))
|
||||
else if (st_delete(RHASH(hash)->tbl, (st_data_t*)&key, &val))
|
||||
return val;
|
||||
if (rb_block_given_p()) {
|
||||
return rb_yield(key);
|
||||
|
|
22
lib/mathn.rb
22
lib/mathn.rb
|
@ -117,7 +117,7 @@ class Rational
|
|||
Unify = true
|
||||
|
||||
def inspect
|
||||
format "%s/%s", @numerator.inspect, @denominator.inspect
|
||||
format "%s/%s", numerator.inspect, denominator.inspect
|
||||
end
|
||||
|
||||
alias power! **
|
||||
|
@ -134,8 +134,8 @@ class Rational
|
|||
return Rational(1,1)
|
||||
end
|
||||
|
||||
npd = @numerator.prime_division
|
||||
dpd = @denominator.prime_division
|
||||
npd = numerator.prime_division
|
||||
dpd = denominator.prime_division
|
||||
if other < 0
|
||||
other = -other
|
||||
npd, dpd = dpd, npd
|
||||
|
@ -164,11 +164,11 @@ class Rational
|
|||
|
||||
elsif other.kind_of?(Integer)
|
||||
if other > 0
|
||||
num = @numerator ** other
|
||||
den = @denominator ** other
|
||||
num = numerator ** other
|
||||
den = denominator ** other
|
||||
elsif other < 0
|
||||
num = @denominator ** -other
|
||||
den = @numerator ** -other
|
||||
num = denominator ** -other
|
||||
den = numerator ** -other
|
||||
elsif other == 0
|
||||
num = 1
|
||||
den = 1
|
||||
|
@ -208,11 +208,11 @@ class Rational
|
|||
|
||||
elsif other.kind_of?(Integer)
|
||||
if other > 0
|
||||
num = @numerator ** other
|
||||
den = @denominator ** other
|
||||
num = numerator ** other
|
||||
den = denominator ** other
|
||||
elsif other < 0
|
||||
num = @denominator ** -other
|
||||
den = @numerator ** -other
|
||||
num = denominator ** -other
|
||||
den = numerator ** -other
|
||||
elsif other == 0
|
||||
num = 1
|
||||
den = 1
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
**********************************************************************/
|
||||
|
||||
#include "ruby.h"
|
||||
#include "env.h"
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
@ -131,7 +132,7 @@ rb_num_coerce_bin(x, y)
|
|||
VALUE x, y;
|
||||
{
|
||||
do_coerce(&x, &y, Qtrue);
|
||||
return rb_funcall(x, rb_frame_last_func(), 1, y);
|
||||
return rb_funcall(x, ruby_frame->orig_func, 1, y);
|
||||
}
|
||||
|
||||
VALUE
|
||||
|
@ -139,7 +140,7 @@ rb_num_coerce_cmp(x, y)
|
|||
VALUE x, y;
|
||||
{
|
||||
if (do_coerce(&x, &y, Qfalse))
|
||||
return rb_funcall(x, rb_frame_last_func(), 1, y);
|
||||
return rb_funcall(x, ruby_frame->orig_func, 1, y);
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
|
@ -150,7 +151,7 @@ num_coerce_relop(x, y)
|
|||
VALUE c, x0 = x, y0 = y;
|
||||
|
||||
if (!do_coerce(&x, &y, Qfalse) ||
|
||||
NIL_P(c = rb_funcall(x, rb_frame_last_func(), 1, y))) {
|
||||
NIL_P(c = rb_funcall(x, ruby_frame->orig_func, 1, y))) {
|
||||
rb_cmperr(x0, y0);
|
||||
return Qnil; /* not reached */
|
||||
}
|
||||
|
|
|
@ -297,7 +297,7 @@ rb_waitpid(pid, st, flags)
|
|||
#else /* NO_WAITPID */
|
||||
if (pid_tbl && st_lookup(pid_tbl, pid, st)) {
|
||||
last_status_set(*st, pid);
|
||||
st_delete(pid_tbl, &pid, NULL);
|
||||
st_delete(pid_tbl, (st_data_t*)&pid, NULL);
|
||||
return pid;
|
||||
}
|
||||
|
||||
|
@ -1487,6 +1487,7 @@ p_sys_issetugid(obj)
|
|||
}
|
||||
#else
|
||||
rb_notimplement();
|
||||
return Qnil; /* not reached */
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
20
variable.c
20
variable.c
|
@ -155,7 +155,7 @@ classname(klass)
|
|||
}
|
||||
path = rb_str_new2(rb_id2name(SYM2ID(path)));
|
||||
st_insert(ROBJECT(klass)->iv_tbl, classpath, path);
|
||||
st_delete(RCLASS(klass)->iv_tbl, &classid, 0);
|
||||
st_delete(RCLASS(klass)->iv_tbl, (st_data_t*)&classid, 0);
|
||||
}
|
||||
if (TYPE(path) != T_STRING) {
|
||||
rb_bug("class path is not set properly");
|
||||
|
@ -188,7 +188,7 @@ rb_class_path(klass)
|
|||
|
||||
path = find_class_path(klass);
|
||||
if (!NIL_P(path)) {
|
||||
st_delete(RCLASS(klass)->iv_tbl, &tmppath, 0);
|
||||
st_delete(RCLASS(klass)->iv_tbl, (st_data_t*)&tmppath, 0);
|
||||
return path;
|
||||
}
|
||||
if (RCLASS(klass)->iv_tbl && st_lookup(RCLASS(klass)->iv_tbl, tmppath, &path)) {
|
||||
|
@ -1085,7 +1085,7 @@ rb_obj_remove_instance_variable(obj, name)
|
|||
case T_OBJECT:
|
||||
case T_CLASS:
|
||||
case T_MODULE:
|
||||
if (ROBJECT(obj)->iv_tbl && st_delete(ROBJECT(obj)->iv_tbl, &id, &val)) {
|
||||
if (ROBJECT(obj)->iv_tbl && st_delete(ROBJECT(obj)->iv_tbl, (st_data_t*)&id, &val)) {
|
||||
return val;
|
||||
}
|
||||
break;
|
||||
|
@ -1184,17 +1184,17 @@ autoload_delete(mod, id)
|
|||
{
|
||||
VALUE val, file = Qnil;
|
||||
|
||||
st_delete(RCLASS(mod)->iv_tbl, &id, 0);
|
||||
st_delete(RCLASS(mod)->iv_tbl, (st_data_t*)&id, 0);
|
||||
if (st_lookup(RCLASS(mod)->iv_tbl, autoload, &val)) {
|
||||
struct st_table *tbl = check_autoload_table(val);
|
||||
|
||||
if (!st_delete(tbl, &id, &file)) file = Qnil;
|
||||
if (!st_delete(tbl, (st_data_t*)&id, &file)) file = Qnil;
|
||||
|
||||
if (tbl->num_entries == 0) {
|
||||
DATA_PTR(val) = 0;
|
||||
st_free_table(tbl);
|
||||
id = autoload;
|
||||
if (st_delete(RCLASS(mod)->iv_tbl, &id, &val)) {
|
||||
if (st_delete(RCLASS(mod)->iv_tbl, (st_data_t*)&id, &val)) {
|
||||
rb_gc_force_recycle(val);
|
||||
}
|
||||
}
|
||||
|
@ -1242,12 +1242,12 @@ autoload_file(mod, id)
|
|||
}
|
||||
|
||||
/* already loaded but not defined */
|
||||
st_delete(tbl, &id, 0);
|
||||
st_delete(tbl, (st_data_t*)&id, 0);
|
||||
if (!tbl->num_entries) {
|
||||
DATA_PTR(val) = 0;
|
||||
st_free_table(tbl);
|
||||
id = autoload;
|
||||
if (st_delete(RCLASS(mod)->iv_tbl, &id, &val)) {
|
||||
if (st_delete(RCLASS(mod)->iv_tbl, (st_data_t*)&id, &val)) {
|
||||
rb_gc_force_recycle(val);
|
||||
}
|
||||
}
|
||||
|
@ -1349,7 +1349,7 @@ rb_mod_remove_const(mod, name)
|
|||
rb_raise(rb_eSecurityError, "Insecure: can't remove constant");
|
||||
if (OBJ_FROZEN(mod)) rb_error_frozen("class/module");
|
||||
|
||||
if (RCLASS(mod)->iv_tbl && st_delete(ROBJECT(mod)->iv_tbl, &id, &val)) {
|
||||
if (RCLASS(mod)->iv_tbl && st_delete(ROBJECT(mod)->iv_tbl, (st_data_t*)&id, &val)) {
|
||||
if (val == Qundef) {
|
||||
autoload_delete(mod, id);
|
||||
val = Qnil;
|
||||
|
@ -1750,7 +1750,7 @@ rb_mod_remove_cvar(mod, name)
|
|||
rb_raise(rb_eSecurityError, "Insecure: can't remove class variable");
|
||||
if (OBJ_FROZEN(mod)) rb_error_frozen("class/module");
|
||||
|
||||
if (RCLASS(mod)->iv_tbl && st_delete(ROBJECT(mod)->iv_tbl, &id, &val)) {
|
||||
if (RCLASS(mod)->iv_tbl && st_delete(ROBJECT(mod)->iv_tbl, (st_data_t*)&id, &val)) {
|
||||
return val;
|
||||
}
|
||||
if (rb_cvar_defined(mod, id)) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче