mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
iseq.c: strip trailing spaces in dump
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63084 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b537823f3d
commit
5ff72d0569
1 changed files with 12 additions and 2 deletions
14
iseq.c
14
iseq.c
|
@ -1806,6 +1806,15 @@ rb_insn_operand_intern(const rb_iseq_t *iseq,
|
|||
return ret;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
right_strip(VALUE str)
|
||||
{
|
||||
const char *beg = RSTRING_PTR(str), *end = RSTRING_END(str);
|
||||
while (end-- > beg && *end == ' ');
|
||||
rb_str_set_len(str, end - beg + 1);
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disassemble a instruction
|
||||
* Iseq -> Iseq inspect object
|
||||
|
@ -1867,12 +1876,13 @@ rb_iseq_disasm_insn(VALUE ret, const VALUE *code, size_t pos,
|
|||
}
|
||||
}
|
||||
|
||||
right_strip(str);
|
||||
if (ret) {
|
||||
rb_str_cat2(str, "\n");
|
||||
rb_str_concat(ret, str);
|
||||
}
|
||||
else {
|
||||
printf("%s\n", RSTRING_PTR(str));
|
||||
printf("%.*s\n", (int)RSTRING_LEN(str), RSTRING_PTR(str));
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
@ -2011,7 +2021,7 @@ rb_iseq_disasm(const rb_iseq_t *iseq)
|
|||
if (*argi) rb_str_catf(str, "<%s>", argi);
|
||||
if ((width -= RSTRING_LEN(str)) > 0) rb_str_catf(str, "%*s", (int)width, "");
|
||||
}
|
||||
rb_str_cat2(str, "\n");
|
||||
rb_str_cat_cstr(right_strip(str), "\n");
|
||||
}
|
||||
|
||||
/* show each line */
|
||||
|
|
Loading…
Reference in a new issue