* array.c: moved to ANSI function style from K&R function style.

(used protoize on windows, so still K&R remains on #ifdef part of
   other platforms. And  `foo _((boo))' stuff is still there)
   [ruby-dev:26975]

* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
  enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
  io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
  prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
  regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
  sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
  version.c: ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ocean 2005-09-12 10:44:21 +00:00
Родитель 51e25545ae
Коммит dda5dc00cf
44 изменённых файлов: 2211 добавлений и 5308 удалений

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

@ -1,3 +1,18 @@
Mon Sep 12 19:26:29 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
other platforms. And `foo _((boo))' stuff is still there)
[ruby-dev:26975]
* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
version.c: ditto.
Sun Sep 11 23:23:02 2005 Shugo Maeda <shugo@ruby-lang.org> Sun Sep 11 23:23:02 2005 Shugo Maeda <shugo@ruby-lang.org>
* lib/net/imap.rb (starttls): supported the STARTTLS command. * lib/net/imap.rb (starttls): supported the STARTTLS command.

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

@ -135,13 +135,7 @@ rb_ary_new(void)
return rb_ary_new2(ARY_DEFAULT_SIZE); return rb_ary_new2(ARY_DEFAULT_SIZE);
} }
#ifdef HAVE_STDARG_PROTOTYPES
#include <stdarg.h> #include <stdarg.h>
#define va_init_list(a,b) va_start(a,b)
#else
#include <varargs.h>
#define va_init_list(a,b) va_start(a)
#endif
VALUE VALUE
rb_ary_new3(long n, ...) rb_ary_new3(long n, ...)
@ -152,7 +146,7 @@ rb_ary_new3(long n, ...)
ary = rb_ary_new2(n); ary = rb_ary_new2(n);
va_init_list(ar, n); va_start(ar, n);
for (i=0; i<n; i++) { for (i=0; i<n; i++) {
RARRAY(ary)->ptr[i] = va_arg(ar, VALUE); RARRAY(ary)->ptr[i] = va_arg(ar, VALUE);
} }
@ -184,7 +178,7 @@ rb_values_new(long n, ...)
long i; long i;
val = ary_new(rb_cValues, n); val = ary_new(rb_cValues, n);
va_init_list(ar, n); va_start(ar, n);
for (i=0; i<n; i++) { for (i=0; i<n; i++) {
RARRAY(val)->ptr[i] = va_arg(ar, VALUE); RARRAY(val)->ptr[i] = va_arg(ar, VALUE);
} }

210
bignum.c
Просмотреть файл

@ -39,10 +39,7 @@ VALUE rb_cBignum;
#define BIGZEROP(x) (RBIGNUM(x)->len == 0 || (RBIGNUM(x)->len == 1 && BDIGITS(x)[0] == 0)) #define BIGZEROP(x) (RBIGNUM(x)->len == 0 || (RBIGNUM(x)->len == 1 && BDIGITS(x)[0] == 0))
static VALUE static VALUE
bignew_1(klass, len, sign) bignew_1(VALUE klass, long len, int sign)
VALUE klass;
long len;
int sign;
{ {
NEWOBJ(big, struct RBignum); NEWOBJ(big, struct RBignum);
OBJSETUP(big, klass, T_BIGNUM); OBJSETUP(big, klass, T_BIGNUM);
@ -56,8 +53,7 @@ bignew_1(klass, len, sign)
#define bignew(len,sign) bignew_1(rb_cBignum,len,sign) #define bignew(len,sign) bignew_1(rb_cBignum,len,sign)
VALUE VALUE
rb_big_clone(x) rb_big_clone(VALUE x)
VALUE x;
{ {
VALUE z = bignew_1(CLASS_OF(x), RBIGNUM(x)->len, RBIGNUM(x)->sign); VALUE z = bignew_1(CLASS_OF(x), RBIGNUM(x)->len, RBIGNUM(x)->sign);
@ -88,15 +84,13 @@ get2comp(VALUE x)
} }
void void
rb_big_2comp(x) /* get 2's complement */ rb_big_2comp(VALUE x) /* get 2's complement */
VALUE x;
{ {
get2comp(x); get2comp(x);
} }
static VALUE static VALUE
bignorm(x) bignorm(VALUE x)
VALUE x;
{ {
if (!FIXNUM_P(x)) { if (!FIXNUM_P(x)) {
long len = RBIGNUM(x)->len; long len = RBIGNUM(x)->len;
@ -122,15 +116,13 @@ bignorm(x)
} }
VALUE VALUE
rb_big_norm(x) rb_big_norm(VALUE x)
VALUE x;
{ {
return bignorm(x); return bignorm(x);
} }
VALUE VALUE
rb_uint2big(n) rb_uint2big(unsigned long n)
unsigned long n;
{ {
BDIGIT_DBL num = n; BDIGIT_DBL num = n;
long i = 0; long i = 0;
@ -151,8 +143,7 @@ rb_uint2big(n)
} }
VALUE VALUE
rb_int2big(n) rb_int2big(long n)
long n;
{ {
long neg = 0; long neg = 0;
VALUE big; VALUE big;
@ -169,16 +160,14 @@ rb_int2big(n)
} }
VALUE VALUE
rb_uint2inum(n) rb_uint2inum(unsigned long n)
unsigned long n;
{ {
if (POSFIXABLE(n)) return LONG2FIX(n); if (POSFIXABLE(n)) return LONG2FIX(n);
return rb_uint2big(n); return rb_uint2big(n);
} }
VALUE VALUE
rb_int2inum(n) rb_int2inum(long n)
long n;
{ {
if (FIXABLE(n)) return LONG2FIX(n); if (FIXABLE(n)) return LONG2FIX(n);
return rb_int2big(n); return rb_int2big(n);
@ -187,9 +176,7 @@ rb_int2inum(n)
#ifdef HAVE_LONG_LONG #ifdef HAVE_LONG_LONG
void void
rb_quad_pack(buf, val) rb_quad_pack(char *buf, VALUE val)
char *buf;
VALUE val;
{ {
LONG_LONG q; LONG_LONG q;
@ -216,9 +203,7 @@ rb_quad_pack(buf, val)
} }
VALUE VALUE
rb_quad_unpack(buf, sign) rb_quad_unpack(const char *buf, int sign)
const char *buf;
int sign;
{ {
unsigned LONG_LONG q; unsigned LONG_LONG q;
long neg = 0; long neg = 0;
@ -313,10 +298,7 @@ rb_quad_unpack(buf, sign)
#endif #endif
VALUE VALUE
rb_cstr_to_inum(str, base, badcheck) rb_cstr_to_inum(const char *str, int base, int badcheck)
const char *str;
int base;
int badcheck;
{ {
const char *s = str; const char *s = str;
char *end; char *end;
@ -508,10 +490,7 @@ rb_cstr_to_inum(str, base, badcheck)
} }
VALUE VALUE
rb_str_to_inum(str, base, badcheck) rb_str_to_inum(VALUE str, int base, int badcheck)
VALUE str;
int base;
int badcheck;
{ {
char *s; char *s;
long len; long len;
@ -539,8 +518,7 @@ rb_str_to_inum(str, base, badcheck)
#if HAVE_LONG_LONG #if HAVE_LONG_LONG
VALUE VALUE
rb_ull2big(n) rb_ull2big(unsigned LONG_LONG n)
unsigned LONG_LONG n;
{ {
BDIGIT_DBL num = n; BDIGIT_DBL num = n;
long i = 0; long i = 0;
@ -561,8 +539,7 @@ rb_ull2big(n)
} }
VALUE VALUE
rb_ll2big(n) rb_ll2big(LONG_LONG n)
LONG_LONG n;
{ {
long neg = 0; long neg = 0;
VALUE big; VALUE big;
@ -579,16 +556,14 @@ rb_ll2big(n)
} }
VALUE VALUE
rb_ull2inum(n) rb_ull2inum(unsigned LONG_LONG n)
unsigned LONG_LONG n;
{ {
if (POSFIXABLE(n)) return LONG2FIX(n); if (POSFIXABLE(n)) return LONG2FIX(n);
return rb_ull2big(n); return rb_ull2big(n);
} }
VALUE VALUE
rb_ll2inum(n) rb_ll2inum(LONG_LONG n)
LONG_LONG n;
{ {
if (FIXABLE(n)) return LONG2FIX(n); if (FIXABLE(n)) return LONG2FIX(n);
return rb_ll2big(n); return rb_ll2big(n);
@ -597,26 +572,20 @@ rb_ll2inum(n)
#endif /* HAVE_LONG_LONG */ #endif /* HAVE_LONG_LONG */
VALUE VALUE
rb_cstr2inum(str, base) rb_cstr2inum(const char *str, int base)
const char *str;
int base;
{ {
return rb_cstr_to_inum(str, base, base==0); return rb_cstr_to_inum(str, base, base==0);
} }
VALUE VALUE
rb_str2inum(str, base) rb_str2inum(VALUE str, int base)
VALUE str;
int base;
{ {
return rb_str_to_inum(str, base, base==0); return rb_str_to_inum(str, base, base==0);
} }
const char ruby_digitmap[] = "0123456789abcdefghijklmnopqrstuvwxyz"; const char ruby_digitmap[] = "0123456789abcdefghijklmnopqrstuvwxyz";
VALUE VALUE
rb_big2str(x, base) rb_big2str(VALUE x, int base)
VALUE x;
int base;
{ {
volatile VALUE t; volatile VALUE t;
BDIGIT *ds; BDIGIT *ds;
@ -712,10 +681,7 @@ rb_big2str(x, base)
*/ */
static VALUE static VALUE
rb_big_to_s(argc, argv, x) rb_big_to_s(int argc, VALUE *argv, VALUE x)
int argc;
VALUE *argv;
VALUE x;
{ {
VALUE b; VALUE b;
int base; int base;
@ -727,10 +693,7 @@ rb_big_to_s(argc, argv, x)
} }
static unsigned long static unsigned long
big2ulong(x, type, check) big2ulong(VALUE x, char *type, int check)
VALUE x;
char *type;
int check;
{ {
long len = RBIGNUM(x)->len; long len = RBIGNUM(x)->len;
BDIGIT_DBL num; BDIGIT_DBL num;
@ -751,8 +714,7 @@ big2ulong(x, type, check)
} }
unsigned long unsigned long
rb_big2ulong_pack(x) rb_big2ulong_pack(VALUE x)
VALUE x;
{ {
unsigned long num = big2ulong(x, "unsigned long", Qfalse); unsigned long num = big2ulong(x, "unsigned long", Qfalse);
if (!RBIGNUM(x)->sign) { if (!RBIGNUM(x)->sign) {
@ -762,8 +724,7 @@ rb_big2ulong_pack(x)
} }
unsigned long unsigned long
rb_big2ulong(x) rb_big2ulong(VALUE x)
VALUE x;
{ {
unsigned long num = big2ulong(x, "unsigned long", Qtrue); unsigned long num = big2ulong(x, "unsigned long", Qtrue);
@ -777,8 +738,7 @@ rb_big2ulong(x)
} }
long long
rb_big2long(x) rb_big2long(VALUE x)
VALUE x;
{ {
unsigned long num = big2ulong(x, "long", Qtrue); unsigned long num = big2ulong(x, "long", Qtrue);
@ -792,9 +752,7 @@ rb_big2long(x)
#if HAVE_LONG_LONG #if HAVE_LONG_LONG
static unsigned LONG_LONG static unsigned LONG_LONG
big2ull(x, type) big2ull(VALUE x, char *type)
VALUE x;
char *type;
{ {
long len = RBIGNUM(x)->len; long len = RBIGNUM(x)->len;
BDIGIT_DBL num; BDIGIT_DBL num;
@ -812,8 +770,7 @@ big2ull(x, type)
} }
unsigned LONG_LONG unsigned LONG_LONG
rb_big2ull(x) rb_big2ull(VALUE x)
VALUE x;
{ {
unsigned LONG_LONG num = big2ull(x, "unsigned long long"); unsigned LONG_LONG num = big2ull(x, "unsigned long long");
@ -822,8 +779,7 @@ rb_big2ull(x)
} }
LONG_LONG LONG_LONG
rb_big2ll(x) rb_big2ll(VALUE x)
VALUE x;
{ {
unsigned LONG_LONG num = big2ull(x, "long long"); unsigned LONG_LONG num = big2ull(x, "long long");
@ -838,8 +794,7 @@ rb_big2ll(x)
#endif /* HAVE_LONG_LONG */ #endif /* HAVE_LONG_LONG */
static VALUE static VALUE
dbl2big(d) dbl2big(double d)
double d;
{ {
long i = 0; long i = 0;
BDIGIT c; BDIGIT c;
@ -871,15 +826,13 @@ dbl2big(d)
} }
VALUE VALUE
rb_dbl2big(d) rb_dbl2big(double d)
double d;
{ {
return bignorm(dbl2big(d)); return bignorm(dbl2big(d));
} }
double double
rb_big2dbl(x) rb_big2dbl(VALUE x)
VALUE x;
{ {
double d = 0.0; double d = 0.0;
long i = RBIGNUM(x)->len; long i = RBIGNUM(x)->len;
@ -906,8 +859,7 @@ rb_big2dbl(x)
*/ */
static VALUE static VALUE
rb_big_to_f(x) rb_big_to_f(VALUE x)
VALUE x;
{ {
return rb_float_new(rb_big2dbl(x)); return rb_float_new(rb_big2dbl(x));
} }
@ -923,8 +875,7 @@ rb_big_to_f(x)
*/ */
VALUE VALUE
rb_big_cmp(x, y) rb_big_cmp(VALUE x, VALUE y)
VALUE x, y;
{ {
long xlen = RBIGNUM(x)->len; long xlen = RBIGNUM(x)->len;
@ -969,8 +920,7 @@ rb_big_cmp(x, y)
*/ */
VALUE VALUE
rb_big_eq(x, y) rb_big_eq(VALUE x, VALUE y)
VALUE x, y;
{ {
switch (TYPE(y)) { switch (TYPE(y)) {
case T_FIXNUM: case T_FIXNUM:
@ -1008,8 +958,7 @@ rb_big_eq(x, y)
*/ */
static VALUE static VALUE
rb_big_eql(x, y) rb_big_eql(VALUE x, VALUE y)
VALUE x, y;
{ {
if (TYPE(y) != T_BIGNUM) return Qfalse; if (TYPE(y) != T_BIGNUM) return Qfalse;
if (RBIGNUM(x)->sign != RBIGNUM(y)->sign) return Qfalse; if (RBIGNUM(x)->sign != RBIGNUM(y)->sign) return Qfalse;
@ -1026,8 +975,7 @@ rb_big_eql(x, y)
*/ */
static VALUE static VALUE
rb_big_uminus(x) rb_big_uminus(VALUE x)
VALUE x;
{ {
VALUE z = rb_big_clone(x); VALUE z = rb_big_clone(x);
@ -1036,8 +984,6 @@ rb_big_uminus(x)
return bignorm(z); return bignorm(z);
} }
static VALUE bigadd _((VALUE,VALUE,int));
/* /*
* call-seq: * call-seq:
* ~big => integer * ~big => integer
@ -1051,8 +997,7 @@ static VALUE bigadd _((VALUE,VALUE,int));
*/ */
static VALUE static VALUE
rb_big_neg(x) rb_big_neg(VALUE x)
VALUE x;
{ {
VALUE z = rb_big_clone(x); VALUE z = rb_big_clone(x);
BDIGIT *ds; BDIGIT *ds;
@ -1071,8 +1016,7 @@ rb_big_neg(x)
} }
static VALUE static VALUE
bigsub(x, y) bigsub(VALUE x, VALUE y)
VALUE x, y;
{ {
VALUE z = 0; VALUE z = 0;
BDIGIT *zds; BDIGIT *zds;
@ -1118,9 +1062,7 @@ bigsub(x, y)
} }
static VALUE static VALUE
bigadd(x, y, sign) bigadd(VALUE x, VALUE y, int sign)
VALUE x, y;
int sign;
{ {
VALUE z; VALUE z;
BDIGIT_DBL num; BDIGIT_DBL num;
@ -1170,8 +1112,7 @@ bigadd(x, y, sign)
*/ */
VALUE VALUE
rb_big_plus(x, y) rb_big_plus(VALUE x, VALUE y)
VALUE x, y;
{ {
switch (TYPE(y)) { switch (TYPE(y)) {
case T_FIXNUM: case T_FIXNUM:
@ -1196,8 +1137,7 @@ rb_big_plus(x, y)
*/ */
VALUE VALUE
rb_big_minus(x, y) rb_big_minus(VALUE x, VALUE y)
VALUE x, y;
{ {
switch (TYPE(y)) { switch (TYPE(y)) {
case T_FIXNUM: case T_FIXNUM:
@ -1215,8 +1155,7 @@ rb_big_minus(x, y)
} }
static VALUE static VALUE
rb_big_mul0(x, y) rb_big_mul0(VALUE x, VALUE y)
VALUE x, y;
{ {
long i, j; long i, j;
BDIGIT_DBL n = 0; BDIGIT_DBL n = 0;
@ -1267,16 +1206,13 @@ rb_big_mul0(x, y)
*/ */
VALUE VALUE
rb_big_mul(x, y) rb_big_mul(VALUE x, VALUE y)
VALUE x, y;
{ {
return bignorm(rb_big_mul0(x, y)); return bignorm(rb_big_mul0(x, y));
} }
static void static void
bigdivrem(x, y, divp, modp) bigdivrem(VALUE x, VALUE y, VALUE *divp, VALUE *modp)
VALUE x, y;
VALUE *divp, *modp;
{ {
long nx = RBIGNUM(x)->len, ny = RBIGNUM(y)->len; long nx = RBIGNUM(x)->len, ny = RBIGNUM(y)->len;
long i, j; long i, j;
@ -1404,9 +1340,7 @@ bigdivrem(x, y, divp, modp)
} }
static void static void
bigdivmod(x, y, divp, modp) bigdivmod(VALUE x, VALUE y, VALUE *divp, VALUE *modp)
VALUE x, y;
VALUE *divp, *modp;
{ {
VALUE mod; VALUE mod;
@ -1430,8 +1364,7 @@ bigdivmod(x, y, divp, modp)
*/ */
VALUE VALUE
rb_big_div(x, y) rb_big_div(VALUE x, VALUE y)
VALUE x, y;
{ {
VALUE z; VALUE z;
@ -1464,8 +1397,7 @@ rb_big_div(x, y)
*/ */
VALUE VALUE
rb_big_modulo(x, y) rb_big_modulo(VALUE x, VALUE y)
VALUE x, y;
{ {
VALUE z; VALUE z;
@ -1495,8 +1427,7 @@ rb_big_modulo(x, y)
* -1234567890987654321.remainder(13731.24) #=> -9906.22531493148 * -1234567890987654321.remainder(13731.24) #=> -9906.22531493148
*/ */
static VALUE static VALUE
rb_big_remainder(x, y) rb_big_remainder(VALUE x, VALUE y)
VALUE x, y;
{ {
VALUE z; VALUE z;
@ -1524,8 +1455,7 @@ rb_big_remainder(x, y)
* *
*/ */
VALUE VALUE
rb_big_divmod(x, y) rb_big_divmod(VALUE x, VALUE y)
VALUE x, y;
{ {
VALUE div, mod; VALUE div, mod;
@ -1558,8 +1488,7 @@ rb_big_divmod(x, y)
*/ */
static VALUE static VALUE
rb_big_quo(x, y) rb_big_quo(VALUE x, VALUE y)
VALUE x, y;
{ {
double dx = rb_big2dbl(x); double dx = rb_big2dbl(x);
double dy; double dy;
@ -1597,8 +1526,7 @@ rb_big_quo(x, y)
*/ */
VALUE VALUE
rb_big_pow(x, y) rb_big_pow(VALUE x, VALUE y)
VALUE x, y;
{ {
double d; double d;
long yy; long yy;
@ -1647,8 +1575,7 @@ rb_big_pow(x, y)
*/ */
VALUE VALUE
rb_big_and(xx, yy) rb_big_and(VALUE xx, VALUE yy)
VALUE xx, yy;
{ {
volatile VALUE x, y, z; volatile VALUE x, y, z;
BDIGIT *ds1, *ds2, *zds; BDIGIT *ds1, *ds2, *zds;
@ -1703,8 +1630,7 @@ rb_big_and(xx, yy)
*/ */
VALUE VALUE
rb_big_or(xx, yy) rb_big_or(VALUE xx, VALUE yy)
VALUE xx, yy;
{ {
volatile VALUE x, y, z; volatile VALUE x, y, z;
BDIGIT *ds1, *ds2, *zds; BDIGIT *ds1, *ds2, *zds;
@ -1761,8 +1687,7 @@ rb_big_or(xx, yy)
*/ */
VALUE VALUE
rb_big_xor(xx, yy) rb_big_xor(VALUE xx, VALUE yy)
VALUE xx, yy;
{ {
volatile VALUE x, y; volatile VALUE x, y;
VALUE z; VALUE z;
@ -1824,8 +1749,7 @@ static VALUE rb_big_rshift _((VALUE,VALUE));
*/ */
VALUE VALUE
rb_big_lshift(x, y) rb_big_lshift(VALUE x, VALUE y)
VALUE x, y;
{ {
BDIGIT *xds, *zds; BDIGIT *xds, *zds;
int shift = NUM2INT(y); int shift = NUM2INT(y);
@ -1860,8 +1784,7 @@ rb_big_lshift(x, y)
*/ */
static VALUE static VALUE
rb_big_rshift(x, y) rb_big_rshift(VALUE x, VALUE y)
VALUE x, y;
{ {
BDIGIT *xds, *zds; BDIGIT *xds, *zds;
int shift = NUM2INT(y); int shift = NUM2INT(y);
@ -1921,8 +1844,7 @@ rb_big_rshift(x, y)
*/ */
static VALUE static VALUE
rb_big_aref(x, y) rb_big_aref(VALUE x, VALUE y)
VALUE x, y;
{ {
BDIGIT *xds; BDIGIT *xds;
int shift; int shift;
@ -1960,8 +1882,7 @@ rb_big_aref(x, y)
*/ */
static VALUE static VALUE
rb_big_hash(x) rb_big_hash(VALUE x)
VALUE x;
{ {
long i, len, key; long i, len, key;
BDIGIT *digits; BDIGIT *digits;
@ -1978,8 +1899,7 @@ rb_big_hash(x)
*/ */
static VALUE static VALUE
rb_big_coerce(x, y) rb_big_coerce(VALUE x, VALUE y)
VALUE x, y;
{ {
if (FIXNUM_P(y)) { if (FIXNUM_P(y)) {
return rb_assoc_new(rb_int2big(FIX2LONG(y)), x); return rb_assoc_new(rb_int2big(FIX2LONG(y)), x);
@ -2005,8 +1925,7 @@ rb_big_coerce(x, y)
*/ */
static VALUE static VALUE
rb_big_abs(x) rb_big_abs(VALUE x)
VALUE x;
{ {
if (!RBIGNUM(x)->sign) { if (!RBIGNUM(x)->sign) {
x = rb_big_clone(x); x = rb_big_clone(x);
@ -2016,9 +1935,7 @@ rb_big_abs(x)
} }
VALUE VALUE
rb_big_rand(max, rand_buf) rb_big_rand(VALUE max, double *rand_buf)
VALUE max;
double *rand_buf;
{ {
VALUE v; VALUE v;
long len = RBIGNUM(max)->len; long len = RBIGNUM(max)->len;
@ -2049,8 +1966,7 @@ rb_big_rand(max, rand_buf)
*/ */
static VALUE static VALUE
rb_big_size(big) rb_big_size(VALUE big)
VALUE big;
{ {
return LONG2FIX(RBIGNUM(big)->len*SIZEOF_BDIGITS); return LONG2FIX(RBIGNUM(big)->len*SIZEOF_BDIGITS);
} }
@ -2074,7 +1990,7 @@ rb_big_size(big)
*/ */
void void
Init_Bignum() Init_Bignum(void)
{ {
rb_cBignum = rb_define_class("Bignum", rb_cInteger); rb_cBignum = rb_define_class("Bignum", rb_cInteger);

208
class.c
Просмотреть файл

@ -19,8 +19,7 @@
extern st_table *rb_class_tbl; extern st_table *rb_class_tbl;
VALUE VALUE
rb_class_boot(super) rb_class_boot(VALUE super)
VALUE super;
{ {
NEWOBJ(klass, struct RClass); NEWOBJ(klass, struct RClass);
OBJSETUP(klass, rb_cClass, T_CLASS); OBJSETUP(klass, rb_cClass, T_CLASS);
@ -35,8 +34,7 @@ rb_class_boot(super)
} }
void void
rb_check_inheritable(super) rb_check_inheritable(VALUE super)
VALUE super;
{ {
if (TYPE(super) != T_CLASS) { if (TYPE(super) != T_CLASS) {
rb_raise(rb_eTypeError, "superclass must be a Class (%s given)", rb_raise(rb_eTypeError, "superclass must be a Class (%s given)",
@ -48,8 +46,7 @@ rb_check_inheritable(super)
} }
VALUE VALUE
rb_class_new(super) rb_class_new(VALUE super)
VALUE super;
{ {
Check_Type(super, T_CLASS); Check_Type(super, T_CLASS);
rb_check_inheritable(super); rb_check_inheritable(super);
@ -60,10 +57,7 @@ rb_class_new(super)
} }
static int static int
clone_method(mid, body, tbl) clone_method(ID mid, NODE *body, st_table *tbl)
ID mid;
NODE *body;
st_table *tbl;
{ {
st_insert(tbl, mid, (st_data_t)NEW_METHOD(body->nd_body, body->nd_noex)); st_insert(tbl, mid, (st_data_t)NEW_METHOD(body->nd_body, body->nd_noex));
return ST_CONTINUE; return ST_CONTINUE;
@ -71,8 +65,7 @@ clone_method(mid, body, tbl)
/* :nodoc: */ /* :nodoc: */
VALUE VALUE
rb_mod_init_copy(clone, orig) rb_mod_init_copy(VALUE clone, VALUE orig)
VALUE clone, orig;
{ {
rb_obj_init_copy(clone, orig); rb_obj_init_copy(clone, orig);
if (!FL_TEST(CLASS_OF(clone), FL_SINGLETON)) { if (!FL_TEST(CLASS_OF(clone), FL_SINGLETON)) {
@ -99,8 +92,7 @@ rb_mod_init_copy(clone, orig)
/* :nodoc: */ /* :nodoc: */
VALUE VALUE
rb_class_init_copy(clone, orig) rb_class_init_copy(VALUE clone, VALUE orig)
VALUE clone, orig;
{ {
if (RCLASS(clone)->super != 0) { if (RCLASS(clone)->super != 0) {
rb_raise(rb_eTypeError, "already initialized class"); rb_raise(rb_eTypeError, "already initialized class");
@ -112,8 +104,7 @@ rb_class_init_copy(clone, orig)
} }
VALUE VALUE
rb_singleton_class_clone(obj) rb_singleton_class_clone(VALUE obj)
VALUE obj;
{ {
VALUE klass = RBASIC(obj)->klass; VALUE klass = RBASIC(obj)->klass;
@ -147,8 +138,7 @@ rb_singleton_class_clone(obj)
} }
void void
rb_singleton_class_attached(klass, obj) rb_singleton_class_attached(VALUE klass, VALUE obj)
VALUE klass, obj;
{ {
if (FL_TEST(klass, FL_SINGLETON)) { if (FL_TEST(klass, FL_SINGLETON)) {
if (!RCLASS(klass)->iv_tbl) { if (!RCLASS(klass)->iv_tbl) {
@ -159,8 +149,7 @@ rb_singleton_class_attached(klass, obj)
} }
VALUE VALUE
rb_make_metaclass(obj, super) rb_make_metaclass(VALUE obj, VALUE super)
VALUE obj, super;
{ {
if (BUILTIN_TYPE(obj) == T_CLASS && FL_TEST(obj, FL_SINGLETON)) { if (BUILTIN_TYPE(obj) == T_CLASS && FL_TEST(obj, FL_SINGLETON)) {
return RBASIC(obj)->klass = rb_cClass; return RBASIC(obj)->klass = rb_cClass;
@ -183,9 +172,7 @@ rb_make_metaclass(obj, super)
} }
VALUE VALUE
rb_define_class_id(id, super) rb_define_class_id(ID id, VALUE super)
ID id;
VALUE super;
{ {
VALUE klass; VALUE klass;
@ -197,17 +184,14 @@ rb_define_class_id(id, super)
} }
VALUE VALUE
rb_class_inherited(super, klass) rb_class_inherited(VALUE super, VALUE klass)
VALUE super, klass;
{ {
if (!super) super = rb_cObject; if (!super) super = rb_cObject;
return rb_funcall(super, rb_intern("inherited"), 1, klass); return rb_funcall(super, rb_intern("inherited"), 1, klass);
} }
VALUE VALUE
rb_define_class(name, super) rb_define_class(const char *name, VALUE super)
const char *name;
VALUE super;
{ {
VALUE klass; VALUE klass;
ID id; ID id;
@ -236,10 +220,7 @@ rb_define_class(name, super)
} }
VALUE VALUE
rb_define_class_under(outer, name, super) rb_define_class_under(VALUE outer, const char *name, VALUE super)
VALUE outer;
const char *name;
VALUE super;
{ {
VALUE klass; VALUE klass;
ID id; ID id;
@ -268,7 +249,7 @@ rb_define_class_under(outer, name, super)
} }
VALUE VALUE
rb_module_new() rb_module_new(void)
{ {
NEWOBJ(mdl, struct RClass); NEWOBJ(mdl, struct RClass);
OBJSETUP(mdl, rb_cModule, T_MODULE); OBJSETUP(mdl, rb_cModule, T_MODULE);
@ -282,8 +263,7 @@ rb_module_new()
} }
VALUE VALUE
rb_define_module_id(id) rb_define_module_id(ID id)
ID id;
{ {
VALUE mdl; VALUE mdl;
@ -294,8 +274,7 @@ rb_define_module_id(id)
} }
VALUE VALUE
rb_define_module(name) rb_define_module(const char *name)
const char *name;
{ {
VALUE module; VALUE module;
ID id; ID id;
@ -315,9 +294,7 @@ rb_define_module(name)
} }
VALUE VALUE
rb_define_module_under(outer, name) rb_define_module_under(VALUE outer, const char *name)
VALUE outer;
const char *name;
{ {
VALUE module; VALUE module;
ID id; ID id;
@ -338,8 +315,7 @@ rb_define_module_under(outer, name)
} }
static VALUE static VALUE
include_class_new(module, super) include_class_new(VALUE module, VALUE super)
VALUE module, super;
{ {
NEWOBJ(klass, struct RClass); NEWOBJ(klass, struct RClass);
OBJSETUP(klass, rb_cClass, T_ICLASS); OBJSETUP(klass, rb_cClass, T_ICLASS);
@ -366,8 +342,7 @@ include_class_new(module, super)
} }
void void
rb_include_module(klass, module) rb_include_module(VALUE klass, VALUE module)
VALUE klass, module;
{ {
VALUE p, c; VALUE p, c;
int changed = 0; int changed = 0;
@ -434,8 +409,7 @@ rb_include_module(klass, module)
*/ */
VALUE VALUE
rb_mod_included_modules(mod) rb_mod_included_modules(VALUE mod)
VALUE mod;
{ {
VALUE ary = rb_ary_new(); VALUE ary = rb_ary_new();
VALUE p; VALUE p;
@ -468,9 +442,7 @@ rb_mod_included_modules(mod)
*/ */
VALUE VALUE
rb_mod_include_p(mod, mod2) rb_mod_include_p(VALUE mod, VALUE mod2)
VALUE mod;
VALUE mod2;
{ {
VALUE p; VALUE p;
@ -500,8 +472,7 @@ rb_mod_include_p(mod, mod2)
*/ */
VALUE VALUE
rb_mod_ancestors(mod) rb_mod_ancestors(VALUE mod)
VALUE mod;
{ {
VALUE p, ary = rb_ary_new(); VALUE p, ary = rb_ary_new();
@ -522,11 +493,7 @@ rb_mod_ancestors(mod)
#define VISI_CHECK(x,f) (VISI(x) == (f)) #define VISI_CHECK(x,f) (VISI(x) == (f))
static int static int
ins_methods_push(name, type, ary, visi) ins_methods_push(ID name, long type, VALUE ary, long visi)
ID name;
long type;
VALUE ary;
long visi;
{ {
if (type == -1) return ST_CONTINUE; if (type == -1) return ST_CONTINUE;
switch (visi) { switch (visi) {
@ -546,46 +513,31 @@ ins_methods_push(name, type, ary, visi)
} }
static int static int
ins_methods_i(name, type, ary) ins_methods_i(ID name, long type, VALUE ary)
ID name;
long type;
VALUE ary;
{ {
return ins_methods_push(name, type, ary, -1); /* everything but private */ return ins_methods_push(name, type, ary, -1); /* everything but private */
} }
static int static int
ins_methods_prot_i(name, type, ary) ins_methods_prot_i(ID name, long type, VALUE ary)
ID name;
long type;
VALUE ary;
{ {
return ins_methods_push(name, type, ary, NOEX_PROTECTED); return ins_methods_push(name, type, ary, NOEX_PROTECTED);
} }
static int static int
ins_methods_priv_i(name, type, ary) ins_methods_priv_i(ID name, long type, VALUE ary)
ID name;
long type;
VALUE ary;
{ {
return ins_methods_push(name, type, ary, NOEX_PRIVATE); return ins_methods_push(name, type, ary, NOEX_PRIVATE);
} }
static int static int
ins_methods_pub_i(name, type, ary) ins_methods_pub_i(ID name, long type, VALUE ary)
ID name;
long type;
VALUE ary;
{ {
return ins_methods_push(name, type, ary, NOEX_PUBLIC); return ins_methods_push(name, type, ary, NOEX_PUBLIC);
} }
static int static int
method_entry(key, body, list) method_entry(ID key, NODE *body, st_table *list)
ID key;
NODE *body;
st_table *list;
{ {
long type; long type;
@ -599,11 +551,7 @@ method_entry(key, body, list)
} }
static VALUE static VALUE
class_instance_method_list(argc, argv, mod, func) class_instance_method_list(int argc, VALUE *argv, VALUE mod, int (*func) (ID, long, VALUE))
int argc;
VALUE *argv;
VALUE mod;
int (*func) _((ID, long, VALUE));
{ {
VALUE ary; VALUE ary;
int recur; int recur;
@ -660,10 +608,7 @@ class_instance_method_list(argc, argv, mod, func)
*/ */
VALUE VALUE
rb_class_instance_methods(argc, argv, mod) rb_class_instance_methods(int argc, VALUE *argv, VALUE mod)
int argc;
VALUE *argv;
VALUE mod;
{ {
return class_instance_method_list(argc, argv, mod, ins_methods_i); return class_instance_method_list(argc, argv, mod, ins_methods_i);
} }
@ -678,10 +623,7 @@ rb_class_instance_methods(argc, argv, mod)
*/ */
VALUE VALUE
rb_class_protected_instance_methods(argc, argv, mod) rb_class_protected_instance_methods(int argc, VALUE *argv, VALUE mod)
int argc;
VALUE *argv;
VALUE mod;
{ {
return class_instance_method_list(argc, argv, mod, ins_methods_prot_i); return class_instance_method_list(argc, argv, mod, ins_methods_prot_i);
} }
@ -704,10 +646,7 @@ rb_class_protected_instance_methods(argc, argv, mod)
*/ */
VALUE VALUE
rb_class_private_instance_methods(argc, argv, mod) rb_class_private_instance_methods(int argc, VALUE *argv, VALUE mod)
int argc;
VALUE *argv;
VALUE mod;
{ {
return class_instance_method_list(argc, argv, mod, ins_methods_priv_i); return class_instance_method_list(argc, argv, mod, ins_methods_priv_i);
} }
@ -722,10 +661,7 @@ rb_class_private_instance_methods(argc, argv, mod)
*/ */
VALUE VALUE
rb_class_public_instance_methods(argc, argv, mod) rb_class_public_instance_methods(int argc, VALUE *argv, VALUE mod)
int argc;
VALUE *argv;
VALUE mod;
{ {
return class_instance_method_list(argc, argv, mod, ins_methods_pub_i); return class_instance_method_list(argc, argv, mod, ins_methods_pub_i);
} }
@ -763,10 +699,7 @@ rb_class_public_instance_methods(argc, argv, mod)
*/ */
VALUE VALUE
rb_obj_singleton_methods(argc, argv, obj) rb_obj_singleton_methods(int argc, VALUE *argv, VALUE obj)
int argc;
VALUE *argv;
VALUE obj;
{ {
VALUE recur, ary, klass; VALUE recur, ary, klass;
st_table *list; st_table *list;
@ -795,49 +728,31 @@ rb_obj_singleton_methods(argc, argv, obj)
} }
void void
rb_define_method_id(klass, name, func, argc) rb_define_method_id(VALUE klass, ID name, VALUE (*func) (/* ??? */), int argc)
VALUE klass;
ID name;
VALUE (*func)();
int argc;
{ {
rb_add_method(klass, name, NEW_CFUNC(func,argc), NOEX_PUBLIC); rb_add_method(klass, name, NEW_CFUNC(func,argc), NOEX_PUBLIC);
} }
void void
rb_define_method(klass, name, func, argc) rb_define_method(VALUE klass, const char *name, VALUE (*func) (/* ??? */), int argc)
VALUE klass;
const char *name;
VALUE (*func)();
int argc;
{ {
rb_add_method(klass, rb_intern(name), NEW_CFUNC(func, argc), NOEX_PUBLIC); rb_add_method(klass, rb_intern(name), NEW_CFUNC(func, argc), NOEX_PUBLIC);
} }
void void
rb_define_protected_method(klass, name, func, argc) rb_define_protected_method(VALUE klass, const char *name, VALUE (*func) (/* ??? */), int argc)
VALUE klass;
const char *name;
VALUE (*func)();
int argc;
{ {
rb_add_method(klass, rb_intern(name), NEW_CFUNC(func, argc), NOEX_PROTECTED); rb_add_method(klass, rb_intern(name), NEW_CFUNC(func, argc), NOEX_PROTECTED);
} }
void void
rb_define_private_method(klass, name, func, argc) rb_define_private_method(VALUE klass, const char *name, VALUE (*func) (/* ??? */), int argc)
VALUE klass;
const char *name;
VALUE (*func)();
int argc;
{ {
rb_add_method(klass, rb_intern(name), NEW_CFUNC(func, argc), NOEX_PRIVATE); rb_add_method(klass, rb_intern(name), NEW_CFUNC(func, argc), NOEX_PRIVATE);
} }
void void
rb_undef_method(klass, name) rb_undef_method(VALUE klass, const char *name)
VALUE klass;
const char *name;
{ {
rb_add_method(klass, rb_intern(name), 0, NOEX_UNDEF); rb_add_method(klass, rb_intern(name), 0, NOEX_UNDEF);
} }
@ -849,8 +764,7 @@ rb_undef_method(klass, name)
} while (0) } while (0)
VALUE VALUE
rb_singleton_class(obj) rb_singleton_class(VALUE obj)
VALUE obj;
{ {
VALUE klass; VALUE klass;
@ -885,77 +799,47 @@ rb_singleton_class(obj)
} }
void void
rb_define_singleton_method(obj, name, func, argc) rb_define_singleton_method(VALUE obj, const char *name, VALUE (*func) (/* ??? */), int argc)
VALUE obj;
const char *name;
VALUE (*func)();
int argc;
{ {
rb_define_method(rb_singleton_class(obj), name, func, argc); rb_define_method(rb_singleton_class(obj), name, func, argc);
} }
void void
rb_define_module_function(module, name, func, argc) rb_define_module_function(VALUE module, const char *name, VALUE (*func) (/* ??? */), int argc)
VALUE module;
const char *name;
VALUE (*func)();
int argc;
{ {
rb_define_private_method(module, name, func, argc); rb_define_private_method(module, name, func, argc);
rb_define_singleton_method(module, name, func, argc); rb_define_singleton_method(module, name, func, argc);
} }
void void
rb_define_global_function(name, func, argc) rb_define_global_function(const char *name, VALUE (*func) (/* ??? */), int argc)
const char *name;
VALUE (*func)();
int argc;
{ {
rb_define_module_function(rb_mKernel, name, func, argc); rb_define_module_function(rb_mKernel, name, func, argc);
} }
void void
rb_define_alias(klass, name1, name2) rb_define_alias(VALUE klass, const char *name1, const char *name2)
VALUE klass;
const char *name1, *name2;
{ {
rb_alias(klass, rb_intern(name1), rb_intern(name2)); rb_alias(klass, rb_intern(name1), rb_intern(name2));
} }
void void
rb_define_attr(klass, name, read, write) rb_define_attr(VALUE klass, const char *name, int read, int write)
VALUE klass;
const char *name;
int read, write;
{ {
rb_attr(klass, rb_intern(name), read, write, Qfalse); rb_attr(klass, rb_intern(name), read, write, Qfalse);
} }
#ifdef HAVE_STDARG_PROTOTYPES
#include <stdarg.h> #include <stdarg.h>
#define va_init_list(a,b) va_start(a,b)
#else
#include <varargs.h>
#define va_init_list(a,b) va_start(a)
#endif
int int
#ifdef HAVE_STDARG_PROTOTYPES
rb_scan_args(int argc, const VALUE *argv, const char *fmt, ...) rb_scan_args(int argc, const VALUE *argv, const char *fmt, ...)
#else
rb_scan_args(argc, argv, fmt, va_alist)
int argc;
const VALUE *argv;
const char *fmt;
va_dcl
#endif
{ {
int n, i = 0; int n, i = 0;
const char *p = fmt; const char *p = fmt;
VALUE *var; VALUE *var;
va_list vargs; va_list vargs;
va_init_list(vargs, fmt); va_start(vargs, fmt);
if (*p == '*') goto rest_arg; if (*p == '*') goto rest_arg;

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

@ -17,8 +17,7 @@ VALUE rb_mComparable;
static ID cmp; static ID cmp;
int int
rb_cmpint(val, a, b) rb_cmpint(VALUE val, VALUE a, VALUE b)
VALUE val, a, b;
{ {
if (NIL_P(val)) { if (NIL_P(val)) {
rb_cmperr(a, b); rb_cmperr(a, b);
@ -34,8 +33,7 @@ rb_cmpint(val, a, b)
} }
void void
rb_cmperr(x, y) rb_cmperr(VALUE x, VALUE y)
VALUE x, y;
{ {
const char *classname; const char *classname;
@ -51,8 +49,7 @@ rb_cmperr(x, y)
} }
static VALUE static VALUE
cmp_eq(a) cmp_eq(VALUE *a)
VALUE *a;
{ {
VALUE c = rb_funcall(a[0], cmp, 1, a[1]); VALUE c = rb_funcall(a[0], cmp, 1, a[1]);
@ -62,7 +59,7 @@ cmp_eq(a)
} }
static VALUE static VALUE
cmp_failed() cmp_failed(void)
{ {
return Qnil; return Qnil;
} }
@ -77,8 +74,7 @@ cmp_failed()
*/ */
static VALUE static VALUE
cmp_equal(x, y) cmp_equal(VALUE x, VALUE y)
VALUE x, y;
{ {
VALUE a[2]; VALUE a[2];
@ -97,8 +93,7 @@ cmp_equal(x, y)
*/ */
static VALUE static VALUE
cmp_gt(x, y) cmp_gt(VALUE x, VALUE y)
VALUE x, y;
{ {
VALUE c = rb_funcall(x, cmp, 1, y); VALUE c = rb_funcall(x, cmp, 1, y);
@ -115,8 +110,7 @@ cmp_gt(x, y)
*/ */
static VALUE static VALUE
cmp_ge(x, y) cmp_ge(VALUE x, VALUE y)
VALUE x, y;
{ {
VALUE c = rb_funcall(x, cmp, 1, y); VALUE c = rb_funcall(x, cmp, 1, y);
@ -133,8 +127,7 @@ cmp_ge(x, y)
*/ */
static VALUE static VALUE
cmp_lt(x, y) cmp_lt(VALUE x, VALUE y)
VALUE x, y;
{ {
VALUE c = rb_funcall(x, cmp, 1, y); VALUE c = rb_funcall(x, cmp, 1, y);
@ -152,8 +145,7 @@ cmp_lt(x, y)
*/ */
static VALUE static VALUE
cmp_le(x, y) cmp_le(VALUE x, VALUE y)
VALUE x, y;
{ {
VALUE c = rb_funcall(x, cmp, 1, y); VALUE c = rb_funcall(x, cmp, 1, y);
@ -177,8 +169,7 @@ cmp_le(x, y)
*/ */
static VALUE static VALUE
cmp_between(x, min, max) cmp_between(VALUE x, VALUE min, VALUE max)
VALUE x, min, max;
{ {
if (RTEST(cmp_lt(x, min))) return Qfalse; if (RTEST(cmp_lt(x, min))) return Qfalse;
if (RTEST(cmp_gt(x, max))) return Qfalse; if (RTEST(cmp_gt(x, max))) return Qfalse;
@ -223,7 +214,7 @@ cmp_between(x, min, max)
*/ */
void void
Init_Comparable() Init_Comparable(void)
{ {
rb_mComparable = rb_define_module("Comparable"); rb_mComparable = rb_define_module("Comparable");
rb_define_method(rb_mComparable, "==", cmp_equal, 1); rb_define_method(rb_mComparable, "==", cmp_equal, 1);

228
dir.c
Просмотреть файл

@ -105,10 +105,7 @@ emx_mblen(p)
# define Inc(p) ((p) = Next(p)) # define Inc(p) ((p) = Next(p))
# define Compare(p1, p2) (CompareImpl(p1, p2, nocase)) # define Compare(p1, p2) (CompareImpl(p1, p2, nocase))
static int static int
CompareImpl(p1, p2, nocase) CompareImpl(const char *p1, const char *p2, int nocase)
const char *p1;
const char *p2;
int nocase;
{ {
const int len1 = Next(p1) - p1; const int len1 = Next(p1) - p1;
const int len2 = Next(p2) - p2; const int len2 = Next(p2) - p2;
@ -165,10 +162,10 @@ CompareImpl(p1, p2, nocase)
#endif /* environment */ #endif /* environment */
static char * static char *
bracket(p, s, flags) bracket(
const char *p; /* pattern (next to '[') */ const char *p, /* pattern (next to '[') */
const char *s; /* string */ const char *s, /* string */
int flags; int flags)
{ {
const int nocase = flags & FNM_CASEFOLD; const int nocase = flags & FNM_CASEFOLD;
const int escape = !(flags & FNM_NOESCAPE); const int escape = !(flags & FNM_NOESCAPE);
@ -215,10 +212,10 @@ bracket(p, s, flags)
#define RETURN(val) return *pcur = p, *scur = s, (val); #define RETURN(val) return *pcur = p, *scur = s, (val);
static int static int
fnmatch_helper(pcur, scur, flags) fnmatch_helper(
const char **pcur; /* pattern */ const char **pcur, /* pattern */
const char **scur; /* string */ const char **scur, /* string */
int flags; int flags)
{ {
const int period = !(flags & FNM_DOTMATCH); const int period = !(flags & FNM_DOTMATCH);
const int pathname = flags & FNM_PATHNAME; const int pathname = flags & FNM_PATHNAME;
@ -292,10 +289,10 @@ fnmatch_helper(pcur, scur, flags)
} }
static int static int
fnmatch(p, s, flags) fnmatch(
const char *p; /* pattern */ const char *p, /* pattern */
const char *s; /* string */ const char *s, /* string */
int flags; int flags)
{ {
const int period = !(flags & FNM_DOTMATCH); const int period = !(flags & FNM_DOTMATCH);
const int pathname = flags & FNM_PATHNAME; const int pathname = flags & FNM_PATHNAME;
@ -345,8 +342,7 @@ struct dir_data {
}; };
static void static void
free_dir(dir) free_dir(struct dir_data *dir)
struct dir_data *dir;
{ {
if (dir) { if (dir) {
if (dir->dir) closedir(dir->dir); if (dir->dir) closedir(dir->dir);
@ -357,10 +353,8 @@ free_dir(dir)
static VALUE dir_close _((VALUE)); static VALUE dir_close _((VALUE));
static VALUE dir_s_alloc _((VALUE));
static VALUE static VALUE
dir_s_alloc(klass) dir_s_alloc(VALUE klass)
VALUE klass;
{ {
struct dir_data *dirp; struct dir_data *dirp;
VALUE obj = Data_Make_Struct(klass, struct dir_data, 0, free_dir, dirp); VALUE obj = Data_Make_Struct(klass, struct dir_data, 0, free_dir, dirp);
@ -378,8 +372,7 @@ dir_s_alloc(klass)
* Returns a new directory object for the named directory. * Returns a new directory object for the named directory.
*/ */
static VALUE static VALUE
dir_initialize(dir, dirname) dir_initialize(VALUE dir, VALUE dirname)
VALUE dir, dirname;
{ {
struct dir_data *dp; struct dir_data *dp;
@ -416,8 +409,7 @@ dir_initialize(dir, dirname)
* block. * block.
*/ */
static VALUE static VALUE
dir_s_open(klass, dirname) dir_s_open(VALUE klass, VALUE dirname)
VALUE klass, dirname;
{ {
struct dir_data *dp; struct dir_data *dp;
VALUE dir = Data_Make_Struct(klass, struct dir_data, 0, free_dir, dp); VALUE dir = Data_Make_Struct(klass, struct dir_data, 0, free_dir, dp);
@ -431,7 +423,7 @@ dir_s_open(klass, dirname)
} }
static void static void
dir_closed() dir_closed(void)
{ {
rb_raise(rb_eIOError, "closed directory"); rb_raise(rb_eIOError, "closed directory");
} }
@ -448,8 +440,7 @@ dir_closed()
* Return a string describing this Dir object. * Return a string describing this Dir object.
*/ */
static VALUE static VALUE
dir_inspect(dir) dir_inspect(VALUE dir)
VALUE dir;
{ {
struct dir_data *dirp; struct dir_data *dirp;
@ -474,8 +465,7 @@ dir_inspect(dir)
* d.path #=> ".." * d.path #=> ".."
*/ */
static VALUE static VALUE
dir_path(dir) dir_path(VALUE dir)
VALUE dir;
{ {
struct dir_data *dirp; struct dir_data *dirp;
@ -497,8 +487,7 @@ dir_path(dir)
* d.read #=> "config.h" * d.read #=> "config.h"
*/ */
static VALUE static VALUE
dir_read(dir) dir_read(VALUE dir)
VALUE dir;
{ {
struct dir_data *dirp; struct dir_data *dirp;
struct dirent *dp; struct dirent *dp;
@ -536,8 +525,7 @@ dir_read(dir)
* Got main.rb * Got main.rb
*/ */
static VALUE static VALUE
dir_each(dir) dir_each(VALUE dir)
VALUE dir;
{ {
struct dir_data *dirp; struct dir_data *dirp;
struct dirent *dp; struct dirent *dp;
@ -566,8 +554,7 @@ dir_each(dir)
* d.tell #=> 12 * d.tell #=> 12
*/ */
static VALUE static VALUE
dir_tell(dir) dir_tell(VALUE dir)
VALUE dir;
{ {
#ifdef HAVE_TELLDIR #ifdef HAVE_TELLDIR
struct dir_data *dirp; struct dir_data *dirp;
@ -596,8 +583,7 @@ dir_tell(dir)
* d.read #=> ".." * d.read #=> ".."
*/ */
static VALUE static VALUE
dir_seek(dir, pos) dir_seek(VALUE dir, VALUE pos)
VALUE dir, pos;
{ {
struct dir_data *dirp; struct dir_data *dirp;
off_t p = NUM2OFFT(pos); off_t p = NUM2OFFT(pos);
@ -626,8 +612,7 @@ dir_seek(dir, pos)
* d.read #=> ".." * d.read #=> ".."
*/ */
static VALUE static VALUE
dir_set_pos(dir, pos) dir_set_pos(VALUE dir, VALUE pos)
VALUE dir, pos;
{ {
dir_seek(dir, pos); dir_seek(dir, pos);
return pos; return pos;
@ -645,8 +630,7 @@ dir_set_pos(dir, pos)
* d.read #=> "." * d.read #=> "."
*/ */
static VALUE static VALUE
dir_rewind(dir) dir_rewind(VALUE dir)
VALUE dir;
{ {
struct dir_data *dirp; struct dir_data *dirp;
@ -666,8 +650,7 @@ dir_rewind(dir)
* d.close #=> nil * d.close #=> nil
*/ */
static VALUE static VALUE
dir_close(dir) dir_close(VALUE dir)
VALUE dir;
{ {
struct dir_data *dirp; struct dir_data *dirp;
@ -679,8 +662,7 @@ dir_close(dir)
} }
static void static void
dir_chdir(path) dir_chdir(VALUE path)
VALUE path;
{ {
if (chdir(RSTRING(path)->ptr) < 0) if (chdir(RSTRING(path)->ptr) < 0)
rb_sys_fail(RSTRING(path)->ptr); rb_sys_fail(RSTRING(path)->ptr);
@ -695,8 +677,7 @@ struct chdir_data {
}; };
static VALUE static VALUE
chdir_yield(args) chdir_yield(struct chdir_data *args)
struct chdir_data *args;
{ {
dir_chdir(args->new_path); dir_chdir(args->new_path);
args->done = Qtrue; args->done = Qtrue;
@ -707,8 +688,7 @@ chdir_yield(args)
} }
static VALUE static VALUE
chdir_restore(args) chdir_restore(struct chdir_data *args)
struct chdir_data *args;
{ {
if (args->done) { if (args->done) {
chdir_blocking--; chdir_blocking--;
@ -759,10 +739,7 @@ chdir_restore(args)
* /var/spool/mail * /var/spool/mail
*/ */
static VALUE static VALUE
dir_s_chdir(argc, argv, obj) dir_s_chdir(int argc, VALUE *argv, VALUE obj)
int argc;
VALUE *argv;
VALUE obj;
{ {
VALUE path = Qnil; VALUE path = Qnil;
@ -810,8 +787,7 @@ dir_s_chdir(argc, argv, obj)
* Dir.getwd #=> "/tmp" * Dir.getwd #=> "/tmp"
*/ */
static VALUE static VALUE
dir_s_getwd(dir) dir_s_getwd(VALUE dir)
VALUE dir;
{ {
char *path; char *path;
VALUE cwd; VALUE cwd;
@ -824,10 +800,8 @@ dir_s_getwd(dir)
return cwd; return cwd;
} }
static void check_dirname _((volatile VALUE *));
static void static void
check_dirname(dir) check_dirname(volatile VALUE *dir)
volatile VALUE *dir;
{ {
char *path, *pend; char *path, *pend;
@ -849,8 +823,7 @@ check_dirname(dir)
* information. * information.
*/ */
static VALUE static VALUE
dir_s_chroot(dir, path) dir_s_chroot(VALUE dir, VALUE path)
VALUE dir, path;
{ {
#if defined(HAVE_CHROOT) && !defined(__CHECKER__) #if defined(HAVE_CHROOT) && !defined(__CHECKER__)
check_dirname(&path); check_dirname(&path);
@ -879,10 +852,7 @@ dir_s_chroot(dir, path)
* *
*/ */
static VALUE static VALUE
dir_s_mkdir(argc, argv, obj) dir_s_mkdir(int argc, VALUE *argv, VALUE obj)
int argc;
VALUE *argv;
VALUE obj;
{ {
VALUE path, vmode; VALUE path, vmode;
int mode; int mode;
@ -911,8 +881,7 @@ dir_s_mkdir(argc, argv, obj)
* <code>SystemCallError</code> if the directory isn't empty. * <code>SystemCallError</code> if the directory isn't empty.
*/ */
static VALUE static VALUE
dir_s_rmdir(obj, dir) dir_s_rmdir(VALUE obj, VALUE dir)
VALUE obj, dir;
{ {
check_dirname(&dir); check_dirname(&dir);
if (rmdir(RSTRING(dir)->ptr) < 0) if (rmdir(RSTRING(dir)->ptr) < 0)
@ -923,9 +892,7 @@ dir_s_rmdir(obj, dir)
/* System call with warning */ /* System call with warning */
static int static int
do_stat(path, pst) do_stat(const char *path, struct stat *pst)
const char *path;
struct stat *pst;
{ {
int ret = stat(path, pst); int ret = stat(path, pst);
if (ret < 0 && errno != ENOENT) if (ret < 0 && errno != ENOENT)
@ -935,9 +902,7 @@ do_stat(path, pst)
} }
static int static int
do_lstat(path, pst) do_lstat(const char *path, struct stat *pst)
const char *path;
struct stat *pst;
{ {
int ret = lstat(path, pst); int ret = lstat(path, pst);
if (ret < 0 && errno != ENOENT) if (ret < 0 && errno != ENOENT)
@ -947,8 +912,7 @@ do_lstat(path, pst)
} }
static DIR * static DIR *
do_opendir(path) do_opendir(const char *path)
const char *path;
{ {
DIR *dirp = opendir(path); DIR *dirp = opendir(path);
if (dirp == NULL && errno != ENOENT && errno != ENOTDIR) if (dirp == NULL && errno != ENOENT && errno != ENOTDIR)
@ -959,9 +923,7 @@ do_opendir(path)
/* Return nonzero if S has any special globbing chars in it. */ /* Return nonzero if S has any special globbing chars in it. */
static int static int
has_magic(s, flags) has_magic(const char *s, int flags)
const char *s;
int flags;
{ {
const int escape = !(flags & FNM_NOESCAPE); const int escape = !(flags & FNM_NOESCAPE);
@ -989,9 +951,7 @@ has_magic(s, flags)
/* Find separator in globbing pattern. */ /* Find separator in globbing pattern. */
static char * static char *
find_dirsep(s, flags) find_dirsep(const char *s, int flags)
const char *s;
int flags;
{ {
const int escape = !(flags & FNM_NOESCAPE); const int escape = !(flags & FNM_NOESCAPE);
@ -1027,8 +987,7 @@ find_dirsep(s, flags)
/* Remove escaping baskclashes */ /* Remove escaping baskclashes */
static void static void
remove_backslashes(p) remove_backslashes(char *p)
char *p;
{ {
char *t = p; char *t = p;
char *s = p; char *s = p;
@ -1060,9 +1019,7 @@ struct glob_pattern {
}; };
static struct glob_pattern * static struct glob_pattern *
glob_make_pattern(p, flags) glob_make_pattern(const char *p, int flags)
const char *p;
int flags;
{ {
struct glob_pattern *list, *tmp, **tail = &list; struct glob_pattern *list, *tmp, **tail = &list;
int dirsep = 0; /* pattern is terminated with '/' */ int dirsep = 0; /* pattern is terminated with '/' */
@ -1106,8 +1063,7 @@ glob_make_pattern(p, flags)
} }
static void static void
glob_free_pattern(list) glob_free_pattern(struct glob_pattern *list)
struct glob_pattern *list;
{ {
while (list) { while (list) {
struct glob_pattern *tmp = list; struct glob_pattern *tmp = list;
@ -1119,10 +1075,7 @@ glob_free_pattern(list)
} }
static char * static char *
join_path(path, dirsep, name) join_path(const char *path, int dirsep, const char *name)
const char *path;
int dirsep;
const char *name;
{ {
long len = strlen(path); long len = strlen(path);
char *buf = ALLOC_N(char, len+strlen(name)+(dirsep?1:0)+1); char *buf = ALLOC_N(char, len+strlen(name)+(dirsep?1:0)+1);
@ -1156,11 +1109,8 @@ struct glob_args {
VALUE v; VALUE v;
}; };
static VALUE glob_func_caller _((VALUE));
static VALUE static VALUE
glob_func_caller(val) glob_func_caller(VALUE val)
VALUE val;
{ {
struct glob_args *args = (struct glob_args *)val; struct glob_args *args = (struct glob_args *)val;
@ -1169,10 +1119,7 @@ glob_func_caller(val)
} }
static int static int
glob_call_func(func, path, arg) glob_call_func(void (*func) (const char *, VALUE), const char *path, VALUE arg)
void (*func) _((const char *, VALUE));
const char *path;
VALUE arg;
{ {
int status; int status;
struct glob_args args; struct glob_args args;
@ -1186,16 +1133,16 @@ glob_call_func(func, path, arg)
} }
static int static int
glob_helper(path, dirsep, exist, isdir, beg, end, flags, func, arg) glob_helper(
const char *path; const char *path,
int dirsep; /* '/' should be placed before appending child entry's name to 'path'. */ int dirsep, /* '/' should be placed before appending child entry's name to 'path'. */
enum answer exist; /* Does 'path' indicate an existing entry? */ enum answer exist, /* Does 'path' indicate an existing entry? */
enum answer isdir; /* Does 'path' indicate a directory or a symlink to a directory? */ enum answer isdir, /* Does 'path' indicate a directory or a symlink to a directory? */
struct glob_pattern **beg; struct glob_pattern **beg,
struct glob_pattern **end; struct glob_pattern **end,
int flags; int flags,
void (*func) _((const char *, VALUE)); void (*func) (const char *, VALUE),
VALUE arg; VALUE arg)
{ {
struct stat st; struct stat st;
int status = 0; int status = 0;
@ -1346,11 +1293,7 @@ glob_helper(path, dirsep, exist, isdir, beg, end, flags, func, arg)
} }
static int static int
rb_glob2(path, flags, func, arg) rb_glob2(const char *path, int flags, void (*func) (const char *, VALUE), VALUE arg)
const char *path;
int flags;
void (*func) _((const char *, VALUE));
VALUE arg;
{ {
struct glob_pattern *list; struct glob_pattern *list;
const char *root, *start; const char *root, *start;
@ -1390,49 +1333,34 @@ struct rb_glob_args {
VALUE arg; VALUE arg;
}; };
static VALUE static void
rb_glob_caller(path, a) rb_glob_caller(const char *path, VALUE a)
const char *path;
VALUE a;
{ {
struct rb_glob_args *args = (struct rb_glob_args *)a; struct rb_glob_args *args = (struct rb_glob_args *)a;
(*args->func)(path, args->arg); (*args->func)(path, args->arg);
return Qnil;
} }
void void
rb_glob(path, func, arg) rb_glob(const char *path, void (*func) (const char *, VALUE), VALUE arg)
const char *path;
void (*func) _((const char*, VALUE));
VALUE arg;
{ {
struct rb_glob_args args; struct rb_glob_args args;
int status; int status;
args.func = func; args.func = func;
args.arg = arg; args.arg = arg;
status = rb_glob2(path, 0, rb_glob_caller, &args); status = rb_glob2(path, 0, rb_glob_caller, (VALUE)&args);
if (status) rb_jump_tag(status); if (status) rb_jump_tag(status);
} }
static void static void
push_pattern(path, ary) push_pattern(const char *path, VALUE ary)
const char *path;
VALUE ary;
{ {
rb_ary_push(ary, rb_tainted_str_new2(path)); rb_ary_push(ary, rb_tainted_str_new2(path));
} }
static int static int
push_glob(VALUE ary, const char *str, long offset, int flags); push_glob(VALUE ary, const char *str, long offset, int flags)
static int
push_glob(ary, str, offset, flags)
VALUE ary;
const char *str;
long offset;
int flags;
{ {
const int escape = !(flags & FNM_NOESCAPE); const int escape = !(flags & FNM_NOESCAPE);
const char *p = str; const char *p = str;
@ -1488,9 +1416,7 @@ push_glob(ary, str, offset, flags)
} }
static VALUE static VALUE
rb_push_glob(str, flags) /* '\0' is delimiter */ rb_push_glob(VALUE str, int flags) /* '\0' is delimiter */
VALUE str;
int flags;
{ {
long offset = 0; long offset = 0;
VALUE ary; VALUE ary;
@ -1527,8 +1453,7 @@ rb_push_glob(str, flags) /* '\0' is delimiter */
* *
*/ */
static VALUE static VALUE
dir_s_aref(obj, str) dir_s_aref(VALUE obj, VALUE str)
VALUE obj, str;
{ {
return rb_push_glob(str, 0); return rb_push_glob(str, 0);
} }
@ -1593,10 +1518,7 @@ dir_s_aref(obj, str)
* Dir.glob(librbfiles) #=> ["lib/song.rb"] * Dir.glob(librbfiles) #=> ["lib/song.rb"]
*/ */
static VALUE static VALUE
dir_s_glob(argc, argv, obj) dir_s_glob(int argc, VALUE *argv, VALUE obj)
int argc;
VALUE *argv;
VALUE obj;
{ {
VALUE str, rflags; VALUE str, rflags;
int flags; int flags;
@ -1610,8 +1532,7 @@ dir_s_glob(argc, argv, obj)
} }
static VALUE static VALUE
dir_open_dir(path) dir_open_dir(VALUE path)
VALUE path;
{ {
VALUE dir = rb_funcall(rb_cDir, rb_intern("open"), 1, path); VALUE dir = rb_funcall(rb_cDir, rb_intern("open"), 1, path);
@ -1642,8 +1563,7 @@ dir_open_dir(path)
* *
*/ */
static VALUE static VALUE
dir_foreach(io, dirname) dir_foreach(VALUE io, VALUE dirname)
VALUE io, dirname;
{ {
VALUE dir; VALUE dir;
@ -1664,8 +1584,7 @@ dir_foreach(io, dirname)
* *
*/ */
static VALUE static VALUE
dir_entries(io, dirname) dir_entries(VALUE io, VALUE dirname)
VALUE io, dirname;
{ {
VALUE dir; VALUE dir;
@ -1753,10 +1672,7 @@ dir_entries(io, dirname)
* File.fnmatch('** IGNORE /foo', 'a/.b/c/foo', File::FNM_PATHNAME | File::FNM_DOTMATCH) #=> true * File.fnmatch('** IGNORE /foo', 'a/.b/c/foo', File::FNM_PATHNAME | File::FNM_DOTMATCH) #=> true
*/ */
static VALUE static VALUE
file_s_fnmatch(argc, argv, obj) file_s_fnmatch(int argc, VALUE *argv, VALUE obj)
int argc;
VALUE *argv;
VALUE obj;
{ {
VALUE pattern, path; VALUE pattern, path;
VALUE rflags; VALUE rflags;
@ -1788,7 +1704,7 @@ file_s_fnmatch(argc, argv, obj)
* (<code>.</code>). * (<code>.</code>).
*/ */
void void
Init_Dir() Init_Dir(void)
{ {
rb_cDir = rb_define_class("Dir", rb_cObject); rb_cDir = rb_define_class("Dir", rb_cObject);

26
dln.c
Просмотреть файл

@ -89,7 +89,7 @@ char *getenv();
# include <image.h> # include <image.h>
#endif #endif
int eaccess(); int eaccess(const char *, int);
#ifndef NO_DLN_LOAD #ifndef NO_DLN_LOAD
@ -107,9 +107,7 @@ int eaccess();
#endif #endif
static int static int
init_funcname_len(buf, file) init_funcname_len(char **buf, const char *file)
char **buf;
const char *file;
{ {
char *p; char *p;
const char *slash; const char *slash;
@ -1161,7 +1159,7 @@ dln_sym(name)
#endif #endif
static const char * static const char *
dln_strerror() dln_strerror(void)
{ {
#ifdef USE_DLN_A_OUT #ifdef USE_DLN_A_OUT
char *strerror(); char *strerror();
@ -1262,8 +1260,7 @@ aix_loaderror(const char *pathname)
#endif /* NO_DLN_LOAD */ #endif /* NO_DLN_LOAD */
void* void*
dln_load(file) dln_load(const char *file)
const char *file;
{ {
#ifdef NO_DLN_LOAD #ifdef NO_DLN_LOAD
rb_raise(rb_eLoadError, "this executable file can't load extension libraries"); rb_raise(rb_eLoadError, "this executable file can't load extension libraries");
@ -1606,12 +1603,10 @@ dln_load(file)
return 0; /* dummy return */ return 0; /* dummy return */
} }
static char *dln_find_1(); static char *dln_find_1(char *fname, char *path, int exe_flag);
char * char *
dln_find_exe(fname, path) dln_find_exe(const char *fname, const char *path)
const char *fname;
const char *path;
{ {
if (!path) { if (!path) {
path = getenv(PATH_ENV); path = getenv(PATH_ENV);
@ -1628,9 +1623,7 @@ dln_find_exe(fname, path)
} }
char * char *
dln_find_file(fname, path) dln_find_file(const char *fname, const char *path)
const char *fname;
const char *path;
{ {
#ifndef __MACOS__ #ifndef __MACOS__
if (!path) path = "."; if (!path) path = ".";
@ -1672,10 +1665,7 @@ conv_to_posix_path(win32, posix, len)
static char fbuf[MAXPATHLEN]; static char fbuf[MAXPATHLEN];
static char * static char *
dln_find_1(fname, path, exe_flag) dln_find_1(char *fname, char *path, int exe_flag /* non 0 if looking for executable. */)
char *fname;
char *path;
int exe_flag; /* non 0 if looking for executable. */
{ {
register char *dp; register char *dp;
register char *ep; register char *ep;

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

@ -1,4 +1,4 @@
void void
Init_ext() Init_ext(void)
{ {
} }

166
enum.c
Просмотреть файл

@ -18,15 +18,13 @@ VALUE rb_mEnumerable;
static ID id_each, id_eqq, id_cmp; static ID id_each, id_eqq, id_cmp;
VALUE VALUE
rb_each(obj) rb_each(VALUE obj)
VALUE obj;
{ {
return rb_funcall(obj, id_each, 0, 0); return rb_funcall(obj, id_each, 0, 0);
} }
static VALUE static VALUE
grep_i(i, arg) grep_i(VALUE i, VALUE *arg)
VALUE i, *arg;
{ {
if (RTEST(rb_funcall(arg[0], id_eqq, 1, i))) { if (RTEST(rb_funcall(arg[0], id_eqq, 1, i))) {
rb_ary_push(arg[1], i); rb_ary_push(arg[1], i);
@ -35,8 +33,7 @@ grep_i(i, arg)
} }
static VALUE static VALUE
grep_iter_i(i, arg) grep_iter_i(VALUE i, VALUE *arg)
VALUE i, *arg;
{ {
if (RTEST(rb_funcall(arg[0], id_eqq, 1, i))) { if (RTEST(rb_funcall(arg[0], id_eqq, 1, i))) {
rb_ary_push(arg[1], rb_yield(i)); rb_ary_push(arg[1], rb_yield(i));
@ -63,8 +60,7 @@ grep_iter_i(i, arg)
*/ */
static VALUE static VALUE
enum_grep(obj, pat) enum_grep(VALUE obj, VALUE pat)
VALUE obj, pat;
{ {
VALUE ary = rb_ary_new(); VALUE ary = rb_ary_new();
VALUE arg[2]; VALUE arg[2];
@ -78,8 +74,7 @@ enum_grep(obj, pat)
} }
static VALUE static VALUE
count_i(i, arg) count_i(VALUE i, VALUE *arg)
VALUE i, *arg;
{ {
if (rb_equal(i, arg[0])) { if (rb_equal(i, arg[0])) {
arg[1]++; arg[1]++;
@ -88,9 +83,7 @@ count_i(i, arg)
} }
static VALUE static VALUE
count_iter_i(i, n) count_iter_i(VALUE i, long *n)
VALUE i;
long *n;
{ {
if (RTEST(rb_yield(i))) { if (RTEST(rb_yield(i))) {
(*n)++; (*n)++;
@ -113,10 +106,7 @@ count_iter_i(i, n)
*/ */
static VALUE static VALUE
enum_count(argc, argv, obj) enum_count(int argc, VALUE *argv, VALUE obj)
int argc;
VALUE* argv;
VALUE obj;
{ {
if (argc == 1) { if (argc == 1) {
VALUE item, args[2]; VALUE item, args[2];
@ -139,9 +129,7 @@ enum_count(argc, argv, obj)
} }
static VALUE static VALUE
find_i(i, memo) find_i(VALUE i, VALUE *memo)
VALUE i;
VALUE *memo;
{ {
if (RTEST(rb_yield(i))) { if (RTEST(rb_yield(i))) {
*memo = i; *memo = i;
@ -166,10 +154,7 @@ find_i(i, memo)
*/ */
static VALUE static VALUE
enum_find(argc, argv, obj) enum_find(int argc, VALUE *argv, VALUE obj)
int argc;
VALUE* argv;
VALUE obj;
{ {
VALUE memo = Qundef; VALUE memo = Qundef;
VALUE if_none; VALUE if_none;
@ -187,8 +172,7 @@ enum_find(argc, argv, obj)
} }
static VALUE static VALUE
find_all_i(i, ary) find_all_i(VALUE i, VALUE ary)
VALUE i, ary;
{ {
if (RTEST(rb_yield(i))) { if (RTEST(rb_yield(i))) {
rb_ary_push(ary, i); rb_ary_push(ary, i);
@ -210,8 +194,7 @@ find_all_i(i, ary)
*/ */
static VALUE static VALUE
enum_find_all(obj) enum_find_all(VALUE obj)
VALUE obj;
{ {
VALUE ary; VALUE ary;
@ -224,8 +207,7 @@ enum_find_all(obj)
} }
static VALUE static VALUE
reject_i(i, ary) reject_i(VALUE i, VALUE ary)
VALUE i, ary;
{ {
if (!RTEST(rb_yield(i))) { if (!RTEST(rb_yield(i))) {
rb_ary_push(ary, i); rb_ary_push(ary, i);
@ -245,8 +227,7 @@ reject_i(i, ary)
*/ */
static VALUE static VALUE
enum_reject(obj) enum_reject(VALUE obj)
VALUE obj;
{ {
VALUE ary; VALUE ary;
@ -259,8 +240,7 @@ enum_reject(obj)
} }
static VALUE static VALUE
collect_i(i, ary) collect_i(VALUE i, VALUE ary)
VALUE i, ary;
{ {
rb_ary_push(ary, rb_yield(i)); rb_ary_push(ary, rb_yield(i));
@ -268,8 +248,7 @@ collect_i(i, ary)
} }
static VALUE static VALUE
collect_all(i, ary) collect_all(VALUE i, VALUE ary)
VALUE i, ary;
{ {
rb_ary_push(ary, i); rb_ary_push(ary, i);
@ -290,8 +269,7 @@ collect_all(i, ary)
*/ */
static VALUE static VALUE
enum_collect(obj) enum_collect(VALUE obj)
VALUE obj;
{ {
VALUE ary; VALUE ary;
@ -314,8 +292,7 @@ enum_collect(obj)
* { 'a'=>1, 'b'=>2, 'c'=>3 }.to_a #=> [["a", 1], ["b", 2], ["c", 3]] * { 'a'=>1, 'b'=>2, 'c'=>3 }.to_a #=> [["a", 1], ["b", 2], ["c", 3]]
*/ */
static VALUE static VALUE
enum_to_a(obj) enum_to_a(VALUE obj)
VALUE obj;
{ {
VALUE ary = rb_ary_new(); VALUE ary = rb_ary_new();
@ -325,9 +302,7 @@ enum_to_a(obj)
} }
static VALUE static VALUE
inject_i(i, memo) inject_i(VALUE i, VALUE *memo)
VALUE i;
VALUE *memo;
{ {
if (*memo == Qundef) { if (*memo == Qundef) {
*memo = i; *memo = i;
@ -370,9 +345,7 @@ inject_i(i, memo)
*/ */
static VALUE static VALUE
enum_inject(argc, argv, obj) enum_inject(int argc, VALUE *argv, VALUE obj)
int argc;
VALUE *argv, obj;
{ {
VALUE memo = Qundef; VALUE memo = Qundef;
@ -384,8 +357,7 @@ enum_inject(argc, argv, obj)
} }
static VALUE static VALUE
partition_i(i, ary) partition_i(VALUE i, VALUE *ary)
VALUE i, *ary;
{ {
if (RTEST(rb_yield(i))) { if (RTEST(rb_yield(i))) {
rb_ary_push(ary[0], i); rb_ary_push(ary[0], i);
@ -409,8 +381,7 @@ partition_i(i, ary)
*/ */
static VALUE static VALUE
enum_partition(obj) enum_partition(VALUE obj)
VALUE obj;
{ {
VALUE ary[2]; VALUE ary[2];
@ -441,15 +412,13 @@ enum_partition(obj)
*/ */
static VALUE static VALUE
enum_sort(obj) enum_sort(VALUE obj)
VALUE obj;
{ {
return rb_ary_sort(enum_to_a(obj)); return rb_ary_sort(enum_to_a(obj));
} }
static VALUE static VALUE
sort_by_i(i, ary) sort_by_i(VALUE i, VALUE ary)
VALUE i, ary;
{ {
VALUE v; VALUE v;
NODE *memo; NODE *memo;
@ -464,8 +433,7 @@ sort_by_i(i, ary)
} }
static int static int
sort_by_cmp(aa, bb) sort_by_cmp(NODE **aa, NODE **bb)
NODE **aa, **bb;
{ {
VALUE a = aa[0]->u1.value; VALUE a = aa[0]->u1.value;
VALUE b = bb[0]->u1.value; VALUE b = bb[0]->u1.value;
@ -543,8 +511,7 @@ sort_by_cmp(aa, bb)
*/ */
static VALUE static VALUE
enum_sort_by(obj) enum_sort_by(VALUE obj)
VALUE obj;
{ {
VALUE ary; VALUE ary;
long i; long i;
@ -573,9 +540,7 @@ enum_sort_by(obj)
} }
static VALUE static VALUE
all_iter_i(i, memo) all_iter_i(VALUE i, VALUE *memo)
VALUE i;
VALUE *memo;
{ {
if (!RTEST(rb_yield(i))) { if (!RTEST(rb_yield(i))) {
*memo = Qfalse; *memo = Qfalse;
@ -585,9 +550,7 @@ all_iter_i(i, memo)
} }
static VALUE static VALUE
all_i(i, memo) all_i(VALUE i, VALUE *memo)
VALUE i;
VALUE *memo;
{ {
if (!RTEST(i)) { if (!RTEST(i)) {
*memo = Qfalse; *memo = Qfalse;
@ -614,8 +577,7 @@ all_i(i, memo)
*/ */
static VALUE static VALUE
enum_all(obj) enum_all(VALUE obj)
VALUE obj;
{ {
VALUE result = Qtrue; VALUE result = Qtrue;
@ -624,9 +586,7 @@ enum_all(obj)
} }
static VALUE static VALUE
any_iter_i(i, memo) any_iter_i(VALUE i, VALUE *memo)
VALUE i;
VALUE *memo;
{ {
if (RTEST(rb_yield(i))) { if (RTEST(rb_yield(i))) {
*memo = Qtrue; *memo = Qtrue;
@ -636,9 +596,7 @@ any_iter_i(i, memo)
} }
static VALUE static VALUE
any_i(i, memo) any_i(VALUE i, VALUE *memo)
VALUE i;
VALUE *memo;
{ {
if (RTEST(i)) { if (RTEST(i)) {
*memo = Qtrue; *memo = Qtrue;
@ -666,8 +624,7 @@ any_i(i, memo)
*/ */
static VALUE static VALUE
enum_any(obj) enum_any(VALUE obj)
VALUE obj;
{ {
VALUE result = Qfalse; VALUE result = Qfalse;
@ -676,9 +633,7 @@ enum_any(obj)
} }
static VALUE static VALUE
min_i(i, memo) min_i(VALUE i, VALUE *memo)
VALUE i;
VALUE *memo;
{ {
VALUE cmp; VALUE cmp;
@ -695,9 +650,7 @@ min_i(i, memo)
} }
static VALUE static VALUE
min_ii(i, memo) min_ii(VALUE i, VALUE *memo)
VALUE i;
VALUE *memo;
{ {
VALUE cmp; VALUE cmp;
@ -729,8 +682,7 @@ min_ii(i, memo)
*/ */
static VALUE static VALUE
enum_min(obj) enum_min(VALUE obj)
VALUE obj;
{ {
VALUE result = Qundef; VALUE result = Qundef;
@ -740,9 +692,7 @@ enum_min(obj)
} }
static VALUE static VALUE
max_i(i, memo) max_i(VALUE i, VALUE *memo)
VALUE i;
VALUE *memo;
{ {
VALUE cmp; VALUE cmp;
@ -759,9 +709,7 @@ max_i(i, memo)
} }
static VALUE static VALUE
max_ii(i, memo) max_ii(VALUE i, VALUE *memo)
VALUE i;
VALUE *memo;
{ {
VALUE cmp; VALUE cmp;
@ -792,8 +740,7 @@ max_ii(i, memo)
*/ */
static VALUE static VALUE
enum_max(obj) enum_max(VALUE obj)
VALUE obj;
{ {
VALUE result = Qundef; VALUE result = Qundef;
@ -803,9 +750,7 @@ enum_max(obj)
} }
static VALUE static VALUE
min_by_i(i, memo) min_by_i(VALUE i, VALUE *memo)
VALUE i;
VALUE *memo;
{ {
VALUE v; VALUE v;
@ -833,8 +778,7 @@ min_by_i(i, memo)
*/ */
static VALUE static VALUE
enum_min_by(obj) enum_min_by(VALUE obj)
VALUE obj;
{ {
VALUE memo[2]; VALUE memo[2];
@ -847,9 +791,7 @@ enum_min_by(obj)
} }
static VALUE static VALUE
max_by_i(i, memo) max_by_i(VALUE i, VALUE *memo)
VALUE i;
VALUE *memo;
{ {
VALUE v; VALUE v;
@ -877,8 +819,7 @@ max_by_i(i, memo)
*/ */
static VALUE static VALUE
enum_max_by(obj) enum_max_by(VALUE obj)
VALUE obj;
{ {
VALUE memo[2]; VALUE memo[2];
@ -891,9 +832,7 @@ enum_max_by(obj)
} }
static VALUE static VALUE
member_i(item, memo) member_i(VALUE item, VALUE *memo)
VALUE item;
VALUE *memo;
{ {
if (rb_equal(item, memo[0])) { if (rb_equal(item, memo[0])) {
memo[1] = Qtrue; memo[1] = Qtrue;
@ -916,8 +855,7 @@ member_i(item, memo)
*/ */
static VALUE static VALUE
enum_member(obj, val) enum_member(VALUE obj, VALUE val)
VALUE obj, val;
{ {
VALUE memo[2]; VALUE memo[2];
@ -928,9 +866,7 @@ enum_member(obj, val)
} }
static VALUE static VALUE
each_with_index_i(val, memo) each_with_index_i(VALUE val, VALUE *memo)
VALUE val;
VALUE *memo;
{ {
rb_yield_values(2, val, INT2FIX(*memo)); rb_yield_values(2, val, INT2FIX(*memo));
++*memo; ++*memo;
@ -953,8 +889,7 @@ each_with_index_i(val, memo)
*/ */
static VALUE static VALUE
enum_each_with_index(obj) enum_each_with_index(VALUE obj)
VALUE obj;
{ {
VALUE memo = 0; VALUE memo = 0;
@ -965,9 +900,7 @@ enum_each_with_index(obj)
} }
static VALUE static VALUE
zip_i(val, memo) zip_i(VALUE val, VALUE *memo)
VALUE val;
VALUE *memo;
{ {
VALUE result = memo[0]; VALUE result = memo[0];
VALUE args = memo[1]; VALUE args = memo[1];
@ -1013,10 +946,7 @@ zip_i(val, memo)
*/ */
static VALUE static VALUE
enum_zip(argc, argv, obj) enum_zip(int argc, VALUE *argv, VALUE obj)
int argc;
VALUE *argv;
VALUE obj;
{ {
int i; int i;
VALUE result; VALUE result;
@ -1046,7 +976,7 @@ enum_zip(argc, argv, obj)
*/ */
void void
Init_Enumerable() Init_Enumerable(void)
{ {
rb_mEnumerable = rb_define_module("Enumerable"); rb_mEnumerable = rb_define_module("Enumerable");

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

@ -24,8 +24,7 @@ static VALUE rb_cEnumerator;
static VALUE sym_each, sym_each_with_index, sym_each_slice, sym_each_cons; static VALUE sym_each, sym_each_with_index, sym_each_slice, sym_each_cons;
static VALUE static VALUE
proc_call(proc, args) proc_call(VALUE proc, VALUE args)
VALUE proc, args;
{ {
if (TYPE(args) != T_ARRAY) { if (TYPE(args) != T_ARRAY) {
args = rb_values_new(1, args); args = rb_values_new(1, args);
@ -34,8 +33,7 @@ proc_call(proc, args)
} }
static VALUE static VALUE
method_call(method, args) method_call(VALUE method, VALUE args)
VALUE method, args;
{ {
int argc = 0; int argc = 0;
VALUE *argv = 0; VALUE *argv = 0;
@ -53,10 +51,8 @@ struct enumerator {
VALUE (*iter)_((VALUE, struct enumerator *)); VALUE (*iter)_((VALUE, struct enumerator *));
}; };
static void enumerator_mark _((void *));
static void static void
enumerator_mark(p) enumerator_mark(void *p)
void *p;
{ {
struct enumerator *ptr = p; struct enumerator *ptr = p;
rb_gc_mark(ptr->method); rb_gc_mark(ptr->method);
@ -65,8 +61,7 @@ enumerator_mark(p)
} }
static struct enumerator * static struct enumerator *
enumerator_ptr(obj) enumerator_ptr(VALUE obj)
VALUE obj;
{ {
struct enumerator *ptr; struct enumerator *ptr;
@ -82,11 +77,8 @@ enumerator_ptr(obj)
return ptr; return ptr;
} }
static VALUE enumerator_iter_i _((VALUE, struct enumerator *));
static VALUE static VALUE
enumerator_iter_i(i, e) enumerator_iter_i(VALUE i, struct enumerator *e)
VALUE i;
struct enumerator *e;
{ {
return rb_yield(proc_call(e->proc, i)); return rb_yield(proc_call(e->proc, i));
} }
@ -110,10 +102,7 @@ enumerator_iter_i(i, e)
* *
*/ */
static VALUE static VALUE
obj_to_enum(argc, argv, obj) obj_to_enum(int argc, VALUE *argv, VALUE obj)
int argc;
VALUE *argv;
VALUE obj;
{ {
VALUE meth = sym_each; VALUE meth = sym_each;
@ -132,16 +121,13 @@ obj_to_enum(argc, argv, obj)
* *
*/ */
static VALUE static VALUE
enumerator_enum_with_index(obj) enumerator_enum_with_index(VALUE obj)
VALUE obj;
{ {
return rb_enumeratorize(obj, sym_each_with_index, 0, 0); return rb_enumeratorize(obj, sym_each_with_index, 0, 0);
} }
static VALUE static VALUE
each_slice_i(val, memo) each_slice_i(VALUE val, VALUE *memo)
VALUE val;
VALUE *memo;
{ {
VALUE ary = memo[0]; VALUE ary = memo[0];
long size = (long)memo[1]; long size = (long)memo[1];
@ -172,8 +158,7 @@ each_slice_i(val, memo)
* *
*/ */
static VALUE static VALUE
enum_each_slice(obj, n) enum_each_slice(VALUE obj, VALUE n)
VALUE obj, n;
{ {
long size = NUM2LONG(n); long size = NUM2LONG(n);
VALUE args[2], ary; VALUE args[2], ary;
@ -199,16 +184,13 @@ enum_each_slice(obj, n)
* *
*/ */
static VALUE static VALUE
enumerator_enum_slice(obj, n) enumerator_enum_slice(VALUE obj, VALUE n)
VALUE obj, n;
{ {
return rb_enumeratorize(obj, sym_each_slice, 1, &n); return rb_enumeratorize(obj, sym_each_slice, 1, &n);
} }
static VALUE static VALUE
each_cons_i(val, memo) each_cons_i(VALUE val, VALUE *memo)
VALUE val;
VALUE *memo;
{ {
VALUE ary = memo[0]; VALUE ary = memo[0];
long size = (long)memo[1]; long size = (long)memo[1];
@ -244,8 +226,7 @@ each_cons_i(val, memo)
* *
*/ */
static VALUE static VALUE
enum_each_cons(obj, n) enum_each_cons(VALUE obj, VALUE n)
VALUE obj, n;
{ {
long size = NUM2LONG(n); long size = NUM2LONG(n);
VALUE args[2]; VALUE args[2];
@ -267,16 +248,13 @@ enum_each_cons(obj, n)
* *
*/ */
static VALUE static VALUE
enumerator_enum_cons(obj, n) enumerator_enum_cons(VALUE obj, VALUE n)
VALUE obj, n;
{ {
return rb_enumeratorize(obj, sym_each_cons, 1, &n); return rb_enumeratorize(obj, sym_each_cons, 1, &n);
} }
static VALUE enumerator_allocate _((VALUE));
static VALUE static VALUE
enumerator_allocate(klass) enumerator_allocate(VALUE klass)
VALUE klass;
{ {
struct enumerator *ptr; struct enumerator *ptr;
return Data_Make_Struct(rb_cEnumerator, struct enumerator, return Data_Make_Struct(rb_cEnumerator, struct enumerator,
@ -284,10 +262,7 @@ enumerator_allocate(klass)
} }
VALUE VALUE
enumerator_init(enum_obj, obj, meth, argc, argv) enumerator_init(VALUE enum_obj, VALUE obj, VALUE meth, int argc, VALUE *argv)
VALUE enum_obj, obj, meth;
int argc;
VALUE *argv;
{ {
struct enumerator *ptr = enumerator_ptr(enum_obj); struct enumerator *ptr = enumerator_ptr(enum_obj);
@ -320,10 +295,7 @@ enumerator_init(enum_obj, obj, meth, argc, argv)
* *
*/ */
static VALUE static VALUE
enumerator_initialize(argc, argv, obj) enumerator_initialize(int argc, VALUE *argv, VALUE obj)
int argc;
VALUE *argv;
VALUE obj;
{ {
VALUE recv, meth = sym_each; VALUE recv, meth = sym_each;
@ -338,18 +310,13 @@ enumerator_initialize(argc, argv, obj)
} }
VALUE VALUE
rb_enumeratorize(obj, meth, argc, argv) rb_enumeratorize(VALUE obj, VALUE meth, int argc, VALUE *argv)
VALUE obj, meth;
int argc;
VALUE *argv;
{ {
return enumerator_init(enumerator_allocate(rb_cEnumerator), obj, meth, argc, argv); return enumerator_init(enumerator_allocate(rb_cEnumerator), obj, meth, argc, argv);
} }
static VALUE enumerator_iter _((VALUE));
static VALUE static VALUE
enumerator_iter(memo) enumerator_iter(VALUE memo)
VALUE memo;
{ {
struct enumerator *e = (struct enumerator *)memo; struct enumerator *e = (struct enumerator *)memo;
@ -365,8 +332,7 @@ enumerator_iter(memo)
* *
*/ */
static VALUE static VALUE
enumerator_each(obj) enumerator_each(VALUE obj)
VALUE obj;
{ {
struct enumerator *e = enumerator_ptr(obj); struct enumerator *e = enumerator_ptr(obj);
@ -374,8 +340,7 @@ enumerator_each(obj)
} }
static VALUE static VALUE
enumerator_with_index_i(val, memo) enumerator_with_index_i(VALUE val, VALUE *memo)
VALUE val, *memo;
{ {
val = rb_yield_values(2, val, INT2FIX(*memo)); val = rb_yield_values(2, val, INT2FIX(*memo));
++*memo; ++*memo;
@ -391,8 +356,7 @@ enumerator_with_index_i(val, memo)
* *
*/ */
static VALUE static VALUE
enumerator_with_index(obj) enumerator_with_index(VALUE obj)
VALUE obj;
{ {
struct enumerator *e = enumerator_ptr(obj); struct enumerator *e = enumerator_ptr(obj);
VALUE memo = 0; VALUE memo = 0;
@ -402,7 +366,7 @@ enumerator_with_index(obj)
} }
void void
Init_Enumerator() Init_Enumerator(void)
{ {
rb_define_method(rb_mKernel, "to_enum", obj_to_enum, -1); rb_define_method(rb_mKernel, "to_enum", obj_to_enum, -1);
rb_define_method(rb_mKernel, "enum_for", obj_to_enum, -1); rb_define_method(rb_mKernel, "enum_for", obj_to_enum, -1);

248
error.c
Просмотреть файл

@ -15,13 +15,7 @@
#include "st.h" #include "st.h"
#include <stdio.h> #include <stdio.h>
#ifdef HAVE_STDARG_PROTOTYPES
#include <stdarg.h> #include <stdarg.h>
#define va_init_list(a,b) va_start(a,b)
#else
#include <varargs.h>
#define va_init_list(a,b) va_start(a)
#endif
#ifdef HAVE_STDLIB_H #ifdef HAVE_STDLIB_H
#include <stdlib.h> #include <stdlib.h>
#endif #endif
@ -34,9 +28,7 @@ extern const char ruby_version[], ruby_release_date[], ruby_platform[];
int ruby_nerrs; int ruby_nerrs;
static int static int
err_position(buf, len) err_position(char *buf, long len)
char *buf;
long len;
{ {
ruby_set_current_source(); ruby_set_current_source();
if (!ruby_sourcefile) { if (!ruby_sourcefile) {
@ -51,11 +43,7 @@ err_position(buf, len)
} }
static void static void
err_snprintf(buf, len, fmt, args) err_snprintf(char *buf, long len, const char *fmt, va_list args)
char *buf;
long len;
const char *fmt;
va_list args;
{ {
long n; long n;
@ -67,9 +55,7 @@ err_snprintf(buf, len, fmt, args)
static void err_append _((const char*)); static void err_append _((const char*));
static void static void
err_print(fmt, args) err_print(const char *fmt, va_list args)
const char *fmt;
va_list args;
{ {
char buf[BUFSIZ]; char buf[BUFSIZ];
@ -78,44 +64,30 @@ err_print(fmt, args)
} }
void void
#ifdef HAVE_STDARG_PROTOTYPES
rb_compile_error(const char *fmt, ...) rb_compile_error(const char *fmt, ...)
#else
rb_compile_error(fmt, va_alist)
const char *fmt;
va_dcl
#endif
{ {
va_list args; va_list args;
va_init_list(args, fmt); va_start(args, fmt);
err_print(fmt, args); err_print(fmt, args);
va_end(args); va_end(args);
ruby_nerrs++; ruby_nerrs++;
} }
void void
#ifdef HAVE_STDARG_PROTOTYPES
rb_compile_error_append(const char *fmt, ...) rb_compile_error_append(const char *fmt, ...)
#else
rb_compile_error_append(fmt, va_alist)
const char *fmt;
va_dcl
#endif
{ {
va_list args; va_list args;
char buf[BUFSIZ]; char buf[BUFSIZ];
va_init_list(args, fmt); va_start(args, fmt);
vsnprintf(buf, BUFSIZ, fmt, args); vsnprintf(buf, BUFSIZ, fmt, args);
va_end(args); va_end(args);
err_append(buf); err_append(buf);
} }
static void static void
warn_print(fmt, args) warn_print(const char *fmt, va_list args)
const char *fmt;
va_list args;
{ {
char buf[BUFSIZ]; char buf[BUFSIZ];
int len; int len;
@ -127,13 +99,7 @@ warn_print(fmt, args)
} }
void void
#ifdef HAVE_STDARG_PROTOTYPES
rb_warn(const char *fmt, ...) rb_warn(const char *fmt, ...)
#else
rb_warn(fmt, va_alist)
const char *fmt;
va_dcl
#endif
{ {
char buf[BUFSIZ]; char buf[BUFSIZ];
va_list args; va_list args;
@ -142,20 +108,14 @@ rb_warn(fmt, va_alist)
snprintf(buf, BUFSIZ, "warning: %s", fmt); snprintf(buf, BUFSIZ, "warning: %s", fmt);
va_init_list(args, fmt); va_start(args, fmt);
warn_print(buf, args); warn_print(buf, args);
va_end(args); va_end(args);
} }
/* rb_warning() reports only in verbose mode */ /* rb_warning() reports only in verbose mode */
void void
#ifdef HAVE_STDARG_PROTOTYPES
rb_warning(const char *fmt, ...) rb_warning(const char *fmt, ...)
#else
rb_warning(fmt, va_alist)
const char *fmt;
va_dcl
#endif
{ {
char buf[BUFSIZ]; char buf[BUFSIZ];
va_list args; va_list args;
@ -164,7 +124,7 @@ rb_warning(fmt, va_alist)
snprintf(buf, BUFSIZ, "warning: %s", fmt); snprintf(buf, BUFSIZ, "warning: %s", fmt);
va_init_list(args, fmt); va_start(args, fmt);
warn_print(buf, args); warn_print(buf, args);
va_end(args); va_end(args);
} }
@ -178,8 +138,7 @@ rb_warning(fmt, va_alist)
*/ */
static VALUE static VALUE
rb_warn_m(self, mesg) rb_warn_m(VALUE self, VALUE mesg)
VALUE self, mesg;
{ {
if (!NIL_P(ruby_verbose)) { if (!NIL_P(ruby_verbose)) {
rb_io_write(rb_stderr, mesg); rb_io_write(rb_stderr, mesg);
@ -189,13 +148,7 @@ rb_warn_m(self, mesg)
} }
void void
#ifdef HAVE_STDARG_PROTOTYPES
rb_bug(const char *fmt, ...) rb_bug(const char *fmt, ...)
#else
rb_bug(fmt, va_alist)
const char *fmt;
va_dcl
#endif
{ {
char buf[BUFSIZ]; char buf[BUFSIZ];
va_list args; va_list args;
@ -205,7 +158,7 @@ rb_bug(fmt, va_alist)
if (fwrite(buf, 1, len, out) == len || if (fwrite(buf, 1, len, out) == len ||
fwrite(buf, 1, len, (out = stdout)) == len) { fwrite(buf, 1, len, (out = stdout)) == len) {
fputs("[BUG] ", out); fputs("[BUG] ", out);
va_init_list(args, fmt); va_start(args, fmt);
vfprintf(out, fmt, args); vfprintf(out, fmt, args);
va_end(args); va_end(args);
fprintf(out, "\nruby %s (%s) [%s]\n\n", fprintf(out, "\nruby %s (%s) [%s]\n\n",
@ -245,9 +198,7 @@ static struct types {
}; };
void void
rb_check_type(x, t) rb_check_type(VALUE x, int t)
VALUE x;
int t;
{ {
struct types *type = builtin_types; struct types *type = builtin_types;
@ -315,25 +266,19 @@ VALUE rb_mErrno;
static VALUE eNOERROR; static VALUE eNOERROR;
VALUE VALUE
rb_exc_new(etype, ptr, len) rb_exc_new(VALUE etype, const char *ptr, long len)
VALUE etype;
const char *ptr;
long len;
{ {
return rb_funcall(etype, rb_intern("new"), 1, rb_str_new(ptr, len)); return rb_funcall(etype, rb_intern("new"), 1, rb_str_new(ptr, len));
} }
VALUE VALUE
rb_exc_new2(etype, s) rb_exc_new2(VALUE etype, const char *s)
VALUE etype;
const char *s;
{ {
return rb_exc_new(etype, s, strlen(s)); return rb_exc_new(etype, s, strlen(s));
} }
VALUE VALUE
rb_exc_new3(etype, str) rb_exc_new3(VALUE etype, VALUE str)
VALUE etype, str;
{ {
StringValue(str); StringValue(str);
return rb_funcall(etype, rb_intern("new"), 1, str); return rb_funcall(etype, rb_intern("new"), 1, str);
@ -348,10 +293,7 @@ rb_exc_new3(etype, str)
*/ */
static VALUE static VALUE
exc_initialize(argc, argv, exc) exc_initialize(int argc, VALUE *argv, VALUE exc)
int argc;
VALUE *argv;
VALUE exc;
{ {
VALUE arg; VALUE arg;
@ -376,10 +318,7 @@ exc_initialize(argc, argv, exc)
*/ */
static VALUE static VALUE
exc_exception(argc, argv, self) exc_exception(int argc, VALUE *argv, VALUE self)
int argc;
VALUE *argv;
VALUE self;
{ {
VALUE exc; VALUE exc;
@ -400,8 +339,7 @@ exc_exception(argc, argv, self)
*/ */
static VALUE static VALUE
exc_to_s(exc) exc_to_s(VALUE exc)
VALUE exc;
{ {
VALUE mesg = rb_attr_get(exc, rb_intern("mesg")); VALUE mesg = rb_attr_get(exc, rb_intern("mesg"));
@ -421,8 +359,7 @@ exc_to_s(exc)
*/ */
static VALUE static VALUE
exc_message(exc) exc_message(VALUE exc)
VALUE exc;
{ {
return rb_funcall(exc, rb_intern("to_s"), 0, 0); return rb_funcall(exc, rb_intern("to_s"), 0, 0);
} }
@ -435,8 +372,7 @@ exc_message(exc)
*/ */
static VALUE static VALUE
exc_inspect(exc) exc_inspect(VALUE exc)
VALUE exc;
{ {
VALUE str, klass; VALUE str, klass;
@ -486,8 +422,7 @@ exc_inspect(exc)
*/ */
static VALUE static VALUE
exc_backtrace(exc) exc_backtrace(VALUE exc)
VALUE exc;
{ {
ID bt = rb_intern("bt"); ID bt = rb_intern("bt");
@ -496,8 +431,7 @@ exc_backtrace(exc)
} }
static VALUE static VALUE
check_backtrace(bt) check_backtrace(VALUE bt)
VALUE bt;
{ {
long i; long i;
static char *err = "backtrace must be Array of String"; static char *err = "backtrace must be Array of String";
@ -529,9 +463,7 @@ check_backtrace(bt)
*/ */
static VALUE static VALUE
exc_set_backtrace(exc, bt) exc_set_backtrace(VALUE exc, VALUE bt)
VALUE exc;
VALUE bt;
{ {
return rb_iv_set(exc, "bt", check_backtrace(bt)); return rb_iv_set(exc, "bt", check_backtrace(bt));
} }
@ -546,9 +478,7 @@ exc_set_backtrace(exc, bt)
*/ */
static VALUE static VALUE
exc_equal(exc, obj) exc_equal(VALUE exc, VALUE obj)
VALUE exc;
VALUE obj;
{ {
ID id_mesg = rb_intern("mesg"); ID id_mesg = rb_intern("mesg");
@ -570,10 +500,7 @@ exc_equal(exc, obj)
*/ */
static VALUE static VALUE
exit_initialize(argc, argv, exc) exit_initialize(int argc, VALUE *argv, VALUE exc)
int argc;
VALUE *argv;
VALUE exc;
{ {
VALUE status = INT2FIX(EXIT_SUCCESS); VALUE status = INT2FIX(EXIT_SUCCESS);
if (argc > 0 && FIXNUM_P(argv[0])) { if (argc > 0 && FIXNUM_P(argv[0])) {
@ -594,8 +521,7 @@ exit_initialize(argc, argv, exc)
*/ */
static VALUE static VALUE
exit_status(exc) exit_status(VALUE exc)
VALUE exc;
{ {
return rb_attr_get(exc, rb_intern("status")); return rb_attr_get(exc, rb_intern("status"));
} }
@ -609,8 +535,7 @@ exit_status(exc)
*/ */
static VALUE static VALUE
exit_success_p(exc) exit_success_p(VALUE exc)
VALUE exc;
{ {
VALUE status = rb_attr_get(exc, rb_intern("status")); VALUE status = rb_attr_get(exc, rb_intern("status"));
if (NIL_P(status)) return Qtrue; if (NIL_P(status)) return Qtrue;
@ -619,20 +544,13 @@ exit_success_p(exc)
} }
void void
#ifdef HAVE_STDARG_PROTOTYPES
rb_name_error(ID id, const char *fmt, ...) rb_name_error(ID id, const char *fmt, ...)
#else
rb_name_error(id, fmt, va_alist)
ID id;
const char *fmt;
va_dcl
#endif
{ {
VALUE exc, argv[2]; VALUE exc, argv[2];
va_list args; va_list args;
char buf[BUFSIZ]; char buf[BUFSIZ];
va_init_list(args, fmt); va_start(args, fmt);
vsnprintf(buf, BUFSIZ, fmt, args); vsnprintf(buf, BUFSIZ, fmt, args);
va_end(args); va_end(args);
@ -652,10 +570,7 @@ rb_name_error(id, fmt, va_alist)
*/ */
static VALUE static VALUE
name_err_initialize(argc, argv, self) name_err_initialize(int argc, VALUE *argv, VALUE self)
int argc;
VALUE *argv;
VALUE self;
{ {
VALUE name; VALUE name;
@ -673,8 +588,7 @@ name_err_initialize(argc, argv, self)
*/ */
static VALUE static VALUE
name_err_name(self) name_err_name(VALUE self)
VALUE self;
{ {
return rb_attr_get(self, rb_intern("name")); return rb_attr_get(self, rb_intern("name"));
} }
@ -687,8 +601,7 @@ name_err_name(self)
*/ */
static VALUE static VALUE
name_err_to_s(exc) name_err_to_s(VALUE exc)
VALUE exc;
{ {
VALUE mesg = rb_attr_get(exc, rb_intern("mesg")); VALUE mesg = rb_attr_get(exc, rb_intern("mesg"));
VALUE str = mesg; VALUE str = mesg;
@ -713,10 +626,7 @@ name_err_to_s(exc)
*/ */
static VALUE static VALUE
nometh_err_initialize(argc, argv, self) nometh_err_initialize(int argc, VALUE *argv, VALUE self)
int argc;
VALUE *argv;
VALUE self;
{ {
VALUE args = (argc > 2) ? argv[--argc] : Qnil; VALUE args = (argc > 2) ? argv[--argc] : Qnil;
name_err_initialize(argc, argv, self); name_err_initialize(argc, argv, self);
@ -726,16 +636,14 @@ nometh_err_initialize(argc, argv, self)
/* :nodoc: */ /* :nodoc: */
static void static void
name_err_mesg_mark(ptr) name_err_mesg_mark(VALUE *ptr)
VALUE *ptr;
{ {
rb_gc_mark_locations(ptr, ptr+3); rb_gc_mark_locations(ptr, ptr+3);
} }
/* :nodoc: */ /* :nodoc: */
static VALUE static VALUE
name_err_mesg_new(obj, mesg, recv, method) name_err_mesg_new(VALUE obj, VALUE mesg, VALUE recv, VALUE method)
VALUE obj, mesg, recv, method;
{ {
VALUE *ptr = ALLOC_N(VALUE, 3); VALUE *ptr = ALLOC_N(VALUE, 3);
@ -747,8 +655,7 @@ name_err_mesg_new(obj, mesg, recv, method)
/* :nodoc: */ /* :nodoc: */
static VALUE static VALUE
name_err_mesg_equal(obj1, obj2) name_err_mesg_equal(VALUE obj1, VALUE obj2)
VALUE obj1, obj2;
{ {
VALUE *ptr1, *ptr2; VALUE *ptr1, *ptr2;
int i; int i;
@ -768,8 +675,7 @@ name_err_mesg_equal(obj1, obj2)
/* :nodoc: */ /* :nodoc: */
static VALUE static VALUE
name_err_mesg_to_str(obj) name_err_mesg_to_str(VALUE obj)
VALUE obj;
{ {
VALUE *ptr, mesg; VALUE *ptr, mesg;
Data_Get_Struct(obj, VALUE, ptr); Data_Get_Struct(obj, VALUE, ptr);
@ -815,8 +721,7 @@ name_err_mesg_to_str(obj)
/* :nodoc: */ /* :nodoc: */
static VALUE static VALUE
name_err_mesg_load(klass, str) name_err_mesg_load(VALUE klass, VALUE str)
VALUE klass, str;
{ {
return str; return str;
} }
@ -830,15 +735,13 @@ name_err_mesg_load(klass, str)
*/ */
static VALUE static VALUE
nometh_err_args(self) nometh_err_args(VALUE self)
VALUE self;
{ {
return rb_attr_get(self, rb_intern("args")); return rb_attr_get(self, rb_intern("args"));
} }
void void
rb_invalid_str(str, type) rb_invalid_str(const char *str, const char *type)
const char *str, *type;
{ {
VALUE s = rb_str_inspect(rb_str_new2(str)); VALUE s = rb_str_inspect(rb_str_new2(str));
@ -879,9 +782,7 @@ rb_invalid_str(str, type)
static st_table *syserr_tbl; static st_table *syserr_tbl;
static VALUE static VALUE
set_syserr(n, name) set_syserr(int n, const char *name)
int n;
const char *name;
{ {
VALUE error; VALUE error;
@ -897,8 +798,7 @@ set_syserr(n, name)
} }
static VALUE static VALUE
get_syserr(n) get_syserr(int n)
int n;
{ {
VALUE error; VALUE error;
@ -923,10 +823,7 @@ get_syserr(n)
*/ */
static VALUE static VALUE
syserr_initialize(argc, argv, self) syserr_initialize(int argc, VALUE *argv, VALUE self)
int argc;
VALUE *argv;
VALUE self;
{ {
#if !defined(_WIN32) && !defined(__VMS) #if !defined(_WIN32) && !defined(__VMS)
char *strerror(); char *strerror();
@ -977,8 +874,7 @@ syserr_initialize(argc, argv, self)
*/ */
static VALUE static VALUE
syserr_errno(self) syserr_errno(VALUE self)
VALUE self;
{ {
return rb_attr_get(self, rb_intern("errno")); return rb_attr_get(self, rb_intern("errno"));
} }
@ -992,8 +888,7 @@ syserr_errno(self)
*/ */
static VALUE static VALUE
syserr_eqq(self, exc) syserr_eqq(VALUE self, VALUE exc)
VALUE self, exc;
{ {
VALUE num, e; VALUE num, e;
@ -1022,8 +917,7 @@ syserr_eqq(self, exc)
* Returns default SystemCallError class. * Returns default SystemCallError class.
*/ */
static VALUE static VALUE
errno_missing(self, id) errno_missing(VALUE self, VALUE id)
VALUE self, id;
{ {
return eNOERROR; return eNOERROR;
} }
@ -1039,7 +933,7 @@ errno_missing(self, id)
*/ */
void void
Init_Exception() Init_Exception(void)
{ {
rb_eException = rb_define_class("Exception", rb_cObject); rb_eException = rb_define_class("Exception", rb_cObject);
rb_define_singleton_method(rb_eException, "exception", rb_class_new_instance, -1); rb_define_singleton_method(rb_eException, "exception", rb_class_new_instance, -1);
@ -1103,44 +997,31 @@ Init_Exception()
} }
void void
#ifdef HAVE_STDARG_PROTOTYPES
rb_raise(VALUE exc, const char *fmt, ...) rb_raise(VALUE exc, const char *fmt, ...)
#else
rb_raise(exc, fmt, va_alist)
VALUE exc;
const char *fmt;
va_dcl
#endif
{ {
va_list args; va_list args;
char buf[BUFSIZ]; char buf[BUFSIZ];
va_init_list(args,fmt); va_start(args,fmt);
vsnprintf(buf, BUFSIZ, fmt, args); vsnprintf(buf, BUFSIZ, fmt, args);
va_end(args); va_end(args);
rb_exc_raise(rb_exc_new2(exc, buf)); rb_exc_raise(rb_exc_new2(exc, buf));
} }
void void
#ifdef HAVE_STDARG_PROTOTYPES
rb_loaderror(const char *fmt, ...) rb_loaderror(const char *fmt, ...)
#else
rb_loaderror(fmt, va_alist)
const char *fmt;
va_dcl
#endif
{ {
va_list args; va_list args;
char buf[BUFSIZ]; char buf[BUFSIZ];
va_init_list(args, fmt); va_start(args, fmt);
vsnprintf(buf, BUFSIZ, fmt, args); vsnprintf(buf, BUFSIZ, fmt, args);
va_end(args); va_end(args);
rb_exc_raise(rb_exc_new2(rb_eLoadError, buf)); rb_exc_raise(rb_exc_new2(rb_eLoadError, buf));
} }
void void
rb_notimplement() rb_notimplement(void)
{ {
rb_raise(rb_eNotImpError, rb_raise(rb_eNotImpError,
"The %s() function is unimplemented on this machine", "The %s() function is unimplemented on this machine",
@ -1148,18 +1029,12 @@ rb_notimplement()
} }
void void
#ifdef HAVE_STDARG_PROTOTYPES
rb_fatal(const char *fmt, ...) rb_fatal(const char *fmt, ...)
#else
rb_fatal(fmt, va_alist)
const char *fmt;
va_dcl
#endif
{ {
va_list args; va_list args;
char buf[BUFSIZ]; char buf[BUFSIZ];
va_init_list(args, fmt); va_start(args, fmt);
vsnprintf(buf, BUFSIZ, fmt, args); vsnprintf(buf, BUFSIZ, fmt, args);
va_end(args); va_end(args);
@ -1168,8 +1043,7 @@ rb_fatal(fmt, va_alist)
} }
void void
rb_sys_fail(mesg) rb_sys_fail(const char *mesg)
const char *mesg;
{ {
int n = errno; int n = errno;
VALUE arg; VALUE arg;
@ -1184,13 +1058,7 @@ rb_sys_fail(mesg)
} }
void void
#ifdef HAVE_STDARG_PROTOTYPES
rb_sys_warning(const char *fmt, ...) rb_sys_warning(const char *fmt, ...)
#else
rb_sys_warning(fmt, va_alist)
const char *fmt;
va_dcl
#endif
{ {
char buf[BUFSIZ]; char buf[BUFSIZ];
va_list args; va_list args;
@ -1203,35 +1071,32 @@ rb_sys_warning(fmt, va_alist)
snprintf(buf, BUFSIZ, "warning: %s", fmt); snprintf(buf, BUFSIZ, "warning: %s", fmt);
snprintf(buf+strlen(buf), BUFSIZ-strlen(buf), ": %s", strerror(errno_save)); snprintf(buf+strlen(buf), BUFSIZ-strlen(buf), ": %s", strerror(errno_save));
va_init_list(args, fmt); va_start(args, fmt);
warn_print(buf, args); warn_print(buf, args);
va_end(args); va_end(args);
errno = errno_save; errno = errno_save;
} }
void void
rb_load_fail(path) rb_load_fail(const char *path)
const char *path;
{ {
rb_loaderror("%s -- %s", strerror(errno), path); rb_loaderror("%s -- %s", strerror(errno), path);
} }
void void
rb_error_frozen(what) rb_error_frozen(const char *what)
const char *what;
{ {
rb_raise(rb_eRuntimeError, "can't modify frozen %s", what); rb_raise(rb_eRuntimeError, "can't modify frozen %s", what);
} }
void void
rb_check_frozen(obj) rb_check_frozen(VALUE obj)
VALUE obj;
{ {
if (OBJ_FROZEN(obj)) rb_error_frozen(rb_obj_classname(obj)); if (OBJ_FROZEN(obj)) rb_error_frozen(rb_obj_classname(obj));
} }
void void
Init_syserr() Init_syserr(void)
{ {
#ifdef EPERM #ifdef EPERM
set_syserr(EPERM, "EPERM"); set_syserr(EPERM, "EPERM");
@ -1603,8 +1468,7 @@ Init_syserr()
} }
static void static void
err_append(s) err_append(const char *s)
const char *s;
{ {
extern VALUE ruby_errinfo; extern VALUE ruby_errinfo;

1353
eval.c

Разница между файлами не показана из-за своего большого размера Загрузить разницу

456
file.c

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -89,12 +89,12 @@ void *alloca ();
static unsigned long malloc_increase = 0; static unsigned long malloc_increase = 0;
static unsigned long malloc_limit = GC_MALLOC_LIMIT; static unsigned long malloc_limit = GC_MALLOC_LIMIT;
static void run_final(); static void run_final(VALUE obj);
static VALUE nomem_error; static VALUE nomem_error;
static void garbage_collect(); static void garbage_collect(void);
void void
rb_memerror() rb_memerror(void)
{ {
static int recurse = 0; static int recurse = 0;
@ -107,8 +107,7 @@ rb_memerror()
} }
void * void *
ruby_xmalloc(size) ruby_xmalloc(long size)
long size;
{ {
void *mem; void *mem;
@ -134,8 +133,7 @@ ruby_xmalloc(size)
} }
void * void *
ruby_xcalloc(n, size) ruby_xcalloc(long n, long size)
long n, size;
{ {
void *mem; void *mem;
@ -146,9 +144,7 @@ ruby_xcalloc(n, size)
} }
void * void *
ruby_xrealloc(ptr, size) ruby_xrealloc(void *ptr, long size)
void *ptr;
long size;
{ {
void *mem; void *mem;
@ -171,8 +167,7 @@ ruby_xrealloc(ptr, size)
} }
void void
ruby_xfree(x) ruby_xfree(void *x)
void *x;
{ {
if (x) if (x)
RUBY_CRITICAL(free(x)); RUBY_CRITICAL(free(x));
@ -198,7 +193,7 @@ static st_table *finalizer_table = 0;
*/ */
VALUE VALUE
rb_gc_enable() rb_gc_enable(void)
{ {
int old = dont_gc; int old = dont_gc;
@ -219,7 +214,7 @@ rb_gc_enable()
*/ */
VALUE VALUE
rb_gc_disable() rb_gc_disable(void)
{ {
int old = dont_gc; int old = dont_gc;
@ -235,8 +230,7 @@ static struct gc_list {
} *global_List = 0; } *global_List = 0;
void void
rb_gc_register_address(addr) rb_gc_register_address(VALUE *addr)
VALUE *addr;
{ {
struct gc_list *tmp; struct gc_list *tmp;
@ -247,8 +241,7 @@ rb_gc_register_address(addr)
} }
void void
rb_gc_unregister_address(addr) rb_gc_unregister_address(VALUE *addr)
VALUE *addr;
{ {
struct gc_list *tmp = global_List; struct gc_list *tmp = global_List;
@ -272,8 +265,7 @@ rb_gc_unregister_address(addr)
#undef GC_DEBUG #undef GC_DEBUG
void void
rb_global_variable(var) rb_global_variable(VALUE *var)
VALUE *var;
{ {
rb_gc_register_address(var); rb_gc_register_address(var);
} }
@ -326,7 +318,7 @@ static int heap_slots = HEAP_MIN_SLOTS;
static RVALUE *himem, *lomem; static RVALUE *himem, *lomem;
static void static void
add_heap() add_heap(void)
{ {
RVALUE *p, *pend; RVALUE *p, *pend;
@ -376,7 +368,7 @@ add_heap()
#define RANY(o) ((RVALUE*)(o)) #define RANY(o) ((RVALUE*)(o))
VALUE VALUE
rb_newobj() rb_newobj(void)
{ {
VALUE obj; VALUE obj;
@ -393,11 +385,7 @@ rb_newobj()
} }
VALUE VALUE
rb_data_object_alloc(klass, datap, dmark, dfree) rb_data_object_alloc(VALUE klass, void *datap, RUBY_DATA_FUNC dmark, RUBY_DATA_FUNC dfree)
VALUE klass;
void *datap;
RUBY_DATA_FUNC dmark;
RUBY_DATA_FUNC dfree;
{ {
NEWOBJ(data, struct RData); NEWOBJ(data, struct RData);
if (klass) Check_Type(klass, T_CLASS); if (klass) Check_Type(klass, T_CLASS);
@ -477,8 +465,7 @@ stack_grow_direction(addr)
} while (0) } while (0)
int int
ruby_stack_length(p) ruby_stack_length(VALUE **p)
VALUE **p;
{ {
SET_STACK_END; SET_STACK_END;
if (p) *p = STACK_UPPER(STACK_END, rb_gc_stack_start, STACK_END); if (p) *p = STACK_UPPER(STACK_END, rb_gc_stack_start, STACK_END);
@ -486,7 +473,7 @@ ruby_stack_length(p)
} }
int int
ruby_stack_check() ruby_stack_check(void)
{ {
int ret; int ret;
@ -500,7 +487,7 @@ static VALUE *mark_stack_ptr;
static int mark_stack_overflow; static int mark_stack_overflow;
static void static void
init_mark_stack() init_mark_stack(void)
{ {
mark_stack_overflow = 0; mark_stack_overflow = 0;
mark_stack_ptr = mark_stack; mark_stack_ptr = mark_stack;
@ -511,8 +498,7 @@ init_mark_stack()
static st_table *source_filenames; static st_table *source_filenames;
char * char *
rb_source_filename(f) rb_source_filename(const char *f)
const char *f;
{ {
char *name; char *name;
@ -528,8 +514,7 @@ rb_source_filename(f)
} }
static void static void
mark_source_filename(f) mark_source_filename(char *f)
char *f;
{ {
if (f) { if (f) {
f[-1] = 1; f[-1] = 1;
@ -537,8 +522,7 @@ mark_source_filename(f)
} }
static int static int
sweep_source_filename(key, value) sweep_source_filename(char *key, char *value)
char *key, *value;
{ {
if (*value) { if (*value) {
*value = 0; *value = 0;
@ -554,7 +538,7 @@ static void gc_mark _((VALUE ptr, int lev));
static void gc_mark_children _((VALUE ptr, int lev)); static void gc_mark_children _((VALUE ptr, int lev));
static void static void
gc_mark_all() gc_mark_all(void)
{ {
RVALUE *p, *pend; RVALUE *p, *pend;
int i; int i;
@ -573,7 +557,7 @@ gc_mark_all()
} }
static void static void
gc_mark_rest() gc_mark_rest(void)
{ {
VALUE tmp_arry[MARK_STACK_MAX]; VALUE tmp_arry[MARK_STACK_MAX];
VALUE *p; VALUE *p;
@ -589,8 +573,7 @@ gc_mark_rest()
} }
static inline int static inline int
is_pointer_to_heap(ptr) is_pointer_to_heap(void *ptr)
void *ptr;
{ {
register RVALUE *p = RANY(ptr); register RVALUE *p = RANY(ptr);
register RVALUE *heap_org; register RVALUE *heap_org;
@ -609,9 +592,7 @@ is_pointer_to_heap(ptr)
} }
static void static void
mark_locations_array(x, n) mark_locations_array(register VALUE *x, register long n)
register VALUE *x;
register long n;
{ {
VALUE v; VALUE v;
while (n--) { while (n--) {
@ -624,8 +605,7 @@ mark_locations_array(x, n)
} }
void void
rb_gc_mark_locations(start, end) rb_gc_mark_locations(VALUE *start, VALUE *end)
VALUE *start, *end;
{ {
long n; long n;
@ -634,36 +614,27 @@ rb_gc_mark_locations(start, end)
} }
static int static int
mark_entry(key, value, lev) mark_entry(ID key, VALUE value, int lev)
ID key;
VALUE value;
int lev;
{ {
gc_mark(value, lev); gc_mark(value, lev);
return ST_CONTINUE; return ST_CONTINUE;
} }
void void
mark_tbl(tbl, lev) mark_tbl(st_table *tbl, int lev)
st_table *tbl;
int lev;
{ {
if (!tbl) return; if (!tbl) return;
st_foreach(tbl, mark_entry, lev); st_foreach(tbl, mark_entry, lev);
} }
void void
rb_mark_tbl(tbl) rb_mark_tbl(st_table *tbl)
st_table *tbl;
{ {
mark_tbl(tbl, 0); mark_tbl(tbl, 0);
} }
static int static int
mark_keyvalue(key, value, lev) mark_keyvalue(VALUE key, VALUE value, int lev)
VALUE key;
VALUE value;
int lev;
{ {
gc_mark(key, lev); gc_mark(key, lev);
gc_mark(value, lev); gc_mark(value, lev);
@ -671,24 +642,20 @@ mark_keyvalue(key, value, lev)
} }
void void
mark_hash(tbl, lev) mark_hash(st_table *tbl, int lev)
st_table *tbl;
int lev;
{ {
if (!tbl) return; if (!tbl) return;
st_foreach(tbl, mark_keyvalue, lev); st_foreach(tbl, mark_keyvalue, lev);
} }
void void
rb_mark_hash(tbl) rb_mark_hash(st_table *tbl)
st_table *tbl;
{ {
mark_hash(tbl, 0); mark_hash(tbl, 0);
} }
void void
rb_gc_mark_maybe(obj) rb_gc_mark_maybe(VALUE obj)
VALUE obj;
{ {
if (is_pointer_to_heap((void *)obj)) { if (is_pointer_to_heap((void *)obj)) {
gc_mark(obj, 0); gc_mark(obj, 0);
@ -698,9 +665,7 @@ rb_gc_mark_maybe(obj)
#define GC_LEVEL_MAX 250 #define GC_LEVEL_MAX 250
static void static void
gc_mark(ptr, lev) gc_mark(VALUE ptr, int lev)
VALUE ptr;
int lev;
{ {
register RVALUE *obj; register RVALUE *obj;
@ -726,16 +691,13 @@ gc_mark(ptr, lev)
} }
void void
rb_gc_mark(ptr) rb_gc_mark(VALUE ptr)
VALUE ptr;
{ {
gc_mark(ptr, 0); gc_mark(ptr, 0);
} }
static void static void
gc_mark_children(ptr, lev) gc_mark_children(VALUE ptr, int lev)
VALUE ptr;
int lev;
{ {
register RVALUE *obj = RANY(ptr); register RVALUE *obj = RANY(ptr);
@ -993,8 +955,7 @@ gc_mark_children(ptr, lev)
static void obj_free _((VALUE)); static void obj_free _((VALUE));
static void static void
finalize_list(p) finalize_list(RVALUE *p)
RVALUE *p;
{ {
while (p) { while (p) {
RVALUE *tmp = p->as.free.next; RVALUE *tmp = p->as.free.next;
@ -1009,7 +970,7 @@ finalize_list(p)
} }
static void static void
free_unused_heaps() free_unused_heaps(void)
{ {
int i, j; int i, j;
@ -1028,7 +989,7 @@ free_unused_heaps()
} }
static void static void
gc_sweep() gc_sweep(void)
{ {
RVALUE *p, *pend, *final_list; RVALUE *p, *pend, *final_list;
int freed = 0; int freed = 0;
@ -1106,8 +1067,7 @@ gc_sweep()
} }
void void
rb_gc_force_recycle(p) rb_gc_force_recycle(VALUE p)
VALUE p;
{ {
RANY(p)->as.free.flags = 0; RANY(p)->as.free.flags = 0;
RANY(p)->as.free.next = freelist; RANY(p)->as.free.next = freelist;
@ -1115,8 +1075,7 @@ rb_gc_force_recycle(p)
} }
static void static void
obj_free(obj) obj_free(VALUE obj)
VALUE obj;
{ {
switch (RANY(obj)->as.basic.flags & T_MASK) { switch (RANY(obj)->as.basic.flags & T_MASK) {
case T_NIL: case T_NIL:
@ -1242,8 +1201,7 @@ obj_free(obj)
} }
void void
rb_gc_mark_frame(frame) rb_gc_mark_frame(struct FRAME *frame)
struct FRAME *frame;
{ {
gc_mark((VALUE)frame->node, 0); gc_mark((VALUE)frame->node, 0);
} }
@ -1287,7 +1245,7 @@ int rb_setjmp (rb_jmp_buf);
#endif /* __GNUC__ */ #endif /* __GNUC__ */
static void static void
garbage_collect() garbage_collect(void)
{ {
struct gc_list *list; struct gc_list *list;
struct FRAME * volatile frame; /* gcc 2.7.2.3 -O2 bug?? */ struct FRAME * volatile frame; /* gcc 2.7.2.3 -O2 bug?? */
@ -1400,7 +1358,7 @@ garbage_collect()
} }
void void
rb_gc() rb_gc(void)
{ {
garbage_collect(); garbage_collect();
rb_gc_finalize_deferred(); rb_gc_finalize_deferred();
@ -1417,15 +1375,14 @@ rb_gc()
*/ */
VALUE VALUE
rb_gc_start() rb_gc_start(void)
{ {
rb_gc(); rb_gc();
return Qnil; return Qnil;
} }
void void
ruby_set_stack_size(size) ruby_set_stack_size(size_t size)
size_t size;
{ {
#ifndef STACK_LEVEL_MAX #ifndef STACK_LEVEL_MAX
STACK_LEVEL_MAX = size/sizeof(VALUE); STACK_LEVEL_MAX = size/sizeof(VALUE);
@ -1433,8 +1390,7 @@ ruby_set_stack_size(size)
} }
void void
Init_stack(addr) Init_stack(VALUE *addr)
VALUE *addr;
{ {
#if defined(_WIN32) || defined(__CYGWIN__) #if defined(_WIN32) || defined(__CYGWIN__)
MEMORY_BASIC_INFORMATION m; MEMORY_BASIC_INFORMATION m;
@ -1505,7 +1461,7 @@ Init_stack(addr)
*/ */
void void
Init_heap() Init_heap(void)
{ {
if (!rb_gc_stack_start) { if (!rb_gc_stack_start) {
Init_stack(0); Init_stack(0);
@ -1514,7 +1470,7 @@ Init_heap()
} }
static VALUE static VALUE
os_live_obj() os_live_obj(void)
{ {
int i; int i;
int n = 0; int n = 0;
@ -1546,8 +1502,7 @@ os_live_obj()
} }
static VALUE static VALUE
os_obj_of(of) os_obj_of(VALUE of)
VALUE of;
{ {
int i; int i;
int n = 0; int n = 0;
@ -1614,9 +1569,7 @@ os_obj_of(of)
*/ */
static VALUE static VALUE
os_each_obj(argc, argv) os_each_obj(int argc, VALUE *argv)
int argc;
VALUE *argv;
{ {
VALUE of; VALUE of;
@ -1635,8 +1588,7 @@ static VALUE finalizers;
*/ */
static VALUE static VALUE
add_final(os, block) add_final(VALUE os, VALUE block)
VALUE os, block;
{ {
rb_warn("ObjectSpace::add_finalizer is deprecated; use define_finalizer"); rb_warn("ObjectSpace::add_finalizer is deprecated; use define_finalizer");
if (!rb_respond_to(block, rb_intern("call"))) { if (!rb_respond_to(block, rb_intern("call"))) {
@ -1651,8 +1603,7 @@ add_final(os, block)
* deprecated * deprecated
*/ */
static VALUE static VALUE
rm_final(os, block) rm_final(VALUE os, VALUE block)
VALUE os, block;
{ {
rb_warn("ObjectSpace::remove_finalizer is deprecated; use undefine_finalizer"); rb_warn("ObjectSpace::remove_finalizer is deprecated; use undefine_finalizer");
rb_ary_delete(finalizers, block); rb_ary_delete(finalizers, block);
@ -1663,7 +1614,7 @@ rm_final(os, block)
* deprecated * deprecated
*/ */
static VALUE static VALUE
finals() finals(void)
{ {
rb_warn("ObjectSpace::finalizers is deprecated"); rb_warn("ObjectSpace::finalizers is deprecated");
return finalizers; return finalizers;
@ -1674,8 +1625,7 @@ finals()
*/ */
static VALUE static VALUE
call_final(os, obj) call_final(VALUE os, VALUE obj)
VALUE os, obj;
{ {
rb_warn("ObjectSpace::call_finalizer is deprecated; use define_finalizer"); rb_warn("ObjectSpace::call_finalizer is deprecated; use define_finalizer");
need_call_final = 1; need_call_final = 1;
@ -1692,8 +1642,7 @@ call_final(os, obj)
*/ */
static VALUE static VALUE
undefine_final(os, obj) undefine_final(VALUE os, VALUE obj)
VALUE os, obj;
{ {
if (finalizer_table) { if (finalizer_table) {
st_delete(finalizer_table, (st_data_t*)&obj, 0); st_delete(finalizer_table, (st_data_t*)&obj, 0);
@ -1711,10 +1660,7 @@ undefine_final(os, obj)
*/ */
static VALUE static VALUE
define_final(argc, argv, os) define_final(int argc, VALUE *argv, VALUE os)
int argc;
VALUE *argv;
VALUE os;
{ {
VALUE obj, block, table; VALUE obj, block, table;
@ -1744,8 +1690,7 @@ define_final(argc, argv, os)
} }
void void
rb_gc_copy_finalizer(dest, obj) rb_gc_copy_finalizer(VALUE dest, VALUE obj)
VALUE dest, obj;
{ {
VALUE table; VALUE table;
@ -1758,16 +1703,14 @@ rb_gc_copy_finalizer(dest, obj)
} }
static VALUE static VALUE
run_single_final(args) run_single_final(VALUE *args)
VALUE *args;
{ {
rb_eval_cmd(args[0], args[1], (int)args[2]); rb_eval_cmd(args[0], args[1], (int)args[2]);
return Qnil; return Qnil;
} }
static void static void
run_final(obj) run_final(VALUE obj)
VALUE obj;
{ {
long i; long i;
int status, critical_save = rb_thread_critical; int status, critical_save = rb_thread_critical;
@ -1795,7 +1738,7 @@ run_final(obj)
} }
void void
rb_gc_finalize_deferred() rb_gc_finalize_deferred(void)
{ {
RVALUE *p = deferred_final_list; RVALUE *p = deferred_final_list;
@ -1807,7 +1750,7 @@ rb_gc_finalize_deferred()
} }
void void
rb_gc_call_finalizer_at_exit() rb_gc_call_finalizer_at_exit(void)
{ {
RVALUE *p, *pend; RVALUE *p, *pend;
int i; int i;
@ -1868,8 +1811,7 @@ rb_gc_call_finalizer_at_exit()
*/ */
static VALUE static VALUE
id2ref(obj, id) id2ref(VALUE obj, VALUE id)
VALUE obj, id;
{ {
#if SIZEOF_LONG == SIZEOF_VOIDP #if SIZEOF_LONG == SIZEOF_VOIDP
#define NUM2PTR(x) NUM2ULONG(x) #define NUM2PTR(x) NUM2ULONG(x)
@ -1908,7 +1850,7 @@ id2ref(obj, id)
*/ */
void void
Init_GC() Init_GC(void)
{ {
VALUE rb_mObSpace; VALUE rb_mObSpace;

375
hash.c

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -48,7 +48,7 @@ void Init_var_tables _((void));
void Init_version _((void)); void Init_version _((void));
void void
rb_call_inits() rb_call_inits(void)
{ {
Init_sym(); Init_sym();
Init_var_tables(); Init_var_tables();

626
io.c

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -22,9 +22,7 @@ static void objcdummyfunction( void ) { objc_msgSend(); }
#endif #endif
int int
main(argc, argv, envp) main(int argc, char **argv, char **envp)
int argc;
char **argv, **envp;
{ {
#ifdef _WIN32 #ifdef _WIN32
NtInitialize(&argc, &argv); NtInitialize(&argc, &argv);

162
marshal.c
Просмотреть файл

@ -31,9 +31,7 @@
#define SHORTLEN(x) (x) #define SHORTLEN(x) (x)
#else #else
static int static int
shortlen(len, ds) shortlen(long len, BDIGIT *ds)
long len;
BDIGIT *ds;
{ {
BDIGIT num; BDIGIT num;
int offset = 0; int offset = 0;
@ -99,8 +97,7 @@ struct dump_call_arg {
}; };
static VALUE static VALUE
class2path(klass) class2path(VALUE klass)
VALUE klass;
{ {
VALUE path = rb_class_path(klass); VALUE path = rb_class_path(klass);
char *n = RSTRING(path)->ptr; char *n = RSTRING(path)->ptr;
@ -119,10 +116,7 @@ class2path(klass)
static void w_long _((long, struct dump_arg*)); static void w_long _((long, struct dump_arg*));
static void static void
w_nbyte(s, n, arg) w_nbyte(char *s, int n, struct dump_arg *arg)
char *s;
int n;
struct dump_arg *arg;
{ {
VALUE buf = arg->str; VALUE buf = arg->str;
rb_str_buf_cat(buf, s, n); rb_str_buf_cat(buf, s, n);
@ -134,36 +128,27 @@ w_nbyte(s, n, arg)
} }
static void static void
w_byte(c, arg) w_byte(char c, struct dump_arg *arg)
char c;
struct dump_arg *arg;
{ {
w_nbyte(&c, 1, arg); w_nbyte(&c, 1, arg);
} }
static void static void
w_bytes(s, n, arg) w_bytes(char *s, int n, struct dump_arg *arg)
char *s;
int n;
struct dump_arg *arg;
{ {
w_long(n, arg); w_long(n, arg);
w_nbyte(s, n, arg); w_nbyte(s, n, arg);
} }
static void static void
w_short(x, arg) w_short(int x, struct dump_arg *arg)
int x;
struct dump_arg *arg;
{ {
w_byte((x >> 0) & 0xff, arg); w_byte((x >> 0) & 0xff, arg);
w_byte((x >> 8) & 0xff, arg); w_byte((x >> 8) & 0xff, arg);
} }
static void static void
w_long(x, arg) w_long(long x, struct dump_arg *arg)
long x;
struct dump_arg *arg;
{ {
char buf[sizeof(long)+1]; char buf[sizeof(long)+1];
int i, len = 0; int i, len = 0;
@ -219,9 +204,7 @@ w_long(x, arg)
#endif #endif
static int static int
save_mantissa(d, buf) save_mantissa(double d, char *buf)
double d;
char *buf;
{ {
int e, i = 0; int e, i = 0;
unsigned long m; unsigned long m;
@ -250,10 +233,7 @@ save_mantissa(d, buf)
} }
static double static double
load_mantissa(d, buf, len) load_mantissa(double d, const char *buf, int len)
double d;
const char *buf;
int len;
{ {
if (--len > 0 && !*buf++) { /* binary mantissa mark */ if (--len > 0 && !*buf++) { /* binary mantissa mark */
int e, s = d < 0, dig = 0; int e, s = d < 0, dig = 0;
@ -294,9 +274,7 @@ load_mantissa(d, buf, len)
#endif #endif
static void static void
w_float(d, arg) w_float(double d, struct dump_arg *arg)
double d;
struct dump_arg *arg;
{ {
char buf[100]; char buf[100];
@ -324,9 +302,7 @@ w_float(d, arg)
} }
static void static void
w_symbol(id, arg) w_symbol(ID id, struct dump_arg *arg)
ID id;
struct dump_arg *arg;
{ {
char *sym = rb_id2name(id); char *sym = rb_id2name(id);
st_data_t num; st_data_t num;
@ -343,9 +319,7 @@ w_symbol(id, arg)
} }
static void static void
w_unique(s, arg) w_unique(char *s, struct dump_arg *arg)
char *s;
struct dump_arg *arg;
{ {
if (s[0] == '#') { if (s[0] == '#') {
rb_raise(rb_eTypeError, "can't dump anonymous class %s", s); rb_raise(rb_eTypeError, "can't dump anonymous class %s", s);
@ -356,9 +330,7 @@ w_unique(s, arg)
static void w_object _((VALUE,struct dump_arg*,int)); static void w_object _((VALUE,struct dump_arg*,int));
static int static int
hash_each(key, value, arg) hash_each(VALUE key, VALUE value, struct dump_call_arg *arg)
VALUE key, value;
struct dump_call_arg *arg;
{ {
w_object(key, arg->arg, arg->limit); w_object(key, arg->arg, arg->limit);
w_object(value, arg->arg, arg->limit); w_object(value, arg->arg, arg->limit);
@ -366,10 +338,7 @@ hash_each(key, value, arg)
} }
static void static void
w_extended(klass, arg, check) w_extended(VALUE klass, struct dump_arg *arg, int check)
VALUE klass;
struct dump_arg *arg;
int check;
{ {
char *path; char *path;
@ -389,11 +358,7 @@ w_extended(klass, arg, check)
} }
static void static void
w_class(type, obj, arg, check) w_class(int type, VALUE obj, struct dump_arg *arg, int check)
int type;
VALUE obj;
struct dump_arg *arg;
int check;
{ {
char *path; char *path;
@ -405,9 +370,7 @@ w_class(type, obj, arg, check)
} }
static void static void
w_uclass(obj, base_klass, arg) w_uclass(VALUE obj, VALUE base_klass, struct dump_arg *arg)
VALUE obj, base_klass;
struct dump_arg *arg;
{ {
VALUE klass = CLASS_OF(obj); VALUE klass = CLASS_OF(obj);
@ -420,10 +383,7 @@ w_uclass(obj, base_klass, arg)
} }
static int static int
w_obj_each(id, value, arg) w_obj_each(ID id, VALUE value, struct dump_call_arg *arg)
ID id;
VALUE value;
struct dump_call_arg *arg;
{ {
w_symbol(id, arg->arg); w_symbol(id, arg->arg);
w_object(value, arg->arg, arg->limit); w_object(value, arg->arg, arg->limit);
@ -431,9 +391,7 @@ w_obj_each(id, value, arg)
} }
static void static void
w_ivar(tbl, arg) w_ivar(st_table *tbl, struct dump_call_arg *arg)
st_table *tbl;
struct dump_call_arg *arg;
{ {
if (tbl) { if (tbl) {
w_long(tbl->num_entries, arg->arg); w_long(tbl->num_entries, arg->arg);
@ -445,10 +403,7 @@ w_ivar(tbl, arg)
} }
static void static void
w_object(obj, arg, limit) w_object(VALUE obj, struct dump_arg *arg, int limit)
VALUE obj;
struct dump_arg *arg;
int limit;
{ {
struct dump_call_arg c_arg; struct dump_call_arg c_arg;
st_table *ivtbl = 0; st_table *ivtbl = 0;
@ -675,8 +630,7 @@ w_object(obj, arg, limit)
} }
static VALUE static VALUE
dump(arg) dump(struct dump_call_arg *arg)
struct dump_call_arg *arg;
{ {
w_object(arg->obj, arg->arg, arg->limit); w_object(arg->obj, arg->arg, arg->limit);
if (arg->arg->dest) { if (arg->arg->dest) {
@ -687,8 +641,7 @@ dump(arg)
} }
static VALUE static VALUE
dump_ensure(arg) dump_ensure(struct dump_arg *arg)
struct dump_arg *arg;
{ {
st_free_table(arg->symbols); st_free_table(arg->symbols);
st_free_table(arg->data); st_free_table(arg->data);
@ -725,9 +678,7 @@ dump_ensure(arg)
* obj.sayHello #=> "hello\n" * obj.sayHello #=> "hello\n"
*/ */
static VALUE static VALUE
marshal_dump(argc, argv) marshal_dump(int argc, VALUE *argv)
int argc;
VALUE* argv;
{ {
VALUE obj, port, a1, a2; VALUE obj, port, a1, a2;
int limit = -1; int limit = -1;
@ -790,8 +741,7 @@ struct load_arg {
static VALUE r_object _((struct load_arg *arg)); static VALUE r_object _((struct load_arg *arg));
static int static int
r_byte(arg) r_byte(struct load_arg *arg)
struct load_arg *arg;
{ {
int c; int c;
@ -813,8 +763,7 @@ r_byte(arg)
} }
static void static void
long_toobig(size) long_toobig(int size)
int size;
{ {
rb_raise(rb_eTypeError, "long too big for this architecture (size %d, given %d)", rb_raise(rb_eTypeError, "long too big for this architecture (size %d, given %d)",
sizeof(long), size); sizeof(long), size);
@ -829,8 +778,7 @@ long_toobig(size)
#endif #endif
static long static long
r_long(arg) r_long(struct load_arg *arg)
struct load_arg *arg;
{ {
register long x; register long x;
int c = SIGN_EXTEND_CHAR(r_byte(arg)); int c = SIGN_EXTEND_CHAR(r_byte(arg));
@ -865,9 +813,7 @@ r_long(arg)
#define r_bytes(arg) r_bytes0(r_long(arg), (arg)) #define r_bytes(arg) r_bytes0(r_long(arg), (arg))
static VALUE static VALUE
r_bytes0(len, arg) r_bytes0(long len, struct load_arg *arg)
long len;
struct load_arg *arg;
{ {
VALUE str; VALUE str;
@ -895,8 +841,7 @@ r_bytes0(len, arg)
} }
static ID static ID
r_symlink(arg) r_symlink(struct load_arg *arg)
struct load_arg *arg;
{ {
ID id; ID id;
long num = r_long(arg); long num = r_long(arg);
@ -908,8 +853,7 @@ r_symlink(arg)
} }
static ID static ID
r_symreal(arg) r_symreal(struct load_arg *arg)
struct load_arg *arg;
{ {
ID id; ID id;
@ -920,8 +864,7 @@ r_symreal(arg)
} }
static ID static ID
r_symbol(arg) r_symbol(struct load_arg *arg)
struct load_arg *arg;
{ {
if (r_byte(arg) == TYPE_SYMLINK) { if (r_byte(arg) == TYPE_SYMLINK) {
return r_symlink(arg); return r_symlink(arg);
@ -930,23 +873,19 @@ r_symbol(arg)
} }
static char* static char*
r_unique(arg) r_unique(struct load_arg *arg)
struct load_arg *arg;
{ {
return rb_id2name(r_symbol(arg)); return rb_id2name(r_symbol(arg));
} }
static VALUE static VALUE
r_string(arg) r_string(struct load_arg *arg)
struct load_arg *arg;
{ {
return r_bytes(arg); return r_bytes(arg);
} }
static VALUE static VALUE
r_entry(v, arg) r_entry(VALUE v, struct load_arg *arg)
VALUE v;
struct load_arg *arg;
{ {
rb_hash_aset(arg->data, INT2FIX(RHASH(arg->data)->tbl->num_entries), v); rb_hash_aset(arg->data, INT2FIX(RHASH(arg->data)->tbl->num_entries), v);
if (arg->taint) OBJ_TAINT(v); if (arg->taint) OBJ_TAINT(v);
@ -954,9 +893,7 @@ r_entry(v, arg)
} }
static void static void
r_ivar(obj, arg) r_ivar(VALUE obj, struct load_arg *arg)
VALUE obj;
struct load_arg *arg;
{ {
long len; long len;
@ -971,8 +908,7 @@ r_ivar(obj, arg)
} }
static VALUE static VALUE
path2class(path) path2class(char *path)
char *path;
{ {
VALUE v = rb_path2class(path); VALUE v = rb_path2class(path);
@ -983,8 +919,7 @@ path2class(path)
} }
static VALUE static VALUE
path2module(path) path2module(char *path)
char *path;
{ {
VALUE v = rb_path2class(path); VALUE v = rb_path2class(path);
@ -995,11 +930,7 @@ path2module(path)
} }
static VALUE static VALUE
r_object0(arg, proc, ivp, extmod) r_object0(struct load_arg *arg, VALUE proc, int *ivp, VALUE extmod)
struct load_arg *arg;
VALUE proc;
int *ivp;
VALUE extmod;
{ {
VALUE v = Qnil; VALUE v = Qnil;
int type = r_byte(arg); int type = r_byte(arg);
@ -1350,22 +1281,19 @@ r_object0(arg, proc, ivp, extmod)
} }
static VALUE static VALUE
r_object(arg) r_object(struct load_arg *arg)
struct load_arg *arg;
{ {
return r_object0(arg, arg->proc, 0, Qnil); return r_object0(arg, arg->proc, 0, Qnil);
} }
static VALUE static VALUE
load(arg) load(struct load_arg *arg)
struct load_arg *arg;
{ {
return r_object(arg); return r_object(arg);
} }
static VALUE static VALUE
load_ensure(arg) load_ensure(struct load_arg *arg)
struct load_arg *arg;
{ {
st_free_table(arg->symbols); st_free_table(arg->symbols);
return 0; return 0;
@ -1383,9 +1311,7 @@ load_ensure(arg)
* is deserialized. * is deserialized.
*/ */
static VALUE static VALUE
marshal_load(argc, argv) marshal_load(int argc, VALUE *argv)
int argc;
VALUE *argv;
{ {
VALUE port, proc; VALUE port, proc;
int major, minor; int major, minor;
@ -1465,7 +1391,7 @@ marshal_load(argc, argv)
* The class method _load should take a String and return an object of this class. * The class method _load should take a String and return an object of this class.
*/ */
void void
Init_marshal() Init_marshal(void)
{ {
VALUE rb_mMarshal = rb_define_module("Marshal"); VALUE rb_mMarshal = rb_define_module("Marshal");
@ -1490,8 +1416,7 @@ Init_marshal()
} }
VALUE VALUE
rb_marshal_dump(obj, port) rb_marshal_dump(VALUE obj, VALUE port)
VALUE obj, port;
{ {
int argc = 1; int argc = 1;
VALUE argv[2]; VALUE argv[2];
@ -1503,8 +1428,7 @@ rb_marshal_dump(obj, port)
} }
VALUE VALUE
rb_marshal_load(port) rb_marshal_load(VALUE port)
VALUE port;
{ {
return marshal_load(1, &port); return marshal_load(1, &port);
} }

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

@ -33,8 +33,7 @@ VALUE rb_mMath;
*/ */
static VALUE static VALUE
math_atan2(obj, y, x) math_atan2(VALUE obj, VALUE y, VALUE x)
VALUE obj, x, y;
{ {
Need_Float2(y, x); Need_Float2(y, x);
return rb_float_new(atan2(RFLOAT(y)->value, RFLOAT(x)->value)); return rb_float_new(atan2(RFLOAT(y)->value, RFLOAT(x)->value));
@ -51,8 +50,7 @@ math_atan2(obj, y, x)
*/ */
static VALUE static VALUE
math_cos(obj, x) math_cos(VALUE obj, VALUE x)
VALUE obj, x;
{ {
Need_Float(x); Need_Float(x);
return rb_float_new(cos(RFLOAT(x)->value)); return rb_float_new(cos(RFLOAT(x)->value));
@ -67,8 +65,7 @@ math_cos(obj, x)
*/ */
static VALUE static VALUE
math_sin(obj, x) math_sin(VALUE obj, VALUE x)
VALUE obj, x;
{ {
Need_Float(x); Need_Float(x);
@ -84,8 +81,7 @@ math_sin(obj, x)
*/ */
static VALUE static VALUE
math_tan(obj, x) math_tan(VALUE obj, VALUE x)
VALUE obj, x;
{ {
Need_Float(x); Need_Float(x);
@ -100,8 +96,7 @@ math_tan(obj, x)
*/ */
static VALUE static VALUE
math_acos(obj, x) math_acos(VALUE obj, VALUE x)
VALUE obj, x;
{ {
double d; double d;
@ -122,8 +117,7 @@ math_acos(obj, x)
*/ */
static VALUE static VALUE
math_asin(obj, x) math_asin(VALUE obj, VALUE x)
VALUE obj, x;
{ {
double d; double d;
@ -144,8 +138,7 @@ math_asin(obj, x)
*/ */
static VALUE static VALUE
math_atan(obj, x) math_atan(VALUE obj, VALUE x)
VALUE obj, x;
{ {
Need_Float(x); Need_Float(x);
return rb_float_new(atan(RFLOAT(x)->value)); return rb_float_new(atan(RFLOAT(x)->value));
@ -168,8 +161,7 @@ cosh(x)
*/ */
static VALUE static VALUE
math_cosh(obj, x) math_cosh(VALUE obj, VALUE x)
VALUE obj, x;
{ {
Need_Float(x); Need_Float(x);
@ -194,8 +186,7 @@ sinh(x)
*/ */
static VALUE static VALUE
math_sinh(obj, x) math_sinh(VALUE obj, VALUE x)
VALUE obj, x;
{ {
Need_Float(x); Need_Float(x);
return rb_float_new(sinh(RFLOAT(x)->value)); return rb_float_new(sinh(RFLOAT(x)->value));
@ -219,8 +210,7 @@ tanh(x)
*/ */
static VALUE static VALUE
math_tanh(obj, x) math_tanh(VALUE obj, VALUE x)
VALUE obj, x;
{ {
Need_Float(x); Need_Float(x);
return rb_float_new(tanh(RFLOAT(x)->value)); return rb_float_new(tanh(RFLOAT(x)->value));
@ -234,8 +224,7 @@ math_tanh(obj, x)
*/ */
static VALUE static VALUE
math_acosh(obj, x) math_acosh(VALUE obj, VALUE x)
VALUE obj, x;
{ {
double d; double d;
@ -256,8 +245,7 @@ math_acosh(obj, x)
*/ */
static VALUE static VALUE
math_asinh(obj, x) math_asinh(VALUE obj, VALUE x)
VALUE obj, x;
{ {
Need_Float(x); Need_Float(x);
return rb_float_new(asinh(RFLOAT(x)->value)); return rb_float_new(asinh(RFLOAT(x)->value));
@ -271,8 +259,7 @@ math_asinh(obj, x)
*/ */
static VALUE static VALUE
math_atanh(obj, x) math_atanh(VALUE obj, VALUE x)
VALUE obj, x;
{ {
double d; double d;
@ -293,8 +280,7 @@ math_atanh(obj, x)
*/ */
static VALUE static VALUE
math_exp(obj, x) math_exp(VALUE obj, VALUE x)
VALUE obj, x;
{ {
Need_Float(x); Need_Float(x);
return rb_float_new(exp(RFLOAT(x)->value)); return rb_float_new(exp(RFLOAT(x)->value));
@ -317,8 +303,7 @@ math_exp(obj, x)
*/ */
static VALUE static VALUE
math_log(obj, x) math_log(VALUE obj, VALUE x)
VALUE obj, x;
{ {
double d; double d;
@ -339,8 +324,7 @@ math_log(obj, x)
*/ */
static VALUE static VALUE
math_log10(obj, x) math_log10(VALUE obj, VALUE x)
VALUE obj, x;
{ {
double d; double d;
@ -362,8 +346,7 @@ math_log10(obj, x)
*/ */
static VALUE static VALUE
math_sqrt(obj, x) math_sqrt(VALUE obj, VALUE x)
VALUE obj, x;
{ {
double d; double d;
@ -389,8 +372,7 @@ math_sqrt(obj, x)
*/ */
static VALUE static VALUE
math_frexp(obj, x) math_frexp(VALUE obj, VALUE x)
VALUE obj, x;
{ {
double d; double d;
int exp; int exp;
@ -412,8 +394,7 @@ math_frexp(obj, x)
*/ */
static VALUE static VALUE
math_ldexp(obj, x, n) math_ldexp(VALUE obj, VALUE x, VALUE n)
VALUE obj, x, n;
{ {
Need_Float(x); Need_Float(x);
return rb_float_new(ldexp(RFLOAT(x)->value, NUM2INT(n))); return rb_float_new(ldexp(RFLOAT(x)->value, NUM2INT(n)));
@ -430,8 +411,7 @@ math_ldexp(obj, x, n)
*/ */
static VALUE static VALUE
math_hypot(obj, x, y) math_hypot(VALUE obj, VALUE x, VALUE y)
VALUE obj, x, y;
{ {
Need_Float2(x, y); Need_Float2(x, y);
return rb_float_new(hypot(RFLOAT(x)->value, RFLOAT(y)->value)); return rb_float_new(hypot(RFLOAT(x)->value, RFLOAT(y)->value));
@ -445,8 +425,7 @@ math_hypot(obj, x, y)
*/ */
static VALUE static VALUE
math_erf(obj, x) math_erf(VALUE obj, VALUE x)
VALUE obj, x;
{ {
Need_Float(x); Need_Float(x);
return rb_float_new(erf(RFLOAT(x)->value)); return rb_float_new(erf(RFLOAT(x)->value));
@ -460,8 +439,7 @@ math_erf(obj, x)
*/ */
static VALUE static VALUE
math_erfc(obj, x) math_erfc(VALUE obj, VALUE x)
VALUE obj, x;
{ {
Need_Float(x); Need_Float(x);
return rb_float_new(erfc(RFLOAT(x)->value)); return rb_float_new(erfc(RFLOAT(x)->value));
@ -476,7 +454,7 @@ math_erfc(obj, x)
void void
Init_Math() Init_Math(void)
{ {
rb_mMath = rb_define_module("Math"); rb_mMath = rb_define_module("Math");

336
numeric.c
Просмотреть файл

@ -74,7 +74,7 @@ VALUE rb_eZeroDivError;
VALUE rb_eFloatDomainError; VALUE rb_eFloatDomainError;
void void
rb_num_zerodiv() rb_num_zerodiv(void)
{ {
rb_raise(rb_eZeroDivError, "divided by 0"); rb_raise(rb_eZeroDivError, "divided by 0");
} }
@ -97,8 +97,7 @@ rb_num_zerodiv()
*/ */
static VALUE static VALUE
num_coerce(x, y) num_coerce(VALUE x, VALUE y)
VALUE x, y;
{ {
if (CLASS_OF(x) == CLASS_OF(y)) if (CLASS_OF(x) == CLASS_OF(y))
return rb_assoc_new(y, x); return rb_assoc_new(y, x);
@ -106,15 +105,13 @@ num_coerce(x, y)
} }
static VALUE static VALUE
coerce_body(x) coerce_body(VALUE *x)
VALUE *x;
{ {
return rb_funcall(x[1], id_coerce, 1, x[0]); return rb_funcall(x[1], id_coerce, 1, x[0]);
} }
static VALUE static VALUE
coerce_rescue(x) coerce_rescue(VALUE *x)
VALUE *x;
{ {
volatile VALUE v = rb_inspect(x[1]); volatile VALUE v = rb_inspect(x[1]);
@ -127,9 +124,7 @@ coerce_rescue(x)
} }
static int static int
do_coerce(x, y, err) do_coerce(VALUE *x, VALUE *y, int err)
VALUE *x, *y;
int err;
{ {
VALUE ary; VALUE ary;
VALUE a[2]; VALUE a[2];
@ -150,16 +145,14 @@ do_coerce(x, y, err)
} }
VALUE VALUE
rb_num_coerce_bin(x, y) rb_num_coerce_bin(VALUE x, VALUE y)
VALUE x, y;
{ {
do_coerce(&x, &y, Qtrue); do_coerce(&x, &y, Qtrue);
return rb_funcall(x, rb_frame_this_func(), 1, y); return rb_funcall(x, rb_frame_this_func(), 1, y);
} }
VALUE VALUE
rb_num_coerce_cmp(x, y) rb_num_coerce_cmp(VALUE x, VALUE y)
VALUE x, y;
{ {
if (do_coerce(&x, &y, Qfalse)) if (do_coerce(&x, &y, Qfalse))
return rb_funcall(x, rb_frame_this_func(), 1, y); return rb_funcall(x, rb_frame_this_func(), 1, y);
@ -167,8 +160,7 @@ rb_num_coerce_cmp(x, y)
} }
VALUE VALUE
rb_num_coerce_relop(x, y) rb_num_coerce_relop(VALUE x, VALUE y)
VALUE x, y;
{ {
VALUE c, x0 = x, y0 = y; VALUE c, x0 = x, y0 = y;
@ -186,8 +178,7 @@ rb_num_coerce_relop(x, y)
*/ */
static VALUE static VALUE
num_sadded(x, name) num_sadded(VALUE x, VALUE name)
VALUE x, name;
{ {
ruby_frame = ruby_frame->prev; /* pop frame for "singleton_method_added" */ ruby_frame = ruby_frame->prev; /* pop frame for "singleton_method_added" */
/* Numerics should be values; singleton_methods should not be added to them */ /* Numerics should be values; singleton_methods should not be added to them */
@ -200,8 +191,7 @@ num_sadded(x, name)
/* :nodoc: */ /* :nodoc: */
static VALUE static VALUE
num_init_copy(x, y) num_init_copy(VALUE x, VALUE y)
VALUE x, y;
{ {
/* Numerics are immutable values, which should not be copied */ /* Numerics are immutable values, which should not be copied */
rb_raise(rb_eTypeError, "can't copy %s", rb_obj_classname(x)); rb_raise(rb_eTypeError, "can't copy %s", rb_obj_classname(x));
@ -216,8 +206,7 @@ num_init_copy(x, y)
*/ */
static VALUE static VALUE
num_uplus(num) num_uplus(VALUE num)
VALUE num;
{ {
return num; return num;
} }
@ -230,8 +219,7 @@ num_uplus(num)
*/ */
static VALUE static VALUE
num_uminus(num) num_uminus(VALUE num)
VALUE num;
{ {
VALUE zero; VALUE zero;
@ -249,8 +237,7 @@ num_uminus(num)
*/ */
static VALUE static VALUE
num_quo(x, y) num_quo(VALUE x, VALUE y)
VALUE x, y;
{ {
return rb_funcall(x, '/', 1, y); return rb_funcall(x, '/', 1, y);
} }
@ -266,8 +253,7 @@ num_quo(x, y)
*/ */
static VALUE static VALUE
num_div(x, y) num_div(VALUE x, VALUE y)
VALUE x, y;
{ {
return rb_Integer(rb_funcall(x, '/', 1, y)); return rb_Integer(rb_funcall(x, '/', 1, y));
} }
@ -315,8 +301,7 @@ num_div(x, y)
*/ */
static VALUE static VALUE
num_divmod(x, y) num_divmod(VALUE x, VALUE y)
VALUE x, y;
{ {
return rb_assoc_new(num_div(x, y), rb_funcall(x, '%', 1, y)); return rb_assoc_new(num_div(x, y), rb_funcall(x, '%', 1, y));
} }
@ -330,8 +315,7 @@ num_divmod(x, y)
*/ */
static VALUE static VALUE
num_modulo(x, y) num_modulo(VALUE x, VALUE y)
VALUE x, y;
{ {
return rb_funcall(x, '%', 1, y); return rb_funcall(x, '%', 1, y);
} }
@ -349,8 +333,7 @@ num_modulo(x, y)
*/ */
static VALUE static VALUE
num_remainder(x, y) num_remainder(VALUE x, VALUE y)
VALUE x, y;
{ {
VALUE z = rb_funcall(x, '%', 1, y); VALUE z = rb_funcall(x, '%', 1, y);
@ -373,8 +356,7 @@ num_remainder(x, y)
*/ */
static VALUE static VALUE
num_int_p(num) num_int_p(VALUE num)
VALUE num;
{ {
return Qfalse; return Qfalse;
} }
@ -391,8 +373,7 @@ num_int_p(num)
*/ */
static VALUE static VALUE
num_abs(num) num_abs(VALUE num)
VALUE num;
{ {
if (RTEST(rb_funcall(num, '<', 1, INT2FIX(0)))) { if (RTEST(rb_funcall(num, '<', 1, INT2FIX(0)))) {
return rb_funcall(num, rb_intern("-@"), 0); return rb_funcall(num, rb_intern("-@"), 0);
@ -409,8 +390,7 @@ num_abs(num)
*/ */
static VALUE static VALUE
num_zero_p(num) num_zero_p(VALUE num)
VALUE num;
{ {
if (rb_equal(num, INT2FIX(0))) { if (rb_equal(num, INT2FIX(0))) {
return Qtrue; return Qtrue;
@ -432,8 +412,7 @@ num_zero_p(num)
*/ */
static VALUE static VALUE
num_nonzero_p(num) num_nonzero_p(VALUE num)
VALUE num;
{ {
if (RTEST(rb_funcall(num, rb_intern("zero?"), 0, 0))) { if (RTEST(rb_funcall(num, rb_intern("zero?"), 0, 0))) {
return Qnil; return Qnil;
@ -450,8 +429,7 @@ num_nonzero_p(num)
*/ */
static VALUE static VALUE
num_to_int(num) num_to_int(VALUE num)
VALUE num;
{ {
return rb_funcall(num, id_to_i, 0, 0); return rb_funcall(num, id_to_i, 0, 0);
} }
@ -466,8 +444,7 @@ num_to_int(num)
*/ */
VALUE VALUE
rb_float_new(d) rb_float_new(double d)
double d;
{ {
NEWOBJ(flt, struct RFloat); NEWOBJ(flt, struct RFloat);
OBJSETUP(flt, rb_cFloat, T_FLOAT); OBJSETUP(flt, rb_cFloat, T_FLOAT);
@ -487,8 +464,7 @@ rb_float_new(d)
*/ */
static VALUE static VALUE
flo_to_s(flt) flo_to_s(VALUE flt)
VALUE flt;
{ {
char buf[32]; char buf[32];
double value = RFLOAT(flt)->value; double value = RFLOAT(flt)->value;
@ -521,8 +497,7 @@ flo_to_s(flt)
*/ */
static VALUE static VALUE
flo_coerce(x, y) flo_coerce(VALUE x, VALUE y)
VALUE x, y;
{ {
return rb_assoc_new(rb_Float(y), x); return rb_assoc_new(rb_Float(y), x);
} }
@ -535,8 +510,7 @@ flo_coerce(x, y)
*/ */
static VALUE static VALUE
flo_uminus(flt) flo_uminus(VALUE flt)
VALUE flt;
{ {
return rb_float_new(-RFLOAT(flt)->value); return rb_float_new(-RFLOAT(flt)->value);
} }
@ -550,8 +524,7 @@ flo_uminus(flt)
*/ */
static VALUE static VALUE
flo_plus(x, y) flo_plus(VALUE x, VALUE y)
VALUE x, y;
{ {
switch (TYPE(y)) { switch (TYPE(y)) {
case T_FIXNUM: case T_FIXNUM:
@ -574,8 +547,7 @@ flo_plus(x, y)
*/ */
static VALUE static VALUE
flo_minus(x, y) flo_minus(VALUE x, VALUE y)
VALUE x, y;
{ {
switch (TYPE(y)) { switch (TYPE(y)) {
case T_FIXNUM: case T_FIXNUM:
@ -598,8 +570,7 @@ flo_minus(x, y)
*/ */
static VALUE static VALUE
flo_mul(x, y) flo_mul(VALUE x, VALUE y)
VALUE x, y;
{ {
switch (TYPE(y)) { switch (TYPE(y)) {
case T_FIXNUM: case T_FIXNUM:
@ -622,8 +593,7 @@ flo_mul(x, y)
*/ */
static VALUE static VALUE
flo_div(x, y) flo_div(VALUE x, VALUE y)
VALUE x, y;
{ {
long f_y; long f_y;
double d; double d;
@ -644,9 +614,7 @@ flo_div(x, y)
static void static void
flodivmod(x, y, divp, modp) flodivmod(double x, double y, double *divp, double *modp)
double x, y;
double *divp, *modp;
{ {
double div, mod; double div, mod;
@ -682,8 +650,7 @@ flodivmod(x, y, divp, modp)
*/ */
static VALUE static VALUE
flo_mod(x, y) flo_mod(VALUE x, VALUE y)
VALUE x, y;
{ {
double fy, mod; double fy, mod;
@ -712,8 +679,7 @@ flo_mod(x, y)
*/ */
static VALUE static VALUE
flo_divmod(x, y) flo_divmod(VALUE x, VALUE y)
VALUE x, y;
{ {
double fy, div, mod; double fy, div, mod;
volatile VALUE a, b; volatile VALUE a, b;
@ -746,8 +712,7 @@ flo_divmod(x, y)
*/ */
static VALUE static VALUE
flo_pow(x, y) flo_pow(VALUE x, VALUE y)
VALUE x, y;
{ {
switch (TYPE(y)) { switch (TYPE(y)) {
case T_FIXNUM: case T_FIXNUM:
@ -774,8 +739,7 @@ flo_pow(x, y)
*/ */
static VALUE static VALUE
num_eql(x, y) num_eql(VALUE x, VALUE y)
VALUE x, y;
{ {
if (TYPE(x) != TYPE(y)) return Qfalse; if (TYPE(x) != TYPE(y)) return Qfalse;
@ -791,16 +755,14 @@ num_eql(x, y)
*/ */
static VALUE static VALUE
num_cmp(x, y) num_cmp(VALUE x, VALUE y)
VALUE x, y;
{ {
if (x == y) return INT2FIX(0); if (x == y) return INT2FIX(0);
return Qnil; return Qnil;
} }
static VALUE static VALUE
num_equal(x, y) num_equal(VALUE x, VALUE y)
VALUE x, y;
{ {
if (x == y) return Qtrue; if (x == y) return Qtrue;
return rb_funcall(y, id_eq, 1, x); return rb_funcall(y, id_eq, 1, x);
@ -819,8 +781,7 @@ num_equal(x, y)
*/ */
static VALUE static VALUE
flo_eq(x, y) flo_eq(VALUE x, VALUE y)
VALUE x, y;
{ {
volatile double a, b; volatile double a, b;
@ -851,8 +812,7 @@ flo_eq(x, y)
*/ */
static VALUE static VALUE
flo_hash(num) flo_hash(VALUE num)
VALUE num;
{ {
double d; double d;
char *c; char *c;
@ -869,8 +829,7 @@ flo_hash(num)
} }
VALUE VALUE
rb_dbl_cmp(a, b) rb_dbl_cmp(double a, double b)
double a, b;
{ {
if (isnan(a) || isnan(b)) return Qnil; if (isnan(a) || isnan(b)) return Qnil;
if (a == b) return INT2FIX(0); if (a == b) return INT2FIX(0);
@ -889,8 +848,7 @@ rb_dbl_cmp(a, b)
*/ */
static VALUE static VALUE
flo_cmp(x, y) flo_cmp(VALUE x, VALUE y)
VALUE x, y;
{ {
double a, b; double a, b;
@ -922,8 +880,7 @@ flo_cmp(x, y)
*/ */
static VALUE static VALUE
flo_gt(x, y) flo_gt(VALUE x, VALUE y)
VALUE x, y;
{ {
double a, b; double a, b;
@ -958,8 +915,7 @@ flo_gt(x, y)
*/ */
static VALUE static VALUE
flo_ge(x, y) flo_ge(VALUE x, VALUE y)
VALUE x, y;
{ {
double a, b; double a, b;
@ -993,8 +949,7 @@ flo_ge(x, y)
*/ */
static VALUE static VALUE
flo_lt(x, y) flo_lt(VALUE x, VALUE y)
VALUE x, y;
{ {
double a, b; double a, b;
@ -1029,8 +984,7 @@ flo_lt(x, y)
*/ */
static VALUE static VALUE
flo_le(x, y) flo_le(VALUE x, VALUE y)
VALUE x, y;
{ {
double a, b; double a, b;
@ -1068,8 +1022,7 @@ flo_le(x, y)
*/ */
static VALUE static VALUE
flo_eql(x, y) flo_eql(VALUE x, VALUE y)
VALUE x, y;
{ {
if (TYPE(y) == T_FLOAT) { if (TYPE(y) == T_FLOAT) {
double a = RFLOAT(x)->value; double a = RFLOAT(x)->value;
@ -1089,8 +1042,7 @@ flo_eql(x, y)
*/ */
static VALUE static VALUE
flo_to_f(num) flo_to_f(VALUE num)
VALUE num;
{ {
return num; return num;
} }
@ -1107,8 +1059,7 @@ flo_to_f(num)
*/ */
static VALUE static VALUE
flo_abs(flt) flo_abs(VALUE flt)
VALUE flt;
{ {
double val = fabs(RFLOAT(flt)->value); double val = fabs(RFLOAT(flt)->value);
return rb_float_new(val); return rb_float_new(val);
@ -1123,8 +1074,7 @@ flo_abs(flt)
*/ */
static VALUE static VALUE
flo_zero_p(num) flo_zero_p(VALUE num)
VALUE num;
{ {
if (RFLOAT(num)->value == 0.0) { if (RFLOAT(num)->value == 0.0) {
return Qtrue; return Qtrue;
@ -1146,8 +1096,7 @@ flo_zero_p(num)
*/ */
static VALUE static VALUE
flo_is_nan_p(num) flo_is_nan_p(VALUE num)
VALUE num;
{ {
double value = RFLOAT(num)->value; double value = RFLOAT(num)->value;
@ -1167,8 +1116,7 @@ flo_is_nan_p(num)
*/ */
static VALUE static VALUE
flo_is_infinite_p(num) flo_is_infinite_p(VALUE num)
VALUE num;
{ {
double value = RFLOAT(num)->value; double value = RFLOAT(num)->value;
@ -1190,8 +1138,7 @@ flo_is_infinite_p(num)
*/ */
static VALUE static VALUE
flo_is_finite_p(num) flo_is_finite_p(VALUE num)
VALUE num;
{ {
double value = RFLOAT(num)->value; double value = RFLOAT(num)->value;
@ -1219,8 +1166,7 @@ flo_is_finite_p(num)
*/ */
static VALUE static VALUE
flo_floor(num) flo_floor(VALUE num)
VALUE num;
{ {
double f = floor(RFLOAT(num)->value); double f = floor(RFLOAT(num)->value);
long val; long val;
@ -1246,8 +1192,7 @@ flo_floor(num)
*/ */
static VALUE static VALUE
flo_ceil(num) flo_ceil(VALUE num)
VALUE num;
{ {
double f = ceil(RFLOAT(num)->value); double f = ceil(RFLOAT(num)->value);
long val; long val;
@ -1277,8 +1222,7 @@ flo_ceil(num)
*/ */
static VALUE static VALUE
flo_round(num) flo_round(VALUE num)
VALUE num;
{ {
double f = RFLOAT(num)->value; double f = RFLOAT(num)->value;
long val; long val;
@ -1303,8 +1247,7 @@ flo_round(num)
*/ */
static VALUE static VALUE
flo_truncate(num) flo_truncate(VALUE num)
VALUE num;
{ {
double f = RFLOAT(num)->value; double f = RFLOAT(num)->value;
long val; long val;
@ -1333,8 +1276,7 @@ flo_truncate(num)
*/ */
static VALUE static VALUE
num_floor(num) num_floor(VALUE num)
VALUE num;
{ {
return flo_floor(rb_Float(num)); return flo_floor(rb_Float(num));
} }
@ -1356,8 +1298,7 @@ num_floor(num)
*/ */
static VALUE static VALUE
num_ceil(num) num_ceil(VALUE num)
VALUE num;
{ {
return flo_ceil(rb_Float(num)); return flo_ceil(rb_Float(num));
} }
@ -1372,8 +1313,7 @@ num_ceil(num)
*/ */
static VALUE static VALUE
num_round(num) num_round(VALUE num)
VALUE num;
{ {
return flo_round(rb_Float(num)); return flo_round(rb_Float(num));
} }
@ -1388,8 +1328,7 @@ num_round(num)
*/ */
static VALUE static VALUE
num_truncate(num) num_truncate(VALUE num)
VALUE num;
{ {
return flo_truncate(rb_Float(num)); return flo_truncate(rb_Float(num));
} }
@ -1423,10 +1362,7 @@ num_truncate(num)
*/ */
static VALUE static VALUE
num_step(argc, argv, from) num_step(int argc, VALUE *argv, VALUE from)
int argc;
VALUE *argv;
VALUE from;
{ {
VALUE to, step; VALUE to, step;
@ -1502,8 +1438,7 @@ num_step(argc, argv, from)
} }
long long
rb_num2long(val) rb_num2long(VALUE val)
VALUE val;
{ {
if (NIL_P(val)) { if (NIL_P(val)) {
rb_raise(rb_eTypeError, "no implicit conversion from nil to integer"); rb_raise(rb_eTypeError, "no implicit conversion from nil to integer");
@ -1536,8 +1471,7 @@ rb_num2long(val)
} }
unsigned long unsigned long
rb_num2ulong(val) rb_num2ulong(VALUE val)
VALUE val;
{ {
if (TYPE(val) == T_BIGNUM) { if (TYPE(val) == T_BIGNUM) {
return rb_big2ulong(val); return rb_big2ulong(val);
@ -1622,23 +1556,20 @@ rb_fix2uint(val)
} }
#else #else
long long
rb_num2int(val) rb_num2int(VALUE val)
VALUE val;
{ {
return rb_num2long(val); return rb_num2long(val);
} }
long long
rb_fix2int(val) rb_fix2int(VALUE val)
VALUE val;
{ {
return FIX2INT(val); return FIX2INT(val);
} }
#endif #endif
VALUE VALUE
rb_num2fix(val) rb_num2fix(VALUE val)
VALUE val;
{ {
long v; long v;
@ -1653,8 +1584,7 @@ rb_num2fix(val)
#if HAVE_LONG_LONG #if HAVE_LONG_LONG
LONG_LONG LONG_LONG
rb_num2ll(val) rb_num2ll(VALUE val)
VALUE val;
{ {
if (NIL_P(val)) { if (NIL_P(val)) {
rb_raise(rb_eTypeError, "no implicit conversion from nil"); rb_raise(rb_eTypeError, "no implicit conversion from nil");
@ -1696,8 +1626,7 @@ rb_num2ll(val)
} }
unsigned LONG_LONG unsigned LONG_LONG
rb_num2ull(val) rb_num2ull(VALUE val)
VALUE val;
{ {
if (TYPE(val) == T_BIGNUM) { if (TYPE(val) == T_BIGNUM) {
return rb_big2ull(val); return rb_big2ull(val);
@ -1731,8 +1660,7 @@ rb_num2ull(val)
*/ */
static VALUE static VALUE
int_to_i(num) int_to_i(VALUE num)
VALUE num;
{ {
return num; return num;
} }
@ -1745,8 +1673,7 @@ int_to_i(num)
*/ */
static VALUE static VALUE
int_int_p(num) int_int_p(VALUE num)
VALUE num;
{ {
return Qtrue; return Qtrue;
} }
@ -1763,8 +1690,7 @@ int_int_p(num)
*/ */
static VALUE static VALUE
int_succ(num) int_succ(VALUE num)
VALUE num;
{ {
if (FIXNUM_P(num)) { if (FIXNUM_P(num)) {
long i = FIX2LONG(num) + 1; long i = FIX2LONG(num) + 1;
@ -1786,8 +1712,7 @@ int_succ(num)
*/ */
static VALUE static VALUE
int_chr(num) int_chr(VALUE num)
VALUE num;
{ {
char c; char c;
long i = NUM2LONG(num); long i = NUM2LONG(num);
@ -1826,8 +1751,7 @@ int_chr(num)
*/ */
static VALUE static VALUE
rb_fix_induced_from(klass, x) rb_fix_induced_from(VALUE klass, VALUE x)
VALUE klass, x;
{ {
return rb_num2fix(x); return rb_num2fix(x);
} }
@ -1840,8 +1764,7 @@ rb_fix_induced_from(klass, x)
*/ */
static VALUE static VALUE
rb_int_induced_from(klass, x) rb_int_induced_from(VALUE klass, VALUE x)
VALUE klass, x;
{ {
switch (TYPE(x)) { switch (TYPE(x)) {
case T_FIXNUM: case T_FIXNUM:
@ -1863,8 +1786,7 @@ rb_int_induced_from(klass, x)
*/ */
static VALUE static VALUE
rb_flo_induced_from(klass, x) rb_flo_induced_from(VALUE klass, VALUE x)
VALUE klass, x;
{ {
switch (TYPE(x)) { switch (TYPE(x)) {
case T_FIXNUM: case T_FIXNUM:
@ -1886,16 +1808,13 @@ rb_flo_induced_from(klass, x)
*/ */
static VALUE static VALUE
fix_uminus(num) fix_uminus(VALUE num)
VALUE num;
{ {
return LONG2NUM(-FIX2LONG(num)); return LONG2NUM(-FIX2LONG(num));
} }
VALUE VALUE
rb_fix2str(x, base) rb_fix2str(VALUE x, int base)
VALUE x;
int base;
{ {
extern const char ruby_digitmap[]; extern const char ruby_digitmap[];
char buf[SIZEOF_LONG*CHAR_BIT + 2], *b = buf + sizeof buf; char buf[SIZEOF_LONG*CHAR_BIT + 2], *b = buf + sizeof buf;
@ -1939,10 +1858,7 @@ rb_fix2str(x, base)
* *
*/ */
static VALUE static VALUE
fix_to_s(argc, argv, x) fix_to_s(int argc, VALUE *argv, VALUE x)
int argc;
VALUE *argv;
VALUE x;
{ {
VALUE b; VALUE b;
int base; int base;
@ -1968,8 +1884,7 @@ fix_to_s(argc, argv, x)
*/ */
static VALUE static VALUE
fix_plus(x, y) fix_plus(VALUE x, VALUE y)
VALUE x, y;
{ {
if (FIXNUM_P(y)) { if (FIXNUM_P(y)) {
long a, b, c; long a, b, c;
@ -2005,8 +1920,7 @@ fix_plus(x, y)
*/ */
static VALUE static VALUE
fix_minus(x, y) fix_minus(VALUE x, VALUE y)
VALUE x, y;
{ {
if (FIXNUM_P(y)) { if (FIXNUM_P(y)) {
long a, b, c; long a, b, c;
@ -2043,8 +1957,7 @@ fix_minus(x, y)
*/ */
static VALUE static VALUE
fix_mul(x, y) fix_mul(VALUE x, VALUE y)
VALUE x, y;
{ {
if (FIXNUM_P(y)) { if (FIXNUM_P(y)) {
long a, b, c; long a, b, c;
@ -2073,9 +1986,7 @@ fix_mul(x, y)
} }
static void static void
fixdivmod(x, y, divp, modp) fixdivmod(long x, long y, long *divp, long *modp)
long x, y;
long *divp, *modp;
{ {
long div, mod; long div, mod;
@ -2114,8 +2025,7 @@ fixdivmod(x, y, divp, modp)
*/ */
static VALUE static VALUE
fix_quo(x, y) fix_quo(VALUE x, VALUE y)
VALUE x, y;
{ {
if (FIXNUM_P(y)) { if (FIXNUM_P(y)) {
return rb_float_new((double)FIX2LONG(x) / (double)FIX2LONG(y)); return rb_float_new((double)FIX2LONG(x) / (double)FIX2LONG(y));
@ -2141,8 +2051,7 @@ fix_quo(x, y)
*/ */
static VALUE static VALUE
fix_div(x, y) fix_div(VALUE x, VALUE y)
VALUE x, y;
{ {
if (FIXNUM_P(y)) { if (FIXNUM_P(y)) {
long div; long div;
@ -2171,8 +2080,7 @@ fix_div(x, y)
*/ */
static VALUE static VALUE
fix_mod(x, y) fix_mod(VALUE x, VALUE y)
VALUE x, y;
{ {
if (FIXNUM_P(y)) { if (FIXNUM_P(y)) {
long mod; long mod;
@ -2203,8 +2111,7 @@ fix_mod(x, y)
* See <code>Numeric#divmod</code>. * See <code>Numeric#divmod</code>.
*/ */
static VALUE static VALUE
fix_divmod(x, y) fix_divmod(VALUE x, VALUE y)
VALUE x, y;
{ {
if (FIXNUM_P(y)) { if (FIXNUM_P(y)) {
long div, mod; long div, mod;
@ -2245,8 +2152,7 @@ fix_divmod(x, y)
*/ */
static VALUE static VALUE
fix_pow(x, y) fix_pow(VALUE x, VALUE y)
VALUE x, y;
{ {
if (FIXNUM_P(y)) { if (FIXNUM_P(y)) {
long a, b; long a, b;
@ -2283,8 +2189,7 @@ fix_pow(x, y)
*/ */
static VALUE static VALUE
fix_equal(x, y) fix_equal(VALUE x, VALUE y)
VALUE x, y;
{ {
if (FIXNUM_P(y)) { if (FIXNUM_P(y)) {
return (FIX2LONG(x) == FIX2LONG(y))?Qtrue:Qfalse; return (FIX2LONG(x) == FIX2LONG(y))?Qtrue:Qfalse;
@ -2309,8 +2214,7 @@ fix_equal(x, y)
*/ */
static VALUE static VALUE
fix_cmp(x, y) fix_cmp(VALUE x, VALUE y)
VALUE x, y;
{ {
if (FIXNUM_P(y)) { if (FIXNUM_P(y)) {
long a = FIX2LONG(x), b = FIX2LONG(y); long a = FIX2LONG(x), b = FIX2LONG(y);
@ -2338,8 +2242,7 @@ fix_cmp(x, y)
*/ */
static VALUE static VALUE
fix_gt(x, y) fix_gt(VALUE x, VALUE y)
VALUE x, y;
{ {
if (FIXNUM_P(y)) { if (FIXNUM_P(y)) {
long a = FIX2LONG(x), b = FIX2LONG(y); long a = FIX2LONG(x), b = FIX2LONG(y);
@ -2366,8 +2269,7 @@ fix_gt(x, y)
*/ */
static VALUE static VALUE
fix_ge(x, y) fix_ge(VALUE x, VALUE y)
VALUE x, y;
{ {
if (FIXNUM_P(y)) { if (FIXNUM_P(y)) {
long a = FIX2LONG(x), b = FIX2LONG(y); long a = FIX2LONG(x), b = FIX2LONG(y);
@ -2394,8 +2296,7 @@ fix_ge(x, y)
*/ */
static VALUE static VALUE
fix_lt(x, y) fix_lt(VALUE x, VALUE y)
VALUE x, y;
{ {
if (FIXNUM_P(y)) { if (FIXNUM_P(y)) {
long a = FIX2LONG(x), b = FIX2LONG(y); long a = FIX2LONG(x), b = FIX2LONG(y);
@ -2422,8 +2323,7 @@ fix_lt(x, y)
*/ */
static VALUE static VALUE
fix_le(x, y) fix_le(VALUE x, VALUE y)
VALUE x, y;
{ {
if (FIXNUM_P(y)) { if (FIXNUM_P(y)) {
long a = FIX2LONG(x), b = FIX2LONG(y); long a = FIX2LONG(x), b = FIX2LONG(y);
@ -2449,8 +2349,7 @@ fix_le(x, y)
*/ */
static VALUE static VALUE
fix_rev(num) fix_rev(VALUE num)
VALUE num;
{ {
long val = FIX2LONG(num); long val = FIX2LONG(num);
@ -2466,8 +2365,7 @@ fix_rev(num)
*/ */
static VALUE static VALUE
fix_and(x, y) fix_and(VALUE x, VALUE y)
VALUE x, y;
{ {
long val; long val;
@ -2486,8 +2384,7 @@ fix_and(x, y)
*/ */
static VALUE static VALUE
fix_or(x, y) fix_or(VALUE x, VALUE y)
VALUE x, y;
{ {
long val; long val;
@ -2506,8 +2403,7 @@ fix_or(x, y)
*/ */
static VALUE static VALUE
fix_xor(x, y) fix_xor(VALUE x, VALUE y)
VALUE x, y;
{ {
long val; long val;
@ -2528,8 +2424,7 @@ static VALUE fix_rshift _((VALUE, VALUE));
*/ */
static VALUE static VALUE
fix_lshift(x, y) fix_lshift(VALUE x, VALUE y)
VALUE x, y;
{ {
long val, width; long val, width;
@ -2553,8 +2448,7 @@ fix_lshift(x, y)
*/ */
static VALUE static VALUE
fix_rshift(x, y) fix_rshift(VALUE x, VALUE y)
VALUE x, y;
{ {
long i, val; long i, val;
@ -2588,8 +2482,7 @@ fix_rshift(x, y)
*/ */
static VALUE static VALUE
fix_aref(fix, idx) fix_aref(VALUE fix, VALUE idx)
VALUE fix, idx;
{ {
long val = FIX2LONG(fix); long val = FIX2LONG(fix);
long i; long i;
@ -2623,8 +2516,7 @@ fix_aref(fix, idx)
*/ */
static VALUE static VALUE
fix_to_f(num) fix_to_f(VALUE num)
VALUE num;
{ {
double val; double val;
@ -2645,8 +2537,7 @@ fix_to_f(num)
*/ */
static VALUE static VALUE
fix_abs(fix) fix_abs(VALUE fix)
VALUE fix;
{ {
long i = FIX2LONG(fix); long i = FIX2LONG(fix);
@ -2671,8 +2562,7 @@ fix_abs(fix)
*/ */
static VALUE static VALUE
fix_id2name(fix) fix_id2name(VALUE fix)
VALUE fix;
{ {
char *name = rb_id2name(FIX2UINT(fix)); char *name = rb_id2name(FIX2UINT(fix));
if (name) return rb_str_new2(name); if (name) return rb_str_new2(name);
@ -2693,8 +2583,7 @@ fix_id2name(fix)
*/ */
static VALUE static VALUE
fix_to_sym(fix) fix_to_sym(VALUE fix)
VALUE fix;
{ {
ID id = FIX2UINT(fix); ID id = FIX2UINT(fix);
@ -2718,8 +2607,7 @@ fix_to_sym(fix)
*/ */
static VALUE static VALUE
fix_size(fix) fix_size(VALUE fix)
VALUE fix;
{ {
return INT2FIX(sizeof(long)); return INT2FIX(sizeof(long));
} }
@ -2739,8 +2627,7 @@ fix_size(fix)
*/ */
static VALUE static VALUE
int_upto(from, to) int_upto(VALUE from, VALUE to)
VALUE from, to;
{ {
if (FIXNUM_P(from) && FIXNUM_P(to)) { if (FIXNUM_P(from) && FIXNUM_P(to)) {
long i, end; long i, end;
@ -2778,8 +2665,7 @@ int_upto(from, to)
*/ */
static VALUE static VALUE
int_downto(from, to) int_downto(VALUE from, VALUE to)
VALUE from, to;
{ {
if (FIXNUM_P(from) && FIXNUM_P(to)) { if (FIXNUM_P(from) && FIXNUM_P(to)) {
long i, end; long i, end;
@ -2818,8 +2704,7 @@ int_downto(from, to)
*/ */
static VALUE static VALUE
int_dotimes(num) int_dotimes(VALUE num)
VALUE num;
{ {
if (FIXNUM_P(num)) { if (FIXNUM_P(num)) {
long i, end; long i, end;
@ -2850,8 +2735,7 @@ int_dotimes(num)
*/ */
static VALUE static VALUE
fix_zero_p(num) fix_zero_p(VALUE num)
VALUE num;
{ {
if (FIX2LONG(num) == 0) { if (FIX2LONG(num) == 0) {
return Qtrue; return Qtrue;
@ -2860,7 +2744,7 @@ fix_zero_p(num)
} }
void void
Init_Numeric() Init_Numeric(void)
{ {
#if defined(__FreeBSD__) && __FreeBSD__ < 4 #if defined(__FreeBSD__) && __FreeBSD__ < 4
/* allow divide by zero -- Inf */ /* allow divide by zero -- Inf */

331
object.c
Просмотреть файл

@ -43,8 +43,7 @@ static ID id_eq, id_eql, id_inspect, id_init_copy;
*/ */
VALUE VALUE
rb_equal(obj1, obj2) rb_equal(VALUE obj1, VALUE obj2)
VALUE obj1, obj2;
{ {
VALUE result; VALUE result;
@ -55,8 +54,7 @@ rb_equal(obj1, obj2)
} }
int int
rb_eql(obj1, obj2) rb_eql(VALUE obj1, VALUE obj2)
VALUE obj1, obj2;
{ {
return RTEST(rb_funcall(obj1, id_eql, 1, obj2)); return RTEST(rb_funcall(obj1, id_eql, 1, obj2));
} }
@ -91,8 +89,7 @@ rb_eql(obj1, obj2)
*/ */
static VALUE static VALUE
rb_obj_equal(obj1, obj2) rb_obj_equal(VALUE obj1, VALUE obj2)
VALUE obj1, obj2;
{ {
if (obj1 == obj2) return Qtrue; if (obj1 == obj2) return Qtrue;
return Qfalse; return Qfalse;
@ -129,8 +126,7 @@ rb_obj_equal(obj1, obj2)
*/ */
VALUE VALUE
rb_obj_id(obj) rb_obj_id(VALUE obj)
VALUE obj;
{ {
if (SPECIAL_CONST_P(obj)) { if (SPECIAL_CONST_P(obj)) {
return LONG2NUM((long)obj); return LONG2NUM((long)obj);
@ -139,8 +135,7 @@ rb_obj_id(obj)
} }
VALUE VALUE
rb_class_real(cl) rb_class_real(VALUE cl)
VALUE cl;
{ {
while (FL_TEST(cl, FL_SINGLETON) || TYPE(cl) == T_ICLASS) { while (FL_TEST(cl, FL_SINGLETON) || TYPE(cl) == T_ICLASS) {
cl = RCLASS(cl)->super; cl = RCLASS(cl)->super;
@ -163,15 +158,13 @@ rb_class_real(cl)
*/ */
VALUE VALUE
rb_obj_class(obj) rb_obj_class(VALUE obj)
VALUE obj;
{ {
return rb_class_real(CLASS_OF(obj)); return rb_class_real(CLASS_OF(obj));
} }
static void static void
init_copy(dest, obj) init_copy(VALUE dest, VALUE obj)
VALUE dest, obj;
{ {
if (OBJ_FROZEN(dest)) { if (OBJ_FROZEN(dest)) {
rb_raise(rb_eTypeError, "[bug] frozen object (%s) allocated", rb_obj_classname(dest)); rb_raise(rb_eTypeError, "[bug] frozen object (%s) allocated", rb_obj_classname(dest));
@ -220,8 +213,7 @@ init_copy(dest, obj)
*/ */
VALUE VALUE
rb_obj_clone(obj) rb_obj_clone(VALUE obj)
VALUE obj;
{ {
VALUE clone; VALUE clone;
@ -256,8 +248,7 @@ rb_obj_clone(obj)
*/ */
VALUE VALUE
rb_obj_dup(obj) rb_obj_dup(VALUE obj)
VALUE obj;
{ {
VALUE dup; VALUE dup;
@ -272,8 +263,7 @@ rb_obj_dup(obj)
/* :nodoc: */ /* :nodoc: */
VALUE VALUE
rb_obj_init_copy(obj, orig) rb_obj_init_copy(VALUE obj, VALUE orig)
VALUE obj, orig;
{ {
if (obj == orig) return obj; if (obj == orig) return obj;
rb_check_frozen(obj); rb_check_frozen(obj);
@ -294,8 +284,7 @@ rb_obj_init_copy(obj, orig)
*/ */
VALUE VALUE
rb_any_to_s(obj) rb_any_to_s(VALUE obj)
VALUE obj;
{ {
char *cname = rb_obj_classname(obj); char *cname = rb_obj_classname(obj);
VALUE str; VALUE str;
@ -307,17 +296,13 @@ rb_any_to_s(obj)
} }
VALUE VALUE
rb_inspect(obj) rb_inspect(VALUE obj)
VALUE obj;
{ {
return rb_obj_as_string(rb_funcall(obj, id_inspect, 0, 0)); return rb_obj_as_string(rb_funcall(obj, id_inspect, 0, 0));
} }
static int static int
inspect_i(id, value, str) inspect_i(ID id, VALUE value, VALUE str)
ID id;
VALUE value;
VALUE str;
{ {
VALUE str2; VALUE str2;
char *ivname; char *ivname;
@ -343,9 +328,7 @@ inspect_i(id, value, str)
} }
static VALUE static VALUE
inspect_obj(obj, str, recur) inspect_obj(VALUE obj, VALUE str, int recur)
VALUE obj, str;
int recur;
{ {
if (recur) { if (recur) {
rb_str_cat2(str, " ..."); rb_str_cat2(str, " ...");
@ -374,8 +357,7 @@ inspect_obj(obj, str, recur)
static VALUE static VALUE
rb_obj_inspect(obj) rb_obj_inspect(VALUE obj)
VALUE obj;
{ {
if (TYPE(obj) == T_OBJECT if (TYPE(obj) == T_OBJECT
&& ROBJECT(obj)->iv_tbl && ROBJECT(obj)->iv_tbl
@ -400,8 +382,7 @@ rb_obj_inspect(obj)
*/ */
VALUE VALUE
rb_obj_is_instance_of(obj, c) rb_obj_is_instance_of(VALUE obj, VALUE c)
VALUE obj, c;
{ {
switch (TYPE(c)) { switch (TYPE(c)) {
case T_MODULE: case T_MODULE:
@ -444,8 +425,7 @@ rb_obj_is_instance_of(obj, c)
*/ */
VALUE VALUE
rb_obj_is_kind_of(obj, c) rb_obj_is_kind_of(VALUE obj, VALUE c)
VALUE obj, c;
{ {
VALUE cl = CLASS_OF(obj); VALUE cl = CLASS_OF(obj);
@ -574,7 +554,7 @@ rb_obj_is_kind_of(obj, c)
*/ */
static VALUE static VALUE
rb_obj_dummy() rb_obj_dummy(void)
{ {
return Qnil; return Qnil;
} }
@ -588,8 +568,7 @@ rb_obj_dummy()
*/ */
VALUE VALUE
rb_obj_tainted(obj) rb_obj_tainted(VALUE obj)
VALUE obj;
{ {
if (OBJ_TAINTED(obj)) if (OBJ_TAINTED(obj))
return Qtrue; return Qtrue;
@ -606,8 +585,7 @@ rb_obj_tainted(obj)
*/ */
VALUE VALUE
rb_obj_taint(obj) rb_obj_taint(VALUE obj)
VALUE obj;
{ {
rb_secure(4); rb_secure(4);
if (!OBJ_TAINTED(obj)) { if (!OBJ_TAINTED(obj)) {
@ -628,8 +606,7 @@ rb_obj_taint(obj)
*/ */
VALUE VALUE
rb_obj_untaint(obj) rb_obj_untaint(VALUE obj)
VALUE obj;
{ {
rb_secure(3); rb_secure(3);
if (OBJ_TAINTED(obj)) { if (OBJ_TAINTED(obj)) {
@ -642,8 +619,7 @@ rb_obj_untaint(obj)
} }
void void
rb_obj_infect(obj1, obj2) rb_obj_infect(VALUE obj1, VALUE obj2)
VALUE obj1, obj2;
{ {
OBJ_INFECT(obj1, obj2); OBJ_INFECT(obj1, obj2);
} }
@ -669,8 +645,7 @@ rb_obj_infect(obj1, obj2)
*/ */
VALUE VALUE
rb_obj_freeze(obj) rb_obj_freeze(VALUE obj)
VALUE obj;
{ {
if (!OBJ_FROZEN(obj)) { if (!OBJ_FROZEN(obj)) {
if (rb_safe_level() >= 4 && !OBJ_TAINTED(obj)) { if (rb_safe_level() >= 4 && !OBJ_TAINTED(obj)) {
@ -693,8 +668,7 @@ rb_obj_freeze(obj)
*/ */
static VALUE static VALUE
rb_obj_frozen_p(obj) rb_obj_frozen_p(VALUE obj)
VALUE obj;
{ {
if (OBJ_FROZEN(obj)) return Qtrue; if (OBJ_FROZEN(obj)) return Qtrue;
return Qfalse; return Qfalse;
@ -718,8 +692,7 @@ rb_obj_frozen_p(obj)
static VALUE static VALUE
nil_to_i(obj) nil_to_i(VALUE obj)
VALUE obj;
{ {
return INT2FIX(0); return INT2FIX(0);
} }
@ -734,8 +707,7 @@ nil_to_i(obj)
*/ */
static VALUE static VALUE
nil_to_f(obj) nil_to_f(VALUE obj)
VALUE obj;
{ {
return rb_float_new(0.0); return rb_float_new(0.0);
} }
@ -750,8 +722,7 @@ nil_to_f(obj)
*/ */
static VALUE static VALUE
nil_to_s(obj) nil_to_s(VALUE obj)
VALUE obj;
{ {
return rb_str_new2(""); return rb_str_new2("");
} }
@ -766,8 +737,7 @@ nil_to_s(obj)
*/ */
static VALUE static VALUE
nil_to_a(obj) nil_to_a(VALUE obj)
VALUE obj;
{ {
return rb_ary_new2(0); return rb_ary_new2(0);
} }
@ -780,8 +750,7 @@ nil_to_a(obj)
*/ */
static VALUE static VALUE
nil_inspect(obj) nil_inspect(VALUE obj)
VALUE obj;
{ {
return rb_str_new2("nil"); return rb_str_new2("nil");
} }
@ -809,8 +778,7 @@ nil_plus(x, y)
#endif #endif
static VALUE static VALUE
main_to_s(obj) main_to_s(VALUE obj)
VALUE obj;
{ {
return rb_str_new2("main"); return rb_str_new2("main");
} }
@ -834,8 +802,7 @@ main_to_s(obj)
*/ */
static VALUE static VALUE
true_to_s(obj) true_to_s(VALUE obj)
VALUE obj;
{ {
return rb_str_new2("true"); return rb_str_new2("true");
} }
@ -850,8 +817,7 @@ true_to_s(obj)
*/ */
static VALUE static VALUE
true_and(obj, obj2) true_and(VALUE obj, VALUE obj2)
VALUE obj, obj2;
{ {
return RTEST(obj2)?Qtrue:Qfalse; return RTEST(obj2)?Qtrue:Qfalse;
} }
@ -873,8 +839,7 @@ true_and(obj, obj2)
*/ */
static VALUE static VALUE
true_or(obj, obj2) true_or(VALUE obj, VALUE obj2)
VALUE obj, obj2;
{ {
return Qtrue; return Qtrue;
} }
@ -890,8 +855,7 @@ true_or(obj, obj2)
*/ */
static VALUE static VALUE
true_xor(obj, obj2) true_xor(VALUE obj, VALUE obj2)
VALUE obj, obj2;
{ {
return RTEST(obj2)?Qfalse:Qtrue; return RTEST(obj2)?Qfalse:Qtrue;
} }
@ -915,8 +879,7 @@ true_xor(obj, obj2)
*/ */
static VALUE static VALUE
false_to_s(obj) false_to_s(VALUE obj)
VALUE obj;
{ {
return rb_str_new2("false"); return rb_str_new2("false");
} }
@ -932,8 +895,7 @@ false_to_s(obj)
*/ */
static VALUE static VALUE
false_and(obj, obj2) false_and(VALUE obj, VALUE obj2)
VALUE obj, obj2;
{ {
return Qfalse; return Qfalse;
} }
@ -949,8 +911,7 @@ false_and(obj, obj2)
*/ */
static VALUE static VALUE
false_or(obj, obj2) false_or(VALUE obj, VALUE obj2)
VALUE obj, obj2;
{ {
return RTEST(obj2)?Qtrue:Qfalse; return RTEST(obj2)?Qtrue:Qfalse;
} }
@ -969,8 +930,7 @@ false_or(obj, obj2)
*/ */
static VALUE static VALUE
false_xor(obj, obj2) false_xor(VALUE obj, VALUE obj2)
VALUE obj, obj2;
{ {
return RTEST(obj2)?Qtrue:Qfalse; return RTEST(obj2)?Qtrue:Qfalse;
} }
@ -983,8 +943,7 @@ false_xor(obj, obj2)
*/ */
static VALUE static VALUE
rb_true(obj) rb_true(VALUE obj)
VALUE obj;
{ {
return Qtrue; return Qtrue;
} }
@ -999,8 +958,7 @@ rb_true(obj)
static VALUE static VALUE
rb_false(obj) rb_false(VALUE obj)
VALUE obj;
{ {
return Qfalse; return Qfalse;
} }
@ -1016,8 +974,7 @@ rb_false(obj)
*/ */
static VALUE static VALUE
rb_obj_pattern_match(obj1, obj2) rb_obj_pattern_match(VALUE obj1, VALUE obj2)
VALUE obj1, obj2;
{ {
return Qnil; return Qnil;
} }
@ -1067,8 +1024,7 @@ rb_obj_pattern_match(obj1, obj2)
*/ */
static VALUE static VALUE
sym_to_i(sym) sym_to_i(VALUE sym)
VALUE sym;
{ {
ID id = SYM2ID(sym); ID id = SYM2ID(sym);
@ -1086,8 +1042,7 @@ sym_to_i(sym)
*/ */
static VALUE static VALUE
sym_inspect(sym) sym_inspect(VALUE sym)
VALUE sym;
{ {
VALUE str; VALUE str;
char *name; char *name;
@ -1117,8 +1072,7 @@ sym_inspect(sym)
static VALUE static VALUE
sym_to_s(sym) sym_to_s(VALUE sym)
VALUE sym;
{ {
return rb_str_new2(rb_id2name(SYM2ID(sym))); return rb_str_new2(rb_id2name(SYM2ID(sym)));
} }
@ -1134,8 +1088,7 @@ sym_to_s(sym)
*/ */
static VALUE static VALUE
sym_to_sym(sym) sym_to_sym(VALUE sym)
VALUE sym;
{ {
return sym; return sym;
} }
@ -1179,9 +1132,7 @@ sym_to_sym(sym)
*/ */
static VALUE static VALUE
rb_mod_to_s(klass) rb_mod_to_s(VALUE klass)
VALUE klass;
{ {
if (FL_TEST(klass, FL_SINGLETON)) { if (FL_TEST(klass, FL_SINGLETON)) {
VALUE s = rb_str_new2("#<"); VALUE s = rb_str_new2("#<");
@ -1211,8 +1162,7 @@ rb_mod_to_s(klass)
*/ */
static VALUE static VALUE
rb_mod_freeze(mod) rb_mod_freeze(VALUE mod)
VALUE mod;
{ {
rb_mod_to_s(mod); rb_mod_to_s(mod);
return rb_obj_freeze(mod); return rb_obj_freeze(mod);
@ -1229,8 +1179,7 @@ rb_mod_freeze(mod)
*/ */
static VALUE static VALUE
rb_mod_eqq(mod, arg) rb_mod_eqq(VALUE mod, VALUE arg)
VALUE mod, arg;
{ {
return rb_obj_is_kind_of(arg, mod); return rb_obj_is_kind_of(arg, mod);
} }
@ -1248,8 +1197,7 @@ rb_mod_eqq(mod, arg)
*/ */
VALUE VALUE
rb_class_inherited_p(mod, arg) rb_class_inherited_p(VALUE mod, VALUE arg)
VALUE mod, arg;
{ {
VALUE start = mod; VALUE start = mod;
@ -1287,8 +1235,7 @@ rb_class_inherited_p(mod, arg)
*/ */
static VALUE static VALUE
rb_mod_lt(mod, arg) rb_mod_lt(VALUE mod, VALUE arg)
VALUE mod, arg;
{ {
if (mod == arg) return Qfalse; if (mod == arg) return Qfalse;
return rb_class_inherited_p(mod, arg); return rb_class_inherited_p(mod, arg);
@ -1308,8 +1255,7 @@ rb_mod_lt(mod, arg)
*/ */
static VALUE static VALUE
rb_mod_ge(mod, arg) rb_mod_ge(VALUE mod, VALUE arg)
VALUE mod, arg;
{ {
switch (TYPE(arg)) { switch (TYPE(arg)) {
case T_MODULE: case T_MODULE:
@ -1334,8 +1280,7 @@ rb_mod_ge(mod, arg)
*/ */
static VALUE static VALUE
rb_mod_gt(mod, arg) rb_mod_gt(VALUE mod, VALUE arg)
VALUE mod, arg;
{ {
if (mod == arg) return Qfalse; if (mod == arg) return Qfalse;
return rb_mod_ge(mod, arg); return rb_mod_ge(mod, arg);
@ -1353,8 +1298,7 @@ rb_mod_gt(mod, arg)
*/ */
static VALUE static VALUE
rb_mod_cmp(mod, arg) rb_mod_cmp(VALUE mod, VALUE arg)
VALUE mod, arg;
{ {
VALUE cmp; VALUE cmp;
@ -1375,10 +1319,8 @@ rb_mod_cmp(mod, arg)
return INT2FIX(1); return INT2FIX(1);
} }
static VALUE rb_module_s_alloc _((VALUE));
static VALUE static VALUE
rb_module_s_alloc(klass) rb_module_s_alloc(VALUE klass)
VALUE klass;
{ {
VALUE mod = rb_module_new(); VALUE mod = rb_module_new();
@ -1386,10 +1328,8 @@ rb_module_s_alloc(klass)
return mod; return mod;
} }
static VALUE rb_class_s_alloc _((VALUE));
static VALUE static VALUE
rb_class_s_alloc(klass) rb_class_s_alloc(VALUE klass)
VALUE klass;
{ {
return rb_class_boot(0); return rb_class_boot(0);
} }
@ -1418,8 +1358,7 @@ rb_class_s_alloc(klass)
*/ */
static VALUE static VALUE
rb_mod_initialize(module) rb_mod_initialize(VALUE module)
VALUE module;
{ {
if (rb_block_given_p()) { if (rb_block_given_p()) {
rb_mod_module_eval(0, 0, module); rb_mod_module_eval(0, 0, module);
@ -1438,10 +1377,7 @@ rb_mod_initialize(module)
*/ */
static VALUE static VALUE
rb_class_initialize(argc, argv, klass) rb_class_initialize(int argc, VALUE *argv, VALUE klass)
int argc;
VALUE *argv;
VALUE klass;
{ {
VALUE super; VALUE super;
@ -1472,8 +1408,7 @@ rb_class_initialize(argc, argv, klass)
*/ */
VALUE VALUE
rb_obj_alloc(klass) rb_obj_alloc(VALUE klass)
VALUE klass;
{ {
VALUE obj; VALUE obj;
@ -1490,10 +1425,8 @@ rb_obj_alloc(klass)
return obj; return obj;
} }
static VALUE rb_class_allocate_instance _((VALUE));
static VALUE static VALUE
rb_class_allocate_instance(klass) rb_class_allocate_instance(VALUE klass)
VALUE klass;
{ {
NEWOBJ(obj, struct RObject); NEWOBJ(obj, struct RObject);
OBJSETUP(obj, klass, T_OBJECT); OBJSETUP(obj, klass, T_OBJECT);
@ -1513,10 +1446,7 @@ rb_class_allocate_instance(klass)
*/ */
VALUE VALUE
rb_class_new_instance(argc, argv, klass) rb_class_new_instance(int argc, VALUE *argv, VALUE klass)
int argc;
VALUE *argv;
VALUE klass;
{ {
VALUE obj; VALUE obj;
@ -1539,8 +1469,7 @@ rb_class_new_instance(argc, argv, klass)
*/ */
static VALUE static VALUE
rb_class_superclass(klass) rb_class_superclass(VALUE klass)
VALUE klass;
{ {
VALUE super = RCLASS(klass)->super; VALUE super = RCLASS(klass)->super;
@ -1557,8 +1486,7 @@ rb_class_superclass(klass)
} }
static ID static ID
str_to_id(str) str_to_id(VALUE str)
VALUE str;
{ {
if (!RSTRING(str)->ptr || RSTRING(str)->len == 0) { if (!RSTRING(str)->ptr || RSTRING(str)->len == 0) {
rb_raise(rb_eArgError, "empty symbol string"); rb_raise(rb_eArgError, "empty symbol string");
@ -1570,8 +1498,7 @@ str_to_id(str)
} }
ID ID
rb_to_id(name) rb_to_id(VALUE name)
VALUE name;
{ {
VALUE tmp; VALUE tmp;
ID id; ID id;
@ -1626,10 +1553,7 @@ rb_to_id(name)
*/ */
static VALUE static VALUE
rb_mod_attr(argc, argv, klass) rb_mod_attr(int argc, VALUE *argv, VALUE klass)
int argc;
VALUE *argv;
VALUE klass;
{ {
VALUE name, pub; VALUE name, pub;
@ -1648,10 +1572,7 @@ rb_mod_attr(argc, argv, klass)
*/ */
static VALUE static VALUE
rb_mod_attr_reader(argc, argv, klass) rb_mod_attr_reader(int argc, VALUE *argv, VALUE klass)
int argc;
VALUE *argv;
VALUE klass;
{ {
int i; int i;
@ -1670,10 +1591,7 @@ rb_mod_attr_reader(argc, argv, klass)
*/ */
static VALUE static VALUE
rb_mod_attr_writer(argc, argv, klass) rb_mod_attr_writer(int argc, VALUE *argv, VALUE klass)
int argc;
VALUE *argv;
VALUE klass;
{ {
int i; int i;
@ -1697,10 +1615,7 @@ rb_mod_attr_writer(argc, argv, klass)
*/ */
static VALUE static VALUE
rb_mod_attr_accessor(argc, argv, klass) rb_mod_attr_accessor(int argc, VALUE *argv, VALUE klass)
int argc;
VALUE *argv;
VALUE klass;
{ {
int i; int i;
@ -1720,8 +1635,7 @@ rb_mod_attr_accessor(argc, argv, klass)
*/ */
static VALUE static VALUE
rb_mod_const_get(mod, name) rb_mod_const_get(VALUE mod, VALUE name)
VALUE mod, name;
{ {
ID id = rb_to_id(name); ID id = rb_to_id(name);
@ -1744,8 +1658,7 @@ rb_mod_const_get(mod, name)
*/ */
static VALUE static VALUE
rb_mod_const_set(mod, name, value) rb_mod_const_set(VALUE mod, VALUE name, VALUE value)
VALUE mod, name, value;
{ {
ID id = rb_to_id(name); ID id = rb_to_id(name);
@ -1767,8 +1680,7 @@ rb_mod_const_set(mod, name, value)
*/ */
static VALUE static VALUE
rb_mod_const_defined(mod, name) rb_mod_const_defined(VALUE mod, VALUE name)
VALUE mod, name;
{ {
ID id = rb_to_id(name); ID id = rb_to_id(name);
@ -1799,10 +1711,7 @@ rb_mod_const_defined(mod, name)
static VALUE static VALUE
rb_obj_methods(argc, argv, obj) rb_obj_methods(int argc, VALUE *argv, VALUE obj)
int argc;
VALUE *argv;
VALUE obj;
{ {
retry: retry:
if (argc == 0) { if (argc == 0) {
@ -1833,10 +1742,7 @@ rb_obj_methods(argc, argv, obj)
*/ */
static VALUE static VALUE
rb_obj_protected_methods(argc, argv, obj) rb_obj_protected_methods(int argc, VALUE *argv, VALUE obj)
int argc;
VALUE *argv;
VALUE obj;
{ {
if (argc == 0) { /* hack to stop warning */ if (argc == 0) { /* hack to stop warning */
VALUE args[1]; VALUE args[1];
@ -1857,10 +1763,7 @@ rb_obj_protected_methods(argc, argv, obj)
*/ */
static VALUE static VALUE
rb_obj_private_methods(argc, argv, obj) rb_obj_private_methods(int argc, VALUE *argv, VALUE obj)
int argc;
VALUE *argv;
VALUE obj;
{ {
if (argc == 0) { /* hack to stop warning */ if (argc == 0) { /* hack to stop warning */
VALUE args[1]; VALUE args[1];
@ -1881,10 +1784,7 @@ rb_obj_private_methods(argc, argv, obj)
*/ */
static VALUE static VALUE
rb_obj_public_methods(argc, argv, obj) rb_obj_public_methods(int argc, VALUE *argv, VALUE obj)
int argc;
VALUE *argv;
VALUE obj;
{ {
if (argc == 0) { /* hack to stop warning */ if (argc == 0) { /* hack to stop warning */
VALUE args[1]; VALUE args[1];
@ -1914,8 +1814,7 @@ rb_obj_public_methods(argc, argv, obj)
*/ */
static VALUE static VALUE
rb_obj_ivar_get(obj, iv) rb_obj_ivar_get(VALUE obj, VALUE iv)
VALUE obj, iv;
{ {
ID id = rb_to_id(iv); ID id = rb_to_id(iv);
@ -1947,8 +1846,7 @@ rb_obj_ivar_get(obj, iv)
*/ */
static VALUE static VALUE
rb_obj_ivar_set(obj, iv, val) rb_obj_ivar_set(VALUE obj, VALUE iv, VALUE val)
VALUE obj, iv, val;
{ {
ID id = rb_to_id(iv); ID id = rb_to_id(iv);
@ -1973,8 +1871,7 @@ rb_obj_ivar_set(obj, iv, val)
*/ */
static VALUE static VALUE
rb_mod_cvar_get(obj, iv) rb_mod_cvar_get(VALUE obj, VALUE iv)
VALUE obj, iv;
{ {
ID id = rb_to_id(iv); ID id = rb_to_id(iv);
@ -2003,8 +1900,7 @@ rb_mod_cvar_get(obj, iv)
*/ */
static VALUE static VALUE
rb_mod_cvar_set(obj, iv, val) rb_mod_cvar_set(VALUE obj, VALUE iv, VALUE val)
VALUE obj, iv, val;
{ {
ID id = rb_to_id(iv); ID id = rb_to_id(iv);
@ -2016,10 +1912,7 @@ rb_mod_cvar_set(obj, iv, val)
} }
static VALUE static VALUE
convert_type(val, tname, method, raise) convert_type(VALUE val, const char *tname, const char *method, int raise)
VALUE val;
const char *tname, *method;
int raise;
{ {
ID m; ID m;
@ -2041,10 +1934,7 @@ convert_type(val, tname, method, raise)
} }
VALUE VALUE
rb_convert_type(val, type, tname, method) rb_convert_type(VALUE val, int type, const char *tname, const char *method)
VALUE val;
int type;
const char *tname, *method;
{ {
VALUE v; VALUE v;
@ -2059,10 +1949,7 @@ rb_convert_type(val, type, tname, method)
} }
VALUE VALUE
rb_check_convert_type(val, type, tname, method) rb_check_convert_type(VALUE val, int type, const char *tname, const char *method)
VALUE val;
int type;
const char *tname, *method;
{ {
VALUE v; VALUE v;
@ -2080,9 +1967,7 @@ rb_check_convert_type(val, type, tname, method)
static VALUE static VALUE
rb_to_integer(val, method) rb_to_integer(VALUE val, const char *method)
VALUE val;
const char *method;
{ {
VALUE v = convert_type(val, "Integer", method, Qtrue); VALUE v = convert_type(val, "Integer", method, Qtrue);
if (!rb_obj_is_kind_of(v, rb_cInteger)) { if (!rb_obj_is_kind_of(v, rb_cInteger)) {
@ -2094,9 +1979,7 @@ rb_to_integer(val, method)
} }
VALUE VALUE
rb_check_to_integer(val, method) rb_check_to_integer(VALUE val, const char *method)
VALUE val;
const char *method;
{ {
VALUE v = convert_type(val, "Integer", method, Qfalse); VALUE v = convert_type(val, "Integer", method, Qfalse);
if (!rb_obj_is_kind_of(v, rb_cInteger)) { if (!rb_obj_is_kind_of(v, rb_cInteger)) {
@ -2106,15 +1989,13 @@ rb_check_to_integer(val, method)
} }
VALUE VALUE
rb_to_int(val) rb_to_int(VALUE val)
VALUE val;
{ {
return rb_to_integer(val, "to_int"); return rb_to_integer(val, "to_int");
} }
VALUE VALUE
rb_Integer(val) rb_Integer(VALUE val)
VALUE val;
{ {
VALUE tmp; VALUE tmp;
@ -2161,16 +2042,13 @@ rb_Integer(val)
*/ */
static VALUE static VALUE
rb_f_integer(obj, arg) rb_f_integer(VALUE obj, VALUE arg)
VALUE obj, arg;
{ {
return rb_Integer(arg); return rb_Integer(arg);
} }
double double
rb_cstr_to_dbl(p, badcheck) rb_cstr_to_dbl(const char *p, int badcheck)
const char *p;
int badcheck;
{ {
const char *q; const char *q;
char *end; char *end;
@ -2237,9 +2115,7 @@ rb_cstr_to_dbl(p, badcheck)
} }
double double
rb_str_to_dbl(str, badcheck) rb_str_to_dbl(VALUE str, int badcheck)
VALUE str;
int badcheck;
{ {
char *s; char *s;
long len; long len;
@ -2263,8 +2139,7 @@ rb_str_to_dbl(str, badcheck)
} }
VALUE VALUE
rb_Float(val) rb_Float(VALUE val)
VALUE val;
{ {
switch (TYPE(val)) { switch (TYPE(val)) {
case T_FIXNUM: case T_FIXNUM:
@ -2307,15 +2182,13 @@ rb_Float(val)
*/ */
static VALUE static VALUE
rb_f_float(obj, arg) rb_f_float(VALUE obj, VALUE arg)
VALUE obj, arg;
{ {
return rb_Float(arg); return rb_Float(arg);
} }
double double
rb_num2dbl(val) rb_num2dbl(VALUE val)
VALUE val;
{ {
switch (TYPE(val)) { switch (TYPE(val)) {
case T_FLOAT: case T_FLOAT:
@ -2337,9 +2210,7 @@ rb_num2dbl(val)
} }
char* char*
rb_str2cstr(str, len) rb_str2cstr(VALUE str, long *len)
VALUE str;
long *len;
{ {
StringValue(str); StringValue(str);
if (len) *len = RSTRING(str)->len; if (len) *len = RSTRING(str)->len;
@ -2350,8 +2221,7 @@ rb_str2cstr(str, len)
} }
VALUE VALUE
rb_String(val) rb_String(VALUE val)
VALUE val;
{ {
return rb_convert_type(val, T_STRING, "String", "to_s"); return rb_convert_type(val, T_STRING, "String", "to_s");
} }
@ -2370,15 +2240,13 @@ rb_String(val)
*/ */
static VALUE static VALUE
rb_f_string(obj, arg) rb_f_string(VALUE obj, VALUE arg)
VALUE obj, arg;
{ {
return rb_String(arg); return rb_String(arg);
} }
VALUE VALUE
rb_Array(val) rb_Array(VALUE val)
VALUE val;
{ {
VALUE tmp = rb_check_array_type(val); VALUE tmp = rb_check_array_type(val);
@ -2404,16 +2272,13 @@ rb_Array(val)
*/ */
static VALUE static VALUE
rb_f_array(obj, arg) rb_f_array(VALUE obj, VALUE arg)
VALUE obj, arg;
{ {
return rb_Array(arg); return rb_Array(arg);
} }
static VALUE static VALUE
boot_defclass(name, super) boot_defclass(char *name, VALUE super)
char *name;
VALUE super;
{ {
extern st_table *rb_class_tbl; extern st_table *rb_class_tbl;
VALUE obj = rb_class_boot(super); VALUE obj = rb_class_boot(super);
@ -2502,7 +2367,7 @@ VALUE ruby_top_self;
*/ */
void void
Init_Object() Init_Object(void)
{ {
VALUE metaclass; VALUE metaclass;

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

@ -135,8 +135,7 @@ define_swapx(f,float)
#else #else
#if SIZEOF_LONG == 4 /* SIZEOF_DOUBLE == 8 && 4 == SIZEOF_LONG */ #if SIZEOF_LONG == 4 /* SIZEOF_DOUBLE == 8 && 4 == SIZEOF_LONG */
static double static double
swapd(d) swapd(const double d)
const double d;
{ {
double dtmp = d; double dtmp = d;
unsigned long utmp[2]; unsigned long utmp[2];
@ -334,8 +333,7 @@ endian()
unsigned long rb_big2ulong_pack _((VALUE x)); unsigned long rb_big2ulong_pack _((VALUE x));
static unsigned long static unsigned long
num2i32(x) num2i32(VALUE x)
VALUE x;
{ {
x = rb_to_int(x); /* is nil OK? (should not) */ x = rb_to_int(x); /* is nil OK? (should not) */
@ -438,8 +436,7 @@ static unsigned long utf8_to_uv _((char*,long*));
*/ */
static VALUE static VALUE
pack_pack(ary, fmt) pack_pack(VALUE ary, VALUE fmt)
VALUE ary, fmt;
{ {
static char *nul10 = "\0\0\0\0\0\0\0\0\0\0"; static char *nul10 = "\0\0\0\0\0\0\0\0\0\0";
static char *spc10 = " "; static char *spc10 = " ";
@ -1008,11 +1005,7 @@ static char b64_table[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
static void static void
encodes(str, s, len, type) encodes(VALUE str, char *s, long len, int type)
VALUE str;
char *s;
long len;
int type;
{ {
char *buff = ALLOCA_N(char, len * 4 / 3 + 6); char *buff = ALLOCA_N(char, len * 4 / 3 + 6);
long i = 0; long i = 0;
@ -1053,9 +1046,7 @@ encodes(str, s, len, type)
static char hex_table[] = "0123456789ABCDEF"; static char hex_table[] = "0123456789ABCDEF";
static void static void
qpencode(str, from, len) qpencode(VALUE str, VALUE from, long len)
VALUE str, from;
long len;
{ {
char buff[1024]; char buff[1024];
long i = 0, n = 0, prev = EOF; long i = 0, n = 0, prev = EOF;
@ -1108,8 +1099,7 @@ qpencode(str, from, len)
} }
static inline int static inline int
hex2num(c) hex2num(char c)
char c;
{ {
switch (c) { switch (c) {
case '0': case '1': case '2': case '3': case '4': case '0': case '1': case '2': case '3': case '4':
@ -1149,10 +1139,7 @@ hex2num(c)
#define PACK_ITEM_ADJUST() while (tmp--) rb_ary_push(ary, Qnil) #define PACK_ITEM_ADJUST() while (tmp--) rb_ary_push(ary, Qnil)
static VALUE static VALUE
infected_str_new(ptr, len, str) infected_str_new(const char *ptr, long len, VALUE str)
const char *ptr;
long len;
VALUE str;
{ {
VALUE s = rb_str_new(ptr, len); VALUE s = rb_str_new(ptr, len);
@ -1299,8 +1286,7 @@ infected_str_new(ptr, len, str)
*/ */
static VALUE static VALUE
pack_unpack(str, fmt) pack_unpack(VALUE str, VALUE fmt)
VALUE str, fmt;
{ {
static char *hexdigits = "0123456789abcdef0123456789ABCDEFx"; static char *hexdigits = "0123456789abcdef0123456789ABCDEFx";
char *s, *send; char *s, *send;
@ -1990,9 +1976,7 @@ pack_unpack(str, fmt)
#define BYTEWIDTH 8 #define BYTEWIDTH 8
static int static int
uv_to_utf8(buf, uv) uv_to_utf8(char *buf, unsigned long uv)
char *buf;
unsigned long uv;
{ {
if (uv <= 0x7f) { if (uv <= 0x7f) {
buf[0] = (char)uv; buf[0] = (char)uv;
@ -2047,9 +2031,7 @@ static const long utf8_limits[] = {
}; };
static unsigned long static unsigned long
utf8_to_uv(p, lenp) utf8_to_uv(char *p, long *lenp)
char *p;
long *lenp;
{ {
int c = *p++ & 0xff; int c = *p++ & 0xff;
unsigned long uv = c; unsigned long uv = c;
@ -2099,7 +2081,7 @@ utf8_to_uv(p, lenp)
} }
void void
Init_pack() Init_pack(void)
{ {
rb_define_method(rb_cArray, "pack", pack_pack, 1); rb_define_method(rb_cArray, "pack", pack_pack, 1);
rb_define_method(rb_cString, "unpack", pack_unpack, 1); rb_define_method(rb_cString, "unpack", pack_unpack, 1);

17
prec.c
Просмотреть файл

@ -32,8 +32,7 @@ static ID prc_pr, prc_if;
*/ */
static VALUE static VALUE
prec_prec(x, klass) prec_prec(VALUE x, VALUE klass)
VALUE x, klass;
{ {
return rb_funcall(klass, prc_if, 1, x); return rb_funcall(klass, prc_if, 1, x);
} }
@ -47,8 +46,7 @@ prec_prec(x, klass)
*/ */
static VALUE static VALUE
prec_prec_i(x) prec_prec_i(VALUE x)
VALUE x;
{ {
VALUE klass = rb_cInteger; VALUE klass = rb_cInteger;
@ -64,8 +62,7 @@ prec_prec_i(x)
*/ */
static VALUE static VALUE
prec_prec_f(x) prec_prec_f(VALUE x)
VALUE x;
{ {
VALUE klass = rb_cFloat; VALUE klass = rb_cFloat;
@ -86,8 +83,7 @@ prec_prec_f(x)
*/ */
static VALUE static VALUE
prec_induced_from(module, x) prec_induced_from(VALUE module, VALUE x)
VALUE module, x;
{ {
rb_raise(rb_eTypeError, "undefined conversion from %s into %s", rb_raise(rb_eTypeError, "undefined conversion from %s into %s",
rb_obj_classname(x), rb_class2name(module)); rb_obj_classname(x), rb_class2name(module));
@ -104,8 +100,7 @@ prec_induced_from(module, x)
*/ */
static VALUE static VALUE
prec_included(module, include) prec_included(VALUE module, VALUE include)
VALUE module, include;
{ {
switch (TYPE(include)) { switch (TYPE(include)) {
case T_CLASS: case T_CLASS:
@ -128,7 +123,7 @@ prec_included(module, include)
*/ */
void void
Init_Precision() Init_Precision(void)
{ {
rb_mPrecision = rb_define_module("Precision"); rb_mPrecision = rb_define_module("Precision");
rb_define_singleton_method(rb_mPrecision, "included", prec_included, 1); rb_define_singleton_method(rb_mPrecision, "included", prec_included, 1);

271
process.c
Просмотреть файл

@ -128,7 +128,7 @@ static VALUE S_Tms;
*/ */
static VALUE static VALUE
get_pid() get_pid(void)
{ {
rb_secure(2); rb_secure(2);
return INT2FIX(getpid()); return INT2FIX(getpid());
@ -152,7 +152,7 @@ get_pid()
*/ */
static VALUE static VALUE
get_ppid() get_ppid(void)
{ {
rb_secure(2); rb_secure(2);
#ifdef _WIN32 #ifdef _WIN32
@ -197,8 +197,7 @@ static VALUE rb_cProcStatus;
VALUE rb_last_status = Qnil; VALUE rb_last_status = Qnil;
static void static void
last_status_set(status, pid) last_status_set(int status, int pid)
int status, pid;
{ {
rb_last_status = rb_obj_alloc(rb_cProcStatus); rb_last_status = rb_obj_alloc(rb_cProcStatus);
rb_iv_set(rb_last_status, "status", INT2FIX(status)); rb_iv_set(rb_last_status, "status", INT2FIX(status));
@ -220,8 +219,7 @@ last_status_set(status, pid)
*/ */
static VALUE static VALUE
pst_to_i(st) pst_to_i(VALUE st)
VALUE st;
{ {
return rb_iv_get(st, "status"); return rb_iv_get(st, "status");
} }
@ -235,8 +233,7 @@ pst_to_i(st)
*/ */
static VALUE static VALUE
pst_to_s(st) pst_to_s(VALUE st)
VALUE st;
{ {
return rb_fix2str(pst_to_i(st), 10); return rb_fix2str(pst_to_i(st), 10);
} }
@ -254,8 +251,7 @@ pst_to_s(st)
*/ */
static VALUE static VALUE
pst_pid(st) pst_pid(VALUE st)
VALUE st;
{ {
return rb_iv_get(st, "pid"); return rb_iv_get(st, "pid");
} }
@ -269,8 +265,7 @@ pst_pid(st)
*/ */
static VALUE static VALUE
pst_inspect(st) pst_inspect(VALUE st)
VALUE st;
{ {
VALUE pid; VALUE pid;
int status; int status;
@ -326,8 +321,7 @@ pst_inspect(st)
*/ */
static VALUE static VALUE
pst_equal(st1, st2) pst_equal(VALUE st1, VALUE st2)
VALUE st1, st2;
{ {
if (st1 == st2) return Qtrue; if (st1 == st2) return Qtrue;
return rb_equal(pst_to_i(st1), st2); return rb_equal(pst_to_i(st1), st2);
@ -347,8 +341,7 @@ pst_equal(st1, st2)
*/ */
static VALUE static VALUE
pst_bitand(st1, st2) pst_bitand(VALUE st1, VALUE st2)
VALUE st1, st2;
{ {
int status = NUM2INT(st1) & NUM2INT(st2); int status = NUM2INT(st1) & NUM2INT(st2);
@ -369,8 +362,7 @@ pst_bitand(st1, st2)
*/ */
static VALUE static VALUE
pst_rshift(st1, st2) pst_rshift(VALUE st1, VALUE st2)
VALUE st1, st2;
{ {
int status = NUM2INT(st1) >> NUM2INT(st2); int status = NUM2INT(st1) >> NUM2INT(st2);
@ -388,8 +380,7 @@ pst_rshift(st1, st2)
*/ */
static VALUE static VALUE
pst_wifstopped(st) pst_wifstopped(VALUE st)
VALUE st;
{ {
int status = NUM2INT(st); int status = NUM2INT(st);
@ -409,8 +400,7 @@ pst_wifstopped(st)
*/ */
static VALUE static VALUE
pst_wstopsig(st) pst_wstopsig(VALUE st)
VALUE st;
{ {
int status = NUM2INT(st); int status = NUM2INT(st);
@ -429,8 +419,7 @@ pst_wstopsig(st)
*/ */
static VALUE static VALUE
pst_wifsignaled(st) pst_wifsignaled(VALUE st)
VALUE st;
{ {
int status = NUM2INT(st); int status = NUM2INT(st);
@ -451,8 +440,7 @@ pst_wifsignaled(st)
*/ */
static VALUE static VALUE
pst_wtermsig(st) pst_wtermsig(VALUE st)
VALUE st;
{ {
int status = NUM2INT(st); int status = NUM2INT(st);
@ -472,8 +460,7 @@ pst_wtermsig(st)
*/ */
static VALUE static VALUE
pst_wifexited(st) pst_wifexited(VALUE st)
VALUE st;
{ {
int status = NUM2INT(st); int status = NUM2INT(st);
@ -504,8 +491,7 @@ pst_wifexited(st)
*/ */
static VALUE static VALUE
pst_wexitstatus(st) pst_wexitstatus(VALUE st)
VALUE st;
{ {
int status = NUM2INT(st); int status = NUM2INT(st);
@ -524,8 +510,7 @@ pst_wexitstatus(st)
*/ */
static VALUE static VALUE
pst_success_p(st) pst_success_p(VALUE st)
VALUE st;
{ {
int status = NUM2INT(st); int status = NUM2INT(st);
@ -544,8 +529,7 @@ pst_success_p(st)
*/ */
static VALUE static VALUE
pst_wcoredump(st) pst_wcoredump(VALUE st)
VALUE st;
{ {
#ifdef WCOREDUMP #ifdef WCOREDUMP
int status = NUM2INT(st); int status = NUM2INT(st);
@ -565,10 +549,7 @@ static st_table *pid_tbl;
#endif #endif
int int
rb_waitpid(pid, st, flags) rb_waitpid(int pid, int *st, int flags)
int pid;
int *st;
int flags;
{ {
int result; int result;
#ifndef NO_WAITPID #ifndef NO_WAITPID
@ -724,9 +705,7 @@ waitall_each(pid, status, ary)
*/ */
static VALUE static VALUE
proc_wait(argc, argv) proc_wait(int argc, VALUE *argv)
int argc;
VALUE *argv;
{ {
VALUE vpid, vflags; VALUE vpid, vflags;
int pid, flags, status; int pid, flags, status;
@ -770,9 +749,7 @@ proc_wait(argc, argv)
*/ */
static VALUE static VALUE
proc_wait2(argc, argv) proc_wait2(int argc, VALUE *argv)
int argc;
VALUE *argv;
{ {
VALUE pid = proc_wait(argc, argv); VALUE pid = proc_wait(argc, argv);
if (NIL_P(pid)) return Qnil; if (NIL_P(pid)) return Qnil;
@ -801,7 +778,7 @@ proc_wait2(argc, argv)
*/ */
static VALUE static VALUE
proc_waitall() proc_waitall(void)
{ {
VALUE result; VALUE result;
int pid, status; int pid, status;
@ -843,8 +820,7 @@ proc_waitall()
} }
static VALUE static VALUE
detach_process_watcher(pid_p) detach_process_watcher(int *pid_p)
int *pid_p;
{ {
int cpid, status; int cpid, status;
@ -856,8 +832,7 @@ detach_process_watcher(pid_p)
} }
VALUE VALUE
rb_detach_process(pid) rb_detach_process(int pid)
int pid;
{ {
return rb_thread_create(detach_process_watcher, (void*)&pid); return rb_thread_create(detach_process_watcher, (void*)&pid);
} }
@ -928,11 +903,10 @@ char *strtok();
#define after_exec() #define after_exec()
#endif #endif
extern char *dln_find_exe(); extern char *dln_find_exe(const char *fname, const char *path);
static void static void
security(str) security(const char *str)
const char *str;
{ {
if (rb_env_path_tainted()) { if (rb_env_path_tainted()) {
if (rb_safe_level() > 0) { if (rb_safe_level() > 0) {
@ -942,9 +916,7 @@ security(str)
} }
static int static int
proc_exec_v(argv, prog) proc_exec_v(char **argv, const char *prog)
char **argv;
const char *prog;
{ {
if (!prog) if (!prog)
prog = argv[0]; prog = argv[0];
@ -999,10 +971,7 @@ proc_exec_v(argv, prog)
} }
int int
rb_proc_exec_n(argc, argv, prog) rb_proc_exec_n(int argc, VALUE *argv, const char *prog)
int argc;
VALUE *argv;
const char *prog;
{ {
char **args; char **args;
int i; int i;
@ -1019,8 +988,7 @@ rb_proc_exec_n(argc, argv, prog)
} }
int int
rb_proc_exec(str) rb_proc_exec(const char *str)
const char *str;
{ {
const char *s = str; const char *s = str;
char *ss, *t; char *ss, *t;
@ -1144,10 +1112,7 @@ proc_spawn_v(argv, prog)
#endif #endif
static int static int
proc_spawn_n(argc, argv, prog) proc_spawn_n(int argc, VALUE *argv, VALUE prog)
int argc;
VALUE *argv;
VALUE prog;
{ {
char **args; char **args;
int i; int i;
@ -1197,9 +1162,7 @@ proc_spawn(str)
#endif #endif
VALUE VALUE
rb_check_argv(argc, argv) rb_check_argv(int argc, VALUE *argv)
int argc;
VALUE *argv;
{ {
VALUE tmp, prog; VALUE tmp, prog;
int i; int i;
@ -1254,9 +1217,7 @@ rb_check_argv(argc, argv)
*/ */
VALUE VALUE
rb_f_exec(argc, argv) rb_f_exec(int argc, VALUE *argv)
int argc;
VALUE *argv;
{ {
struct rb_exec_arg e; struct rb_exec_arg e;
VALUE prog; VALUE prog;
@ -1278,8 +1239,7 @@ rb_f_exec(argc, argv)
} }
int int
rb_exec(e) rb_exec(const struct rb_exec_arg *e)
const struct rb_exec_arg *e;
{ {
int argc = e->argc; int argc = e->argc;
VALUE *argv = e->argv; VALUE *argv = e->argv;
@ -1444,8 +1404,7 @@ rb_fork(status, chfunc, charg)
*/ */
static VALUE static VALUE
rb_f_fork(obj) rb_f_fork(VALUE obj)
VALUE obj;
{ {
#ifdef HAVE_FORK #ifdef HAVE_FORK
int pid; int pid;
@ -1491,10 +1450,7 @@ rb_f_fork(obj)
*/ */
static VALUE static VALUE
rb_f_exit_bang(argc, argv, obj) rb_f_exit_bang(int argc, VALUE *argv, VALUE obj)
int argc;
VALUE *argv;
VALUE obj;
{ {
VALUE status; VALUE status;
int istatus; int istatus;
@ -1526,8 +1482,7 @@ rb_f_exit_bang(argc, argv, obj)
#endif #endif
void void
rb_syswait(pid) rb_syswait(int pid)
int pid;
{ {
static int overriding; static int overriding;
#ifdef SIGHUP #ifdef SIGHUP
@ -1569,9 +1524,7 @@ rb_syswait(pid)
} }
int int
rb_spawn(argc, argv) rb_spawn(int argc, VALUE *argv)
int argc;
VALUE *argv;
{ {
int status; int status;
VALUE prog; VALUE prog;
@ -1631,9 +1584,7 @@ rb_spawn(argc, argv)
*/ */
static VALUE static VALUE
rb_f_system(argc, argv) rb_f_system(int argc, VALUE *argv)
int argc;
VALUE *argv;
{ {
int status; int status;
@ -1656,9 +1607,7 @@ rb_f_system(argc, argv)
*/ */
static VALUE static VALUE
rb_f_spawn(argc, argv) rb_f_spawn(int argc, VALUE *argv)
int argc;
VALUE *argv;
{ {
int pid; int pid;
@ -1690,9 +1639,7 @@ rb_f_spawn(argc, argv)
*/ */
static VALUE static VALUE
rb_f_sleep(argc, argv) rb_f_sleep(int argc, VALUE *argv)
int argc;
VALUE *argv;
{ {
int beg, end; int beg, end;
@ -1725,7 +1672,7 @@ rb_f_sleep(argc, argv)
*/ */
static VALUE static VALUE
proc_getpgrp() proc_getpgrp(void)
{ {
int pgrp; int pgrp;
@ -1755,7 +1702,7 @@ proc_getpgrp()
*/ */
static VALUE static VALUE
proc_setpgrp() proc_setpgrp(void)
{ {
rb_secure(2); rb_secure(2);
/* check for posix setpgid() first; this matches the posix */ /* check for posix setpgid() first; this matches the posix */
@ -1784,8 +1731,7 @@ proc_setpgrp()
*/ */
static VALUE static VALUE
proc_getpgid(obj, pid) proc_getpgid(VALUE obj, VALUE pid)
VALUE obj, pid;
{ {
#if defined(HAVE_GETPGID) && !defined(__CHECKER__) #if defined(HAVE_GETPGID) && !defined(__CHECKER__)
int i; int i;
@ -1809,8 +1755,7 @@ proc_getpgid(obj, pid)
*/ */
static VALUE static VALUE
proc_setpgid(obj, pid, pgrp) proc_setpgid(VALUE obj, VALUE pid, VALUE pgrp)
VALUE obj, pid, pgrp;
{ {
#ifdef HAVE_SETPGID #ifdef HAVE_SETPGID
int ipid, ipgrp; int ipid, ipgrp;
@ -1839,7 +1784,7 @@ proc_setpgid(obj, pid, pgrp)
*/ */
static VALUE static VALUE
proc_setsid() proc_setsid(void)
{ {
#if defined(HAVE_SETSID) #if defined(HAVE_SETSID)
int pid; int pid;
@ -1893,8 +1838,7 @@ proc_setsid()
*/ */
static VALUE static VALUE
proc_getpriority(obj, which, who) proc_getpriority(VALUE obj, VALUE which, VALUE who)
VALUE obj, which, who;
{ {
#ifdef HAVE_GETPRIORITY #ifdef HAVE_GETPRIORITY
int prio, iwhich, iwho; int prio, iwhich, iwho;
@ -1926,8 +1870,7 @@ proc_getpriority(obj, which, who)
*/ */
static VALUE static VALUE
proc_setpriority(obj, which, who, prio) proc_setpriority(VALUE obj, VALUE which, VALUE who, VALUE prio)
VALUE obj, which, who, prio;
{ {
#ifdef HAVE_GETPRIORITY #ifdef HAVE_GETPRIORITY
int iwhich, iwho, iprio; int iwhich, iwho, iprio;
@ -2044,7 +1987,7 @@ proc_setrlimit(VALUE obj, VALUE resource, VALUE rlim_cur, VALUE rlim_max)
static int under_uid_switch = 0; static int under_uid_switch = 0;
static void static void
check_uid_switch() check_uid_switch(void)
{ {
rb_secure(2); rb_secure(2);
if (under_uid_switch) { if (under_uid_switch) {
@ -2054,7 +1997,7 @@ check_uid_switch()
static int under_gid_switch = 0; static int under_gid_switch = 0;
static void static void
check_gid_switch() check_gid_switch(void)
{ {
rb_secure(2); rb_secure(2);
if (under_gid_switch) { if (under_gid_switch) {
@ -2084,8 +2027,7 @@ check_gid_switch()
*/ */
static VALUE static VALUE
p_sys_setuid(obj, id) p_sys_setuid(VALUE obj, VALUE id)
VALUE obj, id;
{ {
#if defined HAVE_SETUID #if defined HAVE_SETUID
check_uid_switch(); check_uid_switch();
@ -2108,8 +2050,7 @@ p_sys_setuid(obj, id)
*/ */
static VALUE static VALUE
p_sys_setruid(obj, id) p_sys_setruid(VALUE obj, VALUE id)
VALUE obj, id;
{ {
#if defined HAVE_SETRUID #if defined HAVE_SETRUID
check_uid_switch(); check_uid_switch();
@ -2131,8 +2072,7 @@ p_sys_setruid(obj, id)
*/ */
static VALUE static VALUE
p_sys_seteuid(obj, id) p_sys_seteuid(VALUE obj, VALUE id)
VALUE obj, id;
{ {
#if defined HAVE_SETEUID #if defined HAVE_SETEUID
check_uid_switch(); check_uid_switch();
@ -2156,8 +2096,7 @@ p_sys_seteuid(obj, id)
*/ */
static VALUE static VALUE
p_sys_setreuid(obj, rid, eid) p_sys_setreuid(VALUE obj, VALUE rid, VALUE eid)
VALUE obj, rid, eid;
{ {
#if defined HAVE_SETREUID #if defined HAVE_SETREUID
check_uid_switch(); check_uid_switch();
@ -2181,8 +2120,7 @@ p_sys_setreuid(obj, rid, eid)
*/ */
static VALUE static VALUE
p_sys_setresuid(obj, rid, eid, sid) p_sys_setresuid(VALUE obj, VALUE rid, VALUE eid, VALUE sid)
VALUE obj, rid, eid, sid;
{ {
#if defined HAVE_SETRESUID #if defined HAVE_SETRESUID
check_uid_switch(); check_uid_switch();
@ -2206,8 +2144,7 @@ p_sys_setresuid(obj, rid, eid, sid)
*/ */
static VALUE static VALUE
proc_getuid(obj) proc_getuid(VALUE obj)
VALUE obj;
{ {
int uid = getuid(); int uid = getuid();
return INT2FIX(uid); return INT2FIX(uid);
@ -2223,8 +2160,7 @@ proc_getuid(obj)
*/ */
static VALUE static VALUE
proc_setuid(obj, id) proc_setuid(VALUE obj, VALUE id)
VALUE obj, id;
{ {
int uid = NUM2INT(id); int uid = NUM2INT(id);
@ -2278,8 +2214,7 @@ static int SAVED_USER_ID;
*/ */
static VALUE static VALUE
p_uid_change_privilege(obj, id) p_uid_change_privilege(VALUE obj, VALUE id)
VALUE obj, id;
{ {
int uid; int uid;
@ -2428,8 +2363,7 @@ p_uid_change_privilege(obj, id)
*/ */
static VALUE static VALUE
p_sys_setgid(obj, id) p_sys_setgid(VALUE obj, VALUE id)
VALUE obj, id;
{ {
#if defined HAVE_SETGID #if defined HAVE_SETGID
check_gid_switch(); check_gid_switch();
@ -2451,8 +2385,7 @@ p_sys_setgid(obj, id)
*/ */
static VALUE static VALUE
p_sys_setrgid(obj, id) p_sys_setrgid(VALUE obj, VALUE id)
VALUE obj, id;
{ {
#if defined HAVE_SETRGID #if defined HAVE_SETRGID
check_gid_switch(); check_gid_switch();
@ -2475,8 +2408,7 @@ p_sys_setrgid(obj, id)
*/ */
static VALUE static VALUE
p_sys_setegid(obj, id) p_sys_setegid(VALUE obj, VALUE id)
VALUE obj, id;
{ {
#if defined HAVE_SETEGID #if defined HAVE_SETEGID
check_gid_switch(); check_gid_switch();
@ -2500,8 +2432,7 @@ p_sys_setegid(obj, id)
*/ */
static VALUE static VALUE
p_sys_setregid(obj, rid, eid) p_sys_setregid(VALUE obj, VALUE rid, VALUE eid)
VALUE obj, rid, eid;
{ {
#if defined HAVE_SETREGID #if defined HAVE_SETREGID
check_gid_switch(); check_gid_switch();
@ -2524,8 +2455,7 @@ p_sys_setregid(obj, rid, eid)
*/ */
static VALUE static VALUE
p_sys_setresgid(obj, rid, eid, sid) p_sys_setresgid(VALUE obj, VALUE rid, VALUE eid, VALUE sid)
VALUE obj, rid, eid, sid;
{ {
#if defined HAVE_SETRESGID #if defined HAVE_SETRESGID
check_gid_switch(); check_gid_switch();
@ -2550,8 +2480,7 @@ p_sys_setresgid(obj, rid, eid, sid)
*/ */
static VALUE static VALUE
p_sys_issetugid(obj) p_sys_issetugid(VALUE obj)
VALUE obj;
{ {
#if defined HAVE_ISSETUGID #if defined HAVE_ISSETUGID
rb_secure(2); rb_secure(2);
@ -2579,8 +2508,7 @@ p_sys_issetugid(obj)
*/ */
static VALUE static VALUE
proc_getgid(obj) proc_getgid(VALUE obj)
VALUE obj;
{ {
int gid = getgid(); int gid = getgid();
return INT2FIX(gid); return INT2FIX(gid);
@ -2595,8 +2523,7 @@ proc_getgid(obj)
*/ */
static VALUE static VALUE
proc_setgid(obj, id) proc_setgid(VALUE obj, VALUE id)
VALUE obj, id;
{ {
int gid = NUM2INT(id); int gid = NUM2INT(id);
@ -2746,8 +2673,7 @@ proc_setgroups(VALUE obj, VALUE ary)
*/ */
static VALUE static VALUE
proc_initgroups(obj, uname, base_grp) proc_initgroups(VALUE obj, VALUE uname, VALUE base_grp)
VALUE obj, uname, base_grp;
{ {
#ifdef HAVE_INITGROUPS #ifdef HAVE_INITGROUPS
if (initgroups(StringValuePtr(uname), (rb_gid_t)NUM2INT(base_grp)) != 0) { if (initgroups(StringValuePtr(uname), (rb_gid_t)NUM2INT(base_grp)) != 0) {
@ -2772,8 +2698,7 @@ proc_initgroups(obj, uname, base_grp)
*/ */
static VALUE static VALUE
proc_getmaxgroups(obj) proc_getmaxgroups(VALUE obj)
VALUE obj;
{ {
return INT2FIX(maxgroups); return INT2FIX(maxgroups);
} }
@ -2814,9 +2739,7 @@ proc_setmaxgroups(VALUE obj, VALUE val)
*/ */
static VALUE static VALUE
proc_daemon(argc, argv) proc_daemon(int argc, VALUE *argv)
int argc;
VALUE *argv;
{ {
VALUE nochdir, noclose; VALUE nochdir, noclose;
int n; int n;
@ -2882,8 +2805,7 @@ static int SAVED_GROUP_ID;
*/ */
static VALUE static VALUE
p_gid_change_privilege(obj, id) p_gid_change_privilege(VALUE obj, VALUE id)
VALUE obj, id;
{ {
int gid; int gid;
@ -3034,8 +2956,7 @@ p_gid_change_privilege(obj, id)
*/ */
static VALUE static VALUE
proc_geteuid(obj) proc_geteuid(VALUE obj)
VALUE obj;
{ {
int euid = geteuid(); int euid = geteuid();
return INT2FIX(euid); return INT2FIX(euid);
@ -3051,8 +2972,7 @@ proc_geteuid(obj)
*/ */
static VALUE static VALUE
proc_seteuid(obj, euid) proc_seteuid(VALUE obj, VALUE euid)
VALUE obj, euid;
{ {
check_uid_switch(); check_uid_switch();
#if defined(HAVE_SETRESUID) && !defined(__CHECKER__) #if defined(HAVE_SETRESUID) && !defined(__CHECKER__)
@ -3076,8 +2996,7 @@ proc_seteuid(obj, euid)
} }
static VALUE static VALUE
rb_seteuid_core(euid) rb_seteuid_core(int euid)
int euid;
{ {
int uid; int uid;
@ -3126,8 +3045,7 @@ rb_seteuid_core(euid)
*/ */
static VALUE static VALUE
p_uid_grant_privilege(obj, id) p_uid_grant_privilege(VALUE obj, VALUE id)
VALUE obj, id;
{ {
return rb_seteuid_core(NUM2INT(id)); return rb_seteuid_core(NUM2INT(id));
} }
@ -3146,8 +3064,7 @@ p_uid_grant_privilege(obj, id)
*/ */
static VALUE static VALUE
proc_getegid(obj) proc_getegid(VALUE obj)
VALUE obj;
{ {
int egid = getegid(); int egid = getegid();
@ -3164,8 +3081,7 @@ proc_getegid(obj)
*/ */
static VALUE static VALUE
proc_setegid(obj, egid) proc_setegid(VALUE obj, VALUE egid)
VALUE obj, egid;
{ {
check_gid_switch(); check_gid_switch();
@ -3190,8 +3106,7 @@ proc_setegid(obj, egid)
} }
static VALUE static VALUE
rb_setegid_core(egid) rb_setegid_core(int egid)
int egid;
{ {
int gid; int gid;
@ -3240,8 +3155,7 @@ rb_setegid_core(egid)
*/ */
static VALUE static VALUE
p_gid_grant_privilege(obj, id) p_gid_grant_privilege(VALUE obj, VALUE id)
VALUE obj, id;
{ {
return rb_setegid_core(NUM2INT(id)); return rb_setegid_core(NUM2INT(id));
} }
@ -3257,7 +3171,7 @@ p_gid_grant_privilege(obj, id)
*/ */
static VALUE static VALUE
p_uid_exchangeable() p_uid_exchangeable(void)
{ {
#if defined(HAVE_SETRESUID) && !defined(__CHECKER__) #if defined(HAVE_SETRESUID) && !defined(__CHECKER__)
return Qtrue; return Qtrue;
@ -3282,8 +3196,7 @@ p_uid_exchangeable()
*/ */
static VALUE static VALUE
p_uid_exchange(obj) p_uid_exchange(VALUE obj)
VALUE obj;
{ {
int uid, euid; int uid, euid;
@ -3315,7 +3228,7 @@ p_uid_exchange(obj)
*/ */
static VALUE static VALUE
p_gid_exchangeable() p_gid_exchangeable(void)
{ {
#if defined(HAVE_SETRESGID) && !defined(__CHECKER__) #if defined(HAVE_SETRESGID) && !defined(__CHECKER__)
return Qtrue; return Qtrue;
@ -3340,8 +3253,7 @@ p_gid_exchangeable()
*/ */
static VALUE static VALUE
p_gid_exchange(obj) p_gid_exchange(VALUE obj)
VALUE obj;
{ {
int gid, egid; int gid, egid;
@ -3374,7 +3286,7 @@ p_gid_exchange(obj)
*/ */
static VALUE static VALUE
p_uid_have_saved_id() p_uid_have_saved_id(void)
{ {
#if defined(HAVE_SETRESUID) || defined(HAVE_SETEUID) || defined(_POSIX_SAVED_IDS) #if defined(HAVE_SETRESUID) || defined(HAVE_SETEUID) || defined(_POSIX_SAVED_IDS)
return Qtrue; return Qtrue;
@ -3441,16 +3353,14 @@ p_uid_switch(obj)
#else #else
static VALUE static VALUE
p_uid_sw_ensure(obj) p_uid_sw_ensure(VALUE obj)
VALUE obj;
{ {
under_uid_switch = 0; under_uid_switch = 0;
return p_uid_exchange(obj); return p_uid_exchange(obj);
} }
static VALUE static VALUE
p_uid_switch(obj) p_uid_switch(VALUE obj)
VALUE obj;
{ {
int uid, euid; int uid, euid;
@ -3486,7 +3396,7 @@ p_uid_switch(obj)
*/ */
static VALUE static VALUE
p_gid_have_saved_id() p_gid_have_saved_id(void)
{ {
#if defined(HAVE_SETRESGID) || defined(HAVE_SETEGID) || defined(_POSIX_SAVED_IDS) #if defined(HAVE_SETRESGID) || defined(HAVE_SETEGID) || defined(_POSIX_SAVED_IDS)
return Qtrue; return Qtrue;
@ -3551,16 +3461,14 @@ p_gid_switch(obj)
} }
#else #else
static VALUE static VALUE
p_gid_sw_ensure(obj) p_gid_sw_ensure(VALUE obj)
VALUE obj;
{ {
under_gid_switch = 0; under_gid_switch = 0;
return p_gid_exchange(obj); return p_gid_exchange(obj);
} }
static VALUE static VALUE
p_gid_switch(obj) p_gid_switch(VALUE obj)
VALUE obj;
{ {
int gid, egid; int gid, egid;
@ -3597,8 +3505,7 @@ p_gid_switch(obj)
*/ */
VALUE VALUE
rb_proc_times(obj) rb_proc_times(VALUE obj)
VALUE obj;
{ {
#if defined(HAVE_TIMES) && !defined(__CHECKER__) #if defined(HAVE_TIMES) && !defined(__CHECKER__)
#ifndef HZ #ifndef HZ
@ -3634,7 +3541,7 @@ VALUE rb_mProcID_Syscall;
*/ */
void void
Init_process() Init_process(void)
{ {
rb_define_virtual_variable("$$", get_pid, 0); rb_define_virtual_variable("$$", get_pid, 0);
rb_define_readonly_variable("$?", &rb_last_status); rb_define_readonly_variable("$?", &rb_last_status);

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

@ -76,8 +76,7 @@ static unsigned long *next;
/* initializes state[N] with a seed */ /* initializes state[N] with a seed */
static void static void
init_genrand(s) init_genrand(unsigned long s)
unsigned long s;
{ {
int j; int j;
state[0]= s & 0xffffffffUL; state[0]= s & 0xffffffffUL;
@ -124,7 +123,7 @@ init_by_array(unsigned long init_key[], int key_length)
} }
static void static void
next_state() next_state(void)
{ {
unsigned long *p=state; unsigned long *p=state;
int j; int j;
@ -165,7 +164,7 @@ genrand_int32(void)
/* generates a random number on [0,1) with 53-bit resolution*/ /* generates a random number on [0,1) with 53-bit resolution*/
static double static double
genrand_real(void) genrand_real(void)
{ {
unsigned long a=genrand_int32()>>5, b=genrand_int32()>>6; unsigned long a=genrand_int32()>>5, b=genrand_int32()>>6;
return(a*67108864.0+b)*(1.0/9007199254740992.0); return(a*67108864.0+b)*(1.0/9007199254740992.0);
@ -193,8 +192,7 @@ static int first = 1;
static VALUE saved_seed = INT2FIX(0); static VALUE saved_seed = INT2FIX(0);
static VALUE static VALUE
rand_init(vseed) rand_init(VALUE vseed)
VALUE vseed;
{ {
volatile VALUE seed; volatile VALUE seed;
VALUE old; VALUE old;
@ -253,7 +251,7 @@ rand_init(vseed)
} }
static VALUE static VALUE
random_seed() random_seed(void)
{ {
static int n = 0; static int n = 0;
struct timeval tv; struct timeval tv;
@ -320,10 +318,7 @@ random_seed()
*/ */
static VALUE static VALUE
rb_f_srand(argc, argv, obj) rb_f_srand(int argc, VALUE *argv, VALUE obj)
int argc;
VALUE *argv;
VALUE obj;
{ {
VALUE seed, old; VALUE seed, old;
@ -436,10 +431,7 @@ limited_big_rand(struct RBignum *limit)
*/ */
static VALUE static VALUE
rb_f_rand(argc, argv, obj) rb_f_rand(int argc, VALUE *argv, VALUE obj)
int argc;
VALUE *argv;
VALUE obj;
{ {
VALUE vmax; VALUE vmax;
long val, max; long val, max;
@ -495,7 +487,7 @@ rb_f_rand(argc, argv, obj)
} }
void void
Init_Random() Init_Random(void)
{ {
rb_define_global_function("srand", rb_f_srand, -1); rb_define_global_function("srand", rb_f_srand, -1);
rb_define_global_function("rand", rb_f_rand, -1); rb_define_global_function("rand", rb_f_rand, -1);

97
range.c
Просмотреть файл

@ -19,23 +19,20 @@ static ID id_cmp, id_succ, id_beg, id_end, id_excl;
#define SET_EXCL(r,v) rb_ivar_set((r), id_excl, (v) ? Qtrue : Qfalse) #define SET_EXCL(r,v) rb_ivar_set((r), id_excl, (v) ? Qtrue : Qfalse)
static VALUE static VALUE
range_failed() range_failed(void)
{ {
rb_raise(rb_eArgError, "bad value for range"); rb_raise(rb_eArgError, "bad value for range");
return Qnil; /* dummy */ return Qnil; /* dummy */
} }
static VALUE static VALUE
range_check(args) range_check(VALUE *args)
VALUE *args;
{ {
return rb_funcall(args[0], id_cmp, 1, args[1]); return rb_funcall(args[0], id_cmp, 1, args[1]);
} }
static void static void
range_init(range, beg, end, exclude_end) range_init(VALUE range, VALUE beg, VALUE end, int exclude_end)
VALUE range, beg, end;
int exclude_end;
{ {
VALUE args[2]; VALUE args[2];
@ -55,9 +52,7 @@ range_init(range, beg, end, exclude_end)
} }
VALUE VALUE
rb_range_new(beg, end, exclude_end) rb_range_new(VALUE beg, VALUE end, int exclude_end)
VALUE beg, end;
int exclude_end;
{ {
VALUE range = rb_obj_alloc(rb_cRange); VALUE range = rb_obj_alloc(rb_cRange);
@ -75,10 +70,7 @@ rb_range_new(beg, end, exclude_end)
*/ */
static VALUE static VALUE
range_initialize(argc, argv, range) range_initialize(int argc, VALUE *argv, VALUE range)
int argc;
VALUE *argv;
VALUE range;
{ {
VALUE beg, end, flags; VALUE beg, end, flags;
@ -100,8 +92,7 @@ range_initialize(argc, argv, range)
*/ */
static VALUE static VALUE
range_exclude_end_p(range) range_exclude_end_p(VALUE range)
VALUE range;
{ {
return EXCL(range) ? Qtrue : Qfalse; return EXCL(range) ? Qtrue : Qfalse;
} }
@ -122,8 +113,7 @@ range_exclude_end_p(range)
*/ */
static VALUE static VALUE
range_eq(range, obj) range_eq(VALUE range, VALUE obj)
VALUE range, obj;
{ {
if (range == obj) return Qtrue; if (range == obj) return Qtrue;
if (!rb_obj_is_instance_of(obj, rb_obj_class(range))) if (!rb_obj_is_instance_of(obj, rb_obj_class(range)))
@ -140,8 +130,7 @@ range_eq(range, obj)
} }
static int static int
r_lt(a, b) r_lt(VALUE a, VALUE b)
VALUE a, b;
{ {
VALUE r = rb_funcall(a, id_cmp, 1, b); VALUE r = rb_funcall(a, id_cmp, 1, b);
@ -151,8 +140,7 @@ r_lt(a, b)
} }
static int static int
r_le(a, b) r_le(VALUE a, VALUE b)
VALUE a, b;
{ {
int c; int c;
VALUE r = rb_funcall(a, id_cmp, 1, b); VALUE r = rb_funcall(a, id_cmp, 1, b);
@ -180,8 +168,7 @@ r_le(a, b)
*/ */
static VALUE static VALUE
range_eql(range, obj) range_eql(VALUE range, VALUE obj)
VALUE range, obj;
{ {
if (range == obj) return Qtrue; if (range == obj) return Qtrue;
if (!rb_obj_is_instance_of(obj, rb_obj_class(range))) if (!rb_obj_is_instance_of(obj, rb_obj_class(range)))
@ -207,8 +194,7 @@ range_eql(range, obj)
*/ */
static VALUE static VALUE
range_hash(range) range_hash(VALUE range)
VALUE range;
{ {
long hash = EXCL(range); long hash = EXCL(range);
VALUE v; VALUE v;
@ -223,18 +209,15 @@ range_hash(range)
} }
static VALUE static VALUE
str_step(args) str_step(VALUE arg)
VALUE *args;
{ {
VALUE *args = (VALUE *)arg;
return rb_str_upto(args[0], args[1], EXCL(args[2])); return rb_str_upto(args[0], args[1], EXCL(args[2]));
} }
static void static void
range_each_func(range, func, v, e, arg) range_each_func(VALUE range, VALUE (*func) (VALUE, void *), VALUE v, VALUE e, void *arg)
VALUE range;
void (*func) _((VALUE, void*));
VALUE v, e;
void *arg;
{ {
int c; int c;
@ -254,10 +237,10 @@ range_each_func(range, func, v, e, arg)
} }
static VALUE static VALUE
step_i(i, iter) step_i(VALUE i, void *arg)
VALUE i;
long *iter;
{ {
long *iter = (long *)arg;
iter[0]--; iter[0]--;
if (iter[0] == 0) { if (iter[0] == 0) {
rb_yield(i); rb_yield(i);
@ -295,10 +278,7 @@ step_i(i, iter)
static VALUE static VALUE
range_step(argc, argv, range) range_step(int argc, VALUE *argv, VALUE range)
int argc;
VALUE *argv;
VALUE range;
{ {
VALUE b, e, step; VALUE b, e, step;
long unit; long unit;
@ -335,8 +315,7 @@ range_step(argc, argv, range)
b = tmp; b = tmp;
args[0] = b; args[1] = e; args[2] = range; args[0] = b; args[1] = e; args[2] = range;
iter[0] = 1; iter[1] = unit; iter[0] = 1; iter[1] = unit;
rb_iterate((VALUE(*)_((VALUE)))str_step, (VALUE)args, step_i, rb_iterate(str_step, (VALUE)args, step_i, (VALUE)iter);
(VALUE)iter);
} }
else if (rb_obj_is_kind_of(b, rb_cNumeric)) { else if (rb_obj_is_kind_of(b, rb_cNumeric)) {
ID c = rb_intern(EXCL(range) ? "<" : "<="); ID c = rb_intern(EXCL(range) ? "<" : "<=");
@ -362,12 +341,11 @@ range_step(argc, argv, range)
return range; return range;
} }
static void static VALUE
each_i(v, arg) each_i(VALUE v, void *arg)
VALUE v;
void *arg;
{ {
rb_yield(v); rb_yield(v);
return Qnil;
} }
/* /*
@ -389,8 +367,7 @@ each_i(v, arg)
*/ */
static VALUE static VALUE
range_each(range) range_each(VALUE range)
VALUE range;
{ {
VALUE beg, end; VALUE beg, end;
@ -418,8 +395,7 @@ range_each(range)
args[0] = beg; args[1] = end; args[2] = range; args[0] = beg; args[1] = end; args[2] = range;
iter[0] = 1; iter[1] = 1; iter[0] = 1; iter[1] = 1;
rb_iterate((VALUE(*)_((VALUE)))str_step, (VALUE)args, step_i, rb_iterate(str_step, (VALUE)args, step_i, (VALUE)iter);
(VALUE)iter);
} }
else { else {
range_each_func(range, each_i, beg, end, NULL); range_each_func(range, each_i, beg, end, NULL);
@ -436,8 +412,7 @@ range_each(range)
*/ */
static VALUE static VALUE
range_first(range) range_first(VALUE range)
VALUE range;
{ {
return rb_ivar_get(range, id_beg); return rb_ivar_get(range, id_beg);
} }
@ -456,18 +431,13 @@ range_first(range)
static VALUE static VALUE
range_last(range) range_last(VALUE range)
VALUE range;
{ {
return rb_ivar_get(range, id_end); return rb_ivar_get(range, id_end);
} }
VALUE VALUE
rb_range_beg_len(range, begp, lenp, len, err) rb_range_beg_len(VALUE range, long *begp, long *lenp, long len, int err)
VALUE range;
long *begp, *lenp;
long len;
int err;
{ {
VALUE b, e; VALUE b, e;
long beg, end, excl; long beg, end, excl;
@ -520,8 +490,7 @@ rb_range_beg_len(range, begp, lenp, len, err)
*/ */
static VALUE static VALUE
range_to_s(range) range_to_s(VALUE range)
VALUE range;
{ {
VALUE str, str2; VALUE str, str2;
@ -546,8 +515,7 @@ range_to_s(range)
static VALUE static VALUE
range_inspect(range) range_inspect(VALUE range)
VALUE range;
{ {
VALUE str, str2; VALUE str, str2;
@ -584,8 +552,7 @@ range_inspect(range)
*/ */
static VALUE static VALUE
range_include(range, val) range_include(VALUE range, VALUE val)
VALUE range, val;
{ {
VALUE beg, end; VALUE beg, end;
@ -656,7 +623,7 @@ range_include(range, val)
*/ */
void void
Init_Range() Init_Range(void)
{ {
rb_cRange = rb_define_class("Range", rb_cObject); rb_cRange = rb_define_class("Range", rb_cObject);
rb_include_module(rb_cRange, rb_mEnumerable); rb_include_module(rb_cRange, rb_mEnumerable);

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

@ -76,9 +76,7 @@ static const char casetable[] = {
#endif #endif
int int
rb_memcicmp(p1, p2, len) rb_memcicmp(char *p1, char *p2, long len)
char *p1, *p2;
long len;
{ {
int tmp; int tmp;
@ -90,9 +88,7 @@ rb_memcicmp(p1, p2, len)
} }
int int
rb_memcmp(p1, p2, len) rb_memcmp(char *p1, char *p2, long len)
char *p1, *p2;
long len;
{ {
if (!ruby_ignorecase) { if (!ruby_ignorecase) {
return memcmp(p1, p2, len); return memcmp(p1, p2, len);
@ -101,9 +97,7 @@ rb_memcmp(p1, p2, len)
} }
long long
rb_memsearch(x0, m, y0, n) rb_memsearch(char *x0, long m, char *y0, long n)
char *x0, *y0;
long m, n;
{ {
unsigned char *x = (unsigned char *)x0, *y = (unsigned char *)y0; unsigned char *x = (unsigned char *)x0, *y = (unsigned char *)y0;
unsigned char *s, *e; unsigned char *s, *e;
@ -168,8 +162,7 @@ rb_memsearch(x0, m, y0, n)
static int reg_kcode = DEFAULT_KCODE; static int reg_kcode = DEFAULT_KCODE;
static void static void
kcode_euc(re) kcode_euc(struct RRegexp *re)
struct RRegexp *re;
{ {
FL_UNSET(re, KCODE_MASK); FL_UNSET(re, KCODE_MASK);
FL_SET(re, KCODE_EUC); FL_SET(re, KCODE_EUC);
@ -177,8 +170,7 @@ kcode_euc(re)
} }
static void static void
kcode_sjis(re) kcode_sjis(struct RRegexp *re)
struct RRegexp *re;
{ {
FL_UNSET(re, KCODE_MASK); FL_UNSET(re, KCODE_MASK);
FL_SET(re, KCODE_SJIS); FL_SET(re, KCODE_SJIS);
@ -186,8 +178,7 @@ kcode_sjis(re)
} }
static void static void
kcode_utf8(re) kcode_utf8(struct RRegexp *re)
struct RRegexp *re;
{ {
FL_UNSET(re, KCODE_MASK); FL_UNSET(re, KCODE_MASK);
FL_SET(re, KCODE_UTF8); FL_SET(re, KCODE_UTF8);
@ -195,8 +186,7 @@ kcode_utf8(re)
} }
static void static void
kcode_none(re) kcode_none(struct RRegexp *re)
struct RRegexp *re;
{ {
FL_UNSET(re, KCODE_MASK); FL_UNSET(re, KCODE_MASK);
FL_SET(re, KCODE_FIXED); FL_SET(re, KCODE_FIXED);
@ -205,8 +195,7 @@ kcode_none(re)
static int curr_kcode; static int curr_kcode;
static void static void
kcode_set_option(re) kcode_set_option(VALUE re)
VALUE re;
{ {
if (!FL_TEST(re, KCODE_FIXED)) return; if (!FL_TEST(re, KCODE_FIXED)) return;
@ -229,7 +218,7 @@ kcode_set_option(re)
} }
static void static void
kcode_reset_option() kcode_reset_option(void)
{ {
if (reg_kcode == curr_kcode) return; if (reg_kcode == curr_kcode) return;
switch (reg_kcode) { switch (reg_kcode) {
@ -249,9 +238,7 @@ kcode_reset_option()
} }
int int
rb_reg_mbclen2(c, re) rb_reg_mbclen2(unsigned int c, VALUE re)
unsigned int c;
VALUE re;
{ {
int len; int len;
unsigned char uc = (unsigned char)c; unsigned char uc = (unsigned char)c;
@ -265,8 +252,7 @@ rb_reg_mbclen2(c, re)
} }
static void static void
rb_reg_check(re) rb_reg_check(VALUE re)
VALUE re;
{ {
if (!RREGEXP(re)->ptr || !RREGEXP(re)->str) { if (!RREGEXP(re)->ptr || !RREGEXP(re)->str) {
rb_raise(rb_eTypeError, "uninitialized Regexp"); rb_raise(rb_eTypeError, "uninitialized Regexp");
@ -274,10 +260,7 @@ rb_reg_check(re)
} }
static void static void
rb_reg_expr_str(str, s, len) rb_reg_expr_str(VALUE str, const char *s, long len)
VALUE str;
const char *s;
long len;
{ {
const char *p, *pend; const char *p, *pend;
int need_escape = 0; int need_escape = 0;
@ -330,10 +313,7 @@ rb_reg_expr_str(str, s, len)
} }
static VALUE static VALUE
rb_reg_desc(s, len, re) rb_reg_desc(const char *s, long len, VALUE re)
const char *s;
long len;
VALUE re;
{ {
VALUE str = rb_str_buf_new2("/"); VALUE str = rb_str_buf_new2("/");
@ -380,8 +360,7 @@ rb_reg_desc(s, len, re)
*/ */
static VALUE static VALUE
rb_reg_source(re) rb_reg_source(VALUE re)
VALUE re;
{ {
VALUE str; VALUE str;
@ -403,8 +382,7 @@ rb_reg_source(re)
*/ */
static VALUE static VALUE
rb_reg_inspect(re) rb_reg_inspect(VALUE re)
VALUE re;
{ {
rb_reg_check(re); rb_reg_check(re);
return rb_reg_desc(RREGEXP(re)->str, RREGEXP(re)->len, re); return rb_reg_desc(RREGEXP(re)->str, RREGEXP(re)->len, re);
@ -432,8 +410,7 @@ rb_reg_inspect(re)
*/ */
static VALUE static VALUE
rb_reg_to_s(re) rb_reg_to_s(VALUE re)
VALUE re;
{ {
int options; int options;
const int embeddable = ONIG_OPTION_MULTILINE|ONIG_OPTION_IGNORECASE|ONIG_OPTION_EXTEND; const int embeddable = ONIG_OPTION_MULTILINE|ONIG_OPTION_IGNORECASE|ONIG_OPTION_EXTEND;
@ -530,12 +507,7 @@ rb_reg_to_s(re)
} }
static void static void
rb_reg_raise(s, len, err, re, ce) rb_reg_raise(const char *s, long len, const char *err, VALUE re, int ce)
const char *s;
long len;
const char *err;
VALUE re;
int ce;
{ {
VALUE desc = rb_reg_desc(s, len, re); VALUE desc = rb_reg_desc(s, len, re);
@ -554,8 +526,7 @@ rb_reg_raise(s, len, err, re, ce)
*/ */
static VALUE static VALUE
rb_reg_casefold_p(re) rb_reg_casefold_p(VALUE re)
VALUE re;
{ {
rb_reg_check(re); rb_reg_check(re);
if (RREGEXP(re)->ptr->options & ONIG_OPTION_IGNORECASE) return Qtrue; if (RREGEXP(re)->ptr->options & ONIG_OPTION_IGNORECASE) return Qtrue;
@ -587,8 +558,7 @@ rb_reg_casefold_p(re)
*/ */
static VALUE static VALUE
rb_reg_options_m(re) rb_reg_options_m(VALUE re)
VALUE re;
{ {
int options = rb_reg_options(re); int options = rb_reg_options(re);
return INT2NUM(options); return INT2NUM(options);
@ -603,8 +573,7 @@ rb_reg_options_m(re)
*/ */
static VALUE static VALUE
rb_reg_kcode_m(re) rb_reg_kcode_m(VALUE re)
VALUE re;
{ {
char *kcode; char *kcode;
@ -628,11 +597,7 @@ rb_reg_kcode_m(re)
} }
static Regexp* static Regexp*
make_regexp(s, len, flags, ce) make_regexp(const char *s, long len, int flags, int ce)
const char *s;
long len;
int flags;
int ce;
{ {
Regexp *rp; Regexp *rp;
char err[ONIG_MAX_ERROR_MESSAGE_LEN]; char err[ONIG_MAX_ERROR_MESSAGE_LEN];
@ -682,10 +647,8 @@ make_regexp(s, len, flags, ce)
static VALUE rb_cMatch; static VALUE rb_cMatch;
static VALUE match_alloc _((VALUE));
static VALUE static VALUE
match_alloc(klass) match_alloc(VALUE klass)
VALUE klass;
{ {
NEWOBJ(match, struct RMatch); NEWOBJ(match, struct RMatch);
OBJSETUP(match, klass, T_MATCH); OBJSETUP(match, klass, T_MATCH);
@ -700,8 +663,7 @@ match_alloc(klass)
/* :nodoc: */ /* :nodoc: */
static VALUE static VALUE
match_init_copy(obj, orig) match_init_copy(VALUE obj, VALUE orig)
VALUE obj, orig;
{ {
if (obj == orig) return obj; if (obj == orig) return obj;
@ -730,8 +692,7 @@ match_init_copy(obj, orig)
*/ */
static VALUE static VALUE
match_size(match) match_size(VALUE match)
VALUE match;
{ {
return INT2FIX(RMATCH(match)->regs->num_regs); return INT2FIX(RMATCH(match)->regs->num_regs);
} }
@ -750,8 +711,7 @@ match_size(match)
*/ */
static VALUE static VALUE
match_offset(match, n) match_offset(VALUE match, VALUE n)
VALUE match, n;
{ {
int i = NUM2INT(n); int i = NUM2INT(n);
@ -779,8 +739,7 @@ match_offset(match, n)
*/ */
static VALUE static VALUE
match_begin(match, n) match_begin(VALUE match, VALUE n)
VALUE match, n;
{ {
int i = NUM2INT(n); int i = NUM2INT(n);
@ -807,8 +766,7 @@ match_begin(match, n)
*/ */
static VALUE static VALUE
match_end(match, n) match_end(VALUE match, VALUE n)
VALUE match, n;
{ {
int i = NUM2INT(n); int i = NUM2INT(n);
@ -824,8 +782,7 @@ match_end(match, n)
#define MATCH_BUSY FL_USER2 #define MATCH_BUSY FL_USER2
void void
rb_match_busy(match) rb_match_busy(VALUE match)
VALUE match;
{ {
FL_SET(match, MATCH_BUSY); FL_SET(match, MATCH_BUSY);
} }
@ -834,8 +791,7 @@ int ruby_ignorecase;
static int may_need_recompile; static int may_need_recompile;
static void static void
rb_reg_prepare_re(re) rb_reg_prepare_re(VALUE re)
VALUE re;
{ {
int need_recompile = 0; int need_recompile = 0;
int state; int state;
@ -885,9 +841,7 @@ rb_reg_prepare_re(re)
} }
long long
rb_reg_adjust_startpos(re, str, pos, reverse) rb_reg_adjust_startpos(VALUE re, VALUE str, long pos, long reverse)
VALUE re, str;
long pos, reverse;
{ {
long range; long range;
OnigEncoding enc; OnigEncoding enc;
@ -926,9 +880,7 @@ rb_reg_adjust_startpos(re, str, pos, reverse)
} }
long long
rb_reg_search(re, str, pos, reverse) rb_reg_search(VALUE re, VALUE str, long pos, long reverse)
VALUE re, str;
long pos, reverse;
{ {
long result; long result;
VALUE match; VALUE match;
@ -998,9 +950,7 @@ rb_reg_search(re, str, pos, reverse)
} }
VALUE VALUE
rb_reg_nth_defined(nth, match) rb_reg_nth_defined(int nth, VALUE match)
int nth;
VALUE match;
{ {
if (NIL_P(match)) return Qnil; if (NIL_P(match)) return Qnil;
if (nth >= RMATCH(match)->regs->num_regs) { if (nth >= RMATCH(match)->regs->num_regs) {
@ -1015,9 +965,7 @@ rb_reg_nth_defined(nth, match)
} }
VALUE VALUE
rb_reg_nth_match(nth, match) rb_reg_nth_match(int nth, VALUE match)
int nth;
VALUE match;
{ {
VALUE str; VALUE str;
long start, end, len; long start, end, len;
@ -1040,8 +988,7 @@ rb_reg_nth_match(nth, match)
} }
VALUE VALUE
rb_reg_last_match(match) rb_reg_last_match(VALUE match)
VALUE match;
{ {
return rb_reg_nth_match(0, match); return rb_reg_nth_match(0, match);
} }
@ -1059,8 +1006,7 @@ rb_reg_last_match(match)
*/ */
VALUE VALUE
rb_reg_match_pre(match) rb_reg_match_pre(VALUE match)
VALUE match;
{ {
VALUE str; VALUE str;
@ -1084,8 +1030,7 @@ rb_reg_match_pre(match)
*/ */
VALUE VALUE
rb_reg_match_post(match) rb_reg_match_post(VALUE match)
VALUE match;
{ {
VALUE str; VALUE str;
long pos; long pos;
@ -1100,8 +1045,7 @@ rb_reg_match_post(match)
} }
VALUE VALUE
rb_reg_match_last(match) rb_reg_match_last(VALUE match)
VALUE match;
{ {
int i; int i;
@ -1115,33 +1059,31 @@ rb_reg_match_last(match)
} }
static VALUE static VALUE
last_match_getter() last_match_getter(void)
{ {
return rb_reg_last_match(rb_backref_get()); return rb_reg_last_match(rb_backref_get());
} }
static VALUE static VALUE
prematch_getter() prematch_getter(void)
{ {
return rb_reg_match_pre(rb_backref_get()); return rb_reg_match_pre(rb_backref_get());
} }
static VALUE static VALUE
postmatch_getter() postmatch_getter(void)
{ {
return rb_reg_match_post(rb_backref_get()); return rb_reg_match_post(rb_backref_get());
} }
static VALUE static VALUE
last_paren_match_getter() last_paren_match_getter(void)
{ {
return rb_reg_match_last(rb_backref_get()); return rb_reg_match_last(rb_backref_get());
} }
static VALUE static VALUE
match_array(match, start) match_array(VALUE match, int start)
VALUE match;
int start;
{ {
struct re_registers *regs = RMATCH(match)->regs; struct re_registers *regs = RMATCH(match)->regs;
VALUE ary = rb_ary_new2(regs->num_regs); VALUE ary = rb_ary_new2(regs->num_regs);
@ -1190,8 +1132,7 @@ match_array(match, start)
*/ */
static VALUE static VALUE
match_to_a(match) match_to_a(VALUE match)
VALUE match;
{ {
return match_array(match, 0); return match_array(match, 0);
} }
@ -1210,8 +1151,7 @@ match_to_a(match)
* f4 #=> "8" * f4 #=> "8"
*/ */
static VALUE static VALUE
match_captures(match) match_captures(VALUE match)
VALUE match;
{ {
return match_array(match, 1); return match_array(match, 1);
} }
@ -1237,10 +1177,7 @@ match_captures(match)
*/ */
static VALUE static VALUE
match_aref(argc, argv, match) match_aref(int argc, VALUE *argv, VALUE match)
int argc;
VALUE *argv;
VALUE match;
{ {
VALUE idx, rest; VALUE idx, rest;
@ -1252,11 +1189,8 @@ match_aref(argc, argv, match)
return rb_reg_nth_match(FIX2INT(idx), match); return rb_reg_nth_match(FIX2INT(idx), match);
} }
static VALUE match_entry _((VALUE, long));
static VALUE static VALUE
match_entry(match, n) match_entry(VALUE match, long n)
VALUE match;
long n;
{ {
return rb_reg_nth_match(n, match); return rb_reg_nth_match(n, match);
} }
@ -1275,10 +1209,7 @@ match_entry(match, n)
*/ */
static VALUE static VALUE
match_values_at(argc, argv, match) match_values_at(int argc, VALUE *argv, VALUE match)
int argc;
VALUE *argv;
VALUE match;
{ {
return rb_get_values_at(match, RMATCH(match)->regs->num_regs, argc, argv, match_entry); return rb_get_values_at(match, RMATCH(match)->regs->num_regs, argc, argv, match_entry);
} }
@ -1297,10 +1228,7 @@ match_values_at(argc, argv, match)
*/ */
static VALUE static VALUE
match_select(argc, argv, match) match_select(int argc, VALUE *argv, VALUE match)
int argc;
VALUE *argv;
VALUE match;
{ {
if (argc > 0) { if (argc > 0) {
rb_raise(rb_eArgError, "wrong number of arguments (%d for 0)", argc); rb_raise(rb_eArgError, "wrong number of arguments (%d for 0)", argc);
@ -1335,8 +1263,7 @@ match_select(argc, argv, match)
*/ */
static VALUE static VALUE
match_to_s(match) match_to_s(VALUE match)
VALUE match;
{ {
VALUE str = rb_reg_last_match(match); VALUE str = rb_reg_last_match(match);
@ -1358,8 +1285,7 @@ match_to_s(match)
*/ */
static VALUE static VALUE
match_string(match) match_string(VALUE match)
VALUE match;
{ {
return RMATCH(match)->str; /* str is frozen */ return RMATCH(match)->str; /* str is frozen */
} }
@ -1367,18 +1293,15 @@ match_string(match)
VALUE rb_cRegexp; VALUE rb_cRegexp;
static void static void
rb_reg_initialize(obj, s, len, options, ce) rb_reg_initialize(VALUE obj, const char *s, long len,
VALUE obj; int options, /* CASEFOLD = 1 */
const char *s;
long len;
int options; /* CASEFOLD = 1 */
/* EXTENDED = 2 */ /* EXTENDED = 2 */
/* MULTILINE = 4 */ /* MULTILINE = 4 */
/* CODE_NONE = 16 */ /* CODE_NONE = 16 */
/* CODE_EUC = 32 */ /* CODE_EUC = 32 */
/* CODE_SJIS = 48 */ /* CODE_SJIS = 48 */
/* CODE_UTF8 = 64 */ /* CODE_UTF8 = 64 */
int ce; /* call rb_compile_error() */ int ce) /* call rb_compile_error() */
{ {
struct RRegexp *re = RREGEXP(obj); struct RRegexp *re = RREGEXP(obj);
@ -1423,10 +1346,8 @@ rb_reg_initialize(obj, s, len, options, ce)
} }
} }
static VALUE rb_reg_s_alloc _((VALUE));
static VALUE static VALUE
rb_reg_s_alloc(klass) rb_reg_s_alloc(VALUE klass)
VALUE klass;
{ {
NEWOBJ(re, struct RRegexp); NEWOBJ(re, struct RRegexp);
OBJSETUP(re, klass, T_REGEXP); OBJSETUP(re, klass, T_REGEXP);
@ -1439,10 +1360,7 @@ rb_reg_s_alloc(klass)
} }
VALUE VALUE
rb_reg_new(s, len, options) rb_reg_new(const char *s, long len, int options)
const char *s;
long len;
int options;
{ {
VALUE re = rb_reg_s_alloc(rb_cRegexp); VALUE re = rb_reg_s_alloc(rb_cRegexp);
@ -1451,10 +1369,7 @@ rb_reg_new(s, len, options)
} }
VALUE VALUE
rb_reg_compile(s, len, options) rb_reg_compile(const char *s, long len, int options)
const char *s;
long len;
int options;
{ {
VALUE re = rb_reg_s_alloc(rb_cRegexp); VALUE re = rb_reg_s_alloc(rb_cRegexp);
@ -1467,8 +1382,7 @@ static int kcode_cache;
static VALUE reg_cache; static VALUE reg_cache;
VALUE VALUE
rb_reg_regcomp(str) rb_reg_regcomp(VALUE str)
VALUE str;
{ {
if (reg_cache && RREGEXP(reg_cache)->len == RSTRING(str)->len if (reg_cache && RREGEXP(reg_cache)->len == RSTRING(str)->len
&& case_cache == ruby_ignorecase && case_cache == ruby_ignorecase
@ -1483,8 +1397,7 @@ rb_reg_regcomp(str)
} }
static int static int
rb_reg_cur_kcode(re) rb_reg_cur_kcode(VALUE re)
VALUE re;
{ {
if (FL_TEST(re, KCODE_FIXED)) { if (FL_TEST(re, KCODE_FIXED)) {
return RBASIC(re)->flags & KCODE_MASK; return RBASIC(re)->flags & KCODE_MASK;
@ -1500,8 +1413,7 @@ rb_reg_cur_kcode(re)
*/ */
static VALUE static VALUE
rb_reg_hash(re) rb_reg_hash(VALUE re)
VALUE re;
{ {
int hashval, len; int hashval, len;
char *p; char *p;
@ -1534,8 +1446,7 @@ rb_reg_hash(re)
*/ */
static VALUE static VALUE
rb_reg_equal(re1, re2) rb_reg_equal(VALUE re1, VALUE re2)
VALUE re1, re2;
{ {
if (re1 == re2) return Qtrue; if (re1 == re2) return Qtrue;
if (TYPE(re2) != T_REGEXP) return Qfalse; if (TYPE(re2) != T_REGEXP) return Qfalse;
@ -1550,9 +1461,7 @@ rb_reg_equal(re1, re2)
} }
static VALUE static VALUE
rb_reg_match_pos(re, str, pos) rb_reg_match_pos(VALUE re, VALUE str, long pos)
VALUE re, str;
long pos;
{ {
if (NIL_P(str)) { if (NIL_P(str)) {
rb_backref_set(Qnil); rb_backref_set(Qnil);
@ -1585,8 +1494,7 @@ rb_reg_match_pos(re, str, pos)
*/ */
VALUE VALUE
rb_reg_match(re, str) rb_reg_match(VALUE re, VALUE str)
VALUE re, str;
{ {
return rb_reg_match_pos(re, str, 0); return rb_reg_match_pos(re, str, 0);
} }
@ -1610,8 +1518,7 @@ rb_reg_match(re, str)
*/ */
VALUE VALUE
rb_reg_eqq(re, str) rb_reg_eqq(VALUE re, VALUE str)
VALUE re, str;
{ {
long start; long start;
@ -1643,8 +1550,7 @@ rb_reg_eqq(re, str)
*/ */
VALUE VALUE
rb_reg_match2(re) rb_reg_match2(VALUE re)
VALUE re;
{ {
long start; long start;
VALUE line = rb_lastline_get(); VALUE line = rb_lastline_get();
@ -1678,10 +1584,7 @@ rb_reg_match2(re)
*/ */
static VALUE static VALUE
rb_reg_match_m(argc, argv, re) rb_reg_match_m(int argc, VALUE *argv, VALUE re)
int argc;
VALUE *argv;
VALUE re;
{ {
VALUE result, str, initpos; VALUE result, str, initpos;
long pos; long pos;
@ -1735,10 +1638,7 @@ rb_reg_match_m(argc, argv, re)
*/ */
static VALUE static VALUE
rb_reg_initialize_m(argc, argv, self) rb_reg_initialize_m(int argc, VALUE *argv, VALUE self)
int argc;
VALUE *argv;
VALUE self;
{ {
const char *s; const char *s;
long len; long len;
@ -1809,8 +1709,7 @@ rb_reg_initialize_m(argc, argv, self)
} }
VALUE VALUE
rb_reg_quote(str) rb_reg_quote(VALUE str)
VALUE str;
{ {
char *s, *send, *t; char *s, *send, *t;
VALUE tmp; VALUE tmp;
@ -1908,9 +1807,7 @@ rb_reg_quote(str)
*/ */
static VALUE static VALUE
rb_reg_s_quote(argc, argv) rb_reg_s_quote(int argc, VALUE *argv)
int argc;
VALUE *argv;
{ {
VALUE str, kcode; VALUE str, kcode;
int kcode_saved = reg_kcode; int kcode_saved = reg_kcode;
@ -1928,7 +1825,7 @@ rb_reg_s_quote(argc, argv)
} }
int int
rb_kcode() rb_kcode(void)
{ {
switch (reg_kcode) { switch (reg_kcode) {
case KCODE_EUC: case KCODE_EUC:
@ -1944,8 +1841,7 @@ rb_kcode()
} }
static int static int
rb_reg_get_kcode(re) rb_reg_get_kcode(VALUE re)
VALUE re;
{ {
switch (RBASIC(re)->flags & KCODE_MASK) { switch (RBASIC(re)->flags & KCODE_MASK) {
case KCODE_NONE: case KCODE_NONE:
@ -1962,8 +1858,7 @@ rb_reg_get_kcode(re)
} }
int int
rb_reg_options(re) rb_reg_options(VALUE re)
VALUE re;
{ {
int options; int options;
@ -1992,9 +1887,7 @@ rb_reg_options(re)
* Regexp.union(/dogs/, /cats/i) #=> /(?-mix:dogs)|(?i-mx:cats)/ * Regexp.union(/dogs/, /cats/i) #=> /(?-mix:dogs)|(?i-mx:cats)/
*/ */
static VALUE static VALUE
rb_reg_s_union(argc, argv) rb_reg_s_union(int argc, VALUE *argv)
int argc;
VALUE *argv;
{ {
if (argc == 0) { if (argc == 0) {
VALUE args[1]; VALUE args[1];
@ -2069,8 +1962,7 @@ rb_reg_s_union(argc, argv)
/* :nodoc: */ /* :nodoc: */
static VALUE static VALUE
rb_reg_init_copy(copy, re) rb_reg_init_copy(VALUE copy, VALUE re)
VALUE copy, re;
{ {
if (copy == re) return copy; if (copy == re) return copy;
rb_check_frozen(copy); rb_check_frozen(copy);
@ -2085,9 +1977,7 @@ rb_reg_init_copy(copy, re)
} }
VALUE VALUE
rb_reg_regsub(str, src, regs) rb_reg_regsub(VALUE str, VALUE src, struct re_registers *regs)
VALUE str, src;
struct re_registers *regs;
{ {
VALUE val = 0; VALUE val = 0;
char *p, *s, *e; char *p, *s, *e;
@ -2172,7 +2062,7 @@ rb_reg_regsub(str, src, regs)
} }
const char* const char*
rb_get_kcode() rb_get_kcode(void)
{ {
switch (reg_kcode) { switch (reg_kcode) {
case KCODE_SJIS: case KCODE_SJIS:
@ -2187,14 +2077,13 @@ rb_get_kcode()
} }
static VALUE static VALUE
kcode_getter() kcode_getter(void)
{ {
return rb_str_new2(rb_get_kcode()); return rb_str_new2(rb_get_kcode());
} }
void void
rb_set_kcode(code) rb_set_kcode(const char *code)
const char *code;
{ {
if (code == 0) goto set_no_conversion; if (code == 0) goto set_no_conversion;
@ -2227,23 +2116,20 @@ rb_set_kcode(code)
} }
static void static void
kcode_setter(val) kcode_setter(VALUE val)
VALUE val;
{ {
may_need_recompile = 1; may_need_recompile = 1;
rb_set_kcode(StringValuePtr(val)); rb_set_kcode(StringValuePtr(val));
} }
static VALUE static VALUE
ignorecase_getter() ignorecase_getter(void)
{ {
return ruby_ignorecase?Qtrue:Qfalse; return ruby_ignorecase?Qtrue:Qfalse;
} }
static void static void
ignorecase_setter(val, id) ignorecase_setter(VALUE val, ID id)
VALUE val;
ID id;
{ {
rb_warn("modifying %s is deprecated", rb_id2name(id)); rb_warn("modifying %s is deprecated", rb_id2name(id));
may_need_recompile = 1; may_need_recompile = 1;
@ -2251,7 +2137,7 @@ ignorecase_setter(val, id)
} }
static VALUE static VALUE
match_getter() match_getter(void)
{ {
VALUE match = rb_backref_get(); VALUE match = rb_backref_get();
@ -2261,8 +2147,7 @@ match_getter()
} }
static void static void
match_setter(val) match_setter(VALUE val)
VALUE val;
{ {
if (!NIL_P(val)) { if (!NIL_P(val)) {
Check_Type(val, T_MATCH); Check_Type(val, T_MATCH);
@ -2288,9 +2173,7 @@ match_setter(val)
*/ */
static VALUE static VALUE
rb_reg_s_last_match(argc, argv) rb_reg_s_last_match(int argc, VALUE *argv)
int argc;
VALUE *argv;
{ {
VALUE nth; VALUE nth;
@ -2312,7 +2195,7 @@ rb_reg_s_last_match(argc, argv)
*/ */
void void
Init_Regexp() Init_Regexp(void)
{ {
rb_eRegexpError = rb_define_class("RegexpError", rb_eStandardError); rb_eRegexpError = rb_define_class("RegexpError", rb_eStandardError);

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

@ -34,7 +34,7 @@ OnigAmbigType OnigDefaultAmbigFlag =
ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE); ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE);
extern OnigAmbigType extern OnigAmbigType
onig_get_default_ambig_flag() onig_get_default_ambig_flag(void)
{ {
return OnigDefaultAmbigFlag; return OnigDefaultAmbigFlag;
} }
@ -4959,7 +4959,7 @@ onig_new(regex_t** reg, const UChar* pattern, const UChar* pattern_end,
} }
extern int extern int
onig_init() onig_init(void)
{ {
if (onig_inited != 0) if (onig_inited != 0)
return 0; return 0;
@ -4981,9 +4981,9 @@ onig_init()
extern int extern int
onig_end() onig_end(void)
{ {
extern int onig_free_shared_cclass_table(); extern int onig_free_shared_cclass_table(void);
THREAD_ATOMIC_START; THREAD_ATOMIC_START;

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

@ -32,13 +32,13 @@
OnigEncoding OnigEncDefaultCharEncoding = ONIG_ENCODING_INIT_DEFAULT; OnigEncoding OnigEncDefaultCharEncoding = ONIG_ENCODING_INIT_DEFAULT;
extern int extern int
onigenc_init() onigenc_init(void)
{ {
return 0; return 0;
} }
extern OnigEncoding extern OnigEncoding
onigenc_get_default_encoding() onigenc_get_default_encoding(void)
{ {
return OnigEncDefaultCharEncoding; return OnigEncDefaultCharEncoding;
} }

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

@ -30,13 +30,7 @@
#include "regint.h" #include "regint.h"
#include <stdio.h> /* for vsnprintf() */ #include <stdio.h> /* for vsnprintf() */
#ifdef HAVE_STDARG_PROTOTYPES
#include <stdarg.h> #include <stdarg.h>
#define va_init_list(a,b) va_start(a,b)
#else
#include <varargs.h>
#define va_init_list(a,b) va_start(a)
#endif
extern char* extern char*
onig_error_code_to_format(int code) onig_error_code_to_format(int code)
@ -185,21 +179,14 @@ onig_error_code_to_format(int code)
#define MAX_ERROR_PAR_LEN 30 #define MAX_ERROR_PAR_LEN 30
extern int extern int
#ifdef HAVE_STDARG_PROTOTYPES
onig_error_code_to_str(UChar* s, int code, ...) onig_error_code_to_str(UChar* s, int code, ...)
#else
onig_error_code_to_str(s, code, va_alist)
UChar* s;
int code;
va_dcl
#endif
{ {
UChar *p, *q; UChar *p, *q;
OnigErrorInfo* einfo; OnigErrorInfo* einfo;
int len; int len;
va_list vargs; va_list vargs;
va_init_list(vargs, code); va_start(vargs, code);
switch (code) { switch (code) {
case ONIGERR_UNDEFINED_NAME_REFERENCE: case ONIGERR_UNDEFINED_NAME_REFERENCE:
@ -255,26 +242,15 @@ onig_error_code_to_str(s, code, va_alist)
void void
#ifdef HAVE_STDARG_PROTOTYPES
onig_snprintf_with_pattern(char buf[], int bufsize, OnigEncoding enc, onig_snprintf_with_pattern(char buf[], int bufsize, OnigEncoding enc,
char* pat, char* pat_end, char *fmt, ...) char* pat, char* pat_end, char *fmt, ...)
#else
onig_snprintf_with_pattern(buf, bufsize, enc, pat, pat_end, fmt, va_alist)
char buf[];
int bufsize;
OnigEncoding enc;
char* pat;
char* pat_end;
const char *fmt;
va_dcl
#endif
{ {
int n, need, len; int n, need, len;
UChar *p, *s, *bp; UChar *p, *s, *bp;
char bs[6]; char bs[6];
va_list args; va_list args;
va_init_list(args, fmt); va_start(args, fmt);
n = vsnprintf(buf, bufsize, fmt, args); n = vsnprintf(buf, bufsize, fmt, args);
va_end(args); va_end(args);

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

@ -227,7 +227,7 @@ onig_region_init(OnigRegion* region)
} }
extern OnigRegion* extern OnigRegion*
onig_region_new() onig_region_new(void)
{ {
OnigRegion* r; OnigRegion* r;

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

@ -1050,7 +1050,7 @@ onig_node_free(Node* node)
#ifdef USE_RECYCLE_NODE #ifdef USE_RECYCLE_NODE
extern int extern int
onig_free_node_list() onig_free_node_list(void)
{ {
FreeNode* n; FreeNode* n;
@ -1066,7 +1066,7 @@ onig_free_node_list()
#endif #endif
static Node* static Node*
node_new() node_new(void)
{ {
Node* node; Node* node;
@ -1094,7 +1094,7 @@ initialize_cclass(CClassNode* cc)
} }
static Node* static Node*
node_new_cclass() node_new_cclass(void)
{ {
Node* node = node_new(); Node* node = node_new();
CHECK_NULL_RETURN(node); CHECK_NULL_RETURN(node);
@ -1163,7 +1163,7 @@ node_new_ctype(int type)
} }
static Node* static Node*
node_new_anychar() node_new_anychar(void)
{ {
Node* node = node_new(); Node* node = node_new();
CHECK_NULL_RETURN(node); CHECK_NULL_RETURN(node);
@ -1434,7 +1434,7 @@ node_new_str_raw(UChar* s, UChar* end)
} }
static Node* static Node*
node_new_empty() node_new_empty(void)
{ {
return node_new_str(NULL, NULL); return node_new_str(NULL, NULL);
} }
@ -4660,7 +4660,7 @@ i_free_shared_class(type_cclass_key* key, Node* node, void* arg)
} }
extern int extern int
onig_free_shared_cclass_table() onig_free_shared_cclass_table(void)
{ {
if (IS_NOT_NULL(OnigTypeCClassTable)) { if (IS_NOT_NULL(OnigTypeCClassTable)) {
onig_st_foreach(OnigTypeCClassTable, i_free_shared_class, 0); onig_st_foreach(OnigTypeCClassTable, i_free_shared_class, 0);

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

@ -303,7 +303,7 @@ extern Node* onig_node_new_anchor P_((int type));
extern Node* onig_node_new_str P_((const UChar* s, const UChar* end)); extern Node* onig_node_new_str P_((const UChar* s, const UChar* end));
extern Node* onig_node_new_list P_((Node* left, Node* right)); extern Node* onig_node_new_list P_((Node* left, Node* right));
extern void onig_node_str_clear P_((Node* node)); extern void onig_node_str_clear P_((Node* node));
extern int onig_free_node_list(); extern int onig_free_node_list(void);
extern int onig_names_free P_((regex_t* reg)); extern int onig_names_free P_((regex_t* reg));
extern int onig_parse_make_tree P_((Node** root, const UChar* pattern, const UChar* end, regex_t* reg, ScanEnv* env)); extern int onig_parse_make_tree P_((Node** root, const UChar* pattern, const UChar* end, regex_t* reg, ScanEnv* env));

79
ruby.c
Просмотреть файл

@ -74,8 +74,7 @@ static int origargc;
static char **origargv; static char **origargv;
static void static void
usage(name) usage(const char *name)
const char *name;
{ {
/* This message really ought to be max 23 lines. /* This message really ought to be max 23 lines.
* Removed -h because the user already knows that option. Others? */ * Removed -h because the user already knows that option. Others? */
@ -119,9 +118,7 @@ extern VALUE rb_load_path;
#if defined _WIN32 || defined __CYGWIN__ || defined __DJGPP__ #if defined _WIN32 || defined __CYGWIN__ || defined __DJGPP__
static char * static char *
rubylib_mangle(s, l) rubylib_mangle(char *s, unsigned int l)
char *s;
unsigned int l;
{ {
static char *newp, *oldp; static char *newp, *oldp;
static int newl, oldl, notfound; static int newl, oldl, notfound;
@ -178,9 +175,7 @@ rubylib_mangle(s, l)
#endif #endif
void void
ruby_push_include(path, filter) ruby_push_include(const char *path, VALUE (*filter) (VALUE))
const char *path;
VALUE (*filter)_((VALUE));
{ {
const char sep = PATH_SEP_CHAR; const char sep = PATH_SEP_CHAR;
@ -216,8 +211,7 @@ ruby_push_include(path, filter)
} }
static VALUE static VALUE
identical_path(path) identical_path(VALUE path)
VALUE path;
{ {
return path; return path;
} }
@ -229,8 +223,7 @@ ruby_incpush(const char *path)
} }
static VALUE static VALUE
expand_include_path(path) expand_include_path(VALUE path)
VALUE path;
{ {
char *p = RSTRING(path)->ptr; char *p = RSTRING(path)->ptr;
if (!p) return path; if (!p) return path;
@ -250,12 +243,8 @@ ruby_incpush_expand(const char *path)
#endif #endif
#if defined DOSISH || defined __CYGWIN__ #if defined DOSISH || defined __CYGWIN__
static inline void translate_char _((char *, int, int));
static inline void static inline void
translate_char(p, from, to) translate_char(char *p, int from, int to)
char *p;
int from, to;
{ {
while (*p) { while (*p) {
if ((unsigned char)*p == from) if ((unsigned char)*p == from)
@ -270,7 +259,7 @@ translate_char(p, from, to)
#endif #endif
void void
ruby_init_loadpath() ruby_init_loadpath(void)
{ {
#if defined LOAD_RELATIVE #if defined LOAD_RELATIVE
char libpath[MAXPATHLEN+1]; char libpath[MAXPATHLEN+1];
@ -353,8 +342,7 @@ struct req_list {
static struct req_list req_list_head, *req_list_last = &req_list_head; static struct req_list req_list_head, *req_list_last = &req_list_head;
static void static void
add_modules(mod) add_modules(const char *mod)
const char *mod;
{ {
struct req_list *list; struct req_list *list;
@ -369,7 +357,7 @@ add_modules(mod)
extern void Init_ext _((void)); extern void Init_ext _((void));
static void static void
require_libraries() require_libraries(void)
{ {
extern NODE *ruby_eval_tree; extern NODE *ruby_eval_tree;
NODE *save[3]; NODE *save[3];
@ -404,7 +392,7 @@ require_libraries()
} }
static void static void
process_sflag() process_sflag(void)
{ {
if (sflag) { if (sflag) {
long n; long n;
@ -465,8 +453,7 @@ process_sflag()
static void proc_options _((int argc, char **argv)); static void proc_options _((int argc, char **argv));
static char* static char*
moreswitches(s) moreswitches(char *s)
char *s;
{ {
int argc; char *argv[3]; int argc; char *argv[3];
char *p = s; char *p = s;
@ -487,9 +474,7 @@ moreswitches(s)
NODE *ruby_eval_tree; NODE *ruby_eval_tree;
static void static void
proc_options(argc, argv) proc_options(int argc, char **argv)
int argc;
char **argv;
{ {
char *argv0 = argv[0]; char *argv0 = argv[0];
int do_search; int do_search;
@ -865,9 +850,7 @@ proc_options(argc, argv)
} }
static void static void
load_file(fname, script) load_file(const char *fname, int script)
const char *fname;
int script;
{ {
extern VALUE rb_stdin; extern VALUE rb_stdin;
VALUE parser; VALUE parser;
@ -994,14 +977,13 @@ load_file(fname, script)
} }
void void
rb_load_file(fname) rb_load_file(const char *fname)
const char *fname;
{ {
load_file(fname, 0); load_file(fname, 0);
} }
static void static void
load_stdin() load_stdin(void)
{ {
forbid_setid("program input from stdin"); forbid_setid("program input from stdin");
load_file("-", 1); load_file("-", 1);
@ -1039,9 +1021,7 @@ set_arg0space()
#endif #endif
static void static void
set_arg0(val, id) set_arg0(VALUE val, ID id)
VALUE val;
ID id;
{ {
char *s; char *s;
long i; long i;
@ -1115,8 +1095,7 @@ set_arg0(val, id)
} }
void void
ruby_script(name) ruby_script(const char *name)
const char *name;
{ {
if (name) { if (name) {
rb_progname = rb_tainted_str_new2(name); rb_progname = rb_tainted_str_new2(name);
@ -1127,7 +1106,7 @@ ruby_script(name)
static int uid, euid, gid, egid; static int uid, euid, gid, egid;
static void static void
init_ids() init_ids(void)
{ {
uid = (int)getuid(); uid = (int)getuid();
euid = (int)geteuid(); euid = (int)geteuid();
@ -1143,8 +1122,7 @@ init_ids()
} }
static void static void
forbid_setid(s) forbid_setid(const char *s)
const char *s;
{ {
if (euid != uid) if (euid != uid)
rb_raise(rb_eSecurityError, "no %s allowed while running setuid", s); rb_raise(rb_eSecurityError, "no %s allowed while running setuid", s);
@ -1155,18 +1133,13 @@ forbid_setid(s)
} }
static void static void
verbose_setter(val, id, variable) verbose_setter(VALUE val, ID id, VALUE *variable)
VALUE val;
ID id;
VALUE *variable;
{ {
ruby_verbose = RTEST(val) ? Qtrue : val; ruby_verbose = RTEST(val) ? Qtrue : val;
} }
static VALUE static VALUE
opt_W_getter(val, id) opt_W_getter(VALUE val, ID id)
VALUE val;
ID id;
{ {
if (ruby_verbose == Qnil) return INT2FIX(0); if (ruby_verbose == Qnil) return INT2FIX(0);
if (ruby_verbose == Qfalse) return INT2FIX(1); if (ruby_verbose == Qfalse) return INT2FIX(1);
@ -1175,7 +1148,7 @@ opt_W_getter(val, id)
} }
void void
ruby_prog_init() ruby_prog_init(void)
{ {
init_ids(); init_ids();
@ -1209,9 +1182,7 @@ ruby_prog_init()
} }
void void
ruby_set_argv(argc, argv) ruby_set_argv(int argc, char **argv)
int argc;
char **argv;
{ {
int i; int i;
@ -1232,9 +1203,7 @@ NODE *rb_parser_append_print _((NODE*));
NODE *rb_parser_while_loop _((NODE*, int, int)); NODE *rb_parser_while_loop _((NODE*, int, int));
void void
ruby_process_options(argc, argv) ruby_process_options(int argc, char **argv)
int argc;
char **argv;
{ {
origargc = argc; origargv = argv; origargc = argc; origargv = argv;

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

@ -169,8 +169,7 @@ static struct signals {
}; };
static int static int
signm2signo(nm) signm2signo(char *nm)
char *nm;
{ {
struct signals *sigs; struct signals *sigs;
@ -181,8 +180,7 @@ signm2signo(nm)
} }
static char* static char*
signo2signm(no) signo2signm(int no)
int no;
{ {
struct signals *sigs; struct signals *sigs;
@ -193,8 +191,7 @@ signo2signm(no)
} }
const char * const char *
ruby_signal_name(no) ruby_signal_name(int no)
int no;
{ {
return signo2signm(no); return signo2signm(no);
} }
@ -224,9 +221,7 @@ ruby_signal_name(no)
*/ */
VALUE VALUE
rb_f_kill(argc, argv) rb_f_kill(int argc, VALUE *argv)
int argc;
VALUE *argv;
{ {
int negative = 0; int negative = 0;
int sig; int sig;
@ -310,7 +305,7 @@ rb_atomic_t rb_trap_immediate;
int rb_prohibit_interrupt = 1; int rb_prohibit_interrupt = 1;
void void
rb_gc_mark_trap_list() rb_gc_mark_trap_list(void)
{ {
#ifndef MACOS_UNUSE_SIGNAL #ifndef MACOS_UNUSE_SIGNAL
int i; int i;
@ -382,9 +377,7 @@ posix_nativethread_signal(signum, handler)
#define ruby_signal(sig,handler) (rb_trap_accept_nativethreads[sig] = 0, signal((sig),(handler))) #define ruby_signal(sig,handler) (rb_trap_accept_nativethreads[sig] = 0, signal((sig),(handler)))
#ifdef HAVE_NATIVETHREAD #ifdef HAVE_NATIVETHREAD
static sighandler_t static sighandler_t
ruby_nativethread_signal(signum, handler) ruby_nativethread_signal(int signum, sighandler_t handler)
int signum;
sighandler_t handler;
{ {
sighandler_t old; sighandler_t old;
@ -395,10 +388,8 @@ ruby_nativethread_signal(signum, handler)
#endif #endif
#endif #endif
static void signal_exec _((int sig));
static void static void
signal_exec(sig) signal_exec(int sig)
int sig;
{ {
if (trap_list[sig].cmd == 0) { if (trap_list[sig].cmd == 0) {
switch (sig) { switch (sig) {
@ -433,8 +424,7 @@ signal_exec(sig)
} }
static void static void
sigsend_to_ruby_thread(sig) sigsend_to_ruby_thread(int sig)
int sig;
{ {
#ifdef HAVE_NATIVETHREAD_KILL #ifdef HAVE_NATIVETHREAD_KILL
# ifdef HAVE_SIGPROCMASK # ifdef HAVE_SIGPROCMASK
@ -457,8 +447,7 @@ sigsend_to_ruby_thread(sig)
static RETSIGTYPE sighandler _((int)); static RETSIGTYPE sighandler _((int));
static RETSIGTYPE static RETSIGTYPE
sighandler(sig) sighandler(int sig)
int sig;
{ {
#ifdef _WIN32 #ifdef _WIN32
#define IN_MAIN_CONTEXT(f, a) (rb_w32_main_context(a, f) ? (void)0 : f(a)) #define IN_MAIN_CONTEXT(f, a) (rb_w32_main_context(a, f) ? (void)0 : f(a))
@ -495,10 +484,8 @@ sighandler(sig)
} }
#ifdef SIGBUS #ifdef SIGBUS
static RETSIGTYPE sigbus _((int));
static RETSIGTYPE static RETSIGTYPE
sigbus(sig) sigbus(int sig)
int sig;
{ {
#if defined(HAVE_NATIVETHREAD) && defined(HAVE_NATIVETHREAD_KILL) #if defined(HAVE_NATIVETHREAD) && defined(HAVE_NATIVETHREAD_KILL)
if (!is_ruby_native_thread() && !rb_trap_accept_nativethreads[sig]) { if (!is_ruby_native_thread() && !rb_trap_accept_nativethreads[sig]) {
@ -512,10 +499,8 @@ sigbus(sig)
#endif #endif
#ifdef SIGSEGV #ifdef SIGSEGV
static RETSIGTYPE sigsegv _((int));
static RETSIGTYPE static RETSIGTYPE
sigsegv(sig) sigsegv(int sig)
int sig;
{ {
#if defined(HAVE_NATIVETHREAD) && defined(HAVE_NATIVETHREAD_KILL) #if defined(HAVE_NATIVETHREAD) && defined(HAVE_NATIVETHREAD_KILL)
if (!is_ruby_native_thread() && !rb_trap_accept_nativethreads[sig]) { if (!is_ruby_native_thread() && !rb_trap_accept_nativethreads[sig]) {
@ -529,17 +514,15 @@ sigsegv(sig)
#endif #endif
#ifdef SIGPIPE #ifdef SIGPIPE
static RETSIGTYPE sigpipe _((int));
static RETSIGTYPE static RETSIGTYPE
sigpipe(sig) sigpipe(int sig)
int sig;
{ {
/* do nothing */ /* do nothing */
} }
#endif #endif
void void
rb_trap_exit() rb_trap_exit(void)
{ {
#ifndef MACOS_UNUSE_SIGNAL #ifndef MACOS_UNUSE_SIGNAL
if (trap_list[0].cmd) { if (trap_list[0].cmd) {
@ -552,7 +535,7 @@ rb_trap_exit()
} }
void void
rb_trap_exec() rb_trap_exec(void)
{ {
#ifndef MACOS_UNUSE_SIGNAL #ifndef MACOS_UNUSE_SIGNAL
int i; int i;
@ -585,8 +568,7 @@ static int trap_last_mask;
# endif # endif
static VALUE static VALUE
trap(arg) trap(struct trap_arg *arg)
struct trap_arg *arg;
{ {
sighandler_t func, oldfunc; sighandler_t func, oldfunc;
VALUE command, tmp, oldcmd; VALUE command, tmp, oldcmd;
@ -740,7 +722,7 @@ trap_ensure(arg)
#endif #endif
void void
rb_trap_restore_mask() rb_trap_restore_mask(void)
{ {
#ifndef _WIN32 #ifndef _WIN32
# ifdef HAVE_SIGPROCMASK # ifdef HAVE_SIGPROCMASK
@ -780,9 +762,7 @@ rb_trap_restore_mask()
* Terminating: 27460 * Terminating: 27460
*/ */
static VALUE static VALUE
sig_trap(argc, argv) sig_trap(int argc, VALUE *argv)
int argc;
VALUE *argv;
{ {
struct trap_arg arg; struct trap_arg arg;
@ -827,7 +807,7 @@ sig_trap(argc, argv)
* Signal.list #=> {"ABRT"=>6, "ALRM"=>14, "BUS"=>7, "CHLD"=>17, "CLD"=>17, "CONT"=>18, "FPE"=>8, "HUP"=>1, "ILL"=>4, "INT"=>2, "IO"=>29, "IOT"=>6, "KILL"=>9, "PIPE"=>13, "POLL"=>29, "PROF"=>27, "PWR"=>30, "QUIT"=>3, "SEGV"=>11, "STOP"=>19, "SYS"=>31, "TERM"=>15, "TRAP"=>5, "TSTP"=>20, "TTIN"=>21, "TTOU"=>22, "URG"=>23, "USR1"=>10, "USR2"=>12, "VTALRM"=>26, "WINCH"=>28, "XCPU"=>24, "XFSZ"=>25} * Signal.list #=> {"ABRT"=>6, "ALRM"=>14, "BUS"=>7, "CHLD"=>17, "CLD"=>17, "CONT"=>18, "FPE"=>8, "HUP"=>1, "ILL"=>4, "INT"=>2, "IO"=>29, "IOT"=>6, "KILL"=>9, "PIPE"=>13, "POLL"=>29, "PROF"=>27, "PWR"=>30, "QUIT"=>3, "SEGV"=>11, "STOP"=>19, "SYS"=>31, "TERM"=>15, "TRAP"=>5, "TSTP"=>20, "TTIN"=>21, "TTOU"=>22, "URG"=>23, "USR1"=>10, "USR2"=>12, "VTALRM"=>26, "WINCH"=>28, "XCPU"=>24, "XFSZ"=>25}
*/ */
static VALUE static VALUE
sig_list() sig_list(void)
{ {
VALUE h = rb_hash_new(); VALUE h = rb_hash_new();
struct signals *sigs; struct signals *sigs;
@ -839,9 +819,7 @@ sig_list()
} }
static void static void
install_sighandler(signum, handler) install_sighandler(int signum, sighandler_t handler)
int signum;
sighandler_t handler;
{ {
sighandler_t old; sighandler_t old;
@ -853,9 +831,7 @@ install_sighandler(signum, handler)
#ifdef HAVE_NATIVETHREAD #ifdef HAVE_NATIVETHREAD
static void static void
install_nativethread_sighandler(signum, handler) install_nativethread_sighandler(int signum, sighandler_t handler)
int signum;
sighandler_t handler;
{ {
sighandler_t old; sighandler_t old;
int old_st; int old_st;
@ -873,8 +849,7 @@ install_nativethread_sighandler(signum, handler)
#endif #endif
static void static void
init_sigchld(sig) init_sigchld(int sig)
int sig;
{ {
sighandler_t oldfunc; sighandler_t oldfunc;
#ifndef _WIN32 #ifndef _WIN32
@ -952,7 +927,7 @@ init_sigchld(sig)
* systems; in particular signal delivery may not always be reliable. * systems; in particular signal delivery may not always be reliable.
*/ */
void void
Init_signal() Init_signal(void)
{ {
#ifndef MACOS_UNUSE_SIGNAL #ifndef MACOS_UNUSE_SIGNAL
VALUE mSignal = rb_define_module("Signal"); VALUE mSignal = rb_define_module("Signal");

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

@ -15,22 +15,14 @@
#include "ruby.h" #include "ruby.h"
#include <ctype.h> #include <ctype.h>
#include <math.h> #include <math.h>
#ifdef HAVE_STDARG_PROTOTYPES
#include <stdarg.h> #include <stdarg.h>
#define va_init_list(a,b) va_start(a,b)
#else
#include <varargs.h>
#define va_init_list(a,b) va_start(a)
#endif
#define BIT_DIGITS(N) (((N)*146)/485 + 1) /* log2(10) =~ 146/485 */ #define BIT_DIGITS(N) (((N)*146)/485 + 1) /* log2(10) =~ 146/485 */
static void fmt_setup _((char*,int,int,int,int)); static void fmt_setup _((char*,int,int,int,int));
static char* static char*
remove_sign_bits(str, base) remove_sign_bits(char *str, int base)
char *str;
int base;
{ {
char *s, *t; char *s, *t;
@ -61,9 +53,7 @@ remove_sign_bits(str, base)
} }
static char static char
sign_bits(base, p) sign_bits(int base, const char *p)
int base;
const char *p;
{ {
char c = '.'; char c = '.';
@ -241,18 +231,13 @@ sign_bits(base, p)
*/ */
VALUE VALUE
rb_f_sprintf(argc, argv) rb_f_sprintf(int argc, const VALUE *argv)
int argc;
const VALUE *argv;
{ {
return rb_str_format(argc - 1, argv + 1, GETNTHARG(0)); return rb_str_format(argc - 1, argv + 1, GETNTHARG(0));
} }
VALUE VALUE
rb_str_format(argc, argv, fmt) rb_str_format(int argc, const VALUE *argv, VALUE fmt)
int argc;
const VALUE *argv;
VALUE fmt;
{ {
const char *p, *end; const char *p, *end;
char *buf; char *buf;
@ -805,10 +790,7 @@ rb_str_format(argc, argv, fmt)
} }
static void static void
fmt_setup(buf, c, flags, width, prec) fmt_setup(char *buf, int c, int flags, int width, int prec)
char *buf;
int c;
int flags, width, prec;
{ {
*buf++ = '%'; *buf++ = '%';
if (flags & FSHARP) *buf++ = '#'; if (flags & FSHARP) *buf++ = '#';
@ -852,9 +834,7 @@ fmt_setup(buf, c, flags, width, prec)
#include "missing/vsnprintf.c" #include "missing/vsnprintf.c"
static int static int
ruby__sfvwrite(fp, uio) ruby__sfvwrite(register rb_printf_buffer *fp, register struct __suio *uio)
register rb_printf_buffer *fp;
register struct __suio *uio;
{ {
struct __siov *iov; struct __siov *iov;
VALUE result = (VALUE)fp->_bf._base; VALUE result = (VALUE)fp->_bf._base;
@ -880,9 +860,7 @@ ruby__sfvwrite(fp, uio)
} }
VALUE VALUE
rb_vsprintf(fmt, ap) rb_vsprintf(const char *fmt, va_list ap)
const char *fmt;
va_list ap;
{ {
rb_printf_buffer f; rb_printf_buffer f;
VALUE result; VALUE result;
@ -903,18 +881,12 @@ rb_vsprintf(fmt, ap)
} }
VALUE VALUE
#ifdef HAVE_STDARG_PROTOTYPES
rb_sprintf(const char *format, ...) rb_sprintf(const char *format, ...)
#else
rb_sprintf(format, va_alist)
const char *format;
va_dcl
#endif
{ {
VALUE result; VALUE result;
va_list ap; va_list ap;
va_init_list(ap, format); va_start(ap, format);
result = rb_vsprintf(format, ap); result = rb_vsprintf(format, ap);
va_end(ap); va_end(ap);

72
st.c
Просмотреть файл

@ -117,8 +117,7 @@ static long primes[] = {
}; };
static int static int
new_size(size) new_size(int size)
int size;
{ {
int i; int i;
@ -155,9 +154,7 @@ stat_col()
#endif #endif
st_table* st_table*
st_init_table_with_size(type, size) st_init_table_with_size(struct st_hash_type *type, int size)
struct st_hash_type *type;
int size;
{ {
st_table *tbl; st_table *tbl;
@ -180,8 +177,7 @@ st_init_table_with_size(type, size)
} }
st_table* st_table*
st_init_table(type) st_init_table(struct st_hash_type *type)
struct st_hash_type *type;
{ {
return st_init_table_with_size(type, 0); return st_init_table_with_size(type, 0);
} }
@ -193,8 +189,7 @@ st_init_numtable(void)
} }
st_table* st_table*
st_init_numtable_with_size(size) st_init_numtable_with_size(int size)
int size;
{ {
return st_init_table_with_size(&type_numhash, size); return st_init_table_with_size(&type_numhash, size);
} }
@ -206,15 +201,13 @@ st_init_strtable(void)
} }
st_table* st_table*
st_init_strtable_with_size(size) st_init_strtable_with_size(int size)
int size;
{ {
return st_init_table_with_size(&type_strhash, size); return st_init_table_with_size(&type_strhash, size);
} }
void void
st_free_table(table) st_free_table(st_table *table)
st_table *table;
{ {
register st_table_entry *ptr, *next; register st_table_entry *ptr, *next;
int i; int i;
@ -253,10 +246,7 @@ st_free_table(table)
} while (0) } while (0)
int int
st_lookup(table, key, value) st_lookup(st_table *table, register st_data_t key, st_data_t *value)
st_table *table;
register st_data_t key;
st_data_t *value;
{ {
unsigned int hash_val, bin_pos; unsigned int hash_val, bin_pos;
register st_table_entry *ptr; register st_table_entry *ptr;
@ -292,10 +282,7 @@ do {\
} while (0) } while (0)
int int
st_insert(table, key, value) st_insert(register st_table *table, register st_data_t key, st_data_t value)
register st_table *table;
register st_data_t key;
st_data_t value;
{ {
unsigned int hash_val, bin_pos; unsigned int hash_val, bin_pos;
register st_table_entry *ptr; register st_table_entry *ptr;
@ -314,10 +301,7 @@ st_insert(table, key, value)
} }
void void
st_add_direct(table, key, value) st_add_direct(st_table *table, st_data_t key, st_data_t value)
st_table *table;
st_data_t key;
st_data_t value;
{ {
unsigned int hash_val, bin_pos; unsigned int hash_val, bin_pos;
@ -327,8 +311,7 @@ st_add_direct(table, key, value)
} }
static void static void
rehash(table) rehash(register st_table *table)
register st_table *table;
{ {
register st_table_entry *ptr, *next, **new_bins; register st_table_entry *ptr, *next, **new_bins;
int i, old_num_bins = table->num_bins, new_num_bins; int i, old_num_bins = table->num_bins, new_num_bins;
@ -353,8 +336,7 @@ rehash(table)
} }
st_table* st_table*
st_copy(old_table) st_copy(st_table *old_table)
st_table *old_table;
{ {
st_table *new_table; st_table *new_table;
st_table_entry *ptr, *entry; st_table_entry *ptr, *entry;
@ -394,10 +376,7 @@ st_copy(old_table)
} }
int int
st_delete(table, key, value) st_delete(register st_table *table, register st_data_t *key, st_data_t *value)
register st_table *table;
register st_data_t *key;
st_data_t *value;
{ {
unsigned int hash_val; unsigned int hash_val;
st_table_entry *tmp; st_table_entry *tmp;
@ -436,11 +415,7 @@ st_delete(table, key, value)
} }
int int
st_delete_safe(table, key, value, never) st_delete_safe(register st_table *table, register st_data_t *key, st_data_t *value, st_data_t never)
register st_table *table;
register st_data_t *key;
st_data_t *value;
st_data_t never;
{ {
unsigned int hash_val; unsigned int hash_val;
register st_table_entry *ptr; register st_table_entry *ptr;
@ -467,17 +442,14 @@ st_delete_safe(table, key, value, never)
} }
static int static int
delete_never(key, value, never) delete_never(st_data_t key, st_data_t value, st_data_t never)
st_data_t key, value, never;
{ {
if (value == never) return ST_DELETE; if (value == never) return ST_DELETE;
return ST_CONTINUE; return ST_CONTINUE;
} }
void void
st_cleanup_safe(table, never) st_cleanup_safe(st_table *table, st_data_t never)
st_table *table;
st_data_t never;
{ {
int num_entries = table->num_entries; int num_entries = table->num_entries;
@ -486,10 +458,7 @@ st_cleanup_safe(table, never)
} }
int int
st_foreach(table, func, arg) st_foreach(st_table *table, int (*func) (/* ??? */), st_data_t arg)
st_table *table;
int (*func)();
st_data_t arg;
{ {
st_table_entry *ptr, *last, *tmp; st_table_entry *ptr, *last, *tmp;
enum st_retval retval; enum st_retval retval;
@ -536,8 +505,7 @@ st_foreach(table, func, arg)
} }
static int static int
strhash(string) strhash(register const char *string)
register const char *string;
{ {
register int c; register int c;
@ -575,15 +543,13 @@ strhash(string)
} }
static int static int
numcmp(x, y) numcmp(long x, long y)
long x, y;
{ {
return x != y; return x != y;
} }
static int static int
numhash(n) numhash(long n)
long n;
{ {
return n; return n;
} }

547
string.c

Разница между файлами не показана из-за своего большого размера Загрузить разницу

150
struct.c
Просмотреть файл

@ -17,9 +17,7 @@ VALUE rb_cStruct;
static VALUE struct_alloc _((VALUE)); static VALUE struct_alloc _((VALUE));
VALUE VALUE
rb_struct_iv_get(c, name) rb_struct_iv_get(VALUE c, char *name)
VALUE c;
char *name;
{ {
ID id; ID id;
@ -34,8 +32,7 @@ rb_struct_iv_get(c, name)
} }
VALUE VALUE
rb_struct_s_members(klass) rb_struct_s_members(VALUE klass)
VALUE klass;
{ {
VALUE members = rb_struct_iv_get(klass, "__members__"); VALUE members = rb_struct_iv_get(klass, "__members__");
@ -46,8 +43,7 @@ rb_struct_s_members(klass)
} }
VALUE VALUE
rb_struct_members(s) rb_struct_members(VALUE s)
VALUE s;
{ {
VALUE members = rb_struct_s_members(rb_obj_class(s)); VALUE members = rb_struct_s_members(rb_obj_class(s));
@ -59,8 +55,7 @@ rb_struct_members(s)
} }
static VALUE static VALUE
rb_struct_s_members_m(klass) rb_struct_s_members_m(VALUE klass)
VALUE klass;
{ {
VALUE members, ary; VALUE members, ary;
VALUE *p, *pend; VALUE *p, *pend;
@ -89,16 +84,13 @@ rb_struct_s_members_m(klass)
*/ */
static VALUE static VALUE
rb_struct_members_m(obj) rb_struct_members_m(VALUE obj)
VALUE obj;
{ {
return rb_struct_s_members_m(rb_obj_class(obj)); return rb_struct_s_members_m(rb_obj_class(obj));
} }
VALUE VALUE
rb_struct_getmember(obj, id) rb_struct_getmember(VALUE obj, ID id)
VALUE obj;
ID id;
{ {
VALUE members, slot; VALUE members, slot;
long i; long i;
@ -115,22 +107,21 @@ rb_struct_getmember(obj, id)
} }
static VALUE static VALUE
rb_struct_ref(obj) rb_struct_ref(VALUE obj)
VALUE obj;
{ {
return rb_struct_getmember(obj, rb_frame_this_func()); return rb_struct_getmember(obj, rb_frame_this_func());
} }
static VALUE rb_struct_ref0(obj) VALUE obj; {return RSTRUCT(obj)->ptr[0];} static VALUE rb_struct_ref0(VALUE obj) {return RSTRUCT(obj)->ptr[0];}
static VALUE rb_struct_ref1(obj) VALUE obj; {return RSTRUCT(obj)->ptr[1];} static VALUE rb_struct_ref1(VALUE obj) {return RSTRUCT(obj)->ptr[1];}
static VALUE rb_struct_ref2(obj) VALUE obj; {return RSTRUCT(obj)->ptr[2];} static VALUE rb_struct_ref2(VALUE obj) {return RSTRUCT(obj)->ptr[2];}
static VALUE rb_struct_ref3(obj) VALUE obj; {return RSTRUCT(obj)->ptr[3];} static VALUE rb_struct_ref3(VALUE obj) {return RSTRUCT(obj)->ptr[3];}
static VALUE rb_struct_ref4(obj) VALUE obj; {return RSTRUCT(obj)->ptr[4];} static VALUE rb_struct_ref4(VALUE obj) {return RSTRUCT(obj)->ptr[4];}
static VALUE rb_struct_ref5(obj) VALUE obj; {return RSTRUCT(obj)->ptr[5];} static VALUE rb_struct_ref5(VALUE obj) {return RSTRUCT(obj)->ptr[5];}
static VALUE rb_struct_ref6(obj) VALUE obj; {return RSTRUCT(obj)->ptr[6];} static VALUE rb_struct_ref6(VALUE obj) {return RSTRUCT(obj)->ptr[6];}
static VALUE rb_struct_ref7(obj) VALUE obj; {return RSTRUCT(obj)->ptr[7];} static VALUE rb_struct_ref7(VALUE obj) {return RSTRUCT(obj)->ptr[7];}
static VALUE rb_struct_ref8(obj) VALUE obj; {return RSTRUCT(obj)->ptr[8];} static VALUE rb_struct_ref8(VALUE obj) {return RSTRUCT(obj)->ptr[8];}
static VALUE rb_struct_ref9(obj) VALUE obj; {return RSTRUCT(obj)->ptr[9];} static VALUE rb_struct_ref9(VALUE obj) {return RSTRUCT(obj)->ptr[9];}
#define N_REF_FUNC (sizeof(ref_func) / sizeof(VALUE (*)())) #define N_REF_FUNC (sizeof(ref_func) / sizeof(VALUE (*)()))
@ -148,8 +139,7 @@ static VALUE (*ref_func[])() = {
}; };
static void static void
rb_struct_modify(s) rb_struct_modify(VALUE s)
VALUE s;
{ {
if (OBJ_FROZEN(s)) rb_error_frozen("Struct"); if (OBJ_FROZEN(s)) rb_error_frozen("Struct");
if (!OBJ_TAINTED(s) && rb_safe_level() >= 4) if (!OBJ_TAINTED(s) && rb_safe_level() >= 4)
@ -157,8 +147,7 @@ rb_struct_modify(s)
} }
static VALUE static VALUE
rb_struct_set(obj, val) rb_struct_set(VALUE obj, VALUE val)
VALUE obj, val;
{ {
VALUE members, slot; VALUE members, slot;
long i; long i;
@ -177,8 +166,7 @@ rb_struct_set(obj, val)
} }
static VALUE static VALUE
make_struct(name, members, klass) make_struct(VALUE name, VALUE members, VALUE klass)
VALUE name, members, klass;
{ {
VALUE nstr; VALUE nstr;
ID id; ID id;
@ -226,22 +214,10 @@ make_struct(name, members, klass)
return nstr; return nstr;
} }
#ifdef HAVE_STDARG_PROTOTYPES
#include <stdarg.h> #include <stdarg.h>
#define va_init_list(a,b) va_start(a,b)
#else
#include <varargs.h>
#define va_init_list(a,b) va_start(a)
#endif
VALUE VALUE
#ifdef HAVE_STDARG_PROTOTYPES
rb_struct_define(const char *name, ...) rb_struct_define(const char *name, ...)
#else
rb_struct_define(name, va_alist)
const char *name;
va_dcl
#endif
{ {
va_list ar; va_list ar;
VALUE nm, ary; VALUE nm, ary;
@ -251,7 +227,7 @@ rb_struct_define(name, va_alist)
else nm = rb_str_new2(name); else nm = rb_str_new2(name);
ary = rb_ary_new(); ary = rb_ary_new();
va_init_list(ar, name); va_start(ar, name);
while (mem = va_arg(ar, char*)) { while (mem = va_arg(ar, char*)) {
ID slot = rb_intern(mem); ID slot = rb_intern(mem);
rb_ary_push(ary, ID2SYM(slot)); rb_ary_push(ary, ID2SYM(slot));
@ -296,10 +272,7 @@ rb_struct_define(name, va_alist)
*/ */
static VALUE static VALUE
rb_struct_s_def(argc, argv, klass) rb_struct_s_def(int argc, VALUE *argv, VALUE klass)
int argc;
VALUE *argv;
VALUE klass;
{ {
VALUE name, rest; VALUE name, rest;
long i; long i;
@ -332,8 +305,7 @@ rb_struct_s_def(argc, argv, klass)
*/ */
static VALUE static VALUE
rb_struct_initialize(self, values) rb_struct_initialize(VALUE self, VALUE values)
VALUE self, values;
{ {
VALUE klass = rb_obj_class(self); VALUE klass = rb_obj_class(self);
VALUE size; VALUE size;
@ -354,8 +326,7 @@ rb_struct_initialize(self, values)
} }
static VALUE static VALUE
struct_alloc(klass) struct_alloc(VALUE klass)
VALUE klass;
{ {
VALUE size; VALUE size;
long n; long n;
@ -373,20 +344,13 @@ struct_alloc(klass)
} }
VALUE VALUE
rb_struct_alloc(klass, values) rb_struct_alloc(VALUE klass, VALUE values)
VALUE klass, values;
{ {
return rb_class_new_instance(RARRAY(values)->len, RARRAY(values)->ptr, klass); return rb_class_new_instance(RARRAY(values)->len, RARRAY(values)->ptr, klass);
} }
VALUE VALUE
#ifdef HAVE_STDARG_PROTOTYPES
rb_struct_new(VALUE klass, ...) rb_struct_new(VALUE klass, ...)
#else
rb_struct_new(klass, va_alist)
VALUE klass;
va_dcl
#endif
{ {
VALUE sz, *mem; VALUE sz, *mem;
long size, i; long size, i;
@ -395,7 +359,7 @@ rb_struct_new(klass, va_alist)
sz = rb_struct_iv_get(klass, "__size__"); sz = rb_struct_iv_get(klass, "__size__");
size = FIX2LONG(sz); size = FIX2LONG(sz);
mem = ALLOCA_N(VALUE, size); mem = ALLOCA_N(VALUE, size);
va_init_list(args, klass); va_start(args, klass);
for (i=0; i<size; i++) { for (i=0; i<size; i++) {
mem[i] = va_arg(args, VALUE); mem[i] = va_arg(args, VALUE);
} }
@ -423,8 +387,7 @@ rb_struct_new(klass, va_alist)
*/ */
static VALUE static VALUE
rb_struct_each(s) rb_struct_each(VALUE s)
VALUE s;
{ {
long i; long i;
@ -454,8 +417,7 @@ rb_struct_each(s)
*/ */
static VALUE static VALUE
rb_struct_each_pair(s) rb_struct_each_pair(VALUE s)
VALUE s;
{ {
VALUE members; VALUE members;
long i; long i;
@ -469,9 +431,7 @@ rb_struct_each_pair(s)
} }
static VALUE static VALUE
inspect_struct(s, dummy, recur) inspect_struct(VALUE s, VALUE dummy, int recur)
VALUE s, dummy;
int recur;
{ {
char *cname = rb_class2name(rb_obj_class(s)); char *cname = rb_class2name(rb_obj_class(s));
VALUE str, members; VALUE str, members;
@ -518,8 +478,7 @@ inspect_struct(s, dummy, recur)
*/ */
static VALUE static VALUE
rb_struct_inspect(s) rb_struct_inspect(VALUE s)
VALUE s;
{ {
return rb_exec_recursive(inspect_struct, s, 0); return rb_exec_recursive(inspect_struct, s, 0);
} }
@ -537,16 +496,14 @@ rb_struct_inspect(s)
*/ */
static VALUE static VALUE
rb_struct_to_a(s) rb_struct_to_a(VALUE s)
VALUE s;
{ {
return rb_ary_new4(RSTRUCT(s)->len, RSTRUCT(s)->ptr); return rb_ary_new4(RSTRUCT(s)->len, RSTRUCT(s)->ptr);
} }
/* :nodoc: */ /* :nodoc: */
static VALUE static VALUE
rb_struct_init_copy(copy, s) rb_struct_init_copy(VALUE copy, VALUE s)
VALUE copy, s;
{ {
if (copy == s) return copy; if (copy == s) return copy;
rb_check_frozen(copy); rb_check_frozen(copy);
@ -561,9 +518,7 @@ rb_struct_init_copy(copy, s)
} }
static VALUE static VALUE
rb_struct_aref_id(s, id) rb_struct_aref_id(VALUE s, ID id)
VALUE s;
ID id;
{ {
VALUE members; VALUE members;
long i, len; long i, len;
@ -599,8 +554,7 @@ rb_struct_aref_id(s, id)
*/ */
VALUE VALUE
rb_struct_aref(s, idx) rb_struct_aref(VALUE s, VALUE idx)
VALUE s, idx;
{ {
long i; long i;
@ -620,9 +574,7 @@ rb_struct_aref(s, idx)
} }
static VALUE static VALUE
rb_struct_aset_id(s, id, val) rb_struct_aset_id(VALUE s, ID id, VALUE val)
VALUE s, val;
ID id;
{ {
VALUE members; VALUE members;
long i, len; long i, len;
@ -665,8 +617,7 @@ rb_struct_aset_id(s, id, val)
*/ */
VALUE VALUE
rb_struct_aset(s, idx, val) rb_struct_aset(VALUE s, VALUE idx, VALUE val)
VALUE s, idx, val;
{ {
long i; long i;
@ -688,11 +639,8 @@ rb_struct_aset(s, idx, val)
return RSTRUCT(s)->ptr[i] = val; return RSTRUCT(s)->ptr[i] = val;
} }
static VALUE struct_entry _((VALUE, long));
static VALUE static VALUE
struct_entry(s, n) struct_entry(VALUE s, long n)
VALUE s;
long n;
{ {
return rb_struct_aref(s, LONG2NUM(n)); return rb_struct_aref(s, LONG2NUM(n));
} }
@ -714,10 +662,7 @@ struct_entry(s, n)
*/ */
static VALUE static VALUE
rb_struct_values_at(argc, argv, s) rb_struct_values_at(int argc, VALUE *argv, VALUE s)
int argc;
VALUE *argv;
VALUE s;
{ {
return rb_get_values_at(s, RSTRUCT(s)->len, argc, argv, struct_entry); return rb_get_values_at(s, RSTRUCT(s)->len, argc, argv, struct_entry);
} }
@ -743,10 +688,7 @@ rb_struct_values_at(argc, argv, s)
*/ */
static VALUE static VALUE
rb_struct_select(argc, argv, s) rb_struct_select(int argc, VALUE *argv, VALUE s)
int argc;
VALUE *argv;
VALUE s;
{ {
VALUE result; VALUE result;
long i; long i;
@ -782,8 +724,7 @@ rb_struct_select(argc, argv, s)
*/ */
static VALUE static VALUE
rb_struct_equal(s, s2) rb_struct_equal(VALUE s, VALUE s2)
VALUE s, s2;
{ {
long i; long i;
@ -808,8 +749,7 @@ rb_struct_equal(s, s2)
*/ */
static VALUE static VALUE
rb_struct_hash(s) rb_struct_hash(VALUE s)
VALUE s;
{ {
long i, h; long i, h;
VALUE n; VALUE n;
@ -832,8 +772,7 @@ rb_struct_hash(s)
*/ */
static VALUE static VALUE
rb_struct_eql(s, s2) rb_struct_eql(VALUE s, VALUE s2)
VALUE s, s2;
{ {
long i; long i;
@ -863,8 +802,7 @@ rb_struct_eql(s, s2)
*/ */
static VALUE static VALUE
rb_struct_size(s) rb_struct_size(VALUE s)
VALUE s;
{ {
return LONG2FIX(RSTRUCT(s)->len); return LONG2FIX(RSTRUCT(s)->len);
} }
@ -885,7 +823,7 @@ rb_struct_size(s)
* <code>Symbol</code> (such as <code>:name</code>). * <code>Symbol</code> (such as <code>:name</code>).
*/ */
void void
Init_Struct() Init_Struct(void)
{ {
rb_cStruct = rb_define_class("Struct", rb_cObject); rb_cStruct = rb_define_class("Struct", rb_cObject);
rb_include_module(rb_cStruct, rb_mEnumerable); rb_include_module(rb_cStruct, rb_mEnumerable);

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

@ -32,19 +32,14 @@ struct time_object {
#define GetTimeval(obj, tobj) \ #define GetTimeval(obj, tobj) \
Data_Get_Struct(obj, struct time_object, tobj) Data_Get_Struct(obj, struct time_object, tobj)
static void time_free _((void *));
static void static void
time_free(tobj) time_free(void *tobj)
void *tobj;
{ {
if (tobj) free(tobj); if (tobj) free(tobj);
} }
static VALUE time_s_alloc _((VALUE));
static VALUE static VALUE
time_s_alloc(klass) time_s_alloc(VALUE klass)
VALUE klass;
{ {
VALUE obj; VALUE obj;
struct time_object *tobj; struct time_object *tobj;
@ -58,8 +53,7 @@ time_s_alloc(klass)
} }
static void static void
time_modify(time) time_modify(VALUE time)
VALUE time;
{ {
rb_check_frozen(time); rb_check_frozen(time);
if (!OBJ_TAINTED(time) && rb_safe_level() >= 4) if (!OBJ_TAINTED(time) && rb_safe_level() >= 4)
@ -91,8 +85,7 @@ time_modify(time)
*/ */
static VALUE static VALUE
time_init(time) time_init(VALUE time)
VALUE time;
{ {
struct time_object *tobj; struct time_object *tobj;
@ -112,8 +105,7 @@ time_init(time)
#define NMOD(x,y) ((y)-(-((x)+1)%(y))-1) #define NMOD(x,y) ((y)-(-((x)+1)%(y))-1)
void void
time_overflow_p(secp, usecp) time_overflow_p(time_t *secp, time_t *usecp)
time_t *secp, *usecp;
{ {
time_t tmp, sec = *secp, usec = *usecp; time_t tmp, sec = *secp, usec = *usecp;
@ -142,9 +134,7 @@ time_overflow_p(secp, usecp)
} }
static VALUE static VALUE
time_new_internal(klass, sec, usec) time_new_internal(VALUE klass, time_t sec, time_t usec)
VALUE klass;
time_t sec, usec;
{ {
VALUE time = time_s_alloc(klass); VALUE time = time_s_alloc(klass);
struct time_object *tobj; struct time_object *tobj;
@ -158,16 +148,13 @@ time_new_internal(klass, sec, usec)
} }
VALUE VALUE
rb_time_new(sec, usec) rb_time_new(time_t sec, time_t usec)
time_t sec, usec;
{ {
return time_new_internal(rb_cTime, sec, usec); return time_new_internal(rb_cTime, sec, usec);
} }
static struct timeval static struct timeval
time_timeval(time, interval) time_timeval(VALUE time, int interval)
VALUE time;
int interval;
{ {
struct timeval t; struct timeval t;
char *tstr = interval ? "time interval" : "time"; char *tstr = interval ? "time interval" : "time";
@ -215,15 +202,13 @@ time_timeval(time, interval)
} }
struct timeval struct timeval
rb_time_interval(time) rb_time_interval(VALUE time)
VALUE time;
{ {
return time_timeval(time, Qtrue); return time_timeval(time, Qtrue);
} }
struct timeval struct timeval
rb_time_timeval(time) rb_time_timeval(VALUE time)
VALUE time;
{ {
struct time_object *tobj; struct time_object *tobj;
struct timeval t; struct timeval t;
@ -252,10 +237,7 @@ rb_time_timeval(time)
*/ */
static VALUE static VALUE
time_s_at(argc, argv, klass) time_s_at(int argc, VALUE *argv, VALUE klass)
int argc;
VALUE *argv;
VALUE klass;
{ {
struct timeval tv; struct timeval tv;
VALUE time, t; VALUE time, t;
@ -284,8 +266,7 @@ static char *months [12] = {
}; };
static long static long
obj2long(obj) obj2long(VALUE obj)
VALUE obj;
{ {
if (TYPE(obj) == T_STRING) { if (TYPE(obj) == T_STRING) {
obj = rb_str_to_inum(obj, 10, Qfalse); obj = rb_str_to_inum(obj, 10, Qfalse);
@ -295,11 +276,7 @@ obj2long(obj)
} }
static void static void
time_arg(argc, argv, tm, usec) time_arg(int argc, VALUE *argv, struct tm *tm, time_t *usec)
int argc;
VALUE *argv;
struct tm *tm;
time_t *usec;
{ {
VALUE v[8]; VALUE v[8];
int i; int i;
@ -401,8 +378,7 @@ static VALUE time_localtime _((VALUE));
static VALUE time_get_tm _((VALUE, int)); static VALUE time_get_tm _((VALUE, int));
static int static int
leap_year_p(y) leap_year_p(long y)
long y;
{ {
return ((y % 4 == 0) && (y % 100 != 0)) || (y % 400 == 0); return ((y % 4 == 0) && (y % 100 != 0)) || (y % 400 == 0);
} }
@ -410,8 +386,7 @@ leap_year_p(y)
#define DIV(n,d) ((n)<0 ? NDIV((n),(d)) : (n)/(d)) #define DIV(n,d) ((n)<0 ? NDIV((n),(d)) : (n)/(d))
static time_t static time_t
timegm_noleapsecond(tm) timegm_noleapsecond(struct tm *tm)
struct tm *tm;
{ {
static int common_year_yday_offset[] = { static int common_year_yday_offset[] = {
-1, -1,
@ -466,9 +441,7 @@ timegm_noleapsecond(tm)
} }
static int static int
tmcmp(a, b) tmcmp(struct tm *a, struct tm *b)
struct tm *a;
struct tm *b;
{ {
if (a->tm_year != b->tm_year) if (a->tm_year != b->tm_year)
return a->tm_year < b->tm_year ? -1 : 1; return a->tm_year < b->tm_year ? -1 : 1;
@ -487,9 +460,7 @@ tmcmp(a, b)
} }
static time_t static time_t
search_time_t(tptr, utc_p) search_time_t(struct tm *tptr, int utc_p)
struct tm *tptr;
int utc_p;
{ {
time_t guess, guess_lo, guess_hi; time_t guess, guess_lo, guess_hi;
struct tm *tm, tm_lo, tm_hi; struct tm *tm, tm_lo, tm_hi;
@ -743,9 +714,7 @@ search_time_t(tptr, utc_p)
} }
static time_t static time_t
make_time_t(tptr, utc_p) make_time_t(struct tm *tptr, int utc_p)
struct tm *tptr;
int utc_p;
{ {
time_t t; time_t t;
struct tm *tmp, buf; struct tm *tmp, buf;
@ -789,11 +758,7 @@ make_time_t(tptr, utc_p)
} }
static VALUE static VALUE
time_utc_or_local(argc, argv, utc_p, klass) time_utc_or_local(int argc, VALUE *argv, int utc_p, VALUE klass)
int argc;
VALUE *argv;
int utc_p;
VALUE klass;
{ {
struct tm tm; struct tm tm;
VALUE time; VALUE time;
@ -827,10 +792,7 @@ time_utc_or_local(argc, argv, utc_p, klass)
* Time.gm(2000,"jan",1,20,15,1) #=> Sat Jan 01 20:15:01 UTC 2000 * Time.gm(2000,"jan",1,20,15,1) #=> Sat Jan 01 20:15:01 UTC 2000
*/ */
static VALUE static VALUE
time_s_mkutc(argc, argv, klass) time_s_mkutc(int argc, VALUE *argv, VALUE klass)
int argc;
VALUE *argv;
VALUE klass;
{ {
return time_utc_or_local(argc, argv, Qtrue, klass); return time_utc_or_local(argc, argv, Qtrue, klass);
} }
@ -849,10 +811,7 @@ time_s_mkutc(argc, argv, klass)
*/ */
static VALUE static VALUE
time_s_mktime(argc, argv, klass) time_s_mktime(int argc, VALUE *argv, VALUE klass)
int argc;
VALUE *argv;
VALUE klass;
{ {
return time_utc_or_local(argc, argv, Qfalse, klass); return time_utc_or_local(argc, argv, Qfalse, klass);
} }
@ -871,8 +830,7 @@ time_s_mktime(argc, argv, klass)
*/ */
static VALUE static VALUE
time_to_i(time) time_to_i(VALUE time)
VALUE time;
{ {
struct time_object *tobj; struct time_object *tobj;
@ -893,8 +851,7 @@ time_to_i(time)
*/ */
static VALUE static VALUE
time_to_f(time) time_to_f(VALUE time)
VALUE time;
{ {
struct time_object *tobj; struct time_object *tobj;
@ -915,8 +872,7 @@ time_to_f(time)
*/ */
static VALUE static VALUE
time_usec(time) time_usec(VALUE time)
VALUE time;
{ {
struct time_object *tobj; struct time_object *tobj;
@ -941,8 +897,7 @@ time_usec(time)
*/ */
static VALUE static VALUE
time_cmp(time1, time2) time_cmp(VALUE time1, VALUE time2)
VALUE time1, time2;
{ {
struct time_object *tobj1, *tobj2; struct time_object *tobj1, *tobj2;
@ -971,8 +926,7 @@ time_cmp(time1, time2)
*/ */
static VALUE static VALUE
time_eql(time1, time2) time_eql(VALUE time1, VALUE time2)
VALUE time1, time2;
{ {
struct time_object *tobj1, *tobj2; struct time_object *tobj1, *tobj2;
@ -1006,8 +960,7 @@ time_eql(time1, time2)
*/ */
static VALUE static VALUE
time_utc_p(time) time_utc_p(VALUE time)
VALUE time;
{ {
struct time_object *tobj; struct time_object *tobj;
@ -1024,8 +977,7 @@ time_utc_p(time)
*/ */
static VALUE static VALUE
time_hash(time) time_hash(VALUE time)
VALUE time;
{ {
struct time_object *tobj; struct time_object *tobj;
long hash; long hash;
@ -1037,8 +989,7 @@ time_hash(time)
/* :nodoc: */ /* :nodoc: */
static VALUE static VALUE
time_init_copy(copy, time) time_init_copy(VALUE copy, VALUE time)
VALUE copy, time;
{ {
struct time_object *tobj, *tcopy; struct time_object *tobj, *tcopy;
@ -1055,8 +1006,7 @@ time_init_copy(copy, time)
} }
static VALUE static VALUE
time_dup(time) time_dup(VALUE time)
VALUE time;
{ {
VALUE dup = time_s_alloc(rb_cTime); VALUE dup = time_s_alloc(rb_cTime);
time_init_copy(dup, time); time_init_copy(dup, time);
@ -1077,8 +1027,7 @@ time_dup(time)
*/ */
static VALUE static VALUE
time_localtime(time) time_localtime(VALUE time)
VALUE time;
{ {
struct time_object *tobj; struct time_object *tobj;
struct tm *tm_tmp; struct tm *tm_tmp;
@ -1121,8 +1070,7 @@ time_localtime(time)
*/ */
static VALUE static VALUE
time_gmtime(time) time_gmtime(VALUE time)
VALUE time;
{ {
struct time_object *tobj; struct time_object *tobj;
struct tm *tm_tmp; struct tm *tm_tmp;
@ -1161,8 +1109,7 @@ time_gmtime(time)
*/ */
static VALUE static VALUE
time_getlocaltime(time) time_getlocaltime(VALUE time)
VALUE time;
{ {
return time_localtime(time_dup(time)); return time_localtime(time_dup(time));
} }
@ -1183,16 +1130,13 @@ time_getlocaltime(time)
*/ */
static VALUE static VALUE
time_getgmtime(time) time_getgmtime(VALUE time)
VALUE time;
{ {
return time_gmtime(time_dup(time)); return time_gmtime(time_dup(time));
} }
static VALUE static VALUE
time_get_tm(time, gmt) time_get_tm(VALUE time, int gmt)
VALUE time;
int gmt;
{ {
if (gmt) return time_gmtime(time); if (gmt) return time_gmtime(time);
return time_localtime(time); return time_localtime(time);
@ -1209,8 +1153,7 @@ time_get_tm(time, gmt)
*/ */
static VALUE static VALUE
time_asctime(time) time_asctime(VALUE time)
VALUE time;
{ {
struct time_object *tobj; struct time_object *tobj;
char *s; char *s;
@ -1239,8 +1182,7 @@ time_asctime(time)
*/ */
static VALUE static VALUE
time_to_s(time) time_to_s(VALUE time)
VALUE time;
{ {
struct time_object *tobj; struct time_object *tobj;
char buf[128]; char buf[128];
@ -1270,10 +1212,7 @@ typedef unsigned long long unsigned_time_t;
#endif #endif
static VALUE static VALUE
time_add(tobj, offset, sign) time_add(struct time_object *tobj, VALUE offset, int sign)
struct time_object *tobj;
VALUE offset;
int sign;
{ {
double v = NUM2DBL(offset); double v = NUM2DBL(offset);
double f, d; double f, d;
@ -1324,8 +1263,7 @@ time_add(tobj, offset, sign)
*/ */
static VALUE static VALUE
time_plus(time1, time2) time_plus(VALUE time1, VALUE time2)
VALUE time1, time2;
{ {
struct time_object *tobj; struct time_object *tobj;
GetTimeval(time1, tobj); GetTimeval(time1, tobj);
@ -1352,8 +1290,7 @@ time_plus(time1, time2)
*/ */
static VALUE static VALUE
time_minus(time1, time2) time_minus(VALUE time1, VALUE time2)
VALUE time1, time2;
{ {
struct time_object *tobj; struct time_object *tobj;
@ -1380,8 +1317,7 @@ time_minus(time1, time2)
*/ */
static VALUE static VALUE
time_succ(time) time_succ(VALUE time)
VALUE time;
{ {
struct time_object *tobj; struct time_object *tobj;
@ -1403,8 +1339,7 @@ time_succ(time)
*/ */
static VALUE static VALUE
time_sec(time) time_sec(VALUE time)
VALUE time;
{ {
struct time_object *tobj; struct time_object *tobj;
@ -1426,8 +1361,7 @@ time_sec(time)
*/ */
static VALUE static VALUE
time_min(time) time_min(VALUE time)
VALUE time;
{ {
struct time_object *tobj; struct time_object *tobj;
@ -1449,8 +1383,7 @@ time_min(time)
*/ */
static VALUE static VALUE
time_hour(time) time_hour(VALUE time)
VALUE time;
{ {
struct time_object *tobj; struct time_object *tobj;
@ -1474,8 +1407,7 @@ time_hour(time)
*/ */
static VALUE static VALUE
time_mday(time) time_mday(VALUE time)
VALUE time;
{ {
struct time_object *tobj; struct time_object *tobj;
@ -1499,8 +1431,7 @@ time_mday(time)
*/ */
static VALUE static VALUE
time_mon(time) time_mon(VALUE time)
VALUE time;
{ {
struct time_object *tobj; struct time_object *tobj;
@ -1522,8 +1453,7 @@ time_mon(time)
*/ */
static VALUE static VALUE
time_year(time) time_year(VALUE time)
VALUE time;
{ {
struct time_object *tobj; struct time_object *tobj;
@ -1546,8 +1476,7 @@ time_year(time)
*/ */
static VALUE static VALUE
time_wday(time) time_wday(VALUE time)
VALUE time;
{ {
struct time_object *tobj; struct time_object *tobj;
@ -1569,8 +1498,7 @@ time_wday(time)
*/ */
static VALUE static VALUE
time_yday(time) time_yday(VALUE time)
VALUE time;
{ {
struct time_object *tobj; struct time_object *tobj;
@ -1596,8 +1524,7 @@ time_yday(time)
*/ */
static VALUE static VALUE
time_isdst(time) time_isdst(VALUE time)
VALUE time;
{ {
struct time_object *tobj; struct time_object *tobj;
@ -1622,8 +1549,7 @@ time_isdst(time)
*/ */
static VALUE static VALUE
time_zone(time) time_zone(VALUE time)
VALUE time;
{ {
struct time_object *tobj; struct time_object *tobj;
#if !defined(HAVE_TM_ZONE) && (!defined(HAVE_TZNAME) || !defined(HAVE_DAYLIGHT)) #if !defined(HAVE_TM_ZONE) && (!defined(HAVE_TZNAME) || !defined(HAVE_DAYLIGHT))
@ -1665,8 +1591,7 @@ time_zone(time)
*/ */
static VALUE static VALUE
time_utc_offset(time) time_utc_offset(VALUE time)
VALUE time;
{ {
struct time_object *tobj; struct time_object *tobj;
@ -1722,8 +1647,7 @@ time_utc_offset(time)
*/ */
static VALUE static VALUE
time_to_a(time) time_to_a(VALUE time)
VALUE time;
{ {
struct time_object *tobj; struct time_object *tobj;
@ -1746,10 +1670,10 @@ time_to_a(time)
#define SMALLBUF 100 #define SMALLBUF 100
static int static int
rb_strftime(buf, format, time) rb_strftime(
char ** volatile buf; char ** volatile buf,
char * volatile format; char * volatile format,
struct tm * volatile time; struct tm * volatile time)
{ {
volatile int size; volatile int size;
int len, flen; int len, flen;
@ -1820,8 +1744,7 @@ rb_strftime(buf, format, time)
*/ */
static VALUE static VALUE
time_strftime(time, format) time_strftime(VALUE time, VALUE format)
VALUE time, format;
{ {
struct time_object *tobj; struct time_object *tobj;
char buffer[SMALLBUF]; char buffer[SMALLBUF];
@ -1874,8 +1797,7 @@ time_strftime(time, format)
*/ */
static VALUE static VALUE
time_s_times(obj) time_s_times(VALUE obj)
VALUE obj;
{ {
rb_warn("obsolete method Time::times; use Process::times"); rb_warn("obsolete method Time::times; use Process::times");
return rb_proc_times(obj); return rb_proc_times(obj);
@ -1886,8 +1808,7 @@ time_s_times(obj)
*/ */
static VALUE static VALUE
time_mdump(time) time_mdump(VALUE time)
VALUE time;
{ {
struct time_object *tobj; struct time_object *tobj;
struct tm *tm; struct tm *tm;
@ -1934,10 +1855,7 @@ time_mdump(time)
*/ */
static VALUE static VALUE
time_dump(argc, argv, time) time_dump(int argc, VALUE *argv, VALUE time)
int argc;
VALUE *argv;
VALUE time;
{ {
VALUE str; VALUE str;
@ -1953,8 +1871,7 @@ time_dump(argc, argv, time)
*/ */
static VALUE static VALUE
time_mload(time, str) time_mload(VALUE time, VALUE str)
VALUE time, str;
{ {
struct time_object *tobj; struct time_object *tobj;
unsigned long p, s; unsigned long p, s;
@ -2014,8 +1931,7 @@ time_mload(time, str)
*/ */
static VALUE static VALUE
time_load(klass, str) time_load(VALUE klass, VALUE str)
VALUE klass, str;
{ {
VALUE time = time_s_alloc(klass); VALUE time = time_s_alloc(klass);
@ -2043,7 +1959,7 @@ time_load(klass, str)
*/ */
void void
Init_Time() Init_Time(void)
{ {
rb_cTime = rb_define_class("Time", rb_cObject); rb_cTime = rb_define_class("Time", rb_cObject);
rb_include_module(rb_cTime, rb_mComparable); rb_include_module(rb_cTime, rb_mComparable);

2
util.h
Просмотреть файл

@ -40,7 +40,7 @@ unsigned long scan_oct _((const char*, int, int*));
unsigned long scan_hex _((const char*, int, int*)); unsigned long scan_hex _((const char*, int, int*));
#if defined(MSDOS) || defined(__CYGWIN32__) || defined(_WIN32) #if defined(MSDOS) || defined(__CYGWIN32__) || defined(_WIN32)
void ruby_add_suffix(); void ruby_add_suffix(VALUE str, char *suffix);
#endif #endif
void ruby_qsort _((void*, const int, const int, int (*)(), void*)); void ruby_qsort _((void*, const int, const int, int (*)(), void*));

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -19,7 +19,7 @@ const char ruby_release_date[] = RUBY_RELEASE_DATE;
const char ruby_platform[] = RUBY_PLATFORM; const char ruby_platform[] = RUBY_PLATFORM;
void void
Init_version() Init_version(void)
{ {
VALUE v = rb_obj_freeze(rb_str_new2(ruby_version)); VALUE v = rb_obj_freeze(rb_str_new2(ruby_version));
VALUE d = rb_obj_freeze(rb_str_new2(ruby_release_date)); VALUE d = rb_obj_freeze(rb_str_new2(ruby_release_date));
@ -31,14 +31,14 @@ Init_version()
} }
void void
ruby_show_version() ruby_show_version(void)
{ {
printf("ruby %s (%s) [%s]\n", RUBY_VERSION, RUBY_RELEASE_DATE, RUBY_PLATFORM); printf("ruby %s (%s) [%s]\n", RUBY_VERSION, RUBY_RELEASE_DATE, RUBY_PLATFORM);
fflush(stdout); fflush(stdout);
} }
void void
ruby_show_copyright() ruby_show_copyright(void)
{ {
printf("ruby - Copyright (C) 1993-%d Yukihiro Matsumoto\n", RUBY_RELEASE_YEAR); printf("ruby - Copyright (C) 1993-%d Yukihiro Matsumoto\n", RUBY_RELEASE_YEAR);
exit(0); exit(0);