summaryrefslogtreecommitdiff
path: root/ruby.c
diff options
context:
space:
mode:
Diffstat (limited to 'ruby.c')
-rw-r--r--ruby.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/ruby.c b/ruby.c
index be2ea2d0cd..0d70dbc84b 100644
--- a/ruby.c
+++ b/ruby.c
@@ -904,12 +904,13 @@ moreswitches(const char *s, ruby_cmdline_options_t *opt, int envopt)
opt->src.enc.name = opt->ext.enc.name = opt->intern.enc.name = 0;
- argstr = rb_str_tmp_new((len = strlen(s)) + (envopt!=0));
+ const int hyphen = *s != '-';
+ argstr = rb_str_tmp_new((len = strlen(s)) + hyphen);
argary = rb_str_tmp_new(0);
p = RSTRING_PTR(argstr);
- if (envopt) *p++ = ' ';
- memcpy(p, s, len + 1);
+ if (hyphen) *p = '-';
+ memcpy(p + hyphen, s, len + 1);
ap = 0;
rb_str_cat(argary, (char *)&ap, sizeof(ap));
while (*p) {