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

* various files: macro fix-up by Michal Rokos.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2411 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2002-04-25 13:57:01 +00:00
parent 4ec25bdd63
commit b134b91278
10 changed files with 47 additions and 48 deletions

22
class.c
View file

@ -661,19 +661,23 @@ rb_undef_method(klass, name)
#if 0
#define SPECIAL_SINGLETON(x,c) if (obj == (x)) {\
if (!FL_TEST(c, FL_SINGLETON)) {\
c = rb_singleton_class_new(c);\
rb_singleton_class_attached(c,obj);\
#define SPECIAL_SINGLETON(x,c) do {
if (obj == (x)) {\
if (!FL_TEST(c, FL_SINGLETON)) {\
c = rb_singleton_class_new(c);\
rb_singleton_class_attached(c,obj);\
}\
return c;\
}\
return c;\
}
} while (0)
#else
#define SPECIAL_SINGLETON(x,c) if (obj == (x)) {\
return c;\
}
#define SPECIAL_SINGLETON(x,c) do {\
if (obj == (x)) {\
return c;\
}\
} while (0)
#endif

2
eval.c
View file

@ -116,7 +116,7 @@ static int scope_vmode;
#define SCOPE_PROTECTED 2
#define SCOPE_MODFUNC 5
#define SCOPE_MASK 7
#define SCOPE_SET(f) scope_vmode=(f)
#define SCOPE_SET(f) (scope_vmode=(f))
#define SCOPE_TEST(f) (scope_vmode&(f))
int ruby_safe_level = 0;

6
gc.c
View file

@ -365,9 +365,9 @@ static unsigned int STACK_LEVEL_MAX = 655300;
# define STACK_END (&stack_end)
#else
# if defined(__GNUC__) && defined(USE_BUILTIN_FRAME_ADDRESS)
# define SET_STACK_END VALUE *stack_end = __builtin_frame_address(0);
# define SET_STACK_END VALUE *stack_end = __builtin_frame_address(0)
# else
# define SET_STACK_END VALUE *stack_end = alloca(1);
# define SET_STACK_END VALUE *stack_end = alloca(1)
# endif
# define STACK_END (stack_end)
#endif
@ -381,7 +381,7 @@ static unsigned int STACK_LEVEL_MAX = 655300;
#define CHECK_STACK(ret) do {\
SET_STACK_END;\
(ret) = (STACK_LENGTH > STACK_LEVEL_MAX);\
} while (0)\
} while (0)
int
ruby_stack_length(p)

View file

@ -65,7 +65,9 @@ end
class Complex < Numeric
@RCS_ID='-$Id: complex.rb,v 1.3 1998/07/08 10:05:28 keiju Exp keiju $-'
undef step
def Complex.generic?(other)
other.kind_of?(Integer) or
other.kind_of?(Float) or

View file

@ -805,12 +805,12 @@ num_step(argc, argv, from)
long i = 0;
if (unit > 0) {
for (i=0; n<=end; i++, n=unit*i+beg) {
for (i=0; n<=end; i++, n=beg+unit*i) {
rb_yield(rb_float_new(n));
}
}
else {
for (i=0; n>=end; i++, n=unit*i+beg) {
for (i=0; n>=end; i++, n=beg+unit*i) {
rb_yield(rb_float_new(n));
}
}

7
pack.c
View file

@ -1046,12 +1046,11 @@ hex2num(c)
PACK_LENGTH_ADJUST_SIZE(t__len); \
} while (0)
#else
#define PACK_LENGTH_ADJUST(type,sz) do { \
PACK_LENGTH_ADJUST_SIZE(sizeof(type)); \
} while (0)
#define PACK_LENGTH_ADJUST(type,sz) \
PACK_LENGTH_ADJUST_SIZE(sizeof(type))
#endif
#define PACK_ITEM_ADJUST() while (tmp--) rb_ary_push(ary, Qnil);
#define PACK_ITEM_ADJUST() while (tmp--) rb_ary_push(ary, Qnil)
static VALUE
pack_unpack(str, fmt)

16
parse.y
View file

@ -68,12 +68,8 @@ typedef unsigned long stack_type;
#endif
static stack_type cond_stack = 0;
#define COND_PUSH(n) do {\
cond_stack = (cond_stack<<1)|((n)&1);\
} while(0)
#define COND_POP() do {\
cond_stack >>= 1;\
} while (0)
#define COND_PUSH(n) (cond_stack = (cond_stack<<1)|((n)&1))
#define COND_POP() (cond_stack >>= 1)
#define COND_LEXPOP() do {\
int last = COND_P();\
cond_stack >>= 1;\
@ -82,12 +78,8 @@ static stack_type cond_stack = 0;
#define COND_P() (cond_stack&1)
static stack_type cmdarg_stack = 0;
#define CMDARG_PUSH(n) do {\
cmdarg_stack = (cmdarg_stack<<1)|((n)&1);\
} while(0)
#define CMDARG_POP() do {\
cmdarg_stack >>= 1;\
} while (0)
#define CMDARG_PUSH(n) (cmdarg_stack = (cmdarg_stack<<1)|((n)&1))
#define CMDARG_POP() (cmdarg_stack >>= 1)
#define CMDARG_LEXPOP() do {\
int last = CMDARG_P();\
cmdarg_stack >>= 1;\

View file

@ -127,7 +127,7 @@ rb_f_srand(argc, argv, obj)
}
old = rand_init(seed);
return rb_uint2inum(old);
return UINT2NUM(old);
}
static VALUE
@ -170,7 +170,7 @@ rb_f_rand(argc, argv, obj)
val = max*RANDOM_NUMBER;
if (val < 0) val = -val;
return rb_int2inum(val);
return LONG2NUM(val);
}
void

View file

@ -69,9 +69,11 @@ extern int rb_prohibit_interrupt;
extern int rb_trap_pending;
void rb_trap_exec _((void));
# define CHECK_INTS if (!rb_prohibit_interrupt) {\
if (rb_trap_pending) rb_trap_exec();\
}
# define CHECK_INTS do {\
if (!rb_prohibit_interrupt) {\
if (rb_trap_pending) rb_trap_exec();\
}\
} while (0)
#endif
/* Make alloca work the best possible way. */
@ -419,7 +421,6 @@ re_set_syntax(syntax)
return 0;
}
/* Macros for re_compile_pattern, which is found below these definitions. */
#define TRANSLATE_P() ((options&RE_OPTION_IGNORECASE) && translate)

21
st.c
View file

@ -233,16 +233,17 @@ st_free_table(table)
#define COLLISION
#endif
#define FIND_ENTRY(table, ptr, hash_val, bin_pos) \
bin_pos = hash_val%(table)->num_bins;\
ptr = (table)->bins[bin_pos];\
if (PTR_NOT_EQUAL(table, ptr, hash_val, key)) {\
COLLISION;\
while (PTR_NOT_EQUAL(table, ptr->next, hash_val, key)) {\
#define FIND_ENTRY(table, ptr, hash_val, bin_pos) do {\
bin_pos = hash_val%(table)->num_bins;\
ptr = (table)->bins[bin_pos];\
if (PTR_NOT_EQUAL(table, ptr, hash_val, key)) {\
COLLISION;\
while (PTR_NOT_EQUAL(table, ptr->next, hash_val, key)) {\
ptr = ptr->next;\
}\
ptr = ptr->next;\
}\
ptr = ptr->next;\
}
} while (0)
int
st_lookup(table, key, value)
@ -266,7 +267,7 @@ st_lookup(table, key, value)
}
#define ADD_DIRECT(table, key, value, hash_val, bin_pos)\
{\
do {\
st_table_entry *entry;\
if (table->num_entries/(table->num_bins) > ST_DEFAULT_MAX_DENSITY) {\
rehash(table);\
@ -281,7 +282,7 @@ st_lookup(table, key, value)
entry->next = table->bins[bin_pos];\
table->bins[bin_pos] = entry;\
table->num_entries++;\
}
} while (0)
int
st_insert(table, key, value)