summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-09-01 04:09:02 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-09-01 04:09:02 +0000
commitc4816a11e4fd954a12f6cb12fc5ba23adf8d6a4b (patch)
treebe571cb0489eb97ea0ad1c92155e59a3b19196f7
parentba3da085961e5ffcdab405416518abef0a1d13ed (diff)
surround macro block with do/while
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64604 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ext/date/date_core.c70
-rw-r--r--ext/date/date_parse.c28
-rw-r--r--ext/date/date_strptime.c32
3 files changed, 65 insertions, 65 deletions
diff --git a/ext/date/date_core.c b/ext/date/date_core.c
index 335b538..ac81268 100644
--- a/ext/date/date_core.c
+++ b/ext/date/date_core.c
@@ -315,7 +315,7 @@ canon(VALUE x)
#ifndef USE_PACK
#define set_to_simple(obj, x, _nth, _jd ,_sg, _year, _mon, _mday, _flags) \
-{\
+do {\
RB_OBJ_WRITE((obj), &(x)->nth, canon(_nth)); \
(x)->jd = _jd;\
(x)->sg = (date_sg_t)(_sg);\
@@ -323,23 +323,23 @@ canon(VALUE x)
(x)->mon = _mon;\
(x)->mday = _mday;\
(x)->flags = _flags;\
-}
+} while (0)
#else
#define set_to_simple(obj, x, _nth, _jd ,_sg, _year, _mon, _mday, _flags) \
-{\
+do {\
RB_OBJ_WRITE((obj), &(x)->nth, canon(_nth)); \
(x)->jd = _jd;\
(x)->sg = (date_sg_t)(_sg);\
(x)->year = _year;\
(x)->pc = PACK2(_mon, _mday);\
(x)->flags = _flags;\
-}
+} while (0)
#endif
#ifndef USE_PACK
#define set_to_complex(obj, x, _nth, _jd ,_df, _sf, _of, _sg,\
_year, _mon, _mday, _hour, _min, _sec, _flags) \
-{\
+do {\
RB_OBJ_WRITE((obj), &(x)->nth, canon(_nth));\
(x)->jd = _jd;\
(x)->df = _df;\
@@ -353,11 +353,11 @@ _year, _mon, _mday, _hour, _min, _sec, _flags) \
(x)->min = _min;\
(x)->sec = _sec;\
(x)->flags = _flags;\
-}
+} while (0)
#else
#define set_to_complex(obj, x, _nth, _jd ,_df, _sf, _of, _sg,\
_year, _mon, _mday, _hour, _min, _sec, _flags) \
-{\
+do {\
RB_OBJ_WRITE((obj), &(x)->nth, canon(_nth));\
(x)->jd = _jd;\
(x)->df = _df;\
@@ -367,12 +367,12 @@ _year, _mon, _mday, _hour, _min, _sec, _flags) \
(x)->year = _year;\
(x)->pc = PACK5(_mon, _mday, _hour, _min, _sec);\
(x)->flags = _flags;\
-}
+} while (0)
#endif
#ifndef USE_PACK
#define copy_simple_to_complex(obj, x, y) \
-{\
+do {\
RB_OBJ_WRITE((obj), &(x)->nth, (y)->nth);\
(x)->jd = (y)->jd;\
(x)->df = 0;\
@@ -386,10 +386,10 @@ _year, _mon, _mday, _hour, _min, _sec, _flags) \
(x)->min = 0;\
(x)->sec = 0;\
(x)->flags = (y)->flags;\
-}
+} while (0)
#else
#define copy_simple_to_complex(obj, x, y) \
-{\
+do {\
RB_OBJ_WRITE((obj), &(x)->nth, (y)->nth);\
(x)->jd = (y)->jd;\
(x)->df = 0;\
@@ -399,12 +399,12 @@ _year, _mon, _mday, _hour, _min, _sec, _flags) \
(x)->year = (y)->year;\
(x)->pc = PACK5(EX_MON((y)->pc), EX_MDAY((y)->pc), 0, 0, 0);\
(x)->flags = (y)->flags;\
-}
+} while (0)
#endif
#ifndef USE_PACK
#define copy_complex_to_simple(obj, x, y) \
-{\
+do {\
RB_OBJ_WRITE((obj), &(x)->nth, (y)->nth);\
(x)->jd = (y)->jd;\
(x)->sg = (date_sg_t)((y)->sg);\
@@ -412,17 +412,17 @@ _year, _mon, _mday, _hour, _min, _sec, _flags) \
(x)->mon = (y)->mon;\
(x)->mday = (y)->mday;\
(x)->flags = (y)->flags;\
-}
+} while (0)
#else
#define copy_complex_to_simple(obj, x, y) \
-{\
+do {\
RB_OBJ_WRITE((obj), &(x)->nth, (y)->nth);\
(x)->jd = (y)->jd;\
(x)->sg = (date_sg_t)((y)->sg);\
(x)->year = (y)->year;\
(x)->pc = PACK2(EX_MON((y)->pc), EX_MDAY((y)->pc));\
(x)->flags = (y)->flags;\
-}
+} while (0)
#endif
/* base */
@@ -1109,7 +1109,7 @@ m_virtual_sg(union DateData *x)
}
#define canonicalize_jd(_nth, _jd) \
-{\
+do {\
if (_jd < 0) {\
_nth = f_sub(_nth, INT2FIX(1));\
_jd += CM_PERIOD;\
@@ -1118,7 +1118,7 @@ m_virtual_sg(union DateData *x)
_nth = f_add(_nth, INT2FIX(1));\
_jd -= CM_PERIOD;\
}\
-}
+} while (0)
inline static void
canonicalize_s_jd(VALUE obj, union DateData *x)
@@ -1928,13 +1928,13 @@ m_sec(union DateData *x)
}
#define decode_offset(of,s,h,m)\
-{\
+do {\
int a;\
s = (of < 0) ? '-' : '+';\
a = (of < 0) ? -of : of;\
h = a / HOUR_IN_SECONDS;\
m = a % HOUR_IN_SECONDS / MINUTE_IN_SECONDS;\
-}
+} while (0)
static VALUE
of2str(int of)
@@ -2418,12 +2418,12 @@ offset_to_sec(VALUE vof, int *rof)
/* date */
#define valid_sg(sg) \
-{\
+do {\
if (!c_valid_start_p(sg)) {\
sg = 0;\
rb_warning("invalid start is ignored");\
}\
-}
+} while (0)
static VALUE
valid_jd_sub(int argc, VALUE *argv, VALUE klass, int need_jd)
@@ -3205,47 +3205,47 @@ s_trunc(VALUE s, VALUE *fr)
}
#define num2num_with_frac(s,n) \
-{\
+do {\
s = s##_trunc(v##s, &fr);\
if (f_nonzero_p(fr)) {\
if (argc > n)\
rb_raise(rb_eArgError, "invalid fraction");\
fr2 = fr;\
}\
-}
+} while (0)
#define num2int_with_frac(s,n) \
-{\
+do {\
s = NUM2INT(s##_trunc(v##s, &fr));\
if (f_nonzero_p(fr)) {\
if (argc > n)\
rb_raise(rb_eArgError, "invalid fraction");\
fr2 = fr;\
}\
-}
+} while (0)
#define canon24oc() \
-{\
+do {\
if (rh == 24) {\
rh = 0;\
fr2 = f_add(fr2, INT2FIX(1));\
}\
-}
+} while (0)
#define add_frac() \
-{\
+do {\
if (f_nonzero_p(fr2))\
ret = d_lite_plus(ret, fr2);\
-}
+} while (0)
#define val2sg(vsg,dsg) \
-{\
+do {\
dsg = NUM2DBL(vsg);\
if (!c_valid_start_p(dsg)) {\
dsg = DEFAULT_SG;\
rb_warning("invalid start is ignored");\
}\
-}
+} while (0)
static VALUE d_lite_plus(VALUE, VALUE);
@@ -4689,12 +4689,12 @@ dup_obj_as_complex(VALUE self)
}
#define val2off(vof,iof) \
-{\
+do {\
if (!offset_to_sec(vof, &iof)) {\
iof = 0;\
rb_warning("invalid offset is ignored");\
}\
-}
+} while (0)
#ifndef NDEBUG
static VALUE
@@ -8646,7 +8646,7 @@ datetime_to_date(VALUE self)
VALUE new = d_lite_s_alloc_simple(cDate);
{
get_d1b(new);
- copy_complex_to_simple(new, &bdat->s, &adat->c)
+ copy_complex_to_simple(new, &bdat->s, &adat->c);
bdat->s.jd = m_local_jd(adat);
bdat->s.flags &= ~(HAVE_DF | HAVE_TIME | COMPLEX_DAT);
return new;
diff --git a/ext/date/date_parse.c b/ext/date/date_parse.c
index f0b33da..99a6bd7 100644
--- a/ext/date/date_parse.c
+++ b/ext/date/date_parse.c
@@ -263,18 +263,18 @@ regcomp(const char *source, long len, int opt)
}
#define REGCOMP(pat,opt) \
-{ \
+do { \
if (NIL_P(pat)) \
pat = regcomp(pat##_source, sizeof pat##_source - 1, opt); \
-}
+} while (0)
#define REGCOMP_0(pat) REGCOMP(pat, 0)
#define REGCOMP_I(pat) REGCOMP(pat, ONIG_OPTION_IGNORECASE)
#define MATCH(s,p,c) \
-{ \
+do { \
return match(s, p, hash, c); \
-}
+} while (0)
static int
match(VALUE str, VALUE pat, VALUE hash, int (*cb)(VALUE, VALUE))
@@ -314,30 +314,30 @@ subx(VALUE str, VALUE rep, VALUE pat, VALUE hash, int (*cb)(VALUE, VALUE))
}
#define SUBS(s,p,c) \
-{ \
+do { \
return subx(s, asp_string(), p, hash, c); \
-}
+} while (0)
#ifdef TIGHT_PARSER
#define SUBA(s,p,c) \
-{ \
+do { \
return subx(s, asuba_string(), p, hash, c); \
-}
+} while (0)
#define SUBB(s,p,c) \
-{ \
+do { \
return subx(s, asubb_string(), p, hash, c); \
-}
+} while (0)
#define SUBW(s,p,c) \
-{ \
+do { \
return subx(s, asubw_string(), p, hash, c); \
-}
+} while (0)
#define SUBT(s,p,c) \
-{ \
+do { \
return subx(s, asubt_string(), p, hash, c); \
-}
+} while (0)
#endif
#include "zonetab.h"
diff --git a/ext/date/date_strptime.c b/ext/date/date_strptime.c
index 7bdd5e5..1cc568b 100644
--- a/ext/date/date_strptime.c
+++ b/ext/date/date_strptime.c
@@ -118,21 +118,21 @@ read_digits(const char *s, VALUE *n, size_t width)
#define del_hash(k) rb_hash_delete(hash, ID2SYM(rb_intern(k"")))
#define fail() \
-{ \
+do { \
set_hash("_fail", Qtrue); \
return 0; \
-}
+} while (0)
#define fail_p() (!NIL_P(ref_hash("_fail")))
#define READ_DIGITS(n,w) \
-{ \
+do { \
size_t l; \
l = read_digits(&str[si], &n, w); \
if (l == 0) \
fail(); \
si += l; \
-}
+} while (0)
#define READ_DIGITS_MAX(n) READ_DIGITS(n, LONG_MAX)
@@ -147,14 +147,14 @@ valid_range_p(VALUE v, int a, int b)
}
#define recur(fmt) \
-{ \
+do { \
size_t l; \
l = date__strptime_internal(&str[si], slen - si, \
fmt, sizeof fmt - 1, hash); \
if (fail_p()) \
return 0; \
si += l; \
-}
+} while (0)
VALUE date_zone_to_diff(VALUE);
@@ -237,9 +237,9 @@ date__strptime_internal(const char *str, size_t slen,
VALUE n;
if (NUM_PATTERN_P())
- READ_DIGITS(n, 2)
+ READ_DIGITS(n, 2);
else
- READ_DIGITS_MAX(n)
+ READ_DIGITS_MAX(n);
set_hash("_cent", n);
goto matched;
}
@@ -278,9 +278,9 @@ date__strptime_internal(const char *str, size_t slen,
VALUE n;
if (NUM_PATTERN_P())
- READ_DIGITS(n, 4)
+ READ_DIGITS(n, 4);
else
- READ_DIGITS_MAX(n)
+ READ_DIGITS_MAX(n);
set_hash("cwyear", n);
goto matched;
}
@@ -358,9 +358,9 @@ date__strptime_internal(const char *str, size_t slen,
}
osi = si;
if (NUM_PATTERN_P())
- READ_DIGITS(n, c == 'L' ? 3 : 9)
+ READ_DIGITS(n, c == 'L' ? 3 : 9);
else
- READ_DIGITS_MAX(n)
+ READ_DIGITS_MAX(n);
if (sign == -1)
n = f_negate(n);
set_hash("sec_fraction",
@@ -539,11 +539,11 @@ date__strptime_internal(const char *str, size_t slen,
si++;
}
if (NUM_PATTERN_P())
- READ_DIGITS(n, 4)
+ READ_DIGITS(n, 4);
else
- READ_DIGITS_MAX(n)
- if (sign == -1)
- n = f_negate(n);
+ READ_DIGITS_MAX(n);
+ if (sign == -1)
+ n = f_negate(n);
set_hash("year", n);
goto matched;
}