Int vs Long cleanup #3 (ruby-core:352)

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2754 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
michal 2002-08-28 08:05:23 +00:00
Родитель 3685a85b3d
Коммит 0d0ae37e50
13 изменённых файлов: 95 добавлений и 97 удалений

Просмотреть файл

@ -35,10 +35,10 @@ int ruby_nerrs;
static void
err_snprintf(buf, len, fmt, args)
char *buf, *fmt;
int len;
long len;
va_list args;
{
int n;
long n;
ruby_set_current_source();
if (!ruby_sourcefile) {

6
eval.c
Просмотреть файл

@ -1006,7 +1006,7 @@ error_print()
}
else {
char *tail = 0;
int len = elen;
long len = elen;
if (RSTRING(epath)->ptr[0] == '#') epath = 0;
if (tail = strchr(einfo, '\n')) {
@ -3518,12 +3518,12 @@ rb_mod_method_defined(mod, mid)
return Qfalse;
}
NORETURN(static void terminate_process _((int, const char*, int)));
NORETURN(static void terminate_process _((int, const char*, long)));
static void
terminate_process(status, mesg, mlen)
int status;
const char *mesg;
int mlen;
long mlen;
{
VALUE exit = rb_exc_new(rb_eSystemExit, mesg, mlen);

38
file.c
Просмотреть файл

@ -79,7 +79,7 @@ VALUE rb_cFile;
VALUE rb_mFileTest;
static VALUE rb_cStat;
static int
static long
apply2files(func, vargs, arg)
void (*func)();
VALUE vargs;
@ -844,7 +844,7 @@ rb_file_s_size(klass, fname)
if (rb_stat(fname, &st) < 0)
rb_sys_fail(RSTRING(fname)->ptr);
return rb_int2inum(st.st_size);
return OFFT2NUM(st.st_size);
}
static VALUE
@ -994,14 +994,15 @@ rb_file_s_chmod(argc, argv)
{
VALUE vmode;
VALUE rest;
int mode, n;
int mode;
long n;
rb_secure(2);
rb_scan_args(argc, argv, "1*", &vmode, &rest);
mode = NUM2INT(vmode);
n = apply2files(chmod_internal, rest, mode);
return INT2FIX(n);
return LONG2FIX(n);
}
static VALUE
@ -1044,14 +1045,15 @@ rb_file_s_lchmod(argc, argv)
{
VALUE vmode;
VALUE rest;
int mode, n;
int mode;
long n;
rb_secure(2);
rb_scan_args(argc, argv, "1*", &vmode, &rest);
mode = NUM2INT(vmode);
n = apply2files(lchmod_internal, rest, mode);
return INT2FIX(n);
return LONG2FIX(n);
}
#else
static VALUE
@ -1083,7 +1085,7 @@ rb_file_s_chown(argc, argv)
{
VALUE o, g, rest;
struct chown_args arg;
int n;
long n;
rb_secure(2);
rb_scan_args(argc, argv, "2*", &o, &g, &rest);
@ -1101,7 +1103,7 @@ rb_file_s_chown(argc, argv)
}
n = apply2files(chown_internal, rest, &arg);
return INT2FIX(n);
return LONG2FIX(n);
}
static VALUE
@ -1141,7 +1143,7 @@ rb_file_s_lchown(argc, argv)
{
VALUE o, g, rest;
struct chown_args arg;
int n;
long n;
rb_secure(2);
rb_scan_args(argc, argv, "2*", &o, &g, &rest);
@ -1159,7 +1161,7 @@ rb_file_s_lchown(argc, argv)
}
n = apply2files(lchown_internal, rest, &arg);
return INT2FIX(n);
return LONG2FIX(n);
}
#else
static VALUE
@ -1191,7 +1193,7 @@ rb_file_s_utime(argc, argv)
{
VALUE atime, mtime, rest;
struct timeval tvp[2];
int n;
long n;
rb_scan_args(argc, argv, "2*", &atime, &mtime, &rest);
@ -1199,7 +1201,7 @@ rb_file_s_utime(argc, argv)
tvp[1] = rb_time_timeval(mtime);
n = apply2files(utime_internal, rest, tvp);
return INT2FIX(n);
return LONG2FIX(n);
}
#else
@ -1237,7 +1239,7 @@ rb_file_s_utime(argc, argv)
VALUE *argv;
{
VALUE atime, mtime, rest;
int n;
long n;
struct timeval tv;
struct utimbuf utbuf;
@ -1249,7 +1251,7 @@ rb_file_s_utime(argc, argv)
utbuf.modtime = tv.tv_sec;
n = apply2files(utime_internal, rest, &utbuf);
return INT2FIX(n);
return LONG2FIX(n);
}
#endif
@ -1322,11 +1324,11 @@ static VALUE
rb_file_s_unlink(klass, args)
VALUE klass, args;
{
int n;
long n;
rb_secure(2);
n = apply2files(unlink_internal, args, 0);
return INT2FIX(n);
return LONG2FIX(n);
}
static VALUE
@ -2266,10 +2268,10 @@ static VALUE
rb_stat_s(obj)
VALUE obj;
{
int size = get_stat(obj)->st_size;
off_t size = get_stat(obj)->st_size;
if (size == 0) return Qnil;
return INT2FIX(size);
return OFFT2NUM(size);
}
static VALUE

4
gc.c
Просмотреть файл

@ -777,7 +777,7 @@ rb_gc_mark_children(ptr)
case T_ARRAY:
{
int i, len = obj->as.array.len;
long i, len = obj->as.array.len;
VALUE *ptr = obj->as.array.ptr;
for (i=0; i < len; i++)
@ -839,7 +839,7 @@ rb_gc_mark_children(ptr)
case T_STRUCT:
{
int i, len = obj->as.rstruct.len;
long i, len = obj->as.rstruct.len;
VALUE *ptr = obj->as.rstruct.ptr;
for (i=0; i < len; i++)

7
io.c
Просмотреть файл

@ -555,7 +555,7 @@ rb_io_fread(ptr, len, f)
while (n > 0) {
#ifdef READ_DATA_PENDING_COUNT
int i = READ_DATA_PENDING_COUNT(f);
long i = READ_DATA_PENDING_COUNT(f);
if (i <= 0) {
rb_thread_wait_fd(fileno(f));
i = READ_DATA_PENDING_COUNT(f);
@ -599,7 +599,6 @@ rb_io_fread(ptr, len, f)
*ptr++ = c;
n--;
}
return len - n;
}
@ -724,7 +723,7 @@ appendline(fptr, delim, strp)
do {
#ifdef READ_DATA_PENDING_PTR
int pending = READ_DATA_PENDING_COUNT(f);
long pending = READ_DATA_PENDING_COUNT(f);
if (pending > 0) {
const char *p = READ_DATA_PENDING_PTR(f);
const char *e = memchr(p, delim, pending);
@ -798,7 +797,7 @@ swallow(fptr, term)
do {
#ifdef READ_DATA_PENDING_PTR
int cnt;
long cnt;
while ((cnt = READ_DATA_PENDING_COUNT(f)) > 0) {
char buf[1024];
const char *p = READ_DATA_PENDING_PTR(f);

Просмотреть файл

@ -1022,7 +1022,7 @@ int_succ(num)
{
if (FIXNUM_P(num)) {
long i = FIX2LONG(num) + 1;
return rb_int2inum(i);
return LONG2NUM(i);
}
return rb_funcall(num, '+', 1, INT2FIX(1));
}
@ -1083,7 +1083,7 @@ static VALUE
fix_uminus(num)
VALUE num;
{
return rb_int2inum(-FIX2LONG(num));
return LONG2NUM(-FIX2LONG(num));
}
VALUE
@ -1385,7 +1385,7 @@ fix_rev(num)
long val = FIX2LONG(num);
val = ~val;
return rb_int2inum(val);
return LONG2NUM(val);
}
static VALUE
@ -1398,7 +1398,7 @@ fix_and(x, y)
return rb_big_and(y, x);
}
val = FIX2LONG(x) & NUM2LONG(y);
return rb_int2inum(val);
return LONG2NUM(val);
}
static VALUE
@ -1411,7 +1411,7 @@ fix_or(x, y)
return rb_big_or(y, x);
}
val = FIX2LONG(x) | NUM2LONG(y);
return rb_int2inum(val);
return LONG2NUM(val);
}
static VALUE
@ -1424,7 +1424,7 @@ fix_xor(x, y)
return rb_big_xor(y, x);
}
val = FIX2LONG(x) ^ NUM2LONG(y);
return rb_int2inum(val);
return LONG2NUM(val);
}
static VALUE fix_rshift _((VALUE, VALUE));
@ -1444,7 +1444,7 @@ fix_lshift(x, y)
return rb_big_lshift(rb_int2big(val), y);
}
val = val << width;
return rb_int2inum(val);
return LONG2NUM(val);
}
static VALUE
@ -1512,7 +1512,7 @@ fix_abs(fix)
if (i < 0) i = -i;
return rb_int2inum(i);
return LONG2NUM(i);
}
static VALUE

68
pack.c
Просмотреть файл

@ -323,11 +323,11 @@ typedef unsigned int U32;
#endif
static char *toofew = "too few arguments";
static void encodes _((VALUE,char*,int,int));
static void qpencode _((VALUE,VALUE,int));
static void encodes _((VALUE,char*,long,int));
static void qpencode _((VALUE,VALUE,long));
static int uv_to_utf8 _((char*,unsigned long));
static unsigned long utf8_to_uv _((char*,int*));
static unsigned long utf8_to_uv _((char*,long*));
static VALUE
pack_pack(ary, fmt)
@ -431,7 +431,7 @@ pack_pack(ary, fmt)
case 'b':
{
int byte = 0;
int i, j = 0;
long i, j = 0;
if (len > plen) {
j = (len - plen + 1)/2;
@ -461,7 +461,7 @@ pack_pack(ary, fmt)
case 'B':
{
int byte = 0;
int i, j = 0;
long i, j = 0;
if (len > plen) {
j = (len - plen + 1)/2;
@ -490,7 +490,7 @@ pack_pack(ary, fmt)
case 'h':
{
int byte = 0;
int i, j = 0;
long i, j = 0;
if (len > plen) {
j = (len - plen + 1)/2;
@ -520,7 +520,7 @@ pack_pack(ary, fmt)
case 'H':
{
int byte = 0;
int i, j = 0;
long i, j = 0;
if (len > plen) {
j = (len - plen + 1)/2;
@ -800,7 +800,7 @@ pack_pack(ary, fmt)
else
len = len / 3 * 3;
while (plen > 0) {
int todo;
long todo;
if (plen > len)
todo = len;
@ -915,11 +915,11 @@ static void
encodes(str, s, len, type)
VALUE str;
char *s;
int len;
long len;
int type;
{
char *buff = ALLOCA_N(char, len * 4 / 3 + 6);
int i = 0;
long i = 0;
char *trans = type == 'u' ? uu_table : b64_table;
int padding;
@ -959,10 +959,10 @@ static char hex_table[] = "0123456789ABCDEF";
static void
qpencode(str, from, len)
VALUE str, from;
int len;
long len;
{
char buff[1024];
int i = 0, n = 0, prev = EOF;
long i = 0, n = 0, prev = EOF;
unsigned char *s = (unsigned char*)RSTRING(from)->ptr;
unsigned char *send = s + RSTRING(from)->len;
@ -1136,7 +1136,7 @@ pack_unpack(str, fmt)
case 'A':
if (len > send - s) len = send - s;
{
int end = len;
long end = len;
char *t = s + len - 1;
while (t >= s) {
@ -1151,7 +1151,7 @@ pack_unpack(str, fmt)
case 'Z':
if (len > send - s) len = send - s;
{
int end = len;
long end = len;
char *t = s + len - 1;
while (t >= s) {
@ -1174,7 +1174,8 @@ pack_unpack(str, fmt)
{
VALUE bitstr;
char *t;
int bits, i;
int bits;
long i;
if (p[-1] == '*' || len > (send - s) * 8)
len = (send - s) * 8;
@ -1193,7 +1194,8 @@ pack_unpack(str, fmt)
{
VALUE bitstr;
char *t;
int bits, i;
int bits;
long i;
if (p[-1] == '*' || len > (send - s) * 8)
len = (send - s) * 8;
@ -1212,7 +1214,8 @@ pack_unpack(str, fmt)
{
VALUE bitstr;
char *t;
int bits, i;
int bits;
long i;
if (p[-1] == '*' || len > (send - s) * 2)
len = (send - s) * 2;
@ -1233,7 +1236,8 @@ pack_unpack(str, fmt)
{
VALUE bitstr;
char *t;
int bits, i;
int bits;
long i;
if (p[-1] == '*' || len > (send - s) * 2)
len = (send - s) * 2;
@ -1297,7 +1301,7 @@ pack_unpack(str, fmt)
int tmp;
memcpy(&tmp, s, sizeof(int));
s += sizeof(int);
rb_ary_push(ary, rb_int2inum(tmp));
rb_ary_push(ary, INT2NUM(tmp));
}
PACK_ITEM_ADJUST();
break;
@ -1308,7 +1312,7 @@ pack_unpack(str, fmt)
unsigned int tmp;
memcpy(&tmp, s, sizeof(unsigned int));
s += sizeof(unsigned int);
rb_ary_push(ary, rb_uint2inum(tmp));
rb_ary_push(ary, UINT2NUM(tmp));
}
PACK_ITEM_ADJUST();
break;
@ -1319,7 +1323,7 @@ pack_unpack(str, fmt)
long tmp = 0;
memcpy(OFF32(&tmp), s, NATINT_LEN(long,4));
s += NATINT_LEN(long,4);
rb_ary_push(ary, rb_int2inum(tmp));
rb_ary_push(ary, LONG2NUM(tmp));
}
PACK_ITEM_ADJUST();
break;
@ -1330,7 +1334,7 @@ pack_unpack(str, fmt)
unsigned long tmp = 0;
memcpy(OFF32(&tmp), s, NATINT_LEN(unsigned long,4));
s += NATINT_LEN(unsigned long,4);
rb_ary_push(ary, rb_uint2inum(tmp));
rb_ary_push(ary, ULONG2NUM(tmp));
}
PACK_ITEM_ADJUST();
break;
@ -1359,7 +1363,7 @@ pack_unpack(str, fmt)
unsigned short tmp = 0;
memcpy(OFF16B(&tmp), s, NATINT_LEN(unsigned short,2));
s += NATINT_LEN(unsigned short,2);
rb_ary_push(ary, rb_uint2inum(ntohs(tmp)));
rb_ary_push(ary, UINT2NUM(ntohs(tmp)));
}
PACK_ITEM_ADJUST();
break;
@ -1370,7 +1374,7 @@ pack_unpack(str, fmt)
unsigned long tmp = 0;
memcpy(OFF32B(&tmp), s, NATINT_LEN(unsigned long,4));
s += NATINT_LEN(unsigned long,4);
rb_ary_push(ary, rb_uint2inum(ntohl(tmp)));
rb_ary_push(ary, ULONG2NUM(ntohl(tmp)));
}
PACK_ITEM_ADJUST();
break;
@ -1381,7 +1385,7 @@ pack_unpack(str, fmt)
unsigned short tmp = 0;
memcpy(OFF16(&tmp), s, NATINT_LEN(unsigned short,2));
s += NATINT_LEN(unsigned short,2);
rb_ary_push(ary, rb_uint2inum(vtohs(tmp)));
rb_ary_push(ary, UINT2NUM(vtohs(tmp)));
}
PACK_ITEM_ADJUST();
break;
@ -1392,7 +1396,7 @@ pack_unpack(str, fmt)
unsigned long tmp = 0;
memcpy(OFF32(&tmp), s, NATINT_LEN(long,4));
s += NATINT_LEN(long,4);
rb_ary_push(ary, rb_uint2inum(vtohl(tmp)));
rb_ary_push(ary, ULONG2NUM(vtohl(tmp)));
}
PACK_ITEM_ADJUST();
break;
@ -1480,12 +1484,12 @@ pack_unpack(str, fmt)
case 'U':
if (len > send - s) len = send - s;
while (len > 0 && s < send) {
int alen = send - s;
long alen = send - s;
unsigned long l;
l = utf8_to_uv(s, &alen);
s += alen; len--;
rb_ary_push(ary, rb_uint2inum(l));
rb_ary_push(ary, ULONG2NUM(l));
}
break;
@ -1508,7 +1512,7 @@ pack_unpack(str, fmt)
}
while (len > 0) {
int mlen = len > 3 ? 3 : len;
long mlen = len > 3 ? 3 : len;
if (s < send && *s >= ' ')
a = (*s++ - ' ') & 077;
@ -1718,7 +1722,7 @@ pack_unpack(str, fmt)
ul <<= 7;
ul |= (*s & 0x7f);
if (!(*s++ & 0x80)) {
rb_ary_push(ary, rb_uint2inum(ul));
rb_ary_push(ary, ULONG2NUM(ul));
len--;
ul = 0;
}
@ -1814,11 +1818,11 @@ uv_to_utf8(buf, uv)
static unsigned long
utf8_to_uv(p, lenp)
char *p;
int *lenp;
long *lenp;
{
int c = (*p++)&0xff;
unsigned long uv;
int n = 1;
long n = 1;
if (c < 0xc0) n = 1;
else if (c < 0xe0) n = 2;

Просмотреть файл

@ -831,8 +831,7 @@ rb_f_system(argc, argv)
if (status == 0) return Qtrue;
return Qfalse;
#else
#ifdef DJGPP
#elif defined(DJGPP)
VALUE cmd;
int status;
@ -855,10 +854,8 @@ rb_f_system(argc, argv)
if (status == 0) return Qtrue;
return Qfalse;
#else
#if defined(__human68k__)
#elif defined(__human68k__)
VALUE prog = 0;
int i;
int status;
fflush(stdin);
@ -885,8 +882,7 @@ rb_f_system(argc, argv)
}
last_status_set(status == -1 ? 127 : status);
return status == 0 ? Qtrue : Qfalse;
#else
#if defined(__VMS)
#elif defined(__VMS)
VALUE cmd;
int status;
@ -962,10 +958,7 @@ rb_f_system(argc, argv)
if (NUM2INT(rb_last_status) == 0)
return Qtrue;
return Qfalse;
#endif /* __VMS */
#endif /* __human68k__ */
#endif /* DJGPP */
#endif /* NT */
#endif
}
static VALUE

10
re.c
Просмотреть файл

@ -782,7 +782,7 @@ rb_reg_nth_match(nth, match)
VALUE match;
{
VALUE str;
int start, end, len;
long start, end, len;
if (NIL_P(match)) return Qnil;
if (nth >= RMATCH(match)->regs->num_regs) {
@ -1094,7 +1094,7 @@ VALUE
rb_reg_match(re, str)
VALUE re, str;
{
int start;
long start;
if (NIL_P(str)) {
rb_backref_set(Qnil);
@ -1105,14 +1105,14 @@ rb_reg_match(re, str)
if (start < 0) {
return Qnil;
}
return INT2FIX(start);
return LONG2FIX(start);
}
VALUE
rb_reg_match2(re)
VALUE re;
{
int start;
long start;
VALUE line = rb_lastline_get();
if (TYPE(line) != T_STRING) {
@ -1124,7 +1124,7 @@ rb_reg_match2(re)
if (start < 0) {
return Qnil;
}
return INT2FIX(start);
return LONG2FIX(start);
}
static VALUE

Просмотреть файл

@ -26,7 +26,7 @@ remove_sign_bits(str, base)
int base;
{
char *s, *t, *end;
int len;
unsigned long len;
s = t = str;
len = strlen(str);

Просмотреть файл

@ -1016,7 +1016,7 @@ rb_str_succ(orig)
VALUE str;
char *sbeg, *s;
int c = -1;
int n = 0;
long n = 0;
str = rb_str_new5(orig,RSTRING(orig)->ptr, RSTRING(orig)->len);
OBJ_INFECT(str, orig);
@ -1216,7 +1216,7 @@ rb_str_subpat_set(str, re, nth, val)
VALUE val;
{
VALUE match;
int start, end, len;
long start, end, len;
if (rb_reg_search(re, str, 0, 0) < 0) {
rb_raise(rb_eIndexError, "regexp not matched");
@ -2999,7 +2999,7 @@ rb_str_sum(argc, argv, str)
VALUE str;
{
VALUE vbits;
int bits;
int bits;
char *p, *pend;
if (rb_scan_args(argc, argv, "01", &vbits) == 0) {

4
time.c
Просмотреть файл

@ -1193,7 +1193,7 @@ time_utc_offset(time)
#else
struct tm *u, *l;
time_t t;
int off;
long off;
l = &tobj->tm;
t = tobj->tv.tv_sec;
u = gmtime(&t);
@ -1210,7 +1210,7 @@ time_utc_offset(time)
off = off * 24 + l->tm_hour - u->tm_hour;
off = off * 60 + l->tm_min - u->tm_min;
off = off * 60 + l->tm_sec - u->tm_sec;
return INT2FIX(off);
return LONG2FIX(off);
#endif
}
}

12
util.c
Просмотреть файл

@ -27,9 +27,9 @@ char *strchr _((char*,char));
unsigned long
scan_oct(start, len, retlen)
const char *start;
int len;
int *retlen;
const char *start;
int len;
int *retlen;
{
register const char *s = start;
register unsigned long retval = 0;
@ -44,9 +44,9 @@ int *retlen;
unsigned long
scan_hex(start, len, retlen)
const char *start;
int len;
int *retlen;
const char *start;
int len;
int *retlen;
{
static char hexdigit[] = "0123456789abcdef0123456789ABCDEF";
register const char *s = start;