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

* ruby.c: parenthesize macro arguments.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30411 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2010-12-27 22:37:59 +00:00
parent 1f4401ebe0
commit 8af7ed6036
2 changed files with 20 additions and 16 deletions

View file

@ -1,3 +1,7 @@
Tue Dec 28 07:37:38 2010 Tanaka Akira <akr@fsij.org>
* ruby.c: parenthesize macro arguments.
Tue Dec 28 07:17:11 2010 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
* NEWS: add ARGF.write and so on.

32
ruby.c
View file

@ -116,7 +116,7 @@ cmdline_options_init(struct cmdline_options *opt)
static NODE *load_file(VALUE, const char *, int, struct cmdline_options *);
static void forbid_setid(const char *, struct cmdline_options *);
#define forbid_setid(s) forbid_setid(s, opt)
#define forbid_setid(s) forbid_setid((s), opt)
static struct {
int argc;
@ -257,10 +257,10 @@ push_include_cygwin(const char *path, VALUE (*filter)(VALUE))
}
#ifdef HAVE_CYGWIN_CONV_PATH
#define CONV_TO_POSIX_PATH(p, lib) \
cygwin_conv_path(CCP_WIN_A_TO_POSIX|CCP_RELATIVE, p, lib, sizeof(lib))
cygwin_conv_path(CCP_WIN_A_TO_POSIX|CCP_RELATIVE, (p), (lib), sizeof(lib))
#else
#define CONV_TO_POSIX_PATH(p, lib) \
cygwin_conv_to_posix_path(p, lib)
cygwin_conv_to_posix_path((p), (lib))
#endif
if (CONV_TO_POSIX_PATH(p, rubylib) == 0)
p = rubylib;
@ -440,10 +440,10 @@ ruby_init_loadpath_safe(int safe_level)
#define BASEPATH() rb_str_buf_cat(rb_str_buf_new(baselen+len), libpath, baselen)
#define RUBY_RELATIVE(path, len) rb_str_buf_cat(BASEPATH(), path, len)
#define RUBY_RELATIVE(path, len) rb_str_buf_cat(BASEPATH(), (path), (len))
#else
static const char exec_prefix[] = RUBY_EXEC_PREFIX;
#define RUBY_RELATIVE(path, len) rubylib_mangled_path(path, len)
#define RUBY_RELATIVE(path, len) rubylib_mangled_path((path), (len))
#define PREFIX_PATH() RUBY_RELATIVE(exec_prefix, sizeof(exec_prefix)-1)
#endif
load_path = GET_VM()->load_path;
@ -619,16 +619,16 @@ moreswitches(const char *s, struct cmdline_options *opt, int envopt)
}
#define NAME_MATCH_P(name, str, len) \
((len) < (int)sizeof(name) && strncmp((str), name, (len)) == 0)
((len) < (int)sizeof(name) && strncmp((str), (name), (len)) == 0)
#define UNSET_WHEN(name, bit, str, len) \
if (NAME_MATCH_P(name, str, len)) { \
if (NAME_MATCH_P((name), (str), (len))) { \
*(unsigned int *)arg &= ~(bit); \
return; \
}
#define SET_WHEN(name, bit, str, len) \
if (NAME_MATCH_P(name, str, len)) { \
if (NAME_MATCH_P((name), (str), (len))) { \
*(unsigned int *)arg |= (bit); \
return; \
}
@ -692,11 +692,11 @@ set_option_encoding_once(const char *type, VALUE *name, const char *e, long elen
}
#define set_internal_encoding_once(opt, e, elen) \
set_option_encoding_once("default_internal", &opt->intern.enc.name, e, elen)
set_option_encoding_once("default_internal", &(opt)->intern.enc.name, (e), (elen))
#define set_external_encoding_once(opt, e, elen) \
set_option_encoding_once("default_external", &opt->ext.enc.name, e, elen)
set_option_encoding_once("default_external", &(opt)->ext.enc.name, (e), (elen))
#define set_source_encoding_once(opt, e, elen) \
set_option_encoding_once("source", &opt->src.enc.name, e, elen)
set_option_encoding_once("source", &(opt)->src.enc.name, (e), (elen))
static long
proc_options(long argc, char **argv, struct cmdline_options *opt, int envopt)
@ -971,17 +971,17 @@ proc_options(long argc, char **argv, struct cmdline_options *opt, int envopt)
s++;
# define is_option_end(c, allow_hyphen) \
(!(c) || (allow_hyphen && (c) == '-') || (c) == '=')
(!(c) || ((allow_hyphen) && (c) == '-') || (c) == '=')
# define check_envopt(name, allow_envopt) \
((allow_envopt || !envopt) ? (void)0 : \
(((allow_envopt) || !envopt) ? (void)0 : \
rb_raise(rb_eRuntimeError, "invalid switch in RUBYOPT: --" name))
# define need_argument(name, s) \
((*s++ ? !*s : (!--argc || !(s = *++argv))) ? \
((*(s)++ ? !*(s) : (!--argc || !((s) = *++argv))) ? \
rb_raise(rb_eRuntimeError, "missing argument for --" name) \
: (void)0)
# define is_option_with_arg(name, allow_hyphen, allow_envopt) \
(strncmp(name, s, n = sizeof(name) - 1) == 0 && is_option_end(s[n], allow_hyphen) ? \
(check_envopt(name, allow_envopt), s += n, need_argument(name, s), 1) : 0)
(strncmp((name), s, n = sizeof(name) - 1) == 0 && is_option_end(s[n], (allow_hyphen)) ? \
(check_envopt(name, (allow_envopt)), s += n, need_argument(name, s), 1) : 0)
if (strcmp("copyright", s) == 0) {
if (envopt) goto noenvopt_long;