summaryrefslogtreecommitdiffhomepage
path: root/src
AgeCommit message (Collapse)Author
2019-12-10Fix behavior of `String#to_i`/`Kernel#Integer` to numbers starting with `_`KOBAYASHI Shuji
#### 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-10Merge pull request #4858 from ↵Yukihiro "Matz" Matsumoto
shuujii/fix-that-String-to_f-accepts-consecutive-_-as-a-numeric-expression Fix that `String#to_f` accepts consecutive `_` as a numeric expression
2019-12-09Fix that `String#to_f` accepts consecutive `_` as a numeric expressionKOBAYASHI Shuji
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-09Fix `mrb_get_argv()` to return array pointer every time; fix #4832Yukihiro "Matz" Matsumoto
2019-12-09Merge pull request #4855 from dearblue/kwargs-uninitYukihiro "Matz" Matsumoto
Fix keyword arguments not be obtained with `mrb_get_args()`; Fix #4754
2019-12-08Fix the error message of `Kernel#Float`KOBAYASHI Shuji
#### Before this patch: ``` $ bin/mruby -e 'Float("1_a")' -e:1: invalid string for float(a) (ArgumentError) ``` #### After this patch: ``` $ bin/mruby -e 'Float("1_a")' -e:1: invalid string for float("1_a") (ArgumentError) ```
2019-12-07Fix keyword arguments not be obtained with `mrb_get_args()`; Fix #4754dearblue
If ":" is after "|" and there is no "?" or "*", the keyword argument could not be obtained and it was not initialized with `undef`. For example: "|oo:"
2019-12-04Refine `mrb_alloca()`KOBAYASHI Shuji
* The allocated memory is guaranteed to be aligned for any data type (it was not guaranteed when string type is embed). * Make allocation size exactly specified size (does not allocate space for a null byte).
2019-11-27Merge pull request #4837 from shuujii/add-assertion-to-RVALUE-sizeYukihiro "Matz" Matsumoto
Add assertion to `RVALUE` size
2019-11-23Rename `BITSIZE` to `BIT` and `BIT` to `BIT_POS` for consistencyKOBAYASHI Shuji
The bit width terminology is unified to `BIT` according to `MRB_INT_BIT` and `CHAR_BIT`. Also the bit position terminology is unified to `BIT_POS`.
2019-11-23Add assertion to `RVALUE` sizeKOBAYASHI Shuji
2019-11-21Introduce `mrb_ssize` type for buffer size on memory; ref #4483KOBAYASHI Shuji
Previously, `mrb_int` was used as the type that represents the buffer size on memory, but the sizes of `RString` and `RArray` exceed 6 words when `MRB_INT64` is enabled on 32-bit CPU. I don't think it is necessary to be able to represent the buffer size on memory that exceeds the virtual address space. Therefore, for this purpose, introduce `mrb_ssize` which doesn't exceed the sizes of `mrb_int` and pointer. I think all `mrb_int` used for this purpose should be changed to `mrb_ssize`, but currently only the members of the structures (`RString`, `mrb_shared_string`, `RArray` and `mrb_shared_array`) are changed.
2019-11-19Refactor `mrb_string_value_cstr`KOBAYASHI Shuji
- Keep `MRB_STR_ASCII` flag. - Avoid a string object creation.
2019-11-18Merge pull request #4825 from shuujii/fix-argument-specs-to-KernelYukihiro "Matz" Matsumoto
Fix argument specs to `Kernel`
2019-11-16Revert "Implement Ruby2.7's frozen strings from `Symbol#to_s`"KOBAYASHI Shuji
This feature was reverted from Ruby 2.7.
2019-11-15Fix argument specs to `Kernel`KOBAYASHI Shuji
2019-11-13Revert a76dc04 to resolve #4820Yukihiro "Matz" Matsumoto
2019-11-11Fix argument specs to `Integer`KOBAYASHI Shuji
2019-11-08Avoid unnecessary `Symbol#to_s` call; fix #4812Yukihiro "Matz" Matsumoto
2019-11-08Avoid crashing of `Array#unshift`; fix #4808Yukihiro "Matz" Matsumoto
On cases like `a.unshift(*a)`.
2019-11-07Clear `MRB_STR_SHARED` flag in `mrb_str_modify_keep_ascii`; close #4807KOBAYASHI Shuji
2019-11-03Remove unused enum in `mrb_cstr_to_dbl`KOBAYASHI Shuji
2019-11-02Fix argument specs to `Hash`KOBAYASHI Shuji
2019-10-31Set `MRB_STR_ASCII` flag to some stringize methodsKOBAYASHI Shuji
- `Fixnum#to_s`, `Fixnum#inspect` - `Float#to_s`, `Float#inspect` - `NilClass#to_s`, `NilClass#inspect` - `FalseClass#to_s`, `FalseClass#inspect` - `TrueClass#to_s`, `TrueClass#inspect` - `Time#to_s`, `Time#inspect`
2019-10-28Remove documents about `Regexp` argument from `String#{[],[]=}` [ci skip]KOBAYASHI Shuji
2019-10-27Refine `String#split` documentKOBAYASHI Shuji
2019-10-26Optimize `chars2bytes` with `MRB_UTF8_STRING` to ASCII only stringKOBAYASHI Shuji
### Benchmark (with `MRB_UTF8_STRING`) ``` $ mruby -e ' COUNT = 150000 SIZE = 10000 strs = Array.new(COUNT) do s = "a" * SIZE s.size # set `MRB_STR_ASCII` flag s end i = 0 t = Time.now while i < COUNT strs[i][-2..-1] = "" i += 1 end printf "%.2f sec\n", Time.now - t ' 1.10 sec # before 0.07 sec # after ```
2019-10-24Fix argument specs to `Exception`KOBAYASHI Shuji
2019-10-23Optimize `str_subseq` with `MRB_UTF8_STRING` to ASCII only stringKOBAYASHI Shuji
### Benchmark (with `MRB_UTF8_STRING`) ```ruby # benchmark.rb COUNT = 300000 SIZE = 10000 s = "a" * SIZE s.size # set `MRB_STR_ASCII` flag i = 0 while i < COUNT s[-1] i += 1 end ``` #### Before this patch: ``` $ time mruby benchmark.rb 2.06 real 2.05 user 0.00 sys ``` #### After this patch: ``` $ time mruby benchmark.rb 0.05 real 0.04 user 0.00 sys ```
2019-10-22Fix incorrect `MRB_STR_ASCII` flag update in `mrb_str_dump`KOBAYASHI Shuji
### Example (with `MRB_UTF8_STRING`) ```ruby s = "\u3042" p s.size s.dump p s.size ``` #### Before this patch: ``` 1 3 ``` #### After this patch: ``` 1 1 ```
2019-10-20Use `mrb_str_cat_str` instead of `mrb_str_concat` if possibleKOBAYASHI Shuji
2019-10-19Fix that `Module#to_s` may return frozen string; ref 08eafe2KOBAYASHI Shuji
2019-10-17delete extern in Cyuri
2019-10-16Use `mrb_sym_name_len` instead of `mrb_sym_name` in `assign_class_name`KOBAYASHI Shuji
2019-10-15Adjust `buf` size in `str_escape`KOBAYASHI Shuji
2019-10-13Refactor `mrb_class_name_class`KOBAYASHI Shuji
- Use `mrb_sym_name_len` instead of `mrb_sym_name` (class name should not be escaped). - Avoid `mrb_str_dup` (it is unnecessary to be shared string because it is changed).
2019-10-12Merge pull request #4770 from ↵Yukihiro "Matz" Matsumoto
shuujii/sHARED-string-is-not-required-when-sharing-POOL-string SHARED string is not required when sharing POOL string
2019-10-12SHARED string is not required when sharing POOL stringKOBAYASHI Shuji
The heap string buffer of POOL string always exists, does not need to be released, and read only, so it can be shared as NOFREE string.
2019-10-12Rename `str_make_shared()` to `str_share()` in `src/string.c`KOBAYASHI Shuji
Because it may not create `struct mrb_shared_string`.
2019-10-10Integrate `mrb_str_inspect` and `mrb_str_dump`KOBAYASHI Shuji
2019-10-08Implement Ruby2.7's frozen strings from `Module#name`KOBAYASHI Shuji
2019-10-06Remove unnecessary function: `mrb_str_freeze`.Yukihiro "Matz" Matsumoto
2019-10-06Get keyword arguments with `mrb_get_args()`dearblue
Keyword arguments can now be retrieved with the `:` specifier and `mrb_kwargs` data. For the interface, I referred to CRuby's `rb_get_kwargs()`. For implementation, I referred to `OP_KARG` or etc.
2019-10-04Freeze strings from `nil.to_s`, `true.to_s`, `false.to_s`.Yukihiro "Matz" Matsumoto
This is an experimental changes in Ruby 2.7.
2019-10-04Implement Ruby2.7's frozen strings from `Symbol#to_s`.Yukihiro "Matz" Matsumoto
2019-10-03Remove duplicates header files in `src/pool.c`dearblue
These are included in `mruby.h`. As a background, if `enable_cxx_abi` is specified, the macro that defines the maximum value in `stdint.h` is undefined depending on the environment. - Confirmed with gcc on FreeBSD 12.0 and mingw32-gcc available on FreeBSD. - `INTPTR_MAX`, `INT64_MAX` and `UINT64_MAX` are defined by `cstdint` added in C++11. But `toolchains :gcc` adds `-std=c++03`, so the macros are not defined. - To have these defined in `C++03`, `__STDC_CONSTANT_MACROS` must be defined in advance. This is already done by `mruby.h`.
2019-10-02Avoid `symhash()` call for inline symbol in `sym_intern()`KOBAYASHI Shuji
2019-09-29Allow rethrowing `MRB_TT_BREAK`dearblue
2019-09-27Simplify arguments check in `String#rindex`KOBAYASHI Shuji
Also fix document about type of the first argument.
2019-09-27Merge pull request #4733 from ↵Yukihiro "Matz" Matsumoto
shuujii/use-type-predicate-macros-instead-of-mrb_type-if-possible Use type predicate macros instead of `mrb_type` if possible