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

*.c: Int vs Long cleanup

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2734 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
michal 2002-08-21 15:47:54 +00:00
parent 022d1f123c
commit ffc13a6525
26 changed files with 147 additions and 157 deletions

12
array.c
View file

@ -250,7 +250,7 @@ rb_ary_initialize(argc, argv, ary)
rb_raise(rb_eArgError, "wrong number of arguments");
}
for (i=0; i<len; i++) {
RARRAY(ary)->ptr[i] = rb_yield(INT2NUM(i));
RARRAY(ary)->ptr[i] = rb_yield(LONG2NUM(i));
RARRAY(ary)->len = i + 1;
}
}
@ -595,7 +595,7 @@ rb_ary_rindex(ary, val)
while (i--) {
if (rb_equal(RARRAY(ary)->ptr[i], val))
return INT2NUM(i);
return LONG2NUM(i);
}
return Qnil;
}
@ -762,7 +762,7 @@ rb_ary_each_index(ary)
long i;
for (i=0; i<RARRAY(ary)->len; i++) {
rb_yield(INT2NUM(i));
rb_yield(LONG2NUM(i));
}
return ary;
}
@ -783,7 +783,7 @@ static VALUE
rb_ary_length(ary)
VALUE ary;
{
return INT2NUM(RARRAY(ary)->len);
return LONG2NUM(RARRAY(ary)->len);
}
static VALUE
@ -1408,7 +1408,7 @@ rb_ary_fill(argc, argv, ary)
if (block_p) {
while (p < pend) {
*p++ = rb_yield(INT2NUM(beg++));
*p++ = rb_yield(LONG2NUM(beg++));
}
}
else {
@ -1767,7 +1767,7 @@ rb_ary_nitems(ary)
if (!NIL_P(*p)) n++;
p++;
}
return INT2NUM(n);
return LONG2NUM(n);
}
static long

View file

@ -108,9 +108,9 @@ bignorm(x)
}
if (num >= 0) {
if (RBIGNUM(x)->sign) {
if (POSFIXABLE(num)) return INT2FIX(num);
if (POSFIXABLE(num)) return LONG2FIX(num);
}
else if (NEGFIXABLE(-(long)num)) return INT2FIX(-(long)num);
else if (NEGFIXABLE(-(long)num)) return LONG2FIX(-(long)num);
}
}
}
@ -133,7 +133,6 @@ rb_uint2big(n)
BDIGIT *digits;
VALUE big;
i = 0;
big = bignew(DIGSPERLONG, 1);
digits = BDIGITS(big);
while (i < DIGSPERLONG) {
@ -169,7 +168,7 @@ VALUE
rb_uint2inum(n)
unsigned long n;
{
if (POSFIXABLE(n)) return INT2FIX(n);
if (POSFIXABLE(n)) return LONG2FIX(n);
return rb_uint2big(n);
}
@ -177,7 +176,7 @@ VALUE
rb_int2inum(n)
long n;
{
if (FIXABLE(n)) return INT2FIX(n);
if (FIXABLE(n)) return LONG2FIX(n);
return rb_int2big(n);
}
@ -217,20 +216,20 @@ rb_quad_unpack(buf, sign)
{
unsigned LONG_LONG q;
long neg = 0;
long i = 0;
long i;
BDIGIT *digits;
VALUE big;
memcpy(&q, buf, SIZEOF_LONG_LONG);
if (sign) {
if (FIXABLE((LONG_LONG)q)) return INT2FIX((LONG_LONG)q);
if (FIXABLE((LONG_LONG)q)) return LONG2FIX((LONG_LONG)q);
if ((LONG_LONG)q < 0) {
q = -(LONG_LONG)q;
neg = 1;
}
}
else {
if (POSFIXABLE(q)) return INT2FIX(q);
if (POSFIXABLE(q)) return LONG2FIX(q);
}
i = 0;
@ -410,10 +409,10 @@ rb_cstr_to_inum(str, base, badcheck)
}
if (POSFIXABLE(val)) {
if (sign) return INT2FIX(val);
if (sign) return LONG2FIX(val);
else {
long result = -(long)val;
return INT2FIX(result);
return LONG2FIX(result);
}
}
else {
@ -498,7 +497,7 @@ rb_str_to_inum(str, base, badcheck)
int badcheck;
{
char *s;
int len;
long len;
StringValue(str);
s = RSTRING(str)->ptr;
@ -527,7 +526,6 @@ rb_ull2big(n)
BDIGIT *digits;
VALUE big;
i = 0;
big = bignew(DIGSPERLL, 1);
digits = BDIGITS(big);
while (i < DIGSPERLL) {
@ -563,7 +561,7 @@ VALUE
rb_ull2inum(n)
unsigned LONG_LONG n;
{
if (POSFIXABLE(n)) return INT2FIX(n);
if (POSFIXABLE(n)) return LONG2FIX(n);
return rb_ull2big(n);
}
@ -571,7 +569,7 @@ VALUE
rb_ll2inum(n)
LONG_LONG n;
{
if (FIXABLE(n)) return INT2FIX(n);
if (FIXABLE(n)) return LONG2FIX(n);
return rb_ll2big(n);
}
@ -937,9 +935,8 @@ bigsub(x, y)
VALUE z = 0;
BDIGIT *zds;
BDIGIT_DBL_SIGNED num;
long i;
i = RBIGNUM(x)->len;
long i = RBIGNUM(x)->len;
/* if x is larger than y, swap */
if (RBIGNUM(x)->len < RBIGNUM(y)->len) {
z = x; x = y; y = z; /* swap x y */
@ -1585,12 +1582,11 @@ rb_big_rshift(x, y)
{
BDIGIT *xds, *zds;
int shift = NUM2INT(y);
int s1 = shift/BITSPERDIG;
int s2 = shift%BITSPERDIG;
long s1 = shift/BITSPERDIG;
long s2 = shift%BITSPERDIG;
VALUE z;
BDIGIT_DBL num = 0;
long i = RBIGNUM(x)->len;
long j;
long i, j;
if (shift < 0) return rb_big_lshift(x, INT2FIX(-shift));
@ -1625,7 +1621,7 @@ rb_big_aref(x, y)
{
BDIGIT *xds;
int shift;
int s1, s2;
long s1, s2;
if (TYPE(y) == T_BIGNUM) {
if (!RBIGNUM(y)->sign || RBIGNUM(x)->sign)
@ -1662,7 +1658,7 @@ rb_big_hash(x)
for (i=0; i<len; i++) {
key ^= *digits++;
}
return INT2FIX(key);
return LONG2FIX(key);
}
static VALUE
@ -1697,9 +1693,8 @@ rb_big_rand(max, rand_buf)
double *rand_buf;
{
VALUE v;
long len;
len = RBIGNUM(max)->len;
long len = RBIGNUM(max)->len;
if (len == 0 && BDIGITS(max)[0] == 0) {
return rb_float_new(rand_buf[0]);
}
@ -1715,7 +1710,7 @@ static VALUE
rb_big_size(big)
VALUE big;
{
return INT2FIX(RBIGNUM(big)->len*SIZEOF_BDIGITS);
return LONG2FIX(RBIGNUM(big)->len*SIZEOF_BDIGITS);
}
void

View file

@ -378,7 +378,7 @@ static VALUE
check_backtrace(bt)
VALUE bt;
{
int i;
long i;
static char *err = "backtrace must be Array of String";
if (!NIL_P(bt)) {

23
eval.c
View file

@ -949,7 +949,7 @@ error_print()
VALUE errat = Qnil; /* OK */
volatile VALUE eclass;
char *einfo;
int elen;
long elen;
if (NIL_P(ruby_errinfo)) return;
@ -1028,7 +1028,7 @@ error_print()
}
if (!NIL_P(errat)) {
int i;
long i;
struct RArray *ep = RARRAY(errat);
#define TRACE_MAX (TRACE_HEAD+TRACE_TAIL+5)
@ -2337,7 +2337,7 @@ rb_eval(self, n)
}
if (nd_type(tag->nd_head) == NODE_WHEN) {
VALUE v = rb_eval(self, tag->nd_head->nd_head);
int i;
long i;
if (TYPE(v) != T_ARRAY) v = rb_ary_to_ary(v);
for (i=0; i<RARRAY(v)->len; i++) {
@ -2380,7 +2380,7 @@ rb_eval(self, n)
}
if (nd_type(tag->nd_head) == NODE_WHEN) {
VALUE v = rb_eval(self, tag->nd_head->nd_head);
int i;
long i;
if (TYPE(v) != T_ARRAY) v = rb_ary_to_ary(v);
for (i=0; i<RARRAY(v)->len; i++) {
@ -3070,7 +3070,7 @@ rb_eval(self, n)
case NODE_ARRAY:
{
VALUE ary;
int i;
long i;
i = node->nd_alen;
ary = rb_ary_new2(i);
@ -3424,7 +3424,7 @@ module_setup(module, n)
int state;
struct FRAME frame;
VALUE result; /* OK */
NODE * cnode = ruby_current_node;
NODE * cnode = ruby_current_node; /* NOT IN USE, is it OK? */
TMP_PROTECT;
frame = *ruby_frame;
@ -4764,7 +4764,7 @@ rb_apply(recv, mid, args)
int argc;
VALUE *argv;
argc = RARRAY(args)->len;
argc = RARRAY(args)->len; /* Assigns LONG, but argc is INT */
argv = ALLOCA_N(VALUE, argc);
MEMCPY(argv, RARRAY(args)->ptr, VALUE, argc);
return rb_call(CLASS_OF(recv), recv, mid, argc, argv, 1);
@ -4788,7 +4788,6 @@ rb_f_send(argc, argv, recv)
return vid;
}
#ifdef HAVE_STDARG_PROTOTYPES
#include <stdarg.h>
#define va_init_list(a,b) va_start(a,b)
@ -4812,7 +4811,7 @@ rb_funcall(recv, mid, n, va_alist)
VALUE *argv;
if (n > 0) {
int i;
long i;
argv = ALLOCA_N(VALUE, n);
@ -4940,7 +4939,7 @@ rb_f_caller(argc, argv)
void
rb_backtrace()
{
int i;
long i;
VALUE ary;
ary = backtrace(-1);
@ -5446,7 +5445,7 @@ rb_feature_p(feature, wait)
{
VALUE v;
char *f;
int i, len = strlen(feature);
long i, len = strlen(feature);
for (i = 0; i < RARRAY(rb_features)->len; ++i) {
v = RARRAY(rb_features)->ptr[i];
@ -5609,7 +5608,7 @@ rb_f_require(obj, fname)
SCOPE_SET(SCOPE_PUBLIC);
handle = dln_load(RSTRING(fname)->ptr);
rb_ary_push(ruby_dln_librefs, INT2NUM((long)handle));
rb_ary_push(ruby_dln_librefs, LONG2NUM((long)handle));
}
POP_TAG();
SCOPE_SET(old_vmode);

6
file.c
View file

@ -85,7 +85,7 @@ apply2files(func, vargs, arg)
VALUE vargs;
void *arg;
{
int i;
long i;
VALUE path;
struct RArray *args = RARRAY(vargs);
@ -2427,7 +2427,7 @@ rb_find_file_ext(filep, ext)
char *path, *found;
char *f = RSTRING(*filep)->ptr;
VALUE fname;
int i, j;
long i, j;
if (f[0] == '~') {
fname = rb_file_s_expand_path(1, filep);
@ -2508,7 +2508,7 @@ rb_find_file(path)
}
if (rb_load_path) {
int i;
long i;
Check_Type(rb_load_path, T_ARRAY);
tmp = rb_ary_new();

3
gc.c
View file

@ -1415,7 +1415,8 @@ static void
run_final(obj)
VALUE obj;
{
int i, status;
long i;
int status;
VALUE args[2], table;
args[1] = rb_ary_new3(1, rb_obj_id(obj)); /* make obj into id */

5
hash.c
View file

@ -372,8 +372,6 @@ static VALUE
rb_hash_default_proc(hash)
VALUE hash;
{
VALUE key;
if (FL_TEST(hash, HASH_PROC_DEFAULT)) {
return RHASH(hash)->ifnone;
}
@ -1339,7 +1337,8 @@ env_reject_bang()
{
volatile VALUE keys;
VALUE *ptr;
int len, del = 0;
long len;
int del = 0;
rb_secure(4);
keys = env_keys();

34
io.c
View file

@ -672,7 +672,7 @@ io_read(argc, argv, io)
VALUE io;
{
OpenFile *fptr;
int n, len;
long n, len;
VALUE length, str;
rb_scan_args(argc, argv, "01", &length);
@ -683,7 +683,7 @@ io_read(argc, argv, io)
return read_all(fptr, remain_size(fptr));
}
len = NUM2INT(length);
len = NUM2LONG(length);
if (len < 0) {
rb_raise(rb_eArgError, "negative length %d given", len);
}
@ -859,7 +859,8 @@ rb_io_getline(rs, fptr)
else {
int c, newline;
char *rsptr;
int rslen, rspara = 0;
long rslen;
int rspara = 0;
StringValue(rs);
rslen = RSTRING(rs)->len;
@ -1346,7 +1347,7 @@ rb_io_syswrite(io, str)
{
OpenFile *fptr;
FILE *f;
int n;
long n;
rb_secure(4);
if (TYPE(str) != T_STRING)
@ -1366,7 +1367,7 @@ rb_io_syswrite(io, str)
if (n == -1) rb_sys_fail(fptr->path);
return INT2FIX(n);
return LONG2FIX(n);
}
static VALUE
@ -1374,10 +1375,10 @@ rb_io_sysread(io, len)
VALUE io, len;
{
OpenFile *fptr;
int n, ilen;
long n, ilen;
VALUE str;
ilen = NUM2INT(len);
ilen = NUM2LONG(len);
GetOpenFile(io, fptr);
rb_io_check_readable(fptr);
@ -2396,7 +2397,7 @@ io_puts_ary(ary, out)
VALUE ary, out;
{
VALUE tmp;
int i;
long i;
for (i=0; i<RARRAY(ary)->len; i++) {
tmp = RARRAY(ary)->ptr[i];
@ -2979,7 +2980,8 @@ rb_f_select(argc, argv, obj)
fd_set *rp, *wp, *ep;
struct timeval *tp, timerec;
OpenFile *fptr;
int i, max = 0, n;
long i;
int max = 0, n;
int interrupt_flag = 0;
int pending = 0;
@ -3140,7 +3142,7 @@ rb_io_ctl(io, req, arg, io_p)
#if !defined(MSDOS) && !defined(__human68k__)
int cmd = NUM2ULONG(req);
OpenFile *fptr;
int len = 0;
long len = 0;
long narg = 0;
int retval;
@ -3151,7 +3153,7 @@ rb_io_ctl(io, req, arg, io_p)
narg = 0;
}
else if (FIXNUM_P(arg)) {
narg = FIX2INT(arg);
narg = FIX2LONG(arg);
}
else if (arg == Qtrue) {
narg = 1;
@ -3253,10 +3255,10 @@ rb_f_syscall(argc, argv)
rb_secure(2);
if (argc == 0)
rb_raise(rb_eArgError, "too few arguments for syscall");
arg[0] = NUM2INT(argv[0]); argv++;
arg[0] = NUM2LONG(argv[0]); argv++;
while (items--) {
if (FIXNUM_P(*argv)) {
arg[i] = (unsigned long)NUM2INT(*argv);
arg[i] = (unsigned long)NUM2LONG(*argv);
}
else {
VALUE v = *argv;
@ -3529,9 +3531,9 @@ argf_read(argc, argv)
VALUE *argv;
{
VALUE tmp, str;
int len = 0;
long len = 0;
if (argc == 1) len = NUM2INT(argv[0]);
if (argc == 1) len = NUM2LONG(argv[0]);
str = Qnil;
retry:
@ -3556,7 +3558,7 @@ argf_read(argc, argv)
}
if (RSTRING(tmp)->len < len) {
len -= RSTRING(tmp)->len;
argv[0] = INT2FIX(len);
argv[0] = LONG2FIX(len);
goto retry;
}

View file

@ -820,7 +820,7 @@ r_object(arg)
switch (type) {
case TYPE_LINK:
id = r_long(arg);
v = rb_hash_aref(arg->data, INT2FIX(id));
v = rb_hash_aref(arg->data, LONG2FIX(id));
if (NIL_P(v)) {
rb_raise(rb_eArgError, "dump format error (unlinked)");
}
@ -864,7 +864,7 @@ r_object(arg)
case TYPE_FIXNUM:
{
long i = r_long(arg);
v = INT2FIX(i);
v = LONG2FIX(i);
}
break;
@ -1004,7 +1004,7 @@ r_object(arg)
rb_id2name(slot),
rb_id2name(SYM2ID(RARRAY(mem)->ptr[i])));
}
rb_struct_aset(v, INT2FIX(i), r_object(arg));
rb_struct_aset(v, LONG2FIX(i), r_object(arg));
}
}
break;

View file

@ -701,7 +701,7 @@ flo_floor(num)
return rb_dbl2big(f);
}
val = f;
return INT2FIX(val);
return LONG2FIX(val);
}
static VALUE
@ -715,7 +715,7 @@ flo_ceil(num)
return rb_dbl2big(f);
}
val = f;
return INT2FIX(val);
return LONG2FIX(val);
}
static VALUE
@ -732,7 +732,7 @@ flo_round(num)
return rb_dbl2big(f);
}
val = f;
return INT2FIX(val);
return LONG2FIX(val);
}
static VALUE
@ -749,7 +749,7 @@ flo_truncate(num)
return rb_dbl2big(f);
}
val = f;
return INT2FIX(val);
return LONG2FIX(val);
}
static VALUE
@ -804,13 +804,13 @@ num_step(argc, argv, from)
if (diff > 0) {
while (i <= end) {
rb_yield(INT2FIX(i));
rb_yield(LONG2FIX(i));
i += diff;
}
}
else {
while (i >= end) {
rb_yield(INT2FIX(i));
rb_yield(LONG2FIX(i));
i += diff;
}
}
@ -942,7 +942,7 @@ rb_num2fix(val)
v = rb_num2long(val);
if (!FIXABLE(v))
rb_raise(rb_eRangeError, "integer %ld out of range of fixnum", v);
return INT2FIX(v);
return LONG2FIX(v);
}
#if HAVE_LONG_LONG
@ -1139,7 +1139,7 @@ fix_plus(x, y)
a = FIX2LONG(x);
b = FIX2LONG(y);
c = a + b;
r = INT2FIX(c);
r = LONG2FIX(c);
if (FIX2LONG(r) != c) {
r = rb_big_plus(rb_int2big(a), rb_int2big(b));
@ -1163,7 +1163,7 @@ fix_minus(x, y)
a = FIX2LONG(x);
b = FIX2LONG(y);
c = a - b;
r = INT2FIX(c);
r = LONG2FIX(c);
if (FIX2LONG(r) != c) {
r = rb_big_minus(rb_int2big(a), rb_int2big(b));
@ -1189,7 +1189,7 @@ fix_mul(x, y)
b = FIX2LONG(y);
c = a * b;
r = INT2FIX(c);
r = LONG2FIX(c);
if (FIX2LONG(r) != c || c/a != b) {
r = rb_big_mul(rb_int2big(a), rb_int2big(b));
@ -1239,7 +1239,7 @@ fix_div(x, y)
long div;
fixdivmod(FIX2LONG(x), FIX2LONG(y), &div, 0);
return INT2NUM(div);
return LONG2NUM(div);
}
return rb_num_coerce_bin(x, y);
}
@ -1252,7 +1252,7 @@ fix_mod(x, y)
long mod;
fixdivmod(FIX2LONG(x), FIX2LONG(y), 0, &mod);
return INT2NUM(mod);
return LONG2NUM(mod);
}
return rb_num_coerce_bin(x, y);
}
@ -1266,7 +1266,7 @@ fix_divmod(x, y)
fixdivmod(FIX2LONG(x), FIX2LONG(y), &div, &mod);
return rb_assoc_new(INT2NUM(div), INT2NUM(mod));
return rb_assoc_new(LONG2NUM(div), LONG2NUM(mod));
}
return rb_num_coerce_bin(x, y);
}
@ -1438,7 +1438,7 @@ fix_lshift(x, y)
val = NUM2LONG(x);
width = NUM2LONG(y);
if (width < 0)
return fix_rshift(x, INT2FIX(-width));
return fix_rshift(x, LONG2FIX(-width));
if (width > (sizeof(VALUE)*CHAR_BIT-1)
|| ((unsigned long)val)>>(sizeof(VALUE)*CHAR_BIT-1-width) > 0) {
return rb_big_lshift(rb_int2big(val), y);
@ -1455,7 +1455,7 @@ fix_rshift(x, y)
i = NUM2LONG(y);
if (i < 0)
return fix_lshift(x, INT2FIX(-i));
return fix_lshift(x, LONG2FIX(-i));
if (i == 0) return x;
val = FIX2LONG(x);
if (i >= sizeof(long)*CHAR_BIT-1) {
@ -1463,7 +1463,7 @@ fix_rshift(x, y)
return INT2FIX(0);
}
val = RSHIFT(val, i);
return INT2FIX(val);
return LONG2FIX(val);
}
static VALUE
@ -1540,7 +1540,7 @@ int_upto(from, to)
end = FIX2LONG(to);
for (i = FIX2LONG(from); i <= end; i++) {
rb_yield(INT2FIX(i));
rb_yield(LONG2FIX(i));
}
}
else {
@ -1564,7 +1564,7 @@ int_downto(from, to)
end = FIX2LONG(to);
for (i=FIX2LONG(from); i >= end; i--) {
rb_yield(INT2FIX(i));
rb_yield(LONG2FIX(i));
}
}
else {
@ -1588,7 +1588,7 @@ int_dotimes(num)
end = FIX2LONG(num);
for (i=0; i<end; i++) {
rb_yield(INT2FIX(i));
rb_yield(LONG2FIX(i));
}
}
else {

View file

@ -68,7 +68,7 @@ rb_obj_id(obj)
VALUE obj;
{
if (SPECIAL_CONST_P(obj)) {
return INT2NUM((long)obj);
return LONG2NUM((long)obj);
}
return (VALUE)((long)obj|FIXNUM_FLAG);
}
@ -472,7 +472,7 @@ sym_to_i(sym)
{
ID id = SYM2ID(sym);
return INT2FIX(id);
return LONG2FIX(id);
}
static VALUE
@ -731,7 +731,7 @@ rb_to_id(name)
case T_STRING:
return rb_intern(RSTRING(name)->ptr);
case T_FIXNUM:
id = FIX2INT(name);
id = FIX2LONG(name);
if (!rb_id2name(id)) {
rb_raise(rb_eArgError, "%d is not a symbol", id);
}
@ -1050,7 +1050,7 @@ rb_str_to_dbl(str, badcheck)
int badcheck;
{
char *s;
int len;
long len;
StringValue(str);
s = RSTRING(str)->ptr;
@ -1133,7 +1133,7 @@ rb_num2dbl(val)
char*
rb_str2cstr(str, len)
VALUE str;
int *len;
long *len;
{
StringValue(str);
if (len) *len = RSTRING(str)->len;

8
pack.c
View file

@ -338,9 +338,8 @@ pack_pack(ary, fmt)
char *p, *pend;
VALUE res, from, associates = 0;
char type;
long items, len, idx;
long items, len, idx, plen;
char *ptr;
int plen;
#ifdef NATINT_PACK
int natint; /* native integer */
#endif
@ -1074,7 +1073,8 @@ pack_unpack(str, fmt)
char *p, *pend;
VALUE ary;
char type;
int len, tmp, star;
long len;
int tmp, star;
#ifdef NATINT_PACK
int natint; /* native integer */
#endif
@ -1493,7 +1493,7 @@ pack_unpack(str, fmt)
{
VALUE buf = infected_str_new(0, (send - s)*3/4, str);
char *ptr = RSTRING(buf)->ptr;
int total = 0;
long total = 0;
while (s < send && *s > ' ' && *s < 'a') {
long a,b,c,d;

View file

@ -954,7 +954,7 @@ arg : lhs '=' arg
if ($2 && nd_type($2) == NODE_LIT && FIXNUM_P($2->nd_lit)) {
long i = FIX2LONG($2->nd_lit);
$2->nd_lit = INT2NUM(-i);
$2->nd_lit = LONG2NUM(-i);
$$ = $2;
}
else {
@ -3020,7 +3020,7 @@ here_document(here)
{
int c, func, indent = 0;
char *eos;
int len;
long len;
VALUE str = 0, line;
eos = RSTRING(here->nd_lit)->ptr;

View file

@ -1033,9 +1033,8 @@ proc_getpgid(obj, pid)
VALUE obj, pid;
{
#if defined(HAVE_GETPGID) && !defined(__CHECKER__)
int i;
int i = getpgid(NUM2INT(pid));
i = getpgid(NUM2INT(pid));
if (i < 0) rb_sys_fail(0);
return INT2NUM(i);
#else
@ -1148,9 +1147,8 @@ static VALUE
proc_setuid(obj, id)
VALUE obj, id;
{
int uid;
int uid = NUM2INT(id);
uid = NUM2INT(id);
#if defined(HAVE_SETRESUID) && !defined(__CHECKER__)
if (setresuid(uid, -1, -1) < 0) rb_sys_fail(0);
#elif defined HAVE_SETREUID
@ -1182,9 +1180,8 @@ static VALUE
proc_setgid(obj, id)
VALUE obj, id;
{
int gid;
int gid = NUM2INT(id);
gid = NUM2INT(id);
#if defined(HAVE_SETRESGID) && !defined(__CHECKER__)
if (setresgid(gid, -1, -1) < 0) rb_sys_fail(0);
#elif defined HAVE_SETREGID
@ -1239,6 +1236,7 @@ proc_getegid(obj)
VALUE obj;
{
int egid = getegid();
return INT2FIX(egid);
}

View file

@ -200,7 +200,7 @@ rb_f_srand(argc, argv, obj)
}
old = rand_init(seed);
return UINT2NUM(old);
return ULONG2NUM(old);
}
static VALUE

View file

@ -247,7 +247,7 @@ range_step(argc, argv, range)
if (!EXCL(range)) end += 1;
for (i=FIX2LONG(b); i<end; i+=unit) {
rb_yield(INT2NUM(i));
rb_yield(LONG2NUM(i));
}
}
else if (rb_obj_is_kind_of(b, rb_cNumeric)) {

29
re.c
View file

@ -66,7 +66,7 @@ static const char casetable[] = {
'\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377',
};
#else
>>> "You lose. You will need a translation table for your character set." <<<
# error >>> "You lose. You will need a translation table for your character set." <<<
#endif
#define MIN(a,b) (((a)>(b))?(b):(a))
@ -217,7 +217,7 @@ static void
rb_reg_expr_str(str, s, len)
VALUE str;
const char *s;
int len;
long len;
{
const char *p, *pend;
int need_escape = 0;
@ -274,7 +274,7 @@ rb_reg_expr_str(str, s, len)
static VALUE
rb_reg_desc(s, len, re)
const char *s;
int len;
long len;
VALUE re;
{
VALUE str = rb_str_buf_new2("/");
@ -425,7 +425,7 @@ rb_reg_to_s(re)
static void
rb_reg_raise(s, len, err, re)
const char *s;
int len;
long len;
const char *err;
VALUE re;
{
@ -482,7 +482,8 @@ rb_reg_kcode_m(re)
static Regexp*
make_regexp(s, len, flags)
const char *s;
int len, flags;
long len;
int flags;
{
Regexp *rp;
char *err;
@ -503,10 +504,10 @@ make_regexp(s, len, flags)
rp->options = flags;
}
err = re_compile_pattern(s, len, rp);
if (err != NULL) {
rb_reg_raise(s, len, err, 0);
}
return rp;
}
@ -650,12 +651,12 @@ rb_reg_prepare_re(re)
}
}
int
long
rb_reg_adjust_startpos(re, str, pos, reverse)
VALUE re, str;
int pos, reverse;
long pos, reverse;
{
int range;
long range;
rb_reg_check(re);
if (may_need_recompile) rb_reg_prepare_re(re);
@ -676,15 +677,15 @@ rb_reg_adjust_startpos(re, str, pos, reverse)
pos, range);
}
int
long
rb_reg_search(re, str, pos, reverse)
VALUE re, str;
int pos, reverse;
long pos, reverse;
{
int result;
long result;
VALUE match;
static struct re_registers regs;
int range;
long range;
if (pos > RSTRING(str)->len || pos < 0) {
rb_backref_set(Qnil);
@ -948,7 +949,7 @@ static void
rb_reg_initialize(obj, s, len, options)
VALUE obj;
const char *s;
int len;
long len;
int options; /* CASEFOLD = 1 */
/* EXTENDED = 2 */
/* MULTILINE = 4 */

4
re.h
View file

@ -29,9 +29,9 @@ struct RMatch {
#define RMATCH(obj) (R_CAST(RMatch)(obj))
VALUE rb_reg_regcomp _((VALUE));
int rb_reg_search _((VALUE, VALUE, int, int));
long rb_reg_search _((VALUE, VALUE, long, long));
VALUE rb_reg_regsub _((VALUE, VALUE, struct re_registers *));
int rb_reg_adjust_startpos _((VALUE, VALUE, int, int));
long rb_reg_adjust_startpos _((VALUE, VALUE, long, long));
void rb_match_busy _((VALUE));
VALUE rb_reg_quote _((VALUE));

View file

@ -185,7 +185,6 @@ typedef struct
regoff_t rm_eo; /* Byte offset from string's start to substring's end. */
} regmatch_t;
#ifdef __STDC__
extern char *re_compile_pattern (const char *, int, struct re_pattern_buffer *);

4
ruby.c
View file

@ -338,7 +338,7 @@ static void
process_sflag()
{
if (sflag) {
int n;
long n;
VALUE *args;
n = RARRAY(rb_argv)->len;
@ -881,7 +881,7 @@ set_arg0(val, id)
ID id;
{
char *s;
int i;
long i;
static int len;
if (origargv == 0) rb_raise(rb_eRuntimeError, "$0 not initialized");

2
ruby.h
View file

@ -261,7 +261,7 @@ double rb_num2dbl _((VALUE));
#define NUM2DBL(x) rb_num2dbl((VALUE)(x))
/* obsolete API - use StringValue() */
char *rb_str2cstr _((VALUE,int*));
char *rb_str2cstr _((VALUE,long*));
/* obsolete API - use StringValuePtr() */
#define STR2CSTR(x) rb_str2cstr((VALUE)(x),0)

View file

@ -256,7 +256,7 @@ rb_f_sprintf(argc, argv)
case 's':
{
VALUE arg = GETARG();
int len;
long len;
str = rb_obj_as_string(arg);
if (OBJ_TAINTED(str)) tainted = 1;

View file

@ -359,7 +359,7 @@ static VALUE
rb_str_length(str)
VALUE str;
{
return INT2NUM(RSTRING(str)->len);
return LONG2NUM(RSTRING(str)->len);
}
static VALUE
@ -875,7 +875,7 @@ rb_str_index_m(argc, argv, str)
char *p = RSTRING(str)->ptr;
for (;pos<len;pos++) {
if (p[pos] == c) return INT2NUM(pos);
if (p[pos] == c) return LONG2NUM(pos);
}
return Qnil;
}
@ -886,7 +886,7 @@ rb_str_index_m(argc, argv, str)
}
if (pos == -1) return Qnil;
return INT2NUM(pos);
return LONG2NUM(pos);
}
static long
@ -927,10 +927,10 @@ rb_str_rindex_m(argc, argv, str)
{
VALUE sub;
VALUE position;
int pos;
long pos;
if (rb_scan_args(argc, argv, "11", &sub, &position) == 2) {
pos = NUM2INT(position);
pos = NUM2LONG(position);
if (pos < 0) {
pos += RSTRING(str)->len;
if (pos < 0) {
@ -952,12 +952,12 @@ rb_str_rindex_m(argc, argv, str)
pos = rb_reg_adjust_startpos(sub, str, pos, 1);
pos = rb_reg_search(sub, str, pos, 1);
}
if (pos >= 0) return INT2NUM(pos);
if (pos >= 0) return LONG2NUM(pos);
break;
case T_STRING:
pos = rb_str_rindex(str, sub, pos);
if (pos >= 0) return INT2NUM(pos);
if (pos >= 0) return LONG2NUM(pos);
break;
case T_FIXNUM:
@ -967,7 +967,7 @@ rb_str_rindex_m(argc, argv, str)
char *pbeg = RSTRING(str)->ptr;
while (pbeg <= p) {
if (*p == c) return INT2NUM(p - RSTRING(str)->ptr);
if (*p == c) return LONG2NUM(p - RSTRING(str)->ptr);
p--;
}
return Qnil;
@ -995,7 +995,7 @@ rb_str_match(x, y)
if (start == -1) {
return Qnil;
}
return INT2NUM(start);
return LONG2NUM(start);
default:
return rb_funcall(y, rb_intern("=~"), 1, x);
@ -1197,7 +1197,7 @@ rb_str_aref_m(argc, argv, str)
if (TYPE(argv[0]) == T_REGEXP) {
return rb_str_subpat(str, argv[0], NUM2INT(argv[1]));
}
return rb_str_substr(str, NUM2INT(argv[0]), NUM2INT(argv[1]));
return rb_str_substr(str, NUM2LONG(argv[0]), NUM2LONG(argv[1]));
}
if (argc != 1) {
rb_raise(rb_eArgError, "wrong number of arguments(%d for 1)", argc);
@ -1208,8 +1208,7 @@ rb_str_aref_m(argc, argv, str)
void
rb_str_update(str, beg, len, val)
VALUE str;
long beg;
long len;
long beg, len;
VALUE val;
{
if (len < 0) rb_raise(rb_eIndexError, "negative length %ld", len);
@ -1293,7 +1292,7 @@ rb_str_aset(str, indx, val)
switch (TYPE(indx)) {
case T_FIXNUM:
num_index:
idx = NUM2INT(indx);
idx = NUM2LONG(indx);
if (RSTRING(str)->len <= idx) {
out_of_range:
rb_raise(rb_eIndexError, "index %ld out of string", idx);
@ -1353,7 +1352,7 @@ rb_str_aset_m(argc, argv, str)
rb_str_subpat_set(str, argv[0], NUM2INT(argv[1]), argv[2]);
}
else {
rb_str_update(str, NUM2INT(argv[0]), NUM2INT(argv[1]), argv[2]);
rb_str_update(str, NUM2LONG(argv[0]), NUM2LONG(argv[1]), argv[2]);
}
return argv[2];
}
@ -2615,10 +2614,9 @@ rb_str_each_line(argc, argv, str)
{
VALUE rs;
int newline;
int rslen;
char *p = RSTRING(str)->ptr, *pend = p + RSTRING(str)->len, *s;
char *ptr = p;
long len = RSTRING(str)->len;
long len = RSTRING(str)->len, rslen;
VALUE line;
if (rb_scan_args(argc, argv, "01", &rs) == 0) {
@ -2733,9 +2731,8 @@ rb_str_chomp_bang(argc, argv, str)
{
VALUE rs;
int newline;
int rslen;
char *p = RSTRING(str)->ptr;
long len = RSTRING(str)->len;
long len = RSTRING(str)->len, rslen;
if (rb_scan_args(argc, argv, "01", &rs) == 0) {
if (len == 0) return Qnil;

View file

@ -166,7 +166,7 @@ make_struct(name, member, klass)
}
nstr = rb_define_class_under(klass, cname, klass);
}
rb_iv_set(nstr, "__size__", INT2NUM(RARRAY(member)->len));
rb_iv_set(nstr, "__size__", LONG2NUM(RARRAY(member)->len));
rb_iv_set(nstr, "__member__", member);
rb_define_singleton_method(nstr, "allocate", struct_alloc, 0);
@ -576,7 +576,7 @@ static VALUE
rb_struct_size(s)
VALUE s;
{
return INT2FIX(RSTRUCT(s)->len);
return LONG2FIX(RSTRUCT(s)->len);
}
void

9
time.c
View file

@ -688,7 +688,7 @@ time_usec(time)
struct time_object *tobj;
GetTimeval(time, tobj);
return INT2NUM(tobj->tv.tv_usec);
return LONG2NUM(tobj->tv.tv_usec);
}
static VALUE
@ -783,7 +783,7 @@ time_hash(time)
GetTimeval(time, tobj);
hash = tobj->tv.tv_sec ^ tobj->tv.tv_usec;
return INT2FIX(hash);
return LONG2FIX(hash);
}
static VALUE
@ -1276,9 +1276,8 @@ time_strftime(time, format)
{
struct time_object *tobj;
char buffer[SMALLBUF];
char *fmt;
char *buf = buffer;
int len;
char *fmt, *buf = buffer;
long len;
VALUE str;
GetTimeval(time, tobj);

2
util.c
View file

@ -166,7 +166,7 @@ ruby_add_suffix(str, suffix)
int baselen;
int extlen = strlen(suffix);
char *s, *t, *p;
int slen;
long slen;
char buf[1024];
if (RSTRING(str)->len > 1000)