Hi,

	this could be the final cleanup for MACROs (at least for those
	in ruby dir).

	All are toys with do { ... } while (0).

		Michal


Index: ruby.h
===================================================================
RCS file: /src/ruby/ruby.h,v
retrieving revision 1.63
diff -u -r1.63 ruby.h
--- ruby.h	2002/04/18 08:46:18	1.63
+++ ruby.h	2002/04/21 15:51:07
@@ -66,7 +66,7 @@
 #endif
 
 #if SIZEOF_LONG != SIZEOF_VOIDP
----->> ruby requires sizeof(void*) == sizeof(long) to be compiled. <<----
+# error ---->> ruby requires sizeof(void*) == sizeof(long) to be compiled. <<----
 #endif
 typedef unsigned long VALUE;
 typedef unsigned long ID;
@@ -271,11 +271,11 @@
 
 VALUE rb_newobj _((void));
 #define NEWOBJ(obj,type) type *obj = (type*)rb_newobj()
-#define OBJSETUP(obj,c,t) {\
+#define OBJSETUP(obj,c,t) do {\
     RBASIC(obj)->flags = (t);\
     RBASIC(obj)->klass = (c);\
     if (rb_safe_level() >= 3) FL_SET(obj, FL_TAINT);\
-}
+} while (0)
 #define CLONESETUP(clone,obj) do {\
     OBJSETUP(clone,rb_singleton_class_clone(RBASIC(obj)->klass),RBASIC(obj)->flags);\
     rb_singleton_class_attached(RBASIC(clone)->klass, (VALUE)clone);\
@@ -365,9 +365,8 @@
 
 VALUE rb_data_object_alloc _((VALUE,void*,RUBY_DATA_FUNC,RUBY_DATA_FUNC));
 
-#define Data_Wrap_Struct(klass,mark,free,sval) (\
-    rb_data_object_alloc(klass,sval,(RUBY_DATA_FUNC)mark,(RUBY_DATA_FUNC)free)\
-)
+#define Data_Wrap_Struct(klass,mark,free,sval)\
+    rb_data_object_alloc(klass,sval,(RUBY_DATA_FUNC)mark,(RUBY_DATA_FUNC)free)
 
 #define Data_Make_Struct(klass,type,mark,free,sval) (\
     sval = ALLOC(type),\
@@ -375,10 +374,10 @@
     Data_Wrap_Struct(klass,mark,free,sval)\
 )
 
-#define Data_Get_Struct(obj,type,sval) {\
+#define Data_Get_Struct(obj,type,sval) do {\
     Check_Type(obj, T_DATA); \
     sval = (type*)DATA_PTR(obj);\
-}
+} while (0)
 
 struct RStruct {
     struct RBasic basic;
Index: rubysig.h
===================================================================
RCS file: /src/ruby/rubysig.h,v
retrieving revision 1.9
diff -u -r1.9 rubysig.h
--- rubysig.h	2001/05/02 04:22:11	1.9
+++ rubysig.h	2002/04/21 15:51:08
@@ -23,8 +23,9 @@
 
 /* Windows doesn't allow interrupt while system calls */
 # define TRAP_BEG do {\
-    rb_atomic_t trap_immediate = ATOMIC_SET(rb_trap_immediate, 1);
-# define TRAP_END ATOMIC_SET(rb_trap_immediate, trap_immediate);\
+    rb_atomic_t trap_immediate = ATOMIC_SET(rb_trap_immediate, 1)
+# define TRAP_END\
+	ATOMIC_SET(rb_trap_immediate, trap_immediate);\
 } while (0)
 # define RUBY_CRITICAL(statements) do {\
     win32_enter_critical();\
@@ -41,7 +42,7 @@
 
 # define TRAP_BEG do {\
     int trap_immediate = rb_trap_immediate;\
-    rb_trap_immediate = 1;
+    rb_trap_immediate = 1
 # define TRAP_END rb_trap_immediate = trap_immediate;\
 } while (0)
 
@@ -55,9 +56,12 @@
 EXTERN rb_atomic_t rb_trap_immediate;
 
 EXTERN int rb_prohibit_interrupt;
-#define DEFER_INTS {rb_prohibit_interrupt++;}
-#define ALLOW_INTS {rb_prohibit_interrupt--; CHECK_INTS;}
-#define ENABLE_INTS {rb_prohibit_interrupt--;}
+#define DEFER_INTS (rb_prohibit_interrupt++)
+#define ALLOW_INTS do {\
+    rb_prohibit_interrupt--;\
+    CHECK_INTS;\
+} while (0)
+#define ENABLE_INTS (rb_prohibit_interrupt--)
 
 VALUE rb_with_disable_interrupt _((VALUE(*)(ANYARGS),VALUE));
 
@@ -68,23 +72,28 @@
 void rb_thread_schedule _((void));
 #if defined(HAVE_SETITIMER) && !defined(__BOW__)
 EXTERN int rb_thread_pending;
-# define CHECK_INTS if (!rb_prohibit_interrupt) {\
-    if (rb_trap_pending) rb_trap_exec();\
-    if (rb_thread_pending && !rb_thread_critical) rb_thread_schedule();\
-}
+# define CHECK_INTS do {\
+    if (!rb_prohibit_interrupt) {\
+	if (rb_trap_pending) rb_trap_exec();\
+	if (rb_thread_pending && !rb_thread_critical)\
+	    rb_thread_schedule();\
+    }\
+} while (0)
 #else
 /* pseudo preemptive thread switching */
 EXTERN int rb_thread_tick;
 #define THREAD_TICK 500
-#define CHECK_INTS if (!rb_prohibit_interrupt) {\
-    if (rb_trap_pending) rb_trap_exec();\
-    if (!rb_thread_critical) {\
-	if (rb_thread_tick-- <= 0) {\
-	    rb_thread_tick = THREAD_TICK;\
-	    rb_thread_schedule();\
+#define CHECK_INTS do {\
+    if (!rb_prohibit_interrupt) {\
+	if (rb_trap_pending) rb_trap_exec();\
+	if (!rb_thread_critical) {\
+	    if (rb_thread_tick-- <= 0) {\
+		rb_thread_tick = THREAD_TICK;\
+		rb_thread_schedule();\
+	    }\
 	}\
     }\
-}
+} while (0)
 #endif
 
 #endif


-- 
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Michal Rokos                         Czech Technical University, Prague
E-mail:m.rokos / sh.cvut.cz  ICQ:36118339  Jabber:majkl / jabber.sh.cvut.cz
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-