13 Commits

Author SHA1 Message Date
Yukihiro "Matz" Matsumoto c5314a29b7 mruby-test: move declarations in driver.c and vformat.c 2024-05-01 13:24:32 +09:00
John Bampton 4fa3359d44 refactor: remove trailing whitespace from C, Header, Ruby and YAML files
Lint
2020-12-15 19:44:02 +10:00
Yukihiro "Matz" Matsumoto 8a87549315 Rename float configuration option names.
- `MRB_WITHOUT_FLOAT` => `MRB_NO_FLOAT`
- `MRB_USE_FLOAT` => `MRB_USE_FLOAT32`

The former is to use `USE_XXX` naming convention. The latter is to make
sure `float` is 32bit float and not floating point number in general.
2020-10-12 16:21:40 +09:00
Yukihiro "Matz" Matsumoto fd1cff7735 Fixed wrong usages of mrb_get_args in vformat.c. 2020-01-01 12:34:30 +09:00
Yukihiro "Matz" Matsumoto 87809742f5 Fix mixed declarations in 429f6de 2019-12-19 10:00:33 +09:00
Yukihiro "Matz" Matsumoto 429f6defdd Reimplement vformat tests; close #4868
Avoid creating `Data` object that refers `mruby` objects.
Also close #4622 ref #4613
2019-12-19 09:35:51 +09:00
Yukihiro "Matz" Matsumoto 7f0e1fc90b Revert "%C value need not to be saved in TestVFormat::Native; close #4868"
This reverts commit f507ff4842.
It makes AppVeyor tests fail.
2019-12-19 00:07:08 +09:00
Yukihiro "Matz" Matsumoto f507ff4842 %C value need not to be saved in TestVFormat::Native; close #4868 2019-12-18 01:40:11 +09:00
Yukihiro "Matz" Matsumoto 98fc887cb3 Reorganize mrb_string_value_cstr and related functions.
`mrb_string_value_cstr` and `mrb_string_value_len`: obsolete
`mrb_string_cstr`: new function to retrieve NULL terminated C string
`RSTRING_CSTR`: wrapper macro of `mrb_string_cstr`
2019-08-07 15:52:10 +09:00
KOBAYASHI Shuji 1e9cb74cc6 Change second argument to %l of mrb_vformat() to size_t from mrb_int
- `size_t` is more commonly used.
- `len` argument of `mrb_str_new()` is `size_t`.

NOTE:

The test for `%l` is temporarily disabled because adding a new type to
`mrbgems/mruby-test/vformat.c` causes an error (memory error?) on Visual
Studio 2017 in AppVeyor.
2019-08-03 19:42:22 +09:00
KOBAYASHI Shuji a4243360a2 Fix mrb_vformat("%f") with MRB_USE_FLOAT
It potentially not work when `mrb_float` is `float` because `float` variable
in variable length arguments is promoted to `double`.

Also I fixed build with `MRB_WITHOUT_FLOAT`.
2019-08-03 11:54:45 +09:00
KOBAYASHI Shuji d1817e7791 Change the mrb_vformat specifier %d for int
It potentially breaks, for example, in the case of `mrb_int` is 64-bit
and more smaller type is passed by `%d`. In fact, the problem could
become apparent when I used `%d` to `backtrace_location::lineno` in
`src/backtrace.c:mrb_unpack_backtrace()` on AppVeyor.

Therefore, change `%d` for `int` (not `mrb_int`) so that it can be
used mostly without casting.
2019-08-02 19:22:08 +09:00
KOBAYASHI Shuji eea42e06af Add new specifiers/modifiers to format string of mrb_vfromat()
Format sequence syntax:

  %[modifier]specifier

Modifiers:

  ----------+------------------------------------------------------------
  Modifier  | Meaning
  ----------+------------------------------------------------------------
      !     | Convert to string by corresponding `inspect` instead of
            | corresponding `to_s`.
  ----------+------------------------------------------------------------

Specifiers:

  ----------+----------------+--------------------------------------------
  Specifier | Argument Type  | Note
  ----------+----------------+--------------------------------------------
      c     | char           |
     d,i    | mrb_int        |
      f     | mrb_float      |
      l     | char*, mrb_int | Arguments are string and length.
      n     | mrb_sym        |
      s     | char*          | Argument is NUL terminated string.
      t     | mrb_value      | Convert to type (class) of object.
     v,S    | mrb_value      |
      C     | struct RClass* |
      T     | mrb_value      | Convert to real type (class) of object.
      Y     | mrb_value      | Same as `!v` if argument is `true`, `false`
            |                | or `nil`, otherwise same as `T`.
      %     | -              | Convert to percent sign itself (no argument
            |                | taken).
  ----------+----------------+--------------------------------------------

This change will increase the binary size, but replacing all format strings
with new specifiers/modifiers will decrease the size because it reduces
inline expansion of `mrb_obj_value()`, etc. at the caller.
2019-08-01 13:24:52 +09:00