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

ruby-changes:18481

From: akr <ko1@a...>
Date: Mon, 10 Jan 2011 11:24:15 +0900 (JST)
Subject: [ruby-changes:18481] Ruby:r30504 (trunk): * util.c: parenthesize macro arguments.

akr	2011-01-10 11:24:04 +0900 (Mon, 10 Jan 2011)

  New Revision: 30504

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

  Log:
    * util.c: parenthesize macro arguments.

  Modified files:
    trunk/ChangeLog
    trunk/util.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 30503)
+++ ChangeLog	(revision 30504)
@@ -1,3 +1,7 @@
+Mon Jan 10 11:22:02 2011  Tanaka Akira  <akr@f...>
+
+	* util.c: parenthesize macro arguments.
+
 Mon Jan 10 07:41:31 2011  Kazuhiro NISHIYAMA  <zn@m...>
 
 	* misc/README: mention rdoc-mode.el and ruby-style.el.
Index: util.c
===================================================================
--- util.c	(revision 30503)
+++ util.c	(revision 30504)
@@ -180,7 +180,7 @@
 #endif
 
 #ifndef S_ISDIR
-#   define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR)
+#   define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
 #endif
 
 #if defined(__CYGWIN32__) || defined(_WIN32)
@@ -259,7 +259,7 @@
 static const char suffix1[] = ".$$$";
 static const char suffix2[] = ".~~~";
 
-#define strEQ(s1,s2) (strcmp(s1,s2) == 0)
+#define strEQ(s1,s2) (strcmp((s1),(s2)) == 0)
 
 extern const char *ruby_find_basename(const char *, long *, long *);
 extern const char *ruby_find_extname(const char *, long *);
@@ -373,12 +373,12 @@
 #define D ((int*)d)
 
 #define mmprepare(base, size) do {\
- if (((VALUE)base & (0x3)) == 0)\
-   if (size >= 16) mmkind = 1;\
-   else            mmkind = 0;\
- else              mmkind = -1;\
- high = (size & (~0xf));\
- low  = (size &  0x0c);\
+ if (((VALUE)(base) & (0x3)) == 0)\
+   if ((size) >= 16) mmkind = 1;\
+   else              mmkind = 0;\
+ else                mmkind = -1;\
+ high = ((size) & (~0xf));\
+ low  = ((size) &  0x0c);\
 } while (0)\
 
 #define mmarg mmkind, size, high, low
@@ -443,11 +443,11 @@
 
 typedef struct { char *LL, *RR; } stack_node; /* Stack structure for L,l,R,r */
 #define PUSH(ll,rr) do { top->LL = (ll); top->RR = (rr); ++top; } while (0)  /* Push L,l,R,r */
-#define POP(ll,rr)  do { --top; ll = top->LL; rr = top->RR; } while (0)      /* Pop L,l,R,r */
+#define POP(ll,rr)  do { --top; (ll) = top->LL; (rr) = top->RR; } while (0)      /* Pop L,l,R,r */
 
-#define med3(a,b,c) ((*cmp)(a,b,d)<0 ?                                   \
-                       ((*cmp)(b,c,d)<0 ? b : ((*cmp)(a,c,d)<0 ? c : a)) : \
-                       ((*cmp)(b,c,d)>0 ? b : ((*cmp)(a,c,d)<0 ? a : c)))
+#define med3(a,b,c) ((*cmp)((a),(b),d)<0 ?                                   \
+                       ((*cmp)((b),(c),d)<0 ? (b) : ((*cmp)((a),(c),d)<0 ? (c) : (a))) : \
+                       ((*cmp)((b),(c),d)>0 ? (b) : ((*cmp)((a),(c),d)<0 ? (a) : (c))))
 
 void
 ruby_qsort(void* base, const size_t nel, const size_t size,
@@ -839,7 +839,7 @@
 
 #ifdef DEBUG
 #include "stdio.h"
-#define Bug(x) {fprintf(stderr, "%s\n", x); exit(1);}
+#define Bug(x) {fprintf(stderr, "%s\n", (x)); exit(1);}
 #endif
 
 #include "stdlib.h"
@@ -924,24 +924,24 @@
 
 #ifdef YES_ALIAS
 typedef double double_u;
-#  define dval(x) x
+#  define dval(x) (x)
 #  ifdef IEEE_LITTLE_ENDIAN
-#    define word0(x) (((ULong *)&x)[1])
-#    define word1(x) (((ULong *)&x)[0])
+#    define word0(x) (((ULong *)&(x))[1])
+#    define word1(x) (((ULong *)&(x))[0])
 #  else
-#    define word0(x) (((ULong *)&x)[0])
-#    define word1(x) (((ULong *)&x)[1])
+#    define word0(x) (((ULong *)&(x))[0])
+#    define word1(x) (((ULong *)&(x))[1])
 #  endif
 #else
 typedef U double_u;
 #  ifdef IEEE_LITTLE_ENDIAN
-#    define word0(x) (x.L[1])
-#    define word1(x) (x.L[0])
+#    define word0(x) ((x).L[1])
+#    define word1(x) ((x).L[0])
 #  else
-#    define word0(x) (x.L[0])
-#    define word1(x) (x.L[1])
+#    define word0(x) ((x).L[0])
+#    define word1(x) ((x).L[1])
 #  endif
-#  define dval(x) (x.d)
+#  define dval(x) ((x).d)
 #endif
 
 /* The following definition of Storeinc is appropriate for MIPS processors.
@@ -949,11 +949,11 @@
  * #define Storeinc(a,b,c) (*a++ = b << 16 | c & 0xffff)
  */
 #if defined(IEEE_LITTLE_ENDIAN) + defined(VAX) + defined(__arm__)
-#define Storeinc(a,b,c) (((unsigned short *)a)[1] = (unsigned short)b, \
-((unsigned short *)a)[0] = (unsigned short)c, a++)
+#define Storeinc(a,b,c) (((unsigned short *)(a))[1] = (unsigned short)(b), \
+((unsigned short *)(a))[0] = (unsigned short)(c), (a)++)
 #else
-#define Storeinc(a,b,c) (((unsigned short *)a)[0] = (unsigned short)b, \
-((unsigned short *)a)[1] = (unsigned short)c, a++)
+#define Storeinc(a,b,c) (((unsigned short *)(a))[0] = (unsigned short)(b), \
+((unsigned short *)(a))[1] = (unsigned short)(c), (a)++)
 #endif
 
 /* #define P DBL_MANT_DIG */
@@ -1076,12 +1076,12 @@
 #endif
 
 #ifdef RND_PRODQUOT
-#define rounded_product(a,b) a = rnd_prod(a, b)
-#define rounded_quotient(a,b) a = rnd_quot(a, b)
+#define rounded_product(a,b) ((a) = rnd_prod((a), (b)))
+#define rounded_quotient(a,b) ((a) = rnd_quot((a), (b)))
 extern double rnd_prod(double, double), rnd_quot(double, double);
 #else
-#define rounded_product(a,b) a *= b
-#define rounded_quotient(a,b) a /= b
+#define rounded_product(a,b) ((a) *= (b))
+#define rounded_quotient(a,b) ((a) /= (b))
 #endif
 
 #define Big0 (Frac_mask1 | Exp_msk1*(DBL_MAX_EXP+Bias-1))
@@ -1180,8 +1180,8 @@
     }
 }
 
-#define Bcopy(x,y) memcpy((char *)&x->sign, (char *)&y->sign, \
-y->wds*sizeof(Long) + 2*sizeof(int))
+#define Bcopy(x,y) memcpy((char *)&(x)->sign, (char *)&(y)->sign, \
+(y)->wds*sizeof(Long) + 2*sizeof(int))
 
 static Bigint *
 multadd(Bigint *b, int m, int a)   /* multiply by m and add a */
@@ -3159,7 +3159,7 @@
     return rv;
 }
 
-#define rv_strdup(s, rve) nrv_alloc(s, rve, strlen(s)+1)
+#define rv_strdup(s, rve) nrv_alloc((s), (rve), strlen(s)+1)
 
 #ifndef MULTIPLE_THREADS
 /* freedtoa(s) must be used to free values s returned by dtoa
@@ -3934,7 +3934,7 @@
 #define	DBL_ADJ	(DBL_MAX_EXP - 2)
 #define	SIGFIGS	((DBL_MANT_DIG + 3) / 4 + 1)
 #define dexp_get(u) ((int)(word0(u) >> Exp_shift) & ~Exp_msk1)
-#define dexp_set(u,v) (word0(u) = (((int)(word0(u)) & ~Exp_mask) | (v << Exp_shift)))
+#define dexp_set(u,v) (word0(u) = (((int)(word0(u)) & ~Exp_mask) | ((v) << Exp_shift)))
 #define dmanh_get(u) ((uint32_t)(word0(u) & Frac_mask))
 #define dmanl_get(u) ((uint32_t)word1(u))
 

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

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