diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-04-04 04:28:47 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-04-04 04:28:47 +0000 |
commit | 5ff72d05693bbb2aba9094144b6ee8d8da77f1ca (patch) | |
tree | d12630484c4e80f1fc68bcd3a7fafe0605031019 /iseq.c | |
parent | b537823f3d1f7ad0eb4f05b68b21a3c9a0a0d295 (diff) | |
download | ruby-5ff72d05693bbb2aba9094144b6ee8d8da77f1ca.tar.gz |
iseq.c: strip trailing spaces in dump
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63084 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'iseq.c')
-rw-r--r-- | iseq.c | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -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 */ |