summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--error.c4
-rw-r--r--eval.c6
-rw-r--r--file.c38
-rw-r--r--gc.c4
-rw-r--r--io.c7
-rw-r--r--numeric.c16
-rw-r--r--pack.c68
-rw-r--r--process.c15
-rw-r--r--re.c10
-rw-r--r--sprintf.c2
-rw-r--r--string.c6
-rw-r--r--time.c4
-rw-r--r--util.c12
13 files changed, 95 insertions, 97 deletions
diff --git a/error.c b/error.c
index adacc3c..6a4641f 100644
--- a/error.c
+++ b/error.c
@@ -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) {
diff --git a/eval.c b/eval.c
index f7b865a..425ee5a 100644
--- a/eval.c
+++ b/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);
diff --git a/file.c b/file.c
index 00b2fb0..20f0d79 100644
--- a/file.c
+++ b/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
diff --git a/gc.c b/gc.c
index 9f35459..678240a 100644
--- a/gc.c
+++ b/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++)
diff --git a/io.c b/io.c
index 3d9a438..4cd4932 100644
--- a/io.c
+++ b/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);
diff --git a/numeric.c b/numeric.c
index 1bc23a7..020fcf6 100644
--- a/numeric.c
+++ b/numeric.c
@@ -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
diff --git a/pack.c b/pack.c
index 7316c1d..0ec3741 100644
--- a/pack.c
+++ b/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;
diff --git a/process.c b/process.c
index 7385ec9..9d98bc5 100644
--- a/process.c
+++ b/process.c
@@ -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
diff --git a/re.c b/re.c
index 87c06d6..60f8140 100644
--- a/re.c
+++ b/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
diff --git a/sprintf.c b/sprintf.c
index 858fa34..e60db6f 100644
--- a/sprintf.c
+++ b/sprintf.c
@@ -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);
diff --git a/string.c b/string.c
index 4f423da..2ef8de5 100644
--- a/string.c
+++ b/string.c
@@ -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) {
diff --git a/time.c b/time.c
index 40e565c..223f5de 100644
--- a/time.c
+++ b/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
}
}
diff --git a/util.c b/util.c
index 1365101..450b865 100644
--- a/util.c
+++ b/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;