[前][次][番号順一覧][スレッド一覧]

ruby-changes:18413

From: akr <ko1@a...>
Date: Fri, 31 Dec 2010 10:28:48 +0900 (JST)
Subject: [ruby-changes:18413] Ruby:r30436 (trunk): * st.c: parenthesize macro arguments.

akr	2010-12-31 10:28:41 +0900 (Fri, 31 Dec 2010)

  New Revision: 30436

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=30436

  Log:
    * st.c: parenthesize macro arguments.

  Modified files:
    trunk/ChangeLog
    trunk/st.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 30435)
+++ ChangeLog	(revision 30436)
@@ -1,3 +1,7 @@
+Fri Dec 31 10:27:34 2010  Tanaka Akira  <akr@f...>
+
+	* st.c: parenthesize macro arguments.
+
 Fri Dec 31 03:23:26 2010  NARUSE, Yui  <naruse@r...>
 
 	* vsnprintf.c (BSD__uqtoa): Fix overflow when long != quad_t.
Index: st.c
===================================================================
--- st.c	(revision 30435)
+++ st.c	(revision 30436)
@@ -69,11 +69,11 @@
 #define alloc(type) (type*)malloc((size_t)sizeof(type))
 #define Calloc(n,s) (char*)calloc((n),(s))
 
-#define EQUAL(table,x,y) ((x)==(y) || (*table->type->compare)((x),(y)) == 0)
+#define EQUAL(table,x,y) ((x)==(y) || (*(table)->type->compare)((x),(y)) == 0)
 
 /* remove cast to unsigned int in the future */
 #define do_hash(key,table) (unsigned int)(st_index_t)(*(table)->type->hash)((key))
-#define do_hash_bin(key,table) (do_hash(key, table)%(table)->num_bins)
+#define do_hash_bin(key,table) (do_hash((key), (table))%(table)->num_bins)
 
 /*
  * MINSIZE is the minimum size of a dictionary.
@@ -282,7 +282,7 @@
 }
 
 #define PTR_NOT_EQUAL(table, ptr, hash_val, key) \
-((ptr) != 0 && (ptr->hash != (hash_val) || !EQUAL((table), (key), (ptr)->key)))
+((ptr) != 0 && ((ptr)->hash != (hash_val) || !EQUAL((table), (key), (ptr)->key)))
 
 #ifdef HASH_LOG
 static void
@@ -307,15 +307,15 @@
 #endif
 
 #define FIND_ENTRY(table, ptr, hash_val, bin_pos) do {\
-    bin_pos = hash_val%(table)->num_bins;\
-    ptr = (table)->bins[bin_pos];\
+    (bin_pos) = (hash_val)%(table)->num_bins;\
+    (ptr) = (table)->bins[(bin_pos)];\
     FOUND_ENTRY;\
-    if (PTR_NOT_EQUAL(table, ptr, hash_val, key)) {\
+    if (PTR_NOT_EQUAL((table), (ptr), (hash_val), key)) {\
 	COLLISION;\
-	while (PTR_NOT_EQUAL(table, ptr->next, hash_val, key)) {\
-	    ptr = ptr->next;\
+	while (PTR_NOT_EQUAL((table), (ptr)->next, (hash_val), key)) {\
+	    (ptr) = (ptr)->next;\
 	}\
-	ptr = ptr->next;\
+	(ptr) = (ptr)->next;\
     }\
 } while (0)
 
@@ -389,28 +389,28 @@
 #define ADD_DIRECT(table, key, value, hash_val, bin_pos)\
 do {\
     st_table_entry *entry;\
-    if (table->num_entries > ST_DEFAULT_MAX_DENSITY * table->num_bins) {\
+    if ((table)->num_entries > ST_DEFAULT_MAX_DENSITY * (table)->num_bins) {\
 	rehash(table);\
-        bin_pos = hash_val % table->num_bins;\
+        (bin_pos) = (hash_val) % (table)->num_bins;\
     }\
     \
     entry = alloc(st_table_entry);\
     \
-    entry->hash = hash_val;\
-    entry->key = key;\
-    entry->record = value;\
-    entry->next = table->bins[bin_pos];\
-    if (table->head != 0) {\
+    entry->hash = (hash_val);\
+    entry->key = (key);\
+    entry->record = (value);\
+    entry->next = (table)->bins[(bin_pos)];\
+    if ((table)->head != 0) {\
 	entry->fore = 0;\
-	(entry->back = table->tail)->fore = entry;\
-	table->tail = entry;\
+	(entry->back = (table)->tail)->fore = entry;\
+	(table)->tail = entry;\
     }\
     else {\
-	table->head = table->tail = entry;\
+	(table)->head = (table)->tail = entry;\
 	entry->fore = entry->back = 0;\
     }\
-    table->bins[bin_pos] = entry;\
-    table->num_entries++;\
+    (table)->bins[(bin_pos)] = entry;\
+    (table)->num_entries++;\
 } while (0)
 
 static void
@@ -606,18 +606,18 @@
 
 #define REMOVE_ENTRY(table, ptr) do					\
     {									\
-	if (ptr->fore == 0 && ptr->back == 0) {				\
-	    table->head = 0;						\
-	    table->tail = 0;						\
+	if ((ptr)->fore == 0 && (ptr)->back == 0) {			\
+	    (table)->head = 0;						\
+	    (table)->tail = 0;						\
 	}								\
 	else {								\
-	    st_table_entry *fore = ptr->fore, *back = ptr->back;	\
+	    st_table_entry *fore = (ptr)->fore, *back = (ptr)->back;	\
 	    if (fore) fore->back = back;				\
 	    if (back) back->fore = fore;				\
-	    if (ptr == table->head) table->head = fore;			\
-	    if (ptr == table->tail) table->tail = back;			\
+	    if ((ptr) == (table)->head) (table)->head = fore;		\
+	    if ((ptr) == (table)->tail) (table)->tail = back;		\
 	}								\
-	table->num_entries--;						\
+	(table)->num_entries--;						\
     } while (0)
 
 int
@@ -1048,12 +1048,12 @@
     return h;
 }
 
-#define murmur_step(h, k) murmur(h, k, 16)
+#define murmur_step(h, k) murmur((h), (k), 16)
 
 #if MURMUR == 1
-#define murmur1(h) murmur_step(h, 16)
+#define murmur1(h) murmur_step((h), 16)
 #else
-#define murmur1(h) murmur_step(h, 24)
+#define murmur1(h) murmur_step((h), 24)
 #endif
 
 st_index_t
@@ -1064,7 +1064,7 @@
 
     h += 0xdeadbeef;
 
-#define data_at(n) (st_index_t)((unsigned char)data[n])
+#define data_at(n) (st_index_t)((unsigned char)data[(n)])
 #define UNALIGNED_ADD_4 UNALIGNED_ADD(2); UNALIGNED_ADD(1); UNALIGNED_ADD(0)
 #if SIZEOF_ST_INDEX_T > 4
 #define UNALIGNED_ADD_8 UNALIGNED_ADD(6); UNALIGNED_ADD(5); UNALIGNED_ADD(4); UNALIGNED_ADD(3); UNALIGNED_ADD_4

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]