diff options
| author | ksss <[email protected]> | 2014-03-05 15:06:29 +0000 |
|---|---|---|
| committer | ksss <[email protected]> | 2014-03-06 13:47:51 +0000 |
| commit | 54132e436494b4797ca53cbd934963e7d752ac42 (patch) | |
| tree | c490aee6faa4fbcc8aac66b205b5087af4c208bc /mrbgems/mruby-sprintf/src | |
| parent | 4070b5987a76a2d633a99e137035749559e2da59 (diff) | |
| download | mruby-54132e436494b4797ca53cbd934963e7d752ac42.tar.gz mruby-54132e436494b4797ca53cbd934963e7d752ac42.zip | |
make embed string when create literals
Diffstat (limited to 'mrbgems/mruby-sprintf/src')
| -rw-r--r-- | mrbgems/mruby-sprintf/src/sprintf.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/mrbgems/mruby-sprintf/src/sprintf.c b/mrbgems/mruby-sprintf/src/sprintf.c index 785068999..8b0bff5be 100644 --- a/mrbgems/mruby-sprintf/src/sprintf.c +++ b/mrbgems/mruby-sprintf/src/sprintf.c @@ -712,7 +712,13 @@ retry: if (*p == 'p') arg = mrb_inspect(mrb, arg); str = mrb_obj_as_string(mrb, arg); len = RSTRING_LEN(str); - RSTRING(result)->as.heap.len = blen; + if (RSTRING(result)->flags & MRB_STR_EMBED) { + int tmp_n = len; + RSTRING(result)->flags &= ~MRB_STR_EMBED_LEN_MASK; + RSTRING(result)->flags |= tmp_n << MRB_STR_EMBED_LEN_SHIFT; + } else { + RSTRING(result)->as.heap.len = blen; + } if (flags&(FPREC|FWIDTH)) { slen = RSTRING_LEN(str); if (slen < 0) { |
