1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* eval.c, file.c, gc.c, io.c, object.c, ruby.c, ruby.h, struct.c,

ext/socket/socket.c: differentiate long and int; use proper
  printf type specifiers and do casts where appropriate.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3014 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
knu 2002-10-29 21:35:28 +00:00
parent 454abc5185
commit a2868ff651
10 changed files with 32 additions and 26 deletions

View file

@ -1,3 +1,9 @@
Wed Oct 30 06:29:00 2002 Akinori MUSHA <knu@iDaemons.org>
* eval.c, file.c, gc.c, io.c, object.c, ruby.c, ruby.h, struct.c,
ext/socket/socket.c: differentiate long and int; use proper
printf type specifiers and do casts where appropriate.
Wed Oct 30 04:07:33 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
* eval.c (error_print, rb_longjmp, rb_thread_schedule): flush

6
eval.c
View file

@ -4722,7 +4722,7 @@ rb_call(klass, recv, mid, argc, argv, scope)
struct cache_entry *ent;
if (!klass) {
rb_raise(rb_eNotImpError, "method `%s' called on terminated object (0x%x)",
rb_raise(rb_eNotImpError, "method `%s' called on terminated object (0x%lx)",
rb_id2name(mid), recv);
}
/* is it in the method cache? */
@ -9512,7 +9512,7 @@ rb_f_throw(argc, argv)
break;
}
if (tt->tag == PROT_THREAD) {
rb_raise(rb_eThreadError, "uncaught throw `%s' in thread 0x%x",
rb_raise(rb_eThreadError, "uncaught throw `%s' in thread 0x%lx",
rb_id2name(t),
curr_thread);
}
@ -9549,7 +9549,7 @@ return_check()
break;
}
if (tt->tag == PROT_THREAD) {
rb_raise(rb_eThreadError, "return from within thread 0x%x",
rb_raise(rb_eThreadError, "return from within thread 0x%lx",
curr_thread);
}
tt = tt->prev;

View file

@ -824,13 +824,13 @@ load_addr_info(h, serv, type, res)
host = NULL;
}
if (FIXNUM_P(serv)) {
snprintf(pbuf, sizeof(pbuf), "%ld", FIX2UINT(serv));
snprintf(pbuf, sizeof(pbuf), "%u", FIX2UINT(serv));
portp = pbuf;
}
else {
SafeStringValue(serv);
if (RSTRING(serv)->len >= sizeof(pbuf))
rb_raise(rb_eArgError, "servicename too long (%d)", RSTRING(serv)->len);
rb_raise(rb_eArgError, "servicename too long (%ld)", RSTRING(serv)->len);
strcpy(pbuf, RSTRING(serv)->ptr);
portp = pbuf;
}
@ -2126,7 +2126,7 @@ sock_s_getaddrinfo(argc, argv)
pptr = NULL;
}
else if (FIXNUM_P(port)) {
snprintf(pbuf, sizeof(pbuf), "%ld", FIX2INT(port));
snprintf(pbuf, sizeof(pbuf), "%d", FIX2INT(port));
pptr = pbuf;
}
else {
@ -2227,7 +2227,7 @@ sock_s_getnameinfo(argc, argv)
}
}
else {
rb_raise(rb_eArgError, "array size should be 3 or 4, %d given",
rb_raise(rb_eArgError, "array size should be 3 or 4, %ld given",
RARRAY(sa)->len);
}
/* host */
@ -2245,7 +2245,7 @@ sock_s_getnameinfo(argc, argv)
pptr = NULL;
}
else if (FIXNUM_P(port)) {
snprintf(pbuf, sizeof(pbuf), "%ld", NUM2INT(port));
snprintf(pbuf, sizeof(pbuf), "%d", NUM2INT(port));
pptr = pbuf;
}
else {
@ -2331,7 +2331,7 @@ sock_s_unpack_sockaddr_in(self, addr)
sockaddr = (struct sockaddr_in*)StringValuePtr(addr);
if (RSTRING(addr)->len != sizeof(struct sockaddr_in)) {
rb_raise(rb_eTypeError, "sockaddr_in size differs - %d required; %d given",
rb_raise(rb_eTypeError, "sockaddr_in size differs - %ld required; %d given",
RSTRING(addr)->len, sizeof(struct sockaddr_in));
}
host = mkipaddr(sockaddr);
@ -2365,7 +2365,7 @@ sock_s_unpack_sockaddr_un(self, addr)
sockaddr = (struct sockaddr_un*)StringValuePtr(addr);
if (RSTRING(addr)->len != sizeof(struct sockaddr_un)) {
rb_raise(rb_eTypeError, "sockaddr_un size differs - %d required; %d given",
rb_raise(rb_eTypeError, "sockaddr_un size differs - %ld required; %d given",
RSTRING(addr)->len, sizeof(struct sockaddr_un));
}
/* xxx: should I check against sun_path size? */

2
file.c
View file

@ -333,7 +333,7 @@ rb_stat_inspect(self)
if (i == 2) { /* mode */
char buf[32];
sprintf(buf, "0%lo", NUM2INT(v));
sprintf(buf, "0%o", NUM2INT(v));
rb_str_buf_cat2(str, buf);
}
else if (i == 0 || i == 6) { /* dev/rdev */

8
gc.c
View file

@ -856,7 +856,7 @@ rb_gc_mark_children(ptr)
break;
default:
rb_bug("rb_gc_mark(): unknown data type 0x%x(0x%x) %s",
rb_bug("rb_gc_mark(): unknown data type 0x%lx(0x%lx) %s",
obj->as.basic.flags & T_MASK, obj,
is_pointer_to_heap(obj) ? "corrupted object" : "non object");
}
@ -1143,7 +1143,7 @@ obj_free(obj)
break;
default:
rb_bug("gc_sweep(): unknown data type 0x%x(%d)", obj,
rb_bug("gc_sweep(): unknown data type 0x%lx(%ld)", obj,
RANY(obj)->as.basic.flags & T_MASK);
}
}
@ -1568,10 +1568,10 @@ id2ref(obj, id)
ptr = id ^ FIXNUM_FLAG; /* unset FIXNUM_FLAG */
if (!is_pointer_to_heap((void *)ptr)) {
rb_raise(rb_eRangeError, "0x%x is not id value", p0);
rb_raise(rb_eRangeError, "0x%lx is not id value", p0);
}
if (BUILTIN_TYPE(ptr) == 0) {
rb_raise(rb_eRangeError, "0x%x is recycled object", p0);
rb_raise(rb_eRangeError, "0x%lx is recycled object", p0);
}
return (VALUE)ptr;
}

2
io.c
View file

@ -786,7 +786,7 @@ io_read(argc, argv, io)
len = NUM2LONG(length);
if (len < 0) {
rb_raise(rb_eArgError, "negative length %d given", len);
rb_raise(rb_eArgError, "negative length %ld given", len);
}
if (feof(fptr->f)) return Qnil;

View file

@ -776,7 +776,7 @@ rb_to_id(name)
case T_FIXNUM:
id = FIX2LONG(name);
if (!rb_id2name(id)) {
rb_raise(rb_eArgError, "%d is not a symbol", id);
rb_raise(rb_eArgError, "%ld is not a symbol", id);
}
break;
case T_SYMBOL:

2
ruby.c
View file

@ -930,7 +930,7 @@ set_arg0(val, id)
}
rb_progname = rb_tainted_str_new(s, i);
#elif defined(HAVE_SETPROCTITLE)
setproctitle("%.*s", i, s);
setproctitle("%.*s", (int)i, s);
rb_progname = rb_tainted_str_new(s, i);
#else
if (len == 0) {

8
ruby.h
View file

@ -240,10 +240,10 @@ int rb_fix2int _((VALUE));
#define NUM2UINT(x) ((unsigned int)NUM2INT(x))
#define FIX2UINT(x) ((unsigned int)FIX2INT(x))
#else
#define NUM2INT(x) NUM2LONG(x)
#define NUM2UINT(x) NUM2ULONG(x)
#define FIX2INT(x) FIX2LONG(x)
#define FIX2UINT(x) FIX2ULONG(x)
#define NUM2INT(x) ((int)NUM2LONG(x))
#define NUM2UINT(x) ((unsigned int)NUM2ULONG(x))
#define FIX2INT(x) ((int)FIX2LONG(x))
#define FIX2UINT(x) ((unsigned int)FIX2ULONG(x))
#endif
#if HAVE_LONG_LONG

View file

@ -472,10 +472,10 @@ rb_struct_aref(s, idx)
i = NUM2LONG(idx);
if (i < 0) i = RSTRUCT(s)->len + i;
if (i < 0)
rb_raise(rb_eIndexError, "offset %d too small for struct(size:%d)",
rb_raise(rb_eIndexError, "offset %ld too small for struct(size:%ld)",
i, RSTRUCT(s)->len);
if (RSTRUCT(s)->len <= i)
rb_raise(rb_eIndexError, "offset %d too large for struct(size:%d)",
rb_raise(rb_eIndexError, "offset %ld too large for struct(size:%ld)",
i, RSTRUCT(s)->len);
return RSTRUCT(s)->ptr[i];
}
@ -517,11 +517,11 @@ rb_struct_aset(s, idx, val)
i = NUM2LONG(idx);
if (i < 0) i = RSTRUCT(s)->len + i;
if (i < 0) {
rb_raise(rb_eIndexError, "offset %d too small for struct(size:%d)",
rb_raise(rb_eIndexError, "offset %ld too small for struct(size:%ld)",
i, RSTRUCT(s)->len);
}
if (RSTRUCT(s)->len <= i) {
rb_raise(rb_eIndexError, "offset %d too large for struct(size:%d)",
rb_raise(rb_eIndexError, "offset %ld too large for struct(size:%ld)",
i, RSTRUCT(s)->len);
}
rb_struct_modify(s);