diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2018-08-13 15:24:51 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2018-08-13 23:15:52 +0900 |
| commit | 1e52d47bc3e0d287e5d2cf5c61df60f8613db2aa (patch) | |
| tree | 50a1240278a5d845c2cb5654e2a68c5385745dbf /mrbgems/mruby-inline-struct/test/inline.c | |
| parent | fee9ec61bb9808b5235a78b923a2b8baeebbea8c (diff) | |
| download | mruby-1e52d47bc3e0d287e5d2cf5c61df60f8613db2aa.tar.gz mruby-1e52d47bc3e0d287e5d2cf5c61df60f8613db2aa.zip | |
Simplify `mruby-inline-struct` tests.
`gcc -O3` raises error on truncation using `snprintf`.
Diffstat (limited to 'mrbgems/mruby-inline-struct/test/inline.c')
| -rw-r--r-- | mrbgems/mruby-inline-struct/test/inline.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/mrbgems/mruby-inline-struct/test/inline.c b/mrbgems/mruby-inline-struct/test/inline.c index 95341d348..91c767f30 100644 --- a/mrbgems/mruby-inline-struct/test/inline.c +++ b/mrbgems/mruby-inline-struct/test/inline.c @@ -11,17 +11,17 @@ istruct_test_initialize(mrb_state *mrb, mrb_value self) mrb_value object; mrb_get_args(mrb, "o", &object); - if (mrb_float_p(object)) - { - snprintf(string, size, "float(%.3f)", mrb_float(object)); + if (mrb_float_p(object)) { + strncpy(string, "float", size-1); } - else if (mrb_fixnum_p(object)) - { - snprintf(string, size, "fixnum(%" MRB_PRId ")", mrb_fixnum(object)); + else if (mrb_fixnum_p(object)) { + strncpy(string, "fixnum", size-1); } - else if (mrb_string_p(object)) - { - snprintf(string, size, "string(%s)", mrb_string_value_cstr(mrb, &object)); + else if (mrb_string_p(object)) { + strncpy(string, "string", size-1); + } + else { + strncpy(string, "anything", size-1); } string[size - 1] = 0; // force NULL at the end |
