summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-04-25 13:57:01 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-04-25 13:57:01 +0000
commitb134b912780e0fd84fbc107a9362e45f04391b47 (patch)
tree3aad53ec0421149c8fb9e163379bba8efb2ab42e
parent4ec25bdd63c8cb9acf70880666c1d113ae0cb51e (diff)
* 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
-rw-r--r--class.c22
-rw-r--r--eval.c2
-rw-r--r--gc.c6
-rw-r--r--lib/complex.rb4
-rw-r--r--numeric.c4
-rw-r--r--pack.c7
-rw-r--r--parse.y16
-rw-r--r--random.c4
-rw-r--r--regex.c9
-rw-r--r--st.c21
10 files changed, 47 insertions, 48 deletions
diff --git a/class.c b/class.c
index 485653517b..1ead9b0027 100644
--- a/class.c
+++ b/class.c
@@ -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
diff --git a/eval.c b/eval.c
index 7fcb742430..48f844c506 100644
--- a/eval.c
+++ b/eval.c
@@ -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;
diff --git a/gc.c b/gc.c
index 69be3b21ba..b4d63650d8 100644
--- a/gc.c
+++ b/gc.c
@@ -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)
diff --git a/lib/complex.rb b/lib/complex.rb
index 77d8859a6a..2de1791288 100644
--- a/lib/complex.rb
+++ b/lib/complex.rb
@@ -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
diff --git a/numeric.c b/numeric.c
index 01dadb8471..3d97c52181 100644
--- a/numeric.c
+++ b/numeric.c
@@ -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));
}
}
diff --git a/pack.c b/pack.c
index b924c7418d..ef13d160bb 100644
--- a/pack.c
+++ b/pack.c
@@ -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)
diff --git a/parse.y b/parse.y
index 2afc4ded5d..c2dc18204c 100644
--- a/parse.y
+++ b/parse.y
@@ -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;\
diff --git a/random.c b/random.c
index e3830166d4..3fdac4a5c4 100644
--- a/random.c
+++ b/random.c
@@ -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
diff --git a/regex.c b/regex.c
index 020b8c8d43..9eea9e480d 100644
--- a/regex.c
+++ b/regex.c
@@ -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)
diff --git a/st.c b/st.c
index 7e5ff2039d..9fbb178ce4 100644
--- a/st.c
+++ b/st.c
@@ -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)