diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-04-25 13:57:01 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-04-25 13:57:01 +0000 |
commit | b134b912780e0fd84fbc107a9362e45f04391b47 (patch) | |
tree | 3aad53ec0421149c8fb9e163379bba8efb2ab42e | |
parent | 4ec25bdd63c8cb9acf70880666c1d113ae0cb51e (diff) | |
download | ruby-b134b912780e0fd84fbc107a9362e45f04391b47.tar.gz |
* 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.c | 22 | ||||
-rw-r--r-- | eval.c | 2 | ||||
-rw-r--r-- | gc.c | 6 | ||||
-rw-r--r-- | lib/complex.rb | 4 | ||||
-rw-r--r-- | numeric.c | 4 | ||||
-rw-r--r-- | pack.c | 7 | ||||
-rw-r--r-- | parse.y | 16 | ||||
-rw-r--r-- | random.c | 4 | ||||
-rw-r--r-- | regex.c | 9 | ||||
-rw-r--r-- | st.c | 21 |
10 files changed, 47 insertions, 48 deletions
@@ -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 @@ -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; @@ -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 @@ -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)); } } @@ -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) @@ -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;\ @@ -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 @@ -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) @@ -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) |