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

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

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

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

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

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

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

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

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

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

@ -18,15 +18,13 @@ VALUE rb_mEnumerable;
static ID id_each, id_eqq, id_cmp;
VALUE
rb_each(obj)
VALUE obj;
rb_each(VALUE obj)
{
return rb_funcall(obj, id_each, 0, 0);
}
static VALUE
grep_i(i, arg)
VALUE i, *arg;
grep_i(VALUE i, VALUE *arg)
{
if (RTEST(rb_funcall(arg[0], id_eqq, 1, i))) {
rb_ary_push(arg[1], i);
@ -35,8 +33,7 @@ grep_i(i, arg)
}
static VALUE
grep_iter_i(i, arg)
VALUE i, *arg;
grep_iter_i(VALUE i, VALUE *arg)
{
if (RTEST(rb_funcall(arg[0], id_eqq, 1, i))) {
rb_ary_push(arg[1], rb_yield(i));
@ -63,8 +60,7 @@ grep_iter_i(i, arg)
*/
static VALUE
enum_grep(obj, pat)
VALUE obj, pat;
enum_grep(VALUE obj, VALUE pat)
{
VALUE ary = rb_ary_new();
VALUE arg[2];
@ -78,8 +74,7 @@ enum_grep(obj, pat)
}
static VALUE
count_i(i, arg)
VALUE i, *arg;
count_i(VALUE i, VALUE *arg)
{
if (rb_equal(i, arg[0])) {
arg[1]++;
@ -88,9 +83,7 @@ count_i(i, arg)
}
static VALUE
count_iter_i(i, n)
VALUE i;
long *n;
count_iter_i(VALUE i, long *n)
{
if (RTEST(rb_yield(i))) {
(*n)++;
@ -113,10 +106,7 @@ count_iter_i(i, n)
*/
static VALUE
enum_count(argc, argv, obj)
int argc;
VALUE* argv;
VALUE obj;
enum_count(int argc, VALUE *argv, VALUE obj)
{
if (argc == 1) {
VALUE item, args[2];
@ -139,9 +129,7 @@ enum_count(argc, argv, obj)
}
static VALUE
find_i(i, memo)
VALUE i;
VALUE *memo;
find_i(VALUE i, VALUE *memo)
{
if (RTEST(rb_yield(i))) {
*memo = i;
@ -166,10 +154,7 @@ find_i(i, memo)
*/
static VALUE
enum_find(argc, argv, obj)
int argc;
VALUE* argv;
VALUE obj;
enum_find(int argc, VALUE *argv, VALUE obj)
{
VALUE memo = Qundef;
VALUE if_none;
@ -187,8 +172,7 @@ enum_find(argc, argv, obj)
}
static VALUE
find_all_i(i, ary)
VALUE i, ary;
find_all_i(VALUE i, VALUE ary)
{
if (RTEST(rb_yield(i))) {
rb_ary_push(ary, i);
@ -210,8 +194,7 @@ find_all_i(i, ary)
*/
static VALUE
enum_find_all(obj)
VALUE obj;
enum_find_all(VALUE obj)
{
VALUE ary;
@ -224,8 +207,7 @@ enum_find_all(obj)
}
static VALUE
reject_i(i, ary)
VALUE i, ary;
reject_i(VALUE i, VALUE ary)
{
if (!RTEST(rb_yield(i))) {
rb_ary_push(ary, i);
@ -245,8 +227,7 @@ reject_i(i, ary)
*/
static VALUE
enum_reject(obj)
VALUE obj;
enum_reject(VALUE obj)
{
VALUE ary;
@ -259,8 +240,7 @@ enum_reject(obj)
}
static VALUE
collect_i(i, ary)
VALUE i, ary;
collect_i(VALUE i, VALUE ary)
{
rb_ary_push(ary, rb_yield(i));
@ -268,8 +248,7 @@ collect_i(i, ary)
}
static VALUE
collect_all(i, ary)
VALUE i, ary;
collect_all(VALUE i, VALUE ary)
{
rb_ary_push(ary, i);
@ -290,8 +269,7 @@ collect_all(i, ary)
*/
static VALUE
enum_collect(obj)
VALUE obj;
enum_collect(VALUE obj)
{
VALUE ary;
@ -314,8 +292,7 @@ enum_collect(obj)
* { 'a'=>1, 'b'=>2, 'c'=>3 }.to_a #=> [["a", 1], ["b", 2], ["c", 3]]
*/
static VALUE
enum_to_a(obj)
VALUE obj;
enum_to_a(VALUE obj)
{
VALUE ary = rb_ary_new();
@ -325,9 +302,7 @@ enum_to_a(obj)
}
static VALUE
inject_i(i, memo)
VALUE i;
VALUE *memo;
inject_i(VALUE i, VALUE *memo)
{
if (*memo == Qundef) {
*memo = i;
@ -370,9 +345,7 @@ inject_i(i, memo)
*/
static VALUE
enum_inject(argc, argv, obj)
int argc;
VALUE *argv, obj;
enum_inject(int argc, VALUE *argv, VALUE obj)
{
VALUE memo = Qundef;
@ -384,8 +357,7 @@ enum_inject(argc, argv, obj)
}
static VALUE
partition_i(i, ary)
VALUE i, *ary;
partition_i(VALUE i, VALUE *ary)
{
if (RTEST(rb_yield(i))) {
rb_ary_push(ary[0], i);
@ -409,8 +381,7 @@ partition_i(i, ary)
*/
static VALUE
enum_partition(obj)
VALUE obj;
enum_partition(VALUE obj)
{
VALUE ary[2];
@ -441,15 +412,13 @@ enum_partition(obj)
*/
static VALUE
enum_sort(obj)
VALUE obj;
enum_sort(VALUE obj)
{
return rb_ary_sort(enum_to_a(obj));
}
static VALUE
sort_by_i(i, ary)
VALUE i, ary;
sort_by_i(VALUE i, VALUE ary)
{
VALUE v;
NODE *memo;
@ -464,8 +433,7 @@ sort_by_i(i, ary)
}
static int
sort_by_cmp(aa, bb)
NODE **aa, **bb;
sort_by_cmp(NODE **aa, NODE **bb)
{
VALUE a = aa[0]->u1.value;
VALUE b = bb[0]->u1.value;
@ -543,8 +511,7 @@ sort_by_cmp(aa, bb)
*/
static VALUE
enum_sort_by(obj)
VALUE obj;
enum_sort_by(VALUE obj)
{
VALUE ary;
long i;
@ -573,9 +540,7 @@ enum_sort_by(obj)
}
static VALUE
all_iter_i(i, memo)
VALUE i;
VALUE *memo;
all_iter_i(VALUE i, VALUE *memo)
{
if (!RTEST(rb_yield(i))) {
*memo = Qfalse;
@ -585,9 +550,7 @@ all_iter_i(i, memo)
}
static VALUE
all_i(i, memo)
VALUE i;
VALUE *memo;
all_i(VALUE i, VALUE *memo)
{
if (!RTEST(i)) {
*memo = Qfalse;
@ -614,8 +577,7 @@ all_i(i, memo)
*/
static VALUE
enum_all(obj)
VALUE obj;
enum_all(VALUE obj)
{
VALUE result = Qtrue;
@ -624,9 +586,7 @@ enum_all(obj)
}
static VALUE
any_iter_i(i, memo)
VALUE i;
VALUE *memo;
any_iter_i(VALUE i, VALUE *memo)
{
if (RTEST(rb_yield(i))) {
*memo = Qtrue;
@ -636,9 +596,7 @@ any_iter_i(i, memo)
}
static VALUE
any_i(i, memo)
VALUE i;
VALUE *memo;
any_i(VALUE i, VALUE *memo)
{
if (RTEST(i)) {
*memo = Qtrue;
@ -666,8 +624,7 @@ any_i(i, memo)
*/
static VALUE
enum_any(obj)
VALUE obj;
enum_any(VALUE obj)
{
VALUE result = Qfalse;
@ -676,9 +633,7 @@ enum_any(obj)
}
static VALUE
min_i(i, memo)
VALUE i;
VALUE *memo;
min_i(VALUE i, VALUE *memo)
{
VALUE cmp;
@ -695,9 +650,7 @@ min_i(i, memo)
}
static VALUE
min_ii(i, memo)
VALUE i;
VALUE *memo;
min_ii(VALUE i, VALUE *memo)
{
VALUE cmp;
@ -729,8 +682,7 @@ min_ii(i, memo)
*/
static VALUE
enum_min(obj)
VALUE obj;
enum_min(VALUE obj)
{
VALUE result = Qundef;
@ -740,9 +692,7 @@ enum_min(obj)
}
static VALUE
max_i(i, memo)
VALUE i;
VALUE *memo;
max_i(VALUE i, VALUE *memo)
{
VALUE cmp;
@ -759,9 +709,7 @@ max_i(i, memo)
}
static VALUE
max_ii(i, memo)
VALUE i;
VALUE *memo;
max_ii(VALUE i, VALUE *memo)
{
VALUE cmp;
@ -792,8 +740,7 @@ max_ii(i, memo)
*/
static VALUE
enum_max(obj)
VALUE obj;
enum_max(VALUE obj)
{
VALUE result = Qundef;
@ -803,9 +750,7 @@ enum_max(obj)
}
static VALUE
min_by_i(i, memo)
VALUE i;
VALUE *memo;
min_by_i(VALUE i, VALUE *memo)
{
VALUE v;
@ -833,8 +778,7 @@ min_by_i(i, memo)
*/
static VALUE
enum_min_by(obj)
VALUE obj;
enum_min_by(VALUE obj)
{
VALUE memo[2];
@ -847,9 +791,7 @@ enum_min_by(obj)
}
static VALUE
max_by_i(i, memo)
VALUE i;
VALUE *memo;
max_by_i(VALUE i, VALUE *memo)
{
VALUE v;
@ -877,8 +819,7 @@ max_by_i(i, memo)
*/
static VALUE
enum_max_by(obj)
VALUE obj;
enum_max_by(VALUE obj)
{
VALUE memo[2];
@ -891,9 +832,7 @@ enum_max_by(obj)
}
static VALUE
member_i(item, memo)
VALUE item;
VALUE *memo;
member_i(VALUE item, VALUE *memo)
{
if (rb_equal(item, memo[0])) {
memo[1] = Qtrue;
@ -916,8 +855,7 @@ member_i(item, memo)
*/
static VALUE
enum_member(obj, val)
VALUE obj, val;
enum_member(VALUE obj, VALUE val)
{
VALUE memo[2];
@ -928,9 +866,7 @@ enum_member(obj, val)
}
static VALUE
each_with_index_i(val, memo)
VALUE val;
VALUE *memo;
each_with_index_i(VALUE val, VALUE *memo)
{
rb_yield_values(2, val, INT2FIX(*memo));
++*memo;
@ -953,8 +889,7 @@ each_with_index_i(val, memo)
*/
static VALUE
enum_each_with_index(obj)
VALUE obj;
enum_each_with_index(VALUE obj)
{
VALUE memo = 0;
@ -965,9 +900,7 @@ enum_each_with_index(obj)
}
static VALUE
zip_i(val, memo)
VALUE val;
VALUE *memo;
zip_i(VALUE val, VALUE *memo)
{
VALUE result = memo[0];
VALUE args = memo[1];
@ -1013,10 +946,7 @@ zip_i(val, memo)
*/
static VALUE
enum_zip(argc, argv, obj)
int argc;
VALUE *argv;
VALUE obj;
enum_zip(int argc, VALUE *argv, VALUE obj)
{
int i;
VALUE result;
@ -1046,7 +976,7 @@ enum_zip(argc, argv, obj)
*/
void
Init_Enumerable()
Init_Enumerable(void)
{
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
proc_call(proc, args)
VALUE proc, args;
proc_call(VALUE proc, VALUE args)
{
if (TYPE(args) != T_ARRAY) {
args = rb_values_new(1, args);
@ -34,8 +33,7 @@ proc_call(proc, args)
}
static VALUE
method_call(method, args)
VALUE method, args;
method_call(VALUE method, VALUE args)
{
int argc = 0;
VALUE *argv = 0;
@ -53,10 +51,8 @@ struct enumerator {
VALUE (*iter)_((VALUE, struct enumerator *));
};
static void enumerator_mark _((void *));
static void
enumerator_mark(p)
void *p;
enumerator_mark(void *p)
{
struct enumerator *ptr = p;
rb_gc_mark(ptr->method);
@ -65,8 +61,7 @@ enumerator_mark(p)
}
static struct enumerator *
enumerator_ptr(obj)
VALUE obj;
enumerator_ptr(VALUE obj)
{
struct enumerator *ptr;
@ -82,11 +77,8 @@ enumerator_ptr(obj)
return ptr;
}
static VALUE enumerator_iter_i _((VALUE, struct enumerator *));
static VALUE
enumerator_iter_i(i, e)
VALUE i;
struct enumerator *e;
enumerator_iter_i(VALUE i, struct enumerator *e)
{
return rb_yield(proc_call(e->proc, i));
}
@ -110,10 +102,7 @@ enumerator_iter_i(i, e)
*
*/
static VALUE
obj_to_enum(argc, argv, obj)
int argc;
VALUE *argv;
VALUE obj;
obj_to_enum(int argc, VALUE *argv, VALUE obj)
{
VALUE meth = sym_each;
@ -132,16 +121,13 @@ obj_to_enum(argc, argv, obj)
*
*/
static VALUE
enumerator_enum_with_index(obj)
VALUE obj;
enumerator_enum_with_index(VALUE obj)
{
return rb_enumeratorize(obj, sym_each_with_index, 0, 0);
}
static VALUE
each_slice_i(val, memo)
VALUE val;
VALUE *memo;
each_slice_i(VALUE val, VALUE *memo)
{
VALUE ary = memo[0];
long size = (long)memo[1];
@ -172,8 +158,7 @@ each_slice_i(val, memo)
*
*/
static VALUE
enum_each_slice(obj, n)
VALUE obj, n;
enum_each_slice(VALUE obj, VALUE n)
{
long size = NUM2LONG(n);
VALUE args[2], ary;
@ -199,16 +184,13 @@ enum_each_slice(obj, n)
*
*/
static VALUE
enumerator_enum_slice(obj, n)
VALUE obj, n;
enumerator_enum_slice(VALUE obj, VALUE n)
{
return rb_enumeratorize(obj, sym_each_slice, 1, &n);
}
static VALUE
each_cons_i(val, memo)
VALUE val;
VALUE *memo;
each_cons_i(VALUE val, VALUE *memo)
{
VALUE ary = memo[0];
long size = (long)memo[1];
@ -244,8 +226,7 @@ each_cons_i(val, memo)
*
*/
static VALUE
enum_each_cons(obj, n)
VALUE obj, n;
enum_each_cons(VALUE obj, VALUE n)
{
long size = NUM2LONG(n);
VALUE args[2];
@ -267,16 +248,13 @@ enum_each_cons(obj, n)
*
*/
static VALUE
enumerator_enum_cons(obj, n)
VALUE obj, n;
enumerator_enum_cons(VALUE obj, VALUE n)
{
return rb_enumeratorize(obj, sym_each_cons, 1, &n);
}
static VALUE enumerator_allocate _((VALUE));
static VALUE
enumerator_allocate(klass)
VALUE klass;
enumerator_allocate(VALUE klass)
{
struct enumerator *ptr;
return Data_Make_Struct(rb_cEnumerator, struct enumerator,
@ -284,10 +262,7 @@ enumerator_allocate(klass)
}
VALUE
enumerator_init(enum_obj, obj, meth, argc, argv)
VALUE enum_obj, obj, meth;
int argc;
VALUE *argv;
enumerator_init(VALUE enum_obj, VALUE obj, VALUE meth, int argc, VALUE *argv)
{
struct enumerator *ptr = enumerator_ptr(enum_obj);
@ -320,10 +295,7 @@ enumerator_init(enum_obj, obj, meth, argc, argv)
*
*/
static VALUE
enumerator_initialize(argc, argv, obj)
int argc;
VALUE *argv;
VALUE obj;
enumerator_initialize(int argc, VALUE *argv, VALUE obj)
{
VALUE recv, meth = sym_each;
@ -338,18 +310,13 @@ enumerator_initialize(argc, argv, obj)
}
VALUE
rb_enumeratorize(obj, meth, argc, argv)
VALUE obj, meth;
int argc;
VALUE *argv;
rb_enumeratorize(VALUE obj, VALUE meth, int argc, VALUE *argv)
{
return enumerator_init(enumerator_allocate(rb_cEnumerator), obj, meth, argc, argv);
}
static VALUE enumerator_iter _((VALUE));
static VALUE
enumerator_iter(memo)
VALUE memo;
enumerator_iter(VALUE memo)
{
struct enumerator *e = (struct enumerator *)memo;
@ -365,8 +332,7 @@ enumerator_iter(memo)
*
*/
static VALUE
enumerator_each(obj)
VALUE obj;
enumerator_each(VALUE obj)
{
struct enumerator *e = enumerator_ptr(obj);
@ -374,8 +340,7 @@ enumerator_each(obj)
}
static VALUE
enumerator_with_index_i(val, memo)
VALUE val, *memo;
enumerator_with_index_i(VALUE val, VALUE *memo)
{
val = rb_yield_values(2, val, INT2FIX(*memo));
++*memo;
@ -391,8 +356,7 @@ enumerator_with_index_i(val, memo)
*
*/
static VALUE
enumerator_with_index(obj)
VALUE obj;
enumerator_with_index(VALUE obj)
{
struct enumerator *e = enumerator_ptr(obj);
VALUE memo = 0;
@ -402,7 +366,7 @@ enumerator_with_index(obj)
}
void
Init_Enumerator()
Init_Enumerator(void)
{
rb_define_method(rb_mKernel, "to_enum", 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 <stdio.h>
#ifdef HAVE_STDARG_PROTOTYPES
#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
#include <stdlib.h>
#endif
@ -34,9 +28,7 @@ extern const char ruby_version[], ruby_release_date[], ruby_platform[];
int ruby_nerrs;
static int
err_position(buf, len)
char *buf;
long len;
err_position(char *buf, long len)
{
ruby_set_current_source();
if (!ruby_sourcefile) {
@ -51,11 +43,7 @@ err_position(buf, len)
}
static void
err_snprintf(buf, len, fmt, args)
char *buf;
long len;
const char *fmt;
va_list args;
err_snprintf(char *buf, long len, const char *fmt, va_list args)
{
long n;
@ -67,9 +55,7 @@ err_snprintf(buf, len, fmt, args)
static void err_append _((const char*));
static void
err_print(fmt, args)
const char *fmt;
va_list args;
err_print(const char *fmt, va_list args)
{
char buf[BUFSIZ];
@ -78,44 +64,30 @@ err_print(fmt, args)
}
void
#ifdef HAVE_STDARG_PROTOTYPES
rb_compile_error(const char *fmt, ...)
#else
rb_compile_error(fmt, va_alist)
const char *fmt;
va_dcl
#endif
{
va_list args;
va_init_list(args, fmt);
va_start(args, fmt);
err_print(fmt, args);
va_end(args);
ruby_nerrs++;
}
void
#ifdef HAVE_STDARG_PROTOTYPES
rb_compile_error_append(const char *fmt, ...)
#else
rb_compile_error_append(fmt, va_alist)
const char *fmt;
va_dcl
#endif
{
va_list args;
char buf[BUFSIZ];
va_init_list(args, fmt);
va_start(args, fmt);
vsnprintf(buf, BUFSIZ, fmt, args);
va_end(args);
err_append(buf);
}
static void
warn_print(fmt, args)
const char *fmt;
va_list args;
warn_print(const char *fmt, va_list args)
{
char buf[BUFSIZ];
int len;
@ -127,13 +99,7 @@ warn_print(fmt, args)
}
void
#ifdef HAVE_STDARG_PROTOTYPES
rb_warn(const char *fmt, ...)
#else
rb_warn(fmt, va_alist)
const char *fmt;
va_dcl
#endif
{
char buf[BUFSIZ];
va_list args;
@ -142,20 +108,14 @@ rb_warn(fmt, va_alist)
snprintf(buf, BUFSIZ, "warning: %s", fmt);
va_init_list(args, fmt);
va_start(args, fmt);
warn_print(buf, args);
va_end(args);
}
/* rb_warning() reports only in verbose mode */
void
#ifdef HAVE_STDARG_PROTOTYPES
rb_warning(const char *fmt, ...)
#else
rb_warning(fmt, va_alist)
const char *fmt;
va_dcl
#endif
{
char buf[BUFSIZ];
va_list args;
@ -164,7 +124,7 @@ rb_warning(fmt, va_alist)
snprintf(buf, BUFSIZ, "warning: %s", fmt);
va_init_list(args, fmt);
va_start(args, fmt);
warn_print(buf, args);
va_end(args);
}
@ -178,8 +138,7 @@ rb_warning(fmt, va_alist)
*/
static VALUE
rb_warn_m(self, mesg)
VALUE self, mesg;
rb_warn_m(VALUE self, VALUE mesg)
{
if (!NIL_P(ruby_verbose)) {
rb_io_write(rb_stderr, mesg);
@ -189,13 +148,7 @@ rb_warn_m(self, mesg)
}
void
#ifdef HAVE_STDARG_PROTOTYPES
rb_bug(const char *fmt, ...)
#else
rb_bug(fmt, va_alist)
const char *fmt;
va_dcl
#endif
{
char buf[BUFSIZ];
va_list args;
@ -205,7 +158,7 @@ rb_bug(fmt, va_alist)
if (fwrite(buf, 1, len, out) == len ||
fwrite(buf, 1, len, (out = stdout)) == len) {
fputs("[BUG] ", out);
va_init_list(args, fmt);
va_start(args, fmt);
vfprintf(out, fmt, args);
va_end(args);
fprintf(out, "\nruby %s (%s) [%s]\n\n",
@ -245,9 +198,7 @@ static struct types {
};
void
rb_check_type(x, t)
VALUE x;
int t;
rb_check_type(VALUE x, int t)
{
struct types *type = builtin_types;
@ -315,25 +266,19 @@ VALUE rb_mErrno;
static VALUE eNOERROR;
VALUE
rb_exc_new(etype, ptr, len)
VALUE etype;
const char *ptr;
long len;
rb_exc_new(VALUE etype, const char *ptr, long len)
{
return rb_funcall(etype, rb_intern("new"), 1, rb_str_new(ptr, len));
}
VALUE
rb_exc_new2(etype, s)
VALUE etype;
const char *s;
rb_exc_new2(VALUE etype, const char *s)
{
return rb_exc_new(etype, s, strlen(s));
}
VALUE
rb_exc_new3(etype, str)
VALUE etype, str;
rb_exc_new3(VALUE etype, VALUE str)
{
StringValue(str);
return rb_funcall(etype, rb_intern("new"), 1, str);
@ -348,10 +293,7 @@ rb_exc_new3(etype, str)
*/
static VALUE
exc_initialize(argc, argv, exc)
int argc;
VALUE *argv;
VALUE exc;
exc_initialize(int argc, VALUE *argv, VALUE exc)
{
VALUE arg;
@ -376,10 +318,7 @@ exc_initialize(argc, argv, exc)
*/
static VALUE
exc_exception(argc, argv, self)
int argc;
VALUE *argv;
VALUE self;
exc_exception(int argc, VALUE *argv, VALUE self)
{
VALUE exc;
@ -400,8 +339,7 @@ exc_exception(argc, argv, self)
*/
static VALUE
exc_to_s(exc)
VALUE exc;
exc_to_s(VALUE exc)
{
VALUE mesg = rb_attr_get(exc, rb_intern("mesg"));
@ -421,8 +359,7 @@ exc_to_s(exc)
*/
static VALUE
exc_message(exc)
VALUE exc;
exc_message(VALUE exc)
{
return rb_funcall(exc, rb_intern("to_s"), 0, 0);
}
@ -435,8 +372,7 @@ exc_message(exc)
*/
static VALUE
exc_inspect(exc)
VALUE exc;
exc_inspect(VALUE exc)
{
VALUE str, klass;
@ -486,8 +422,7 @@ exc_inspect(exc)
*/
static VALUE
exc_backtrace(exc)
VALUE exc;
exc_backtrace(VALUE exc)
{
ID bt = rb_intern("bt");
@ -496,8 +431,7 @@ exc_backtrace(exc)
}
static VALUE
check_backtrace(bt)
VALUE bt;
check_backtrace(VALUE bt)
{
long i;
static char *err = "backtrace must be Array of String";
@ -529,9 +463,7 @@ check_backtrace(bt)
*/
static VALUE
exc_set_backtrace(exc, bt)
VALUE exc;
VALUE bt;
exc_set_backtrace(VALUE exc, VALUE bt)
{
return rb_iv_set(exc, "bt", check_backtrace(bt));
}
@ -546,9 +478,7 @@ exc_set_backtrace(exc, bt)
*/
static VALUE
exc_equal(exc, obj)
VALUE exc;
VALUE obj;
exc_equal(VALUE exc, VALUE obj)
{
ID id_mesg = rb_intern("mesg");
@ -570,10 +500,7 @@ exc_equal(exc, obj)
*/
static VALUE
exit_initialize(argc, argv, exc)
int argc;
VALUE *argv;
VALUE exc;
exit_initialize(int argc, VALUE *argv, VALUE exc)
{
VALUE status = INT2FIX(EXIT_SUCCESS);
if (argc > 0 && FIXNUM_P(argv[0])) {
@ -594,8 +521,7 @@ exit_initialize(argc, argv, exc)
*/
static VALUE
exit_status(exc)
VALUE exc;
exit_status(VALUE exc)
{
return rb_attr_get(exc, rb_intern("status"));
}
@ -609,8 +535,7 @@ exit_status(exc)
*/
static VALUE
exit_success_p(exc)
VALUE exc;
exit_success_p(VALUE exc)
{
VALUE status = rb_attr_get(exc, rb_intern("status"));
if (NIL_P(status)) return Qtrue;
@ -619,20 +544,13 @@ exit_success_p(exc)
}
void
#ifdef HAVE_STDARG_PROTOTYPES
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];
va_list args;
char buf[BUFSIZ];
va_init_list(args, fmt);
va_start(args, fmt);
vsnprintf(buf, BUFSIZ, fmt, args);
va_end(args);
@ -652,10 +570,7 @@ rb_name_error(id, fmt, va_alist)
*/
static VALUE
name_err_initialize(argc, argv, self)
int argc;
VALUE *argv;
VALUE self;
name_err_initialize(int argc, VALUE *argv, VALUE self)
{
VALUE name;
@ -673,8 +588,7 @@ name_err_initialize(argc, argv, self)
*/
static VALUE
name_err_name(self)
VALUE self;
name_err_name(VALUE self)
{
return rb_attr_get(self, rb_intern("name"));
}
@ -687,8 +601,7 @@ name_err_name(self)
*/
static VALUE
name_err_to_s(exc)
VALUE exc;
name_err_to_s(VALUE exc)
{
VALUE mesg = rb_attr_get(exc, rb_intern("mesg"));
VALUE str = mesg;
@ -713,10 +626,7 @@ name_err_to_s(exc)
*/
static VALUE
nometh_err_initialize(argc, argv, self)
int argc;
VALUE *argv;
VALUE self;
nometh_err_initialize(int argc, VALUE *argv, VALUE self)
{
VALUE args = (argc > 2) ? argv[--argc] : Qnil;
name_err_initialize(argc, argv, self);
@ -726,16 +636,14 @@ nometh_err_initialize(argc, argv, self)
/* :nodoc: */
static void
name_err_mesg_mark(ptr)
VALUE *ptr;
name_err_mesg_mark(VALUE *ptr)
{
rb_gc_mark_locations(ptr, ptr+3);
}
/* :nodoc: */
static VALUE
name_err_mesg_new(obj, mesg, recv, method)
VALUE obj, mesg, recv, method;
name_err_mesg_new(VALUE obj, VALUE mesg, VALUE recv, VALUE method)
{
VALUE *ptr = ALLOC_N(VALUE, 3);
@ -747,8 +655,7 @@ name_err_mesg_new(obj, mesg, recv, method)
/* :nodoc: */
static VALUE
name_err_mesg_equal(obj1, obj2)
VALUE obj1, obj2;
name_err_mesg_equal(VALUE obj1, VALUE obj2)
{
VALUE *ptr1, *ptr2;
int i;
@ -768,8 +675,7 @@ name_err_mesg_equal(obj1, obj2)
/* :nodoc: */
static VALUE
name_err_mesg_to_str(obj)
VALUE obj;
name_err_mesg_to_str(VALUE obj)
{
VALUE *ptr, mesg;
Data_Get_Struct(obj, VALUE, ptr);
@ -815,8 +721,7 @@ name_err_mesg_to_str(obj)
/* :nodoc: */
static VALUE
name_err_mesg_load(klass, str)
VALUE klass, str;
name_err_mesg_load(VALUE klass, VALUE str)
{
return str;
}
@ -830,15 +735,13 @@ name_err_mesg_load(klass, str)
*/
static VALUE
nometh_err_args(self)
VALUE self;
nometh_err_args(VALUE self)
{
return rb_attr_get(self, rb_intern("args"));
}
void
rb_invalid_str(str, type)
const char *str, *type;
rb_invalid_str(const char *str, const char *type)
{
VALUE s = rb_str_inspect(rb_str_new2(str));
@ -879,9 +782,7 @@ rb_invalid_str(str, type)
static st_table *syserr_tbl;
static VALUE
set_syserr(n, name)
int n;
const char *name;
set_syserr(int n, const char *name)
{
VALUE error;
@ -897,8 +798,7 @@ set_syserr(n, name)
}
static VALUE
get_syserr(n)
int n;
get_syserr(int n)
{
VALUE error;
@ -923,10 +823,7 @@ get_syserr(n)
*/
static VALUE
syserr_initialize(argc, argv, self)
int argc;
VALUE *argv;
VALUE self;
syserr_initialize(int argc, VALUE *argv, VALUE self)
{
#if !defined(_WIN32) && !defined(__VMS)
char *strerror();
@ -977,8 +874,7 @@ syserr_initialize(argc, argv, self)
*/
static VALUE
syserr_errno(self)
VALUE self;
syserr_errno(VALUE self)
{
return rb_attr_get(self, rb_intern("errno"));
}
@ -992,8 +888,7 @@ syserr_errno(self)
*/
static VALUE
syserr_eqq(self, exc)
VALUE self, exc;
syserr_eqq(VALUE self, VALUE exc)
{
VALUE num, e;
@ -1022,8 +917,7 @@ syserr_eqq(self, exc)
* Returns default SystemCallError class.
*/
static VALUE
errno_missing(self, id)
VALUE self, id;
errno_missing(VALUE self, VALUE id)
{
return eNOERROR;
}
@ -1039,7 +933,7 @@ errno_missing(self, id)
*/
void
Init_Exception()
Init_Exception(void)
{
rb_eException = rb_define_class("Exception", rb_cObject);
rb_define_singleton_method(rb_eException, "exception", rb_class_new_instance, -1);
@ -1103,44 +997,31 @@ Init_Exception()
}
void
#ifdef HAVE_STDARG_PROTOTYPES
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;
char buf[BUFSIZ];
va_init_list(args,fmt);
va_start(args,fmt);
vsnprintf(buf, BUFSIZ, fmt, args);
va_end(args);
rb_exc_raise(rb_exc_new2(exc, buf));
}
void
#ifdef HAVE_STDARG_PROTOTYPES
rb_loaderror(const char *fmt, ...)
#else
rb_loaderror(fmt, va_alist)
const char *fmt;
va_dcl
#endif
{
va_list args;
char buf[BUFSIZ];
va_init_list(args, fmt);
va_start(args, fmt);
vsnprintf(buf, BUFSIZ, fmt, args);
va_end(args);
rb_exc_raise(rb_exc_new2(rb_eLoadError, buf));
}
void
rb_notimplement()
rb_notimplement(void)
{
rb_raise(rb_eNotImpError,
"The %s() function is unimplemented on this machine",
@ -1148,18 +1029,12 @@ rb_notimplement()
}
void
#ifdef HAVE_STDARG_PROTOTYPES
rb_fatal(const char *fmt, ...)
#else
rb_fatal(fmt, va_alist)
const char *fmt;
va_dcl
#endif
{
va_list args;
char buf[BUFSIZ];
va_init_list(args, fmt);
va_start(args, fmt);
vsnprintf(buf, BUFSIZ, fmt, args);
va_end(args);
@ -1168,8 +1043,7 @@ rb_fatal(fmt, va_alist)
}
void
rb_sys_fail(mesg)
const char *mesg;
rb_sys_fail(const char *mesg)
{
int n = errno;
VALUE arg;
@ -1184,13 +1058,7 @@ rb_sys_fail(mesg)
}
void
#ifdef HAVE_STDARG_PROTOTYPES
rb_sys_warning(const char *fmt, ...)
#else
rb_sys_warning(fmt, va_alist)
const char *fmt;
va_dcl
#endif
{
char buf[BUFSIZ];
va_list args;
@ -1203,35 +1071,32 @@ rb_sys_warning(fmt, va_alist)
snprintf(buf, BUFSIZ, "warning: %s", fmt);
snprintf(buf+strlen(buf), BUFSIZ-strlen(buf), ": %s", strerror(errno_save));
va_init_list(args, fmt);
va_start(args, fmt);
warn_print(buf, args);
va_end(args);
errno = errno_save;
}
void
rb_load_fail(path)
const char *path;
rb_load_fail(const char *path)
{
rb_loaderror("%s -- %s", strerror(errno), path);
}
void
rb_error_frozen(what)
const char *what;
rb_error_frozen(const char *what)
{
rb_raise(rb_eRuntimeError, "can't modify frozen %s", what);
}
void
rb_check_frozen(obj)
VALUE obj;
rb_check_frozen(VALUE obj)
{
if (OBJ_FROZEN(obj)) rb_error_frozen(rb_obj_classname(obj));
}
void
Init_syserr()
Init_syserr(void)
{
#ifdef EPERM
set_syserr(EPERM, "EPERM");
@ -1603,8 +1468,7 @@ Init_syserr()
}
static void
err_append(s)
const char *s;
err_append(const char *s)
{
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_limit = GC_MALLOC_LIMIT;
static void run_final();
static void run_final(VALUE obj);
static VALUE nomem_error;
static void garbage_collect();
static void garbage_collect(void);
void
rb_memerror()
rb_memerror(void)
{
static int recurse = 0;
@ -107,8 +107,7 @@ rb_memerror()
}
void *
ruby_xmalloc(size)
long size;
ruby_xmalloc(long size)
{
void *mem;
@ -134,8 +133,7 @@ ruby_xmalloc(size)
}
void *
ruby_xcalloc(n, size)
long n, size;
ruby_xcalloc(long n, long size)
{
void *mem;
@ -146,9 +144,7 @@ ruby_xcalloc(n, size)
}
void *
ruby_xrealloc(ptr, size)
void *ptr;
long size;
ruby_xrealloc(void *ptr, long size)
{
void *mem;
@ -171,8 +167,7 @@ ruby_xrealloc(ptr, size)
}
void
ruby_xfree(x)
void *x;
ruby_xfree(void *x)
{
if (x)
RUBY_CRITICAL(free(x));
@ -198,7 +193,7 @@ static st_table *finalizer_table = 0;
*/
VALUE
rb_gc_enable()
rb_gc_enable(void)
{
int old = dont_gc;
@ -219,7 +214,7 @@ rb_gc_enable()
*/
VALUE
rb_gc_disable()
rb_gc_disable(void)
{
int old = dont_gc;
@ -235,8 +230,7 @@ static struct gc_list {
} *global_List = 0;
void
rb_gc_register_address(addr)
VALUE *addr;
rb_gc_register_address(VALUE *addr)
{
struct gc_list *tmp;
@ -247,8 +241,7 @@ rb_gc_register_address(addr)
}
void
rb_gc_unregister_address(addr)
VALUE *addr;
rb_gc_unregister_address(VALUE *addr)
{
struct gc_list *tmp = global_List;
@ -272,8 +265,7 @@ rb_gc_unregister_address(addr)
#undef GC_DEBUG
void
rb_global_variable(var)
VALUE *var;
rb_global_variable(VALUE *var)
{
rb_gc_register_address(var);
}
@ -326,7 +318,7 @@ static int heap_slots = HEAP_MIN_SLOTS;
static RVALUE *himem, *lomem;
static void
add_heap()
add_heap(void)
{
RVALUE *p, *pend;
@ -376,7 +368,7 @@ add_heap()
#define RANY(o) ((RVALUE*)(o))
VALUE
rb_newobj()
rb_newobj(void)
{
VALUE obj;
@ -393,11 +385,7 @@ rb_newobj()
}
VALUE
rb_data_object_alloc(klass, datap, dmark, dfree)
VALUE klass;
void *datap;
RUBY_DATA_FUNC dmark;
RUBY_DATA_FUNC dfree;
rb_data_object_alloc(VALUE klass, void *datap, RUBY_DATA_FUNC dmark, RUBY_DATA_FUNC dfree)
{
NEWOBJ(data, struct RData);
if (klass) Check_Type(klass, T_CLASS);
@ -477,8 +465,7 @@ stack_grow_direction(addr)
} while (0)
int
ruby_stack_length(p)
VALUE **p;
ruby_stack_length(VALUE **p)
{
SET_STACK_END;
if (p) *p = STACK_UPPER(STACK_END, rb_gc_stack_start, STACK_END);
@ -486,7 +473,7 @@ ruby_stack_length(p)
}
int
ruby_stack_check()
ruby_stack_check(void)
{
int ret;
@ -500,7 +487,7 @@ static VALUE *mark_stack_ptr;
static int mark_stack_overflow;
static void
init_mark_stack()
init_mark_stack(void)
{
mark_stack_overflow = 0;
mark_stack_ptr = mark_stack;
@ -511,8 +498,7 @@ init_mark_stack()
static st_table *source_filenames;
char *
rb_source_filename(f)
const char *f;
rb_source_filename(const char *f)
{
char *name;
@ -528,8 +514,7 @@ rb_source_filename(f)
}
static void
mark_source_filename(f)
char *f;
mark_source_filename(char *f)
{
if (f) {
f[-1] = 1;
@ -537,8 +522,7 @@ mark_source_filename(f)
}
static int
sweep_source_filename(key, value)
char *key, *value;
sweep_source_filename(char *key, char *value)
{
if (*value) {
*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_all()
gc_mark_all(void)
{
RVALUE *p, *pend;
int i;
@ -573,7 +557,7 @@ gc_mark_all()
}
static void
gc_mark_rest()
gc_mark_rest(void)
{
VALUE tmp_arry[MARK_STACK_MAX];
VALUE *p;
@ -589,8 +573,7 @@ gc_mark_rest()
}
static inline int
is_pointer_to_heap(ptr)
void *ptr;
is_pointer_to_heap(void *ptr)
{
register RVALUE *p = RANY(ptr);
register RVALUE *heap_org;
@ -609,9 +592,7 @@ is_pointer_to_heap(ptr)
}
static void
mark_locations_array(x, n)
register VALUE *x;
register long n;
mark_locations_array(register VALUE *x, register long n)
{
VALUE v;
while (n--) {
@ -624,8 +605,7 @@ mark_locations_array(x, n)
}
void
rb_gc_mark_locations(start, end)
VALUE *start, *end;
rb_gc_mark_locations(VALUE *start, VALUE *end)
{
long n;
@ -634,36 +614,27 @@ rb_gc_mark_locations(start, end)
}
static int
mark_entry(key, value, lev)
ID key;
VALUE value;
int lev;
mark_entry(ID key, VALUE value, int lev)
{
gc_mark(value, lev);
return ST_CONTINUE;
}
void
mark_tbl(tbl, lev)
st_table *tbl;
int lev;
mark_tbl(st_table *tbl, int lev)
{
if (!tbl) return;
st_foreach(tbl, mark_entry, lev);
}
void
rb_mark_tbl(tbl)
st_table *tbl;
rb_mark_tbl(st_table *tbl)
{
mark_tbl(tbl, 0);
}
static int
mark_keyvalue(key, value, lev)
VALUE key;
VALUE value;
int lev;
mark_keyvalue(VALUE key, VALUE value, int lev)
{
gc_mark(key, lev);
gc_mark(value, lev);
@ -671,24 +642,20 @@ mark_keyvalue(key, value, lev)
}
void
mark_hash(tbl, lev)
st_table *tbl;
int lev;
mark_hash(st_table *tbl, int lev)
{
if (!tbl) return;
st_foreach(tbl, mark_keyvalue, lev);
}
void
rb_mark_hash(tbl)
st_table *tbl;
rb_mark_hash(st_table *tbl)
{
mark_hash(tbl, 0);
}
void
rb_gc_mark_maybe(obj)
VALUE obj;
rb_gc_mark_maybe(VALUE obj)
{
if (is_pointer_to_heap((void *)obj)) {
gc_mark(obj, 0);
@ -698,9 +665,7 @@ rb_gc_mark_maybe(obj)
#define GC_LEVEL_MAX 250
static void
gc_mark(ptr, lev)
VALUE ptr;
int lev;
gc_mark(VALUE ptr, int lev)
{
register RVALUE *obj;
@ -726,16 +691,13 @@ gc_mark(ptr, lev)
}
void
rb_gc_mark(ptr)
VALUE ptr;
rb_gc_mark(VALUE ptr)
{
gc_mark(ptr, 0);
}
static void
gc_mark_children(ptr, lev)
VALUE ptr;
int lev;
gc_mark_children(VALUE ptr, int lev)
{
register RVALUE *obj = RANY(ptr);
@ -993,8 +955,7 @@ gc_mark_children(ptr, lev)
static void obj_free _((VALUE));
static void
finalize_list(p)
RVALUE *p;
finalize_list(RVALUE *p)
{
while (p) {
RVALUE *tmp = p->as.free.next;
@ -1009,7 +970,7 @@ finalize_list(p)
}
static void
free_unused_heaps()
free_unused_heaps(void)
{
int i, j;
@ -1028,7 +989,7 @@ free_unused_heaps()
}
static void
gc_sweep()
gc_sweep(void)
{
RVALUE *p, *pend, *final_list;
int freed = 0;
@ -1106,8 +1067,7 @@ gc_sweep()
}
void
rb_gc_force_recycle(p)
VALUE p;
rb_gc_force_recycle(VALUE p)
{
RANY(p)->as.free.flags = 0;
RANY(p)->as.free.next = freelist;
@ -1115,8 +1075,7 @@ rb_gc_force_recycle(p)
}
static void
obj_free(obj)
VALUE obj;
obj_free(VALUE obj)
{
switch (RANY(obj)->as.basic.flags & T_MASK) {
case T_NIL:
@ -1242,8 +1201,7 @@ obj_free(obj)
}
void
rb_gc_mark_frame(frame)
struct FRAME *frame;
rb_gc_mark_frame(struct FRAME *frame)
{
gc_mark((VALUE)frame->node, 0);
}
@ -1287,7 +1245,7 @@ int rb_setjmp (rb_jmp_buf);
#endif /* __GNUC__ */
static void
garbage_collect()
garbage_collect(void)
{
struct gc_list *list;
struct FRAME * volatile frame; /* gcc 2.7.2.3 -O2 bug?? */
@ -1400,7 +1358,7 @@ garbage_collect()
}
void
rb_gc()
rb_gc(void)
{
garbage_collect();
rb_gc_finalize_deferred();
@ -1417,15 +1375,14 @@ rb_gc()
*/
VALUE
rb_gc_start()
rb_gc_start(void)
{
rb_gc();
return Qnil;
}
void
ruby_set_stack_size(size)
size_t size;
ruby_set_stack_size(size_t size)
{
#ifndef STACK_LEVEL_MAX
STACK_LEVEL_MAX = size/sizeof(VALUE);
@ -1433,8 +1390,7 @@ ruby_set_stack_size(size)
}
void
Init_stack(addr)
VALUE *addr;
Init_stack(VALUE *addr)
{
#if defined(_WIN32) || defined(__CYGWIN__)
MEMORY_BASIC_INFORMATION m;
@ -1505,7 +1461,7 @@ Init_stack(addr)
*/
void
Init_heap()
Init_heap(void)
{
if (!rb_gc_stack_start) {
Init_stack(0);
@ -1514,7 +1470,7 @@ Init_heap()
}
static VALUE
os_live_obj()
os_live_obj(void)
{
int i;
int n = 0;
@ -1546,8 +1502,7 @@ os_live_obj()
}
static VALUE
os_obj_of(of)
VALUE of;
os_obj_of(VALUE of)
{
int i;
int n = 0;
@ -1614,9 +1569,7 @@ os_obj_of(of)
*/
static VALUE
os_each_obj(argc, argv)
int argc;
VALUE *argv;
os_each_obj(int argc, VALUE *argv)
{
VALUE of;
@ -1635,8 +1588,7 @@ static VALUE finalizers;
*/
static VALUE
add_final(os, block)
VALUE os, block;
add_final(VALUE os, VALUE block)
{
rb_warn("ObjectSpace::add_finalizer is deprecated; use define_finalizer");
if (!rb_respond_to(block, rb_intern("call"))) {
@ -1651,8 +1603,7 @@ add_final(os, block)
* deprecated
*/
static VALUE
rm_final(os, block)
VALUE os, block;
rm_final(VALUE os, VALUE block)
{
rb_warn("ObjectSpace::remove_finalizer is deprecated; use undefine_finalizer");
rb_ary_delete(finalizers, block);
@ -1663,7 +1614,7 @@ rm_final(os, block)
* deprecated
*/
static VALUE
finals()
finals(void)
{
rb_warn("ObjectSpace::finalizers is deprecated");
return finalizers;
@ -1674,8 +1625,7 @@ finals()
*/
static VALUE
call_final(os, obj)
VALUE os, obj;
call_final(VALUE os, VALUE obj)
{
rb_warn("ObjectSpace::call_finalizer is deprecated; use define_finalizer");
need_call_final = 1;
@ -1692,8 +1642,7 @@ call_final(os, obj)
*/
static VALUE
undefine_final(os, obj)
VALUE os, obj;
undefine_final(VALUE os, VALUE obj)
{
if (finalizer_table) {
st_delete(finalizer_table, (st_data_t*)&obj, 0);
@ -1711,10 +1660,7 @@ undefine_final(os, obj)
*/
static VALUE
define_final(argc, argv, os)
int argc;
VALUE *argv;
VALUE os;
define_final(int argc, VALUE *argv, VALUE os)
{
VALUE obj, block, table;
@ -1744,8 +1690,7 @@ define_final(argc, argv, os)
}
void
rb_gc_copy_finalizer(dest, obj)
VALUE dest, obj;
rb_gc_copy_finalizer(VALUE dest, VALUE obj)
{
VALUE table;
@ -1758,16 +1703,14 @@ rb_gc_copy_finalizer(dest, obj)
}
static VALUE
run_single_final(args)
VALUE *args;
run_single_final(VALUE *args)
{
rb_eval_cmd(args[0], args[1], (int)args[2]);
return Qnil;
}
static void
run_final(obj)
VALUE obj;
run_final(VALUE obj)
{
long i;
int status, critical_save = rb_thread_critical;
@ -1795,7 +1738,7 @@ run_final(obj)
}
void
rb_gc_finalize_deferred()
rb_gc_finalize_deferred(void)
{
RVALUE *p = deferred_final_list;
@ -1807,7 +1750,7 @@ rb_gc_finalize_deferred()
}
void
rb_gc_call_finalizer_at_exit()
rb_gc_call_finalizer_at_exit(void)
{
RVALUE *p, *pend;
int i;
@ -1868,8 +1811,7 @@ rb_gc_call_finalizer_at_exit()
*/
static VALUE
id2ref(obj, id)
VALUE obj, id;
id2ref(VALUE obj, VALUE id)
{
#if SIZEOF_LONG == SIZEOF_VOIDP
#define NUM2PTR(x) NUM2ULONG(x)
@ -1908,7 +1850,7 @@ id2ref(obj, id)
*/
void
Init_GC()
Init_GC(void)
{
VALUE rb_mObSpace;

375
hash.c

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

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

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

626
io.c

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

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

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

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

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

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

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

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

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

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

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

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

@ -135,8 +135,7 @@ define_swapx(f,float)
#else
#if SIZEOF_LONG == 4 /* SIZEOF_DOUBLE == 8 && 4 == SIZEOF_LONG */
static double
swapd(d)
const double d;
swapd(const double d)
{
double dtmp = d;
unsigned long utmp[2];
@ -334,8 +333,7 @@ endian()
unsigned long rb_big2ulong_pack _((VALUE x));
static unsigned long
num2i32(x)
VALUE x;
num2i32(VALUE x)
{
x = rb_to_int(x); /* is nil OK? (should not) */
@ -438,8 +436,7 @@ static unsigned long utf8_to_uv _((char*,long*));
*/
static VALUE
pack_pack(ary, fmt)
VALUE ary, fmt;
pack_pack(VALUE ary, VALUE fmt)
{
static char *nul10 = "\0\0\0\0\0\0\0\0\0\0";
static char *spc10 = " ";
@ -1008,11 +1005,7 @@ static char b64_table[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
static void
encodes(str, s, len, type)
VALUE str;
char *s;
long len;
int type;
encodes(VALUE str, char *s, long len, int type)
{
char *buff = ALLOCA_N(char, len * 4 / 3 + 6);
long i = 0;
@ -1053,9 +1046,7 @@ encodes(str, s, len, type)
static char hex_table[] = "0123456789ABCDEF";
static void
qpencode(str, from, len)
VALUE str, from;
long len;
qpencode(VALUE str, VALUE from, long len)
{
char buff[1024];
long i = 0, n = 0, prev = EOF;
@ -1108,8 +1099,7 @@ qpencode(str, from, len)
}
static inline int
hex2num(c)
char c;
hex2num(char c)
{
switch (c) {
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)
static VALUE
infected_str_new(ptr, len, str)
const char *ptr;
long len;
VALUE str;
infected_str_new(const char *ptr, long len, VALUE str)
{
VALUE s = rb_str_new(ptr, len);
@ -1299,8 +1286,7 @@ infected_str_new(ptr, len, str)
*/
static VALUE
pack_unpack(str, fmt)
VALUE str, fmt;
pack_unpack(VALUE str, VALUE fmt)
{
static char *hexdigits = "0123456789abcdef0123456789ABCDEFx";
char *s, *send;
@ -1990,9 +1976,7 @@ pack_unpack(str, fmt)
#define BYTEWIDTH 8
static int
uv_to_utf8(buf, uv)
char *buf;
unsigned long uv;
uv_to_utf8(char *buf, unsigned long uv)
{
if (uv <= 0x7f) {
buf[0] = (char)uv;
@ -2047,9 +2031,7 @@ static const long utf8_limits[] = {
};
static unsigned long
utf8_to_uv(p, lenp)
char *p;
long *lenp;
utf8_to_uv(char *p, long *lenp)
{
int c = *p++ & 0xff;
unsigned long uv = c;
@ -2099,7 +2081,7 @@ utf8_to_uv(p, lenp)
}
void
Init_pack()
Init_pack(void)
{
rb_define_method(rb_cArray, "pack", pack_pack, 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
prec_prec(x, klass)
VALUE x, klass;
prec_prec(VALUE x, VALUE klass)
{
return rb_funcall(klass, prc_if, 1, x);
}
@ -47,8 +46,7 @@ prec_prec(x, klass)
*/
static VALUE
prec_prec_i(x)
VALUE x;
prec_prec_i(VALUE x)
{
VALUE klass = rb_cInteger;
@ -64,8 +62,7 @@ prec_prec_i(x)
*/
static VALUE
prec_prec_f(x)
VALUE x;
prec_prec_f(VALUE x)
{
VALUE klass = rb_cFloat;
@ -86,8 +83,7 @@ prec_prec_f(x)
*/
static VALUE
prec_induced_from(module, x)
VALUE module, x;
prec_induced_from(VALUE module, VALUE x)
{
rb_raise(rb_eTypeError, "undefined conversion from %s into %s",
rb_obj_classname(x), rb_class2name(module));
@ -104,8 +100,7 @@ prec_induced_from(module, x)
*/
static VALUE
prec_included(module, include)
VALUE module, include;
prec_included(VALUE module, VALUE include)
{
switch (TYPE(include)) {
case T_CLASS:
@ -128,7 +123,7 @@ prec_included(module, include)
*/
void
Init_Precision()
Init_Precision(void)
{
rb_mPrecision = rb_define_module("Precision");
rb_define_singleton_method(rb_mPrecision, "included", prec_included, 1);

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

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

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

@ -76,8 +76,7 @@ static unsigned long *next;
/* initializes state[N] with a seed */
static void
init_genrand(s)
unsigned long s;
init_genrand(unsigned long s)
{
int j;
state[0]= s & 0xffffffffUL;
@ -124,7 +123,7 @@ init_by_array(unsigned long init_key[], int key_length)
}
static void
next_state()
next_state(void)
{
unsigned long *p=state;
int j;
@ -165,7 +164,7 @@ genrand_int32(void)
/* generates a random number on [0,1) with 53-bit resolution*/
static double
genrand_real(void)
genrand_real(void)
{
unsigned long a=genrand_int32()>>5, b=genrand_int32()>>6;
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
rand_init(vseed)
VALUE vseed;
rand_init(VALUE vseed)
{
volatile VALUE seed;
VALUE old;
@ -253,7 +251,7 @@ rand_init(vseed)
}
static VALUE
random_seed()
random_seed(void)
{
static int n = 0;
struct timeval tv;
@ -320,10 +318,7 @@ random_seed()
*/
static VALUE
rb_f_srand(argc, argv, obj)
int argc;
VALUE *argv;
VALUE obj;
rb_f_srand(int argc, VALUE *argv, VALUE obj)
{
VALUE seed, old;
@ -436,10 +431,7 @@ limited_big_rand(struct RBignum *limit)
*/
static VALUE
rb_f_rand(argc, argv, obj)
int argc;
VALUE *argv;
VALUE obj;
rb_f_rand(int argc, VALUE *argv, VALUE obj)
{
VALUE vmax;
long val, max;
@ -495,7 +487,7 @@ rb_f_rand(argc, argv, obj)
}
void
Init_Random()
Init_Random(void)
{
rb_define_global_function("srand", rb_f_srand, -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)
static VALUE
range_failed()
range_failed(void)
{
rb_raise(rb_eArgError, "bad value for range");
return Qnil; /* dummy */
}
static VALUE
range_check(args)
VALUE *args;
range_check(VALUE *args)
{
return rb_funcall(args[0], id_cmp, 1, args[1]);
}
static void
range_init(range, beg, end, exclude_end)
VALUE range, beg, end;
int exclude_end;
range_init(VALUE range, VALUE beg, VALUE end, int exclude_end)
{
VALUE args[2];
@ -55,9 +52,7 @@ range_init(range, beg, end, exclude_end)
}
VALUE
rb_range_new(beg, end, exclude_end)
VALUE beg, end;
int exclude_end;
rb_range_new(VALUE beg, VALUE end, int exclude_end)
{
VALUE range = rb_obj_alloc(rb_cRange);
@ -75,10 +70,7 @@ rb_range_new(beg, end, exclude_end)
*/
static VALUE
range_initialize(argc, argv, range)
int argc;
VALUE *argv;
VALUE range;
range_initialize(int argc, VALUE *argv, VALUE range)
{
VALUE beg, end, flags;
@ -100,8 +92,7 @@ range_initialize(argc, argv, range)
*/
static VALUE
range_exclude_end_p(range)
VALUE range;
range_exclude_end_p(VALUE range)
{
return EXCL(range) ? Qtrue : Qfalse;
}
@ -122,8 +113,7 @@ range_exclude_end_p(range)
*/
static VALUE
range_eq(range, obj)
VALUE range, obj;
range_eq(VALUE range, VALUE obj)
{
if (range == obj) return Qtrue;
if (!rb_obj_is_instance_of(obj, rb_obj_class(range)))
@ -140,8 +130,7 @@ range_eq(range, obj)
}
static int
r_lt(a, b)
VALUE a, b;
r_lt(VALUE a, VALUE b)
{
VALUE r = rb_funcall(a, id_cmp, 1, b);
@ -151,8 +140,7 @@ r_lt(a, b)
}
static int
r_le(a, b)
VALUE a, b;
r_le(VALUE a, VALUE b)
{
int c;
VALUE r = rb_funcall(a, id_cmp, 1, b);
@ -180,8 +168,7 @@ r_le(a, b)
*/
static VALUE
range_eql(range, obj)
VALUE range, obj;
range_eql(VALUE range, VALUE obj)
{
if (range == obj) return Qtrue;
if (!rb_obj_is_instance_of(obj, rb_obj_class(range)))
@ -207,8 +194,7 @@ range_eql(range, obj)
*/
static VALUE
range_hash(range)
VALUE range;
range_hash(VALUE range)
{
long hash = EXCL(range);
VALUE v;
@ -223,18 +209,15 @@ range_hash(range)
}
static VALUE
str_step(args)
VALUE *args;
str_step(VALUE arg)
{
VALUE *args = (VALUE *)arg;
return rb_str_upto(args[0], args[1], EXCL(args[2]));
}
static void
range_each_func(range, func, v, e, arg)
VALUE range;
void (*func) _((VALUE, void*));
VALUE v, e;
void *arg;
range_each_func(VALUE range, VALUE (*func) (VALUE, void *), VALUE v, VALUE e, void *arg)
{
int c;
@ -254,10 +237,10 @@ range_each_func(range, func, v, e, arg)
}
static VALUE
step_i(i, iter)
VALUE i;
long *iter;
step_i(VALUE i, void *arg)
{
long *iter = (long *)arg;
iter[0]--;
if (iter[0] == 0) {
rb_yield(i);
@ -295,10 +278,7 @@ step_i(i, iter)
static VALUE
range_step(argc, argv, range)
int argc;
VALUE *argv;
VALUE range;
range_step(int argc, VALUE *argv, VALUE range)
{
VALUE b, e, step;
long unit;
@ -335,8 +315,7 @@ range_step(argc, argv, range)
b = tmp;
args[0] = b; args[1] = e; args[2] = range;
iter[0] = 1; iter[1] = unit;
rb_iterate((VALUE(*)_((VALUE)))str_step, (VALUE)args, step_i,
(VALUE)iter);
rb_iterate(str_step, (VALUE)args, step_i, (VALUE)iter);
}
else if (rb_obj_is_kind_of(b, rb_cNumeric)) {
ID c = rb_intern(EXCL(range) ? "<" : "<=");
@ -362,12 +341,11 @@ range_step(argc, argv, range)
return range;
}
static void
each_i(v, arg)
VALUE v;
void *arg;
static VALUE
each_i(VALUE v, void *arg)
{
rb_yield(v);
return Qnil;
}
/*
@ -389,8 +367,7 @@ each_i(v, arg)
*/
static VALUE
range_each(range)
VALUE range;
range_each(VALUE range)
{
VALUE beg, end;
@ -418,8 +395,7 @@ range_each(range)
args[0] = beg; args[1] = end; args[2] = range;
iter[0] = 1; iter[1] = 1;
rb_iterate((VALUE(*)_((VALUE)))str_step, (VALUE)args, step_i,
(VALUE)iter);
rb_iterate(str_step, (VALUE)args, step_i, (VALUE)iter);
}
else {
range_each_func(range, each_i, beg, end, NULL);
@ -436,8 +412,7 @@ range_each(range)
*/
static VALUE
range_first(range)
VALUE range;
range_first(VALUE range)
{
return rb_ivar_get(range, id_beg);
}
@ -456,18 +431,13 @@ range_first(range)
static VALUE
range_last(range)
VALUE range;
range_last(VALUE range)
{
return rb_ivar_get(range, id_end);
}
VALUE
rb_range_beg_len(range, begp, lenp, len, err)
VALUE range;
long *begp, *lenp;
long len;
int err;
rb_range_beg_len(VALUE range, long *begp, long *lenp, long len, int err)
{
VALUE b, e;
long beg, end, excl;
@ -520,8 +490,7 @@ rb_range_beg_len(range, begp, lenp, len, err)
*/
static VALUE
range_to_s(range)
VALUE range;
range_to_s(VALUE range)
{
VALUE str, str2;
@ -546,8 +515,7 @@ range_to_s(range)
static VALUE
range_inspect(range)
VALUE range;
range_inspect(VALUE range)
{
VALUE str, str2;
@ -584,8 +552,7 @@ range_inspect(range)
*/
static VALUE
range_include(range, val)
VALUE range, val;
range_include(VALUE range, VALUE val)
{
VALUE beg, end;
@ -656,7 +623,7 @@ range_include(range, val)
*/
void
Init_Range()
Init_Range(void)
{
rb_cRange = rb_define_class("Range", rb_cObject);
rb_include_module(rb_cRange, rb_mEnumerable);

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

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

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

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

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

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

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

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

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

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

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

@ -1050,7 +1050,7 @@ onig_node_free(Node* node)
#ifdef USE_RECYCLE_NODE
extern int
onig_free_node_list()
onig_free_node_list(void)
{
FreeNode* n;
@ -1066,7 +1066,7 @@ onig_free_node_list()
#endif
static Node*
node_new()
node_new(void)
{
Node* node;
@ -1094,7 +1094,7 @@ initialize_cclass(CClassNode* cc)
}
static Node*
node_new_cclass()
node_new_cclass(void)
{
Node* node = node_new();
CHECK_NULL_RETURN(node);
@ -1163,7 +1163,7 @@ node_new_ctype(int type)
}
static Node*
node_new_anychar()
node_new_anychar(void)
{
Node* node = node_new();
CHECK_NULL_RETURN(node);
@ -1434,7 +1434,7 @@ node_new_str_raw(UChar* s, UChar* end)
}
static Node*
node_new_empty()
node_new_empty(void)
{
return node_new_str(NULL, NULL);
}
@ -4660,7 +4660,7 @@ i_free_shared_class(type_cclass_key* key, Node* node, void* arg)
}
extern int
onig_free_shared_cclass_table()
onig_free_shared_cclass_table(void)
{
if (IS_NOT_NULL(OnigTypeCClassTable)) {
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_list P_((Node* left, Node* right));
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_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 void
usage(name)
const char *name;
usage(const char *name)
{
/* This message really ought to be max 23 lines.
* 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__
static char *
rubylib_mangle(s, l)
char *s;
unsigned int l;
rubylib_mangle(char *s, unsigned int l)
{
static char *newp, *oldp;
static int newl, oldl, notfound;
@ -178,9 +175,7 @@ rubylib_mangle(s, l)
#endif
void
ruby_push_include(path, filter)
const char *path;
VALUE (*filter)_((VALUE));
ruby_push_include(const char *path, VALUE (*filter) (VALUE))
{
const char sep = PATH_SEP_CHAR;
@ -216,8 +211,7 @@ ruby_push_include(path, filter)
}
static VALUE
identical_path(path)
VALUE path;
identical_path(VALUE path)
{
return path;
}
@ -229,8 +223,7 @@ ruby_incpush(const char *path)
}
static VALUE
expand_include_path(path)
VALUE path;
expand_include_path(VALUE path)
{
char *p = RSTRING(path)->ptr;
if (!p) return path;
@ -250,12 +243,8 @@ ruby_incpush_expand(const char *path)
#endif
#if defined DOSISH || defined __CYGWIN__
static inline void translate_char _((char *, int, int));
static inline void
translate_char(p, from, to)
char *p;
int from, to;
translate_char(char *p, int from, int to)
{
while (*p) {
if ((unsigned char)*p == from)
@ -270,7 +259,7 @@ translate_char(p, from, to)
#endif
void
ruby_init_loadpath()
ruby_init_loadpath(void)
{
#if defined LOAD_RELATIVE
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 void
add_modules(mod)
const char *mod;
add_modules(const char *mod)
{
struct req_list *list;
@ -369,7 +357,7 @@ add_modules(mod)
extern void Init_ext _((void));
static void
require_libraries()
require_libraries(void)
{
extern NODE *ruby_eval_tree;
NODE *save[3];
@ -404,7 +392,7 @@ require_libraries()
}
static void
process_sflag()
process_sflag(void)
{
if (sflag) {
long n;
@ -465,8 +453,7 @@ process_sflag()
static void proc_options _((int argc, char **argv));
static char*
moreswitches(s)
char *s;
moreswitches(char *s)
{
int argc; char *argv[3];
char *p = s;
@ -487,9 +474,7 @@ moreswitches(s)
NODE *ruby_eval_tree;
static void
proc_options(argc, argv)
int argc;
char **argv;
proc_options(int argc, char **argv)
{
char *argv0 = argv[0];
int do_search;
@ -865,9 +850,7 @@ proc_options(argc, argv)
}
static void
load_file(fname, script)
const char *fname;
int script;
load_file(const char *fname, int script)
{
extern VALUE rb_stdin;
VALUE parser;
@ -994,14 +977,13 @@ load_file(fname, script)
}
void
rb_load_file(fname)
const char *fname;
rb_load_file(const char *fname)
{
load_file(fname, 0);
}
static void
load_stdin()
load_stdin(void)
{
forbid_setid("program input from stdin");
load_file("-", 1);
@ -1039,9 +1021,7 @@ set_arg0space()
#endif
static void
set_arg0(val, id)
VALUE val;
ID id;
set_arg0(VALUE val, ID id)
{
char *s;
long i;
@ -1115,8 +1095,7 @@ set_arg0(val, id)
}
void
ruby_script(name)
const char *name;
ruby_script(const char *name)
{
if (name) {
rb_progname = rb_tainted_str_new2(name);
@ -1127,7 +1106,7 @@ ruby_script(name)
static int uid, euid, gid, egid;
static void
init_ids()
init_ids(void)
{
uid = (int)getuid();
euid = (int)geteuid();
@ -1143,8 +1122,7 @@ init_ids()
}
static void
forbid_setid(s)
const char *s;
forbid_setid(const char *s)
{
if (euid != uid)
rb_raise(rb_eSecurityError, "no %s allowed while running setuid", s);
@ -1155,18 +1133,13 @@ forbid_setid(s)
}
static void
verbose_setter(val, id, variable)
VALUE val;
ID id;
VALUE *variable;
verbose_setter(VALUE val, ID id, VALUE *variable)
{
ruby_verbose = RTEST(val) ? Qtrue : val;
}
static VALUE
opt_W_getter(val, id)
VALUE val;
ID id;
opt_W_getter(VALUE val, ID id)
{
if (ruby_verbose == Qnil) return INT2FIX(0);
if (ruby_verbose == Qfalse) return INT2FIX(1);
@ -1175,7 +1148,7 @@ opt_W_getter(val, id)
}
void
ruby_prog_init()
ruby_prog_init(void)
{
init_ids();
@ -1209,9 +1182,7 @@ ruby_prog_init()
}
void
ruby_set_argv(argc, argv)
int argc;
char **argv;
ruby_set_argv(int argc, char **argv)
{
int i;
@ -1232,9 +1203,7 @@ NODE *rb_parser_append_print _((NODE*));
NODE *rb_parser_while_loop _((NODE*, int, int));
void
ruby_process_options(argc, argv)
int argc;
char **argv;
ruby_process_options(int argc, char **argv)
{
origargc = argc; origargv = argv;

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

@ -169,8 +169,7 @@ static struct signals {
};
static int
signm2signo(nm)
char *nm;
signm2signo(char *nm)
{
struct signals *sigs;
@ -181,8 +180,7 @@ signm2signo(nm)
}
static char*
signo2signm(no)
int no;
signo2signm(int no)
{
struct signals *sigs;
@ -193,8 +191,7 @@ signo2signm(no)
}
const char *
ruby_signal_name(no)
int no;
ruby_signal_name(int no)
{
return signo2signm(no);
}
@ -224,9 +221,7 @@ ruby_signal_name(no)
*/
VALUE
rb_f_kill(argc, argv)
int argc;
VALUE *argv;
rb_f_kill(int argc, VALUE *argv)
{
int negative = 0;
int sig;
@ -310,7 +305,7 @@ rb_atomic_t rb_trap_immediate;
int rb_prohibit_interrupt = 1;
void
rb_gc_mark_trap_list()
rb_gc_mark_trap_list(void)
{
#ifndef MACOS_UNUSE_SIGNAL
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)))
#ifdef HAVE_NATIVETHREAD
static sighandler_t
ruby_nativethread_signal(signum, handler)
int signum;
sighandler_t handler;
ruby_nativethread_signal(int signum, sighandler_t handler)
{
sighandler_t old;
@ -395,10 +388,8 @@ ruby_nativethread_signal(signum, handler)
#endif
#endif
static void signal_exec _((int sig));
static void
signal_exec(sig)
int sig;
signal_exec(int sig)
{
if (trap_list[sig].cmd == 0) {
switch (sig) {
@ -433,8 +424,7 @@ signal_exec(sig)
}
static void
sigsend_to_ruby_thread(sig)
int sig;
sigsend_to_ruby_thread(int sig)
{
#ifdef HAVE_NATIVETHREAD_KILL
# ifdef HAVE_SIGPROCMASK
@ -457,8 +447,7 @@ sigsend_to_ruby_thread(sig)
static RETSIGTYPE sighandler _((int));
static RETSIGTYPE
sighandler(sig)
int sig;
sighandler(int sig)
{
#ifdef _WIN32
#define IN_MAIN_CONTEXT(f, a) (rb_w32_main_context(a, f) ? (void)0 : f(a))
@ -495,10 +484,8 @@ sighandler(sig)
}
#ifdef SIGBUS
static RETSIGTYPE sigbus _((int));
static RETSIGTYPE
sigbus(sig)
int sig;
sigbus(int sig)
{
#if defined(HAVE_NATIVETHREAD) && defined(HAVE_NATIVETHREAD_KILL)
if (!is_ruby_native_thread() && !rb_trap_accept_nativethreads[sig]) {
@ -512,10 +499,8 @@ sigbus(sig)
#endif
#ifdef SIGSEGV
static RETSIGTYPE sigsegv _((int));
static RETSIGTYPE
sigsegv(sig)
int sig;
sigsegv(int sig)
{
#if defined(HAVE_NATIVETHREAD) && defined(HAVE_NATIVETHREAD_KILL)
if (!is_ruby_native_thread() && !rb_trap_accept_nativethreads[sig]) {
@ -529,17 +514,15 @@ sigsegv(sig)
#endif
#ifdef SIGPIPE
static RETSIGTYPE sigpipe _((int));
static RETSIGTYPE
sigpipe(sig)
int sig;
sigpipe(int sig)
{
/* do nothing */
}
#endif
void
rb_trap_exit()
rb_trap_exit(void)
{
#ifndef MACOS_UNUSE_SIGNAL
if (trap_list[0].cmd) {
@ -552,7 +535,7 @@ rb_trap_exit()
}
void
rb_trap_exec()
rb_trap_exec(void)
{
#ifndef MACOS_UNUSE_SIGNAL
int i;
@ -585,8 +568,7 @@ static int trap_last_mask;
# endif
static VALUE
trap(arg)
struct trap_arg *arg;
trap(struct trap_arg *arg)
{
sighandler_t func, oldfunc;
VALUE command, tmp, oldcmd;
@ -740,7 +722,7 @@ trap_ensure(arg)
#endif
void
rb_trap_restore_mask()
rb_trap_restore_mask(void)
{
#ifndef _WIN32
# ifdef HAVE_SIGPROCMASK
@ -780,9 +762,7 @@ rb_trap_restore_mask()
* Terminating: 27460
*/
static VALUE
sig_trap(argc, argv)
int argc;
VALUE *argv;
sig_trap(int argc, VALUE *argv)
{
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}
*/
static VALUE
sig_list()
sig_list(void)
{
VALUE h = rb_hash_new();
struct signals *sigs;
@ -839,9 +819,7 @@ sig_list()
}
static void
install_sighandler(signum, handler)
int signum;
sighandler_t handler;
install_sighandler(int signum, sighandler_t handler)
{
sighandler_t old;
@ -853,9 +831,7 @@ install_sighandler(signum, handler)
#ifdef HAVE_NATIVETHREAD
static void
install_nativethread_sighandler(signum, handler)
int signum;
sighandler_t handler;
install_nativethread_sighandler(int signum, sighandler_t handler)
{
sighandler_t old;
int old_st;
@ -873,8 +849,7 @@ install_nativethread_sighandler(signum, handler)
#endif
static void
init_sigchld(sig)
int sig;
init_sigchld(int sig)
{
sighandler_t oldfunc;
#ifndef _WIN32
@ -952,7 +927,7 @@ init_sigchld(sig)
* systems; in particular signal delivery may not always be reliable.
*/
void
Init_signal()
Init_signal(void)
{
#ifndef MACOS_UNUSE_SIGNAL
VALUE mSignal = rb_define_module("Signal");

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

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

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

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

547
string.c

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

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

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

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

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