summaryrefslogtreecommitdiffhomepage
path: root/src
AgeCommit message (Collapse)Author
2019-07-13Change type of a variable for signedness mismatch; ref #4573Yukihiro "Matz" Matsumoto
2019-07-13Avoid `mrb_funcall()` if possible using `mrb_Float()`; ref #4555Yukihiro "Matz" Matsumoto
2019-07-12Fix heap buffer overflow; fix #4569dearblue
2019-07-11Improve performance `String#index` with UTF-8dearblue
Based on Boyer-Moore-Horspool algorithm (Quick Search algorithm). As a side effect, the correct position is returned even if an invalid UTF-8 string is given. ```console % ./mruby@master -e 'p ("\xd1" * 100 + "#").index("#")' 50 % ./mruby@improve-index -e 'p ("\xd1" * 100 + "#").index("#")' 100 ``` The other behavior should be the same as the current implementation.
2019-07-10Remove an unused argument of `str_with_class()`KOBAYASHI Shuji
2019-07-09Set `MRB_STR_ASCII` flag when an inline symbol is stringizedKOBAYASHI Shuji
2019-07-08Add macros for inline symbol for readabilityKOBAYASHI Shuji
2019-07-06Fix missing `#ifndef MRB_ENABLE_ALL_SYMBOLS`KOBAYASHI Shuji
2019-07-05Read/write `MRB_STR_ASCII` flag only when `MRB_UTF8_STRING` is definedKOBAYASHI Shuji
2019-07-04It was too early to check `key` for `undef`; ref #4534Yukihiro "Matz" Matsumoto
2019-07-04Rename `MRB_STR_NO_UTF` to 'MRB_STR_ASCII`; close #4550Yukihiro "Matz" Matsumoto
In #4550, @shuuji proposed the name name `MRB_STR_NO_MULTI_BYTE` for more precise description. Although I agree that the name name is correct, but the flag means the string does not contain multi byte UTF-8 characters, i.e. all characters fit in the range of ASCII.
2019-07-04Fix heap buffer overflow; ref #4549dearblue
This patch is showed in #4549.
2019-07-03Refine document to mrb_get_args()` [ci skip]KOBAYASHI Shuji
2019-07-02Fix and refine error message in `mrb_obj_to_sym()`KOBAYASHI Shuji
Before this patch: $ bin/mruby -e '1.respond_to?(2)' #=> nil is not a symbol After this patch (same as Ruby): $ bin/mruby -e '1.respond_to?(2)' #=> 2 is not a symbol nor a string
2019-07-01Remove unused C header file from `src/etc.c`KOBAYASHI Shuji
2019-06-30Fix `include`, `prepend` and `extend` to frozen objectKOBAYASHI Shuji
2019-06-29Simplify `mrb_str_aref_m()` and `mrb_str_aref()`dearblue
It is integration with part of argument parsing used in `mrb_str_aset_m()`.
2019-06-29Replace `String#[]=` method by C implementsdearblue
The purpose is to eliminate string objects that are temporarily created during processing.
2019-06-28Remove unnecessary backticks in `src/range.c`; ref #2858KOBAYASHI Shuji
2019-06-27Skip copying delete keys in a hash; fix #4534Yukihiro "Matz" Matsumoto
2019-06-26Silence unused label warnings from gcc; ref #4524KOBAYASHI Shuji
mruby/mruby/src/string.c:1722:4: warning: label 'bytes' defined but not used [-Wunused-label] bytes: ^~~~~
2019-06-26Merge pull request #4524 from dearblue/reverse-utf8Yukihiro "Matz" Matsumoto
Change to UTF-8 string reversing with in place
2019-06-26Merge pull request #4532 from ↵Yukihiro "Matz" Matsumoto
shuujii/fix-String-byteslice-with-MRB_UTF8_STRING-and-some-edge-cases Fix `String#byteslice` with `MRB_UTF8_STRING` and some edge cases
2019-06-25Fix `String#byteslice` with `MRB_UTF8_STRING` and some edge casesKOBAYASHI Shuji
Example: $ bin/mruby -e ' p "あa".byteslice(1) p "bar".byteslice(3) p "bar".byteslice(4..0) ' Before this patch: "a" "" RangeError (4..0 out of range) After this patch (same as Ruby): "\x81" nil nil
2019-06-25Merge pull request #4528 from shuujii/fix-argument-specs-to-ArrayYukihiro "Matz" Matsumoto
Fix argument specs to `Array`
2019-06-25Merge pull request #4530 from ↵Yukihiro "Matz" Matsumoto
shuujii/compare-obj-pointer-directly-instead-of-using-mrb_obj_eq-in-mrb_gc_unregister Compare obj pointer directly instead of using mrb_obj_eq in mrb_gc_unregister
2019-06-25Fixed `mrb_iv_remove` with immediate objects; fix #4519Yukihiro "Matz" Matsumoto
The #4520 tried to address the issue, but it changes the type of `mrb_check_frozen` argument; close #4520
2019-06-25Fix `mrb_str_to_str()` to handle symbols.Yukihiro "Matz" Matsumoto
2019-06-24Compare obj pointer directly instead of using mrb_obj_eq in mrb_gc_unregisterKOBAYASHI Shuji
Because immediate values are not registered.
2019-06-23Fix argument specs to `Array`KOBAYASHI Shuji
2019-06-23Merge pull request #4526 from shuujii/refine-Hash-rehash-exampleYukihiro "Matz" Matsumoto
Refine `Hash#rehash` example [ci skip]
2019-06-22Fix the unnecessary `mrb_str_modify()` calldearblue
Now to be calls `mrb_str_modify()` only once when 2 or more characters.
2019-06-22Delete the unnecessary block brace in `mrb_str_reverse_bang`dearblue
2019-06-22Fix string brakes for one UTF-8 charactordearblue
2019-06-22Change to UTF-8 string reversing with in placedearblue
Reverses UTF-8 strings without allocated heap for working memory. 1. String before reversing: ``` "!yburmの界世" # byte unit [33, 121, 98, 117, 114, 109, 227, 129, 174, 231, 149, 140, 228, 184, 150] ``` 2. Reverse the byte order of each character: ``` [33, 121, 98, 117, 114, 109, 174, 129, 227, 140, 149, 231, 150, 184, 228] ``` 3. Reverse the whole byte order and complete: ``` [228, 184, 150, 231, 149, 140, 227, 129, 174, 109, 114, 117, 98, 121, 33] # string "世界のmruby!" ```
2019-06-22Replacement to function for string reversingdearblue
2019-06-22Refine `Hash#rehash` example [ci skip]KOBAYASHI Shuji
Previous example doesn't work because string key (frozen) can't be modified.
2019-06-22Fix potential overflow in `utf8len()`dearblue
For example on 32 bit mode, when `p = 0xfffffffd`, `e = 0xfffffffe` and `len = 4`, the sum of `p` and `len` can be to `1`, and comparison with `e` will to be false. As a result, a segmentation fault occurs by referring to address 0.
2019-06-16Fix cvar, ivar, const and method can be removed to frozen objectKOBAYASHI Shuji
2019-06-13Fix class name validation in `Struct.new`KOBAYASHI Shuji
Before this patch: $ bin/mruby -e 'p Struct.new("A-")' #=> Struct::"A-" After this patch: $ bin/mruby -e 'p Struct.new("A-")' #=> NameError: identifier A- needs to be constant
2019-06-10`Kernel#global_variables` should not include undefined `$1`-`$9`KOBAYASHI Shuji
- They are not include in Ruby. - Appear in duplicate when `$1`-`$9` are defined.
2019-06-07Remove `Kernel#global_variables` from coreKOBAYASHI Shuji
This method is defined in `mruby-metaprog` gem.
2019-05-30Fix inverted compilation condition; fix #4478Yukihiro "Matz" Matsumoto
2019-05-29Add `mrb_alloca` again; ref #4470Yukihiro "Matz" Matsumoto
This time, the allocated memory comes from the string object, which is referenced from GC arena. The memory region will be reclaimed when the C function called from VM is terminated, or the GC arena is restored.
2019-05-27Merge pull request #4470 from dearblue/remove-mrb_allocaYukihiro "Matz" Matsumoto
Remove `mrb_alloca()` function
2019-05-26Move `mrb_mod_s_nesting()` to `mruby-metaprog` gem from the coreKOBAYASHI Shuji
2019-05-25Remove `mrb_alloca()` functiondearblue
When I found this function, I expected it to behave the same as the `alloca(3)` function, but it is accually the `mrb_alloca()` function does not free the heap until the `mrb_close()` function is called. Also, even if it is deleted, it can be replaced with the combination of the `MRB_TT_DATA` object and the `mrb_gv_set()` function if it is sure necessary.
2019-05-25Fix double rounded by negative indexdearblue
- Before patched: ``` $ mruby -e 'p (-12..-1).map { |i| "Hello"[i] }.join' "HelloHello" ``` - After patched: ``` $ mruby -e 'p (-12..-1).map { |i| "Hello"[i] }.join' "Hello" ```
2019-05-25Name the return value of `mrb_range_beg_len()`dearblue
2019-05-22Merge pull request #4403 from dearblue/read-irep-from-bufYukihiro "Matz" Matsumoto
Read irep from buffers