* 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:
parent
4ec25bdd63
commit
b134b91278
12
class.c
12
class.c
@ -661,19 +661,23 @@ rb_undef_method(klass, name)
|
|||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
|
||||||
#define SPECIAL_SINGLETON(x,c) if (obj == (x)) {\
|
#define SPECIAL_SINGLETON(x,c) do {
|
||||||
|
if (obj == (x)) {\
|
||||||
if (!FL_TEST(c, FL_SINGLETON)) {\
|
if (!FL_TEST(c, FL_SINGLETON)) {\
|
||||||
c = rb_singleton_class_new(c);\
|
c = rb_singleton_class_new(c);\
|
||||||
rb_singleton_class_attached(c,obj);\
|
rb_singleton_class_attached(c,obj);\
|
||||||
}\
|
}\
|
||||||
return c;\
|
return c;\
|
||||||
}
|
}\
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#define SPECIAL_SINGLETON(x,c) if (obj == (x)) {\
|
#define SPECIAL_SINGLETON(x,c) do {\
|
||||||
|
if (obj == (x)) {\
|
||||||
return c;\
|
return c;\
|
||||||
}
|
}\
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
2
eval.c
2
eval.c
@ -116,7 +116,7 @@ static int scope_vmode;
|
|||||||
#define SCOPE_PROTECTED 2
|
#define SCOPE_PROTECTED 2
|
||||||
#define SCOPE_MODFUNC 5
|
#define SCOPE_MODFUNC 5
|
||||||
#define SCOPE_MASK 7
|
#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))
|
#define SCOPE_TEST(f) (scope_vmode&(f))
|
||||||
|
|
||||||
int ruby_safe_level = 0;
|
int ruby_safe_level = 0;
|
||||||
|
6
gc.c
6
gc.c
@ -365,9 +365,9 @@ static unsigned int STACK_LEVEL_MAX = 655300;
|
|||||||
# define STACK_END (&stack_end)
|
# define STACK_END (&stack_end)
|
||||||
#else
|
#else
|
||||||
# if defined(__GNUC__) && defined(USE_BUILTIN_FRAME_ADDRESS)
|
# 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
|
# else
|
||||||
# define SET_STACK_END VALUE *stack_end = alloca(1);
|
# define SET_STACK_END VALUE *stack_end = alloca(1)
|
||||||
# endif
|
# endif
|
||||||
# define STACK_END (stack_end)
|
# define STACK_END (stack_end)
|
||||||
#endif
|
#endif
|
||||||
@ -381,7 +381,7 @@ static unsigned int STACK_LEVEL_MAX = 655300;
|
|||||||
#define CHECK_STACK(ret) do {\
|
#define CHECK_STACK(ret) do {\
|
||||||
SET_STACK_END;\
|
SET_STACK_END;\
|
||||||
(ret) = (STACK_LENGTH > STACK_LEVEL_MAX);\
|
(ret) = (STACK_LENGTH > STACK_LEVEL_MAX);\
|
||||||
} while (0)\
|
} while (0)
|
||||||
|
|
||||||
int
|
int
|
||||||
ruby_stack_length(p)
|
ruby_stack_length(p)
|
||||||
|
@ -66,6 +66,8 @@ end
|
|||||||
class Complex < Numeric
|
class Complex < Numeric
|
||||||
@RCS_ID='-$Id: complex.rb,v 1.3 1998/07/08 10:05:28 keiju Exp keiju $-'
|
@RCS_ID='-$Id: complex.rb,v 1.3 1998/07/08 10:05:28 keiju Exp keiju $-'
|
||||||
|
|
||||||
|
undef step
|
||||||
|
|
||||||
def Complex.generic?(other)
|
def Complex.generic?(other)
|
||||||
other.kind_of?(Integer) or
|
other.kind_of?(Integer) or
|
||||||
other.kind_of?(Float) or
|
other.kind_of?(Float) or
|
||||||
|
@ -805,12 +805,12 @@ num_step(argc, argv, from)
|
|||||||
long i = 0;
|
long i = 0;
|
||||||
|
|
||||||
if (unit > 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));
|
rb_yield(rb_float_new(n));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
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));
|
rb_yield(rb_float_new(n));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
7
pack.c
7
pack.c
@ -1046,12 +1046,11 @@ hex2num(c)
|
|||||||
PACK_LENGTH_ADJUST_SIZE(t__len); \
|
PACK_LENGTH_ADJUST_SIZE(t__len); \
|
||||||
} while (0)
|
} while (0)
|
||||||
#else
|
#else
|
||||||
#define PACK_LENGTH_ADJUST(type,sz) do { \
|
#define PACK_LENGTH_ADJUST(type,sz) \
|
||||||
PACK_LENGTH_ADJUST_SIZE(sizeof(type)); \
|
PACK_LENGTH_ADJUST_SIZE(sizeof(type))
|
||||||
} while (0)
|
|
||||||
#endif
|
#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
|
static VALUE
|
||||||
pack_unpack(str, fmt)
|
pack_unpack(str, fmt)
|
||||||
|
16
parse.y
16
parse.y
@ -68,12 +68,8 @@ typedef unsigned long stack_type;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static stack_type cond_stack = 0;
|
static stack_type cond_stack = 0;
|
||||||
#define COND_PUSH(n) do {\
|
#define COND_PUSH(n) (cond_stack = (cond_stack<<1)|((n)&1))
|
||||||
cond_stack = (cond_stack<<1)|((n)&1);\
|
#define COND_POP() (cond_stack >>= 1)
|
||||||
} while(0)
|
|
||||||
#define COND_POP() do {\
|
|
||||||
cond_stack >>= 1;\
|
|
||||||
} while (0)
|
|
||||||
#define COND_LEXPOP() do {\
|
#define COND_LEXPOP() do {\
|
||||||
int last = COND_P();\
|
int last = COND_P();\
|
||||||
cond_stack >>= 1;\
|
cond_stack >>= 1;\
|
||||||
@ -82,12 +78,8 @@ static stack_type cond_stack = 0;
|
|||||||
#define COND_P() (cond_stack&1)
|
#define COND_P() (cond_stack&1)
|
||||||
|
|
||||||
static stack_type cmdarg_stack = 0;
|
static stack_type cmdarg_stack = 0;
|
||||||
#define CMDARG_PUSH(n) do {\
|
#define CMDARG_PUSH(n) (cmdarg_stack = (cmdarg_stack<<1)|((n)&1))
|
||||||
cmdarg_stack = (cmdarg_stack<<1)|((n)&1);\
|
#define CMDARG_POP() (cmdarg_stack >>= 1)
|
||||||
} while(0)
|
|
||||||
#define CMDARG_POP() do {\
|
|
||||||
cmdarg_stack >>= 1;\
|
|
||||||
} while (0)
|
|
||||||
#define CMDARG_LEXPOP() do {\
|
#define CMDARG_LEXPOP() do {\
|
||||||
int last = CMDARG_P();\
|
int last = CMDARG_P();\
|
||||||
cmdarg_stack >>= 1;\
|
cmdarg_stack >>= 1;\
|
||||||
|
4
random.c
4
random.c
@ -127,7 +127,7 @@ rb_f_srand(argc, argv, obj)
|
|||||||
}
|
}
|
||||||
old = rand_init(seed);
|
old = rand_init(seed);
|
||||||
|
|
||||||
return rb_uint2inum(old);
|
return UINT2NUM(old);
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
@ -170,7 +170,7 @@ rb_f_rand(argc, argv, obj)
|
|||||||
val = max*RANDOM_NUMBER;
|
val = max*RANDOM_NUMBER;
|
||||||
|
|
||||||
if (val < 0) val = -val;
|
if (val < 0) val = -val;
|
||||||
return rb_int2inum(val);
|
return LONG2NUM(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
7
regex.c
7
regex.c
@ -69,9 +69,11 @@ extern int rb_prohibit_interrupt;
|
|||||||
extern int rb_trap_pending;
|
extern int rb_trap_pending;
|
||||||
void rb_trap_exec _((void));
|
void rb_trap_exec _((void));
|
||||||
|
|
||||||
# define CHECK_INTS if (!rb_prohibit_interrupt) {\
|
# define CHECK_INTS do {\
|
||||||
|
if (!rb_prohibit_interrupt) {\
|
||||||
if (rb_trap_pending) rb_trap_exec();\
|
if (rb_trap_pending) rb_trap_exec();\
|
||||||
}
|
}\
|
||||||
|
} while (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Make alloca work the best possible way. */
|
/* Make alloca work the best possible way. */
|
||||||
@ -419,7 +421,6 @@ re_set_syntax(syntax)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Macros for re_compile_pattern, which is found below these definitions. */
|
/* Macros for re_compile_pattern, which is found below these definitions. */
|
||||||
|
|
||||||
#define TRANSLATE_P() ((options&RE_OPTION_IGNORECASE) && translate)
|
#define TRANSLATE_P() ((options&RE_OPTION_IGNORECASE) && translate)
|
||||||
|
15
st.c
15
st.c
@ -233,16 +233,17 @@ st_free_table(table)
|
|||||||
#define COLLISION
|
#define COLLISION
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define FIND_ENTRY(table, ptr, hash_val, bin_pos) \
|
#define FIND_ENTRY(table, ptr, hash_val, bin_pos) do {\
|
||||||
bin_pos = hash_val%(table)->num_bins;\
|
bin_pos = hash_val%(table)->num_bins;\
|
||||||
ptr = (table)->bins[bin_pos];\
|
ptr = (table)->bins[bin_pos];\
|
||||||
if (PTR_NOT_EQUAL(table, ptr, hash_val, key)) {\
|
if (PTR_NOT_EQUAL(table, ptr, hash_val, key)) {\
|
||||||
COLLISION;\
|
COLLISION;\
|
||||||
while (PTR_NOT_EQUAL(table, ptr->next, hash_val, key)) {\
|
while (PTR_NOT_EQUAL(table, ptr->next, hash_val, key)) {\
|
||||||
ptr = ptr->next;\
|
ptr = ptr->next;\
|
||||||
}\
|
}\
|
||||||
ptr = ptr->next;\
|
ptr = ptr->next;\
|
||||||
}
|
}\
|
||||||
|
} while (0)
|
||||||
|
|
||||||
int
|
int
|
||||||
st_lookup(table, key, value)
|
st_lookup(table, key, value)
|
||||||
@ -266,7 +267,7 @@ st_lookup(table, key, value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define ADD_DIRECT(table, key, value, hash_val, bin_pos)\
|
#define ADD_DIRECT(table, key, value, hash_val, bin_pos)\
|
||||||
{\
|
do {\
|
||||||
st_table_entry *entry;\
|
st_table_entry *entry;\
|
||||||
if (table->num_entries/(table->num_bins) > ST_DEFAULT_MAX_DENSITY) {\
|
if (table->num_entries/(table->num_bins) > ST_DEFAULT_MAX_DENSITY) {\
|
||||||
rehash(table);\
|
rehash(table);\
|
||||||
@ -281,7 +282,7 @@ st_lookup(table, key, value)
|
|||||||
entry->next = table->bins[bin_pos];\
|
entry->next = table->bins[bin_pos];\
|
||||||
table->bins[bin_pos] = entry;\
|
table->bins[bin_pos] = entry;\
|
||||||
table->num_entries++;\
|
table->num_entries++;\
|
||||||
}
|
} while (0)
|
||||||
|
|
||||||
int
|
int
|
||||||
st_insert(table, key, value)
|
st_insert(table, key, value)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user