48 Commits

Author SHA1 Message Date
Yukihiro "Matz" Matsumoto 49ae2a69f2 Add mrb_get_arg1() that retrieves single (and only) argument.
`mrb_get_arg1()` raises `ArgumentError` if the method does not receive one
argument.

And replaces all `mrb_get_args(mrb, "o", &arg)` by the new function.
2020-06-20 12:49:46 +09:00
Yukihiro "Matz" Matsumoto ccf28775b8 Fix mrb_str_len_to_dbl to support Hexadecimal like 0x10. 2020-01-06 15:52:39 +09:00
KOBAYASHI Shuji 7192429e83 Fix behavior of Kernel#Integer to numbers ending with _ and spaces
#### Before this patch:

  ```ruby
  Integer("1_ ")  #=> 1
  ```

#### After this patch (same as Ruby):

  ```ruby
  Integer("1_ ")  #=> ArgumentError
  ```
2019-12-11 16:40:39 +09:00
KOBAYASHI Shuji bf431e77b8 Fix behavior of String#to_i/Kernel#Integer to numbers starting with _
#### Before this patch:

  ```ruby
  Integer("_1")  #=> 1
  "_1".to_i      #=> 1
  ```

#### After this patch (same as Ruby):

  ```ruby
  Integer("_1")  #=> ArgumentError
  "_1".to_i      #=> 0
  ```
2019-12-10 21:31:30 +09:00
KOBAYASHI Shuji 0893ee492c Fix that String#to_f accepts consecutive _ as a numeric expression
Consecutive `_` is not allowed as a numeric expression:

  1_2__3             #=> SyntaxError
  Float("1_2__3")    #=> ArgumentError
  Integer("1_2__3")  #=> ArgumentError
  "1_2__3".to_i      #=> 12

But `String#to_f` accept it, so I fixed the issue.

Before this patch:

  "1_2__3".to_f      #=> 123

After this patch:

  "1_2__3".to_f      #=> 12
2019-12-09 21:47:59 +09:00
KOBAYASHI Shuji 04baaab311 Fix argument specs to Kernel 2019-11-15 19:07:42 +09:00
KOBAYASHI Shuji feaf80d899 Use type predicate macros instead of mrb_type if possible
For efficiency with `MRB_WORD_BOXING` (implement type predicate macros for
all `enum mrb_vtype`).
2019-09-26 22:23:27 +09:00
KOBAYASHI Shuji 334afb167c Use new specifiers/modifiers of mrb_vfromat()
The binary sizes (gems are only `mruby-bin-mruby`) are reduced slightly in
my environment than before the introduction of new specifiers/modifiers
(5116789a) with this change.

  ------------+-------------------+-------------------+--------
   BINARY     | BEFORE (5116789a) |   AFTER (This PR) |  RATIO
  ------------+-------------------+-------------------+--------
   mruby      |      593416 bytes |      593208 bytes | -0.04%
   libmruby.a |      769048 bytes |      767264 bytes | -0.23%
  ------------+-------------------+-------------------+--------

BTW, I accidentally changed `tasks/toolchains/visualcpp.rake` at #4613,
so I put it back.
2019-08-05 13:18:50 +09:00
KOBAYASHI Shuji 05493e651d Clarify mruby-(kernel|object)-ext gem summary; ref 8e637bdd [ci skip] 2019-06-06 20:21:40 +09:00
dearblue 56e0e1934d Name the return value of mrb_range_beg_len() 2019-05-25 12:12:21 +09:00
Yukihiro "Matz" Matsumoto 8e637bdd83 Should clarify the role of mruby-kernel-ext and mruby-object-ext; close #4449
The former should contain function like methods, and the latter should
contain methods shared by all objects.
2019-05-19 22:17:56 +09:00
KOBAYASHI Shuji 1975dedb21 Use mrb_string_value_cstr in mrb_str_to_dbl 2019-05-08 20:35:03 +09:00
Yukihiro "Matz" Matsumoto cca19532c5 Remove Kernel#class_defined? which is not available in CRuby; #3829 2019-01-03 11:34:35 +09:00
Yukihiro "Matz" Matsumoto 610bcc88c2 Removed to_hash conversion method. 2018-11-19 12:08:28 +09:00
Yukihiro "Matz" Matsumoto 698f5f707c Removed to_ary conversion method. 2018-11-19 12:08:28 +09:00
Yukihiro "Matz" Matsumoto ff08856fe3 Remove implicit conversion using to_str method; fix #3854
We have added internal convenience method `__to_str` which
does string type check.

The issue #3854 was fixed but fundamental flaw of lack of stack
depth check along with fibers still remains. Use `MRB_GC_FIXED_ARENA`
for workaround.
2018-11-19 12:05:46 +09:00
Yukihiro "Matz" Matsumoto afca99a40b Remove implicit conversion using to_int method.
The ISO standard does not include implicit type conversion using
`to_int`. This implicit conversion often causes vulnerability.
There will be no more attacks like #4120.

In addition, we have added internal convenience method `__to_int` which
does type check and conversion (from floats).
2018-11-19 11:28:51 +09:00
Yukihiro "Matz" Matsumoto c8fb7453fc Add then alias to yield_self.
`then' was added in CRuby 2.6.
2018-05-23 08:30:50 +09:00
YAMAMOTO Masaya 625f9f6fa3 Merge branch 'master' of github.com:mruby/mruby 2017-11-04 01:23:12 +09:00
Yukihiro "Matz" Matsumoto fc930700b7 Add Kernel#itself; CRuby2.2 2017-10-18 10:21:54 +09:00
Yukihiro "Matz" Matsumoto 1519616ecb Add Kernel#yield_self; CRuby2.5 2017-10-17 09:10:13 +09:00
YAMAMOTO Masaya b70d69de09 Support MRB_WIHTOUT_FLOAT to mruby-kernel-ext 2017-10-16 18:15:47 +09:00
Yukihiro "Matz" Matsumoto d2458e66c2 Remove class info from backtrace lines. 2017-05-23 23:50:42 +09:00
ksss b1c5c3b0a5 Fix lost lineno 2017-03-25 15:56:27 +09:00
Tomasz Dabrowski e4fa59f5ed Fixed aspec for Kernel#caller 2017-02-12 11:15:40 +01:00
Yukihiro "Matz" Matsumoto 5e1d923381 Changed the behavior of mrb_range_beg_len(); close #3411
The new API is:

int mrb_range_beg_len(mrb, range, &beg, &len, len, trunc)

The new argument `trunc` is a boolean value that specifies
whether the function truncates the range. The new return value
is an integer instead of a boolean, that is:

 0: not a range
 1: range with proper edges
 2: out of range

To get the old behavior, you have to rewrite:

  mrb_range_beg_len(mrb, range, &beg, &len, len)

to:

  mrn_range_beg_len(mrb, range, &beg, &len, len, TRUE) == 1

[Breaking Change]
2017-01-23 14:35:26 +09:00
ksss 59d9f313df Skip when backtrace doesn't get 2017-01-14 22:01:20 +09:00
ksss 6f9cb7406a Implement Kernel.#caller 2017-01-14 22:01:20 +09:00
Nobuyoshi Nakada 6511bfd79a Removed trailing spaces 2016-09-28 12:29:41 +09:00
Syohei YOSHIDA 2a661ac612 Add tests which passes all zero string to Kernel#Integer 2016-01-14 11:05:03 +09:00
Yukihiro "Matz" Matsumoto 5c405dea3d include changed from by quotes ("") to by brackets (<>); close #3032 2015-11-27 17:48:23 +09:00
Seba Gamboa 25c8e95365 Revert "Mark core gems with mrbgem tag"
This reverts commit 5cdcce8dbd.
2015-10-21 14:31:13 -03:00
Seba Gamboa 13b552538a Remove obvious warnings from docs 2015-10-20 12:48:31 -03:00
Seba Gamboa 5cdcce8dbd Mark core gems with mrbgem tag 2015-10-20 12:16:47 -03:00
Jun Hiroe 4e4929bc72 Rename extended xxxx class or module to xxxx class or module extension 2015-06-28 11:18:52 +09:00
Jun Hiroe c69d1201e1 Fix typo; Replace extensional with extended 2015-06-28 00:05:58 +09:00
Yukihiro "Matz" Matsumoto cbbf840440 use mrb_get_args to parse Integer() option; ref #2625 2014-10-29 13:22:04 +09:00
Jun Hiroe 28c804621a Add Kernel.Integer 2014-10-29 01:30:30 +09:00
Jun Hiroe 140e9bbf4b Add Kernel.Float 2014-10-24 01:55:55 +09:00
Jun Hiroe 9e05366451 Add Kernel.Hash 2014-10-21 23:48:44 +09:00
Jun Hiroe de04d3f080 Add Kernel.String 2014-10-20 22:35:58 +09:00
Jun Hiroe 9b1d9a7901 Refactor mrb_f_array func 2014-10-19 20:06:27 +09:00
Yukihiro "Matz" Matsumoto 4fd28deff9 refactoring C part of #2611 2014-10-19 19:39:02 +09:00
Jun Hiroe b6edf24a01 Add Kernel.Array 2014-10-19 19:25:31 +09:00
Yukihiro "Matz" Matsumoto e52533a703 update Kernel#raise/fail argument description 2014-06-05 13:17:29 +09:00
take_cheeze d0c0beb880 Move __method__ to mruby-kernel-ext since it's not ISO method. 2014-05-09 22:44:10 +09:00
yui-knk 27167f8de0 Replace from include <>, to include "". 2014-05-08 08:46:55 +09:00
take_cheeze 208bafba2d Move Kernel#fail definition to mruby-kernel-ext mrbgem. 2014-05-07 00:01:30 +09:00