1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* sprintf.c: parenthesize macro arguments.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30426 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2010-12-30 02:50:34 +00:00
parent ae167e1e79
commit ae47a529f4
2 changed files with 16 additions and 12 deletions

View file

@ -1,3 +1,7 @@
Thu Dec 30 11:49:40 2010 Tanaka Akira <akr@fsij.org>
* sprintf.c: parenthesize macro arguments.
Wed Dec 29 21:20:13 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* io.c (maygvl_copy_stream_wait_readwrite): define if USE_SENDFILE

View file

@ -94,13 +94,13 @@ sign_bits(int base, const char *p)
#define PUSH(s, l) do { \
CHECK(l);\
memcpy(&buf[blen], s, l);\
memcpy(&buf[blen], (s), (l));\
blen += (l);\
} while (0)
#define FILL(c, l) do { \
CHECK(l);\
memset(&buf[blen], c, l);\
memset(&buf[blen], (c), (l));\
blen += (l);\
} while (0)
@ -112,29 +112,29 @@ sign_bits(int base, const char *p)
(posarg = nextarg++, GETNTHARG(posarg)))
#define GETPOSARG(n) (posarg > 0 ? \
(rb_raise(rb_eArgError, "numbered(%d) after unnumbered(%d)", n, posarg), 0) : \
(rb_raise(rb_eArgError, "numbered(%d) after unnumbered(%d)", (n), posarg), 0) : \
posarg == -2 ? \
(rb_raise(rb_eArgError, "numbered(%d) after named", n), 0) : \
((n < 1) ? (rb_raise(rb_eArgError, "invalid index - %d$", n), 0) : \
(rb_raise(rb_eArgError, "numbered(%d) after named", (n)), 0) : \
(((n) < 1) ? (rb_raise(rb_eArgError, "invalid index - %d$", (n)), 0) : \
(posarg = -1, GETNTHARG(n))))
#define GETNTHARG(nth) \
((nth >= argc) ? (rb_raise(rb_eArgError, "too few arguments"), 0) : argv[nth])
(((nth) >= argc) ? (rb_raise(rb_eArgError, "too few arguments"), 0) : argv[(nth)])
#define GETNAMEARG(id, name, len) ( \
posarg > 0 ? \
(rb_raise(rb_eArgError, "named%.*s after unnumbered(%d)", (len), (name), posarg), 0) : \
posarg == -1 ? \
(rb_raise(rb_eArgError, "named%.*s after numbered", (len), (name)), 0) : \
(posarg = -2, rb_hash_lookup2(get_hash(&hash, argc, argv), id, Qundef)))
(posarg = -2, rb_hash_lookup2(get_hash(&hash, argc, argv), (id), Qundef)))
#define GETNUM(n, val) \
for (; p < end && rb_enc_isdigit(*p, enc); p++) { \
int next_n = 10 * n + (*p - '0'); \
if (next_n / 10 != n) {\
int next_n = 10 * (n) + (*p - '0'); \
if (next_n / 10 != (n)) {\
rb_raise(rb_eArgError, #val " too big"); \
} \
n = next_n; \
(n) = next_n; \
} \
if (p >= end) { \
rb_raise(rb_eArgError, "malformed format string - %%*[0-9]"); \
@ -143,7 +143,7 @@ sign_bits(int base, const char *p)
#define GETASTER(val) do { \
t = p++; \
n = 0; \
GETNUM(n, val); \
GETNUM(n, (val)); \
if (*p == '$') { \
tmp = GETPOSARG(n); \
} \
@ -151,7 +151,7 @@ sign_bits(int base, const char *p)
tmp = GETARG(); \
p = t; \
} \
val = NUM2INT(tmp); \
(val) = NUM2INT(tmp); \
} while (0)
static VALUE