summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-string-ext/src
AgeCommit message (Collapse)Author
2021-12-16string-ext.c: fix memory leak in `tr_parse_pattern`.Yukihiro "Matz" Matsumoto
2021-12-13string-ext/string.c: fixed memory leak from `tr` on exception.Yukihiro "Matz" Matsumoto
With some refactoring. * `ret` argument is always non-nil, so no check needed. * move allocation check right after malloc(). * simplify conditions.
2021-11-15string-ext/string.c: fixed a memory leak.Yukihiro "Matz" Matsumoto
2021-09-07string.h: rename `mrb_str_to_inum` to `mrb_str_to_integer`.Yukihiro "Matz" Matsumoto
Consistent naming: `integer` to represent integer packed in `mrb_value` instead of `inum`.
2021-09-01string-ext/string.c: implement `casecmp` in C.Yukihiro "Matz" Matsumoto
* should not raise error for non-string arguments * avoid allocating case converted string internally
2021-09-01Do no use return values from `mrb_ensure_` functions.Yukihiro "Matz" Matsumoto
They return the checking argument without modification, so the values are already there. Maybe we should change the return type to `void` but keep them unchanged for compatibility.
2021-07-10Update internal methods not to be listed in backtraces.Yukihiro "Matz" Matsumoto
- String#__lines - Array#__ary_eq - Array#__ary_cmp - Hash#__delete - Kernel#__case_eqq - Integer#__coerce_step_counter
2021-05-17Global renaming regarding `integer` and `float`.Yukihiro "Matz" Matsumoto
Consistent number conversion function names: * `mrb_value` to immediate (C) value * `mrb_int()` -> `mrb_as_int()` * `mrb_to_flo()` -> `mrb_as_float()` * `mrb_value` to `mrb_value` (converted) * `mrb_to_int()' * `mrb_Integer()` - removed * `mrb_Float()` -> `mrb_to_float` Consistent function name (avoid `_flo` suffix): * `mrb_div_flo()` -> `mrb_div_float`
2021-05-05Extend the tab with 8 whitespacedearblue
This work was done as follows: - check: `git grep $'\011' -- :^oss-fuzz` - convert: `ruby -pi -e 'nil while $_.sub!(/^(.*?)\t/) { $1 + " " * (8 - $1.size % 8) }'` The `doc/guide/{compile,mrbgems}.md` file adds and removes whitespace to make the directory tree look the same. In `mrbgems/mruby-socket/src/socket.c`, there is a part where the indent is changed from 4 to 2 at the same time as the tab is changed.
2020-10-22Prohibit array changes by "a"/"*" specifier of `mrb_get_args()`dearblue
The "a"/"*" specifier of the `mrb_get_args()` function will now return `const mrb_value *`. This is because it is difficult for the caller to check if it is an array object and write-barrier if necessary. And it requires calling `mrb_ary_modify()` on the unmodified array object, which is also difficult (this is similar to #5087).
2020-10-12Reorganize `Integer` system.Yukihiro "Matz" Matsumoto
- Integrate `Fixnum` and `Integer` - Remove `Integral` - `int / int -> int` - Replace `mrb_fixnum()` to `mrb_int()` - Replace `mrb_fixnum_value()` to `mrb_int_value()`. - Use `mrb_integer_p()` instead of `mrb_fixnum_p()`
2020-10-12Rename float configuration option names.Yukihiro "Matz" Matsumoto
- `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-09-25Prohibit string changes by "s"/"z" specifier of `mrb_get_args()`dearblue
- The `s` specifier is a string pointer obtained without performing `mrb_str_modify()`, so it cannot be changed. - The `z` specifier cannot be changed because it is a string pointer obtained by `RSTRING_CSTR()` which returns `const char *`.
2020-06-20Add `mrb_get_arg1()` that retrieves single (and only) argument.Yukihiro "Matz" Matsumoto
`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-05Add proper casts to silence VC warnings.Yukihiro "Matz" Matsumoto
2019-10-20Use `mrb_str_cat_str` instead of `mrb_str_concat` if possibleKOBAYASHI Shuji
2019-09-21Use `mrb_define_method` instead of `mrb_define_alias`KOBAYASHI Shuji
2019-09-18Remove `mrb_get_args(mrb, "")`; ref 30f37872KOBAYASHI Shuji
2019-09-14Add a macro `mrb_frozen_p` that points to `MRB_FROZEN_P`.Yukihiro "Matz" Matsumoto
2019-09-11Move `String#{getbyte,setbyte,byteslice}` to the core; #4696Yukihiro "Matz" Matsumoto
Unlike CRuby, there's no way to process strings byte-wise by core methods because there's no per string encoding in mruby, so that we moved 3 byte-wise operation methods from `mruby-string-ext` gem.
2019-08-18Simplify get argumentsdearblue
- `mrb_str_index_m()` and `mrb_str_rindex()` Make `mrb_get_args()` called only once from called twice. - `mrb_str_byteslice()` Replace `goto` with `if ~ else`.
2019-08-05Use new specifiers/modifiers of `mrb_vfromat()`KOBAYASHI Shuji
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-07-24Add `return` to silence a warning; ref #4593Yukihiro "Matz" Matsumoto
2019-07-23Add encoding argument to `Integral#chr`KOBAYASHI Shuji
Currently, `Integral#chr` in mruby changes behavior by `MRB_UTF8_STRING` setting. before this patch: $ bin/mruby -e 'p 171.chr' #=> "\xab" (`MRB_UTF8_STRING` is disabled) $ bin/mruby -e 'p 171.chr' #=> "«" (`MRB_UTF8_STRING` is enabled) This behavior is incompatible with Ruby, and a little inconvenient because it can't be interpreted as ASCII-8BIT with `MRB_UTF8_STRING`, I think. So add encoding argument according to Ruby. after this patch: $ bin/mruby -e 'p 171.chr' #=> "\xab" $ bin/mruby -e 'p 171.chr("ASCII-8BIT")' #=> "\xab" $ bin/mruby -e 'p 171.chr("UTF-8")' #=> "«" Allow only `String` for encoding because mruby doesn't have `Encoding` class, and `"ASCII-8BIT"` (`"BINARY"`) and `"UTF-8"` (only with `MRB_UTF8_STRING`) are valid value (default is `"ASCII-8BIT"`).
2019-07-21Integrate `Integral#chr` (`Fixnum#chr`) to `mruby-string-ext`KOBAYASHI Shuji
Because they're defined in both `mruby-string-ext` and `mruby-numeric-ext` (they seem more natural to define in N, but `mruby-string-ext` depends on `Integral#chr`).
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-12Fix typo in `String#setbyte` error messageKOBAYASHI Shuji
2019-05-25Name the return value of `mrb_range_beg_len()`dearblue
2018-11-19Remove implicit conversion using `to_str` method; fix #3854Yukihiro "Matz" Matsumoto
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-15`String#{squeeze,delete,count}` to use bitmap for matching; ref #4163Yukihiro "Matz" Matsumoto
2018-11-15Pattern length may overflow `uint16_t`; fixed #4163Yukihiro "Matz" Matsumoto
The issue is reported by `https://hackerone.com/dgaletic`.
2018-11-02Empty pattern string for `String#tr` should remove characters; fix #4157Yukihiro "Matz" Matsumoto
2018-11-02Empty pattern string can generate `TR_UNINITIALIZED` pattern; fix #4156Yukihiro "Matz" Matsumoto
2018-11-01Silence Appveyor's VC compilation warnings.Yukihiro "Matz" Matsumoto
2018-10-30VS 2017 C does not understand inline struct initialization; ref #4153Yukihiro "Matz" Matsumoto
2018-10-29Keep tr_pattern statictake-cheeze
2018-09-27Fixed a `String#squeeze` bug in handling `iso-8859-1` strings; ref #4127Yukihiro "Matz" Matsumoto
2018-09-26Revert "Fix comparisons in str_squeeze."Yukihiro "Matz" Matsumoto
This reverts commit 7b04fcd092006b6e78cd63619fb7ae972f8e0c5d. The issue was addressed by 9e3cbaa. No longer needed.
2018-09-26Avoid using `memmove()` for performance; fix #4130Yukihiro "Matz" Matsumoto
2018-09-26Rename `tr_pattern_free()` to `tr_free_pattern()`.Yukihiro "Matz" Matsumoto
2018-09-25Fix leak in `mrb_str_count`Takeshi Watanabe
2018-09-24Fix comparisons in str_squeeze.Clayton Smith
2018-09-21Implement `String#delete` and `#delete!`; ref #4086Yukihiro "Matz" Matsumoto
mruby restriction: In mruby, `String#delete` only takes single pattern argument.
2018-09-21Implement `String#count`; ref #4086Yukihiro "Matz" Matsumoto
mruby restriction: In mruby, `String#count` does not take multiple pattern arguments, but only one pattern.
2018-09-21Add `String#squeeze` and `#squeeze!`; ref #4086Yukihiro "Matz" Matsumoto
mruby restriction: `String#squeeze` can take more than 1 pattern arguments in CRuby, in that case, the intersection of patterns will be used to match. But in mruby, it doesn't take multiple patterns.
2018-09-21Add `String#tr_s` and `String#tr_s!`; ref #4086Yukihiro "Matz" Matsumoto
2018-09-21Add `String#tr` and `#tr!` to `mruby-string-ext` gem; fix #4086Yukihiro "Matz" Matsumoto
This patch is based on `mruby/c` implementation by Hirohito Higashi. We might need to add `#tr_s`, `#squeeze` and `#delete` as well. Adding them should not be too hard using functions we implemented here.
2018-07-30New bytecode implementation of mruby VM.Yukihiro "Matz" Matsumoto
2018-04-21Implement `String#upto` in Ruby.Yukihiro "Matz" Matsumoto
Avoid using `mrb_yield` in C code. The function is not recommended. Because it doesn't work well with fibers.
2018-04-19CRuby2.6 stops deprecating `String#lines` with a block.Yukihiro "Matz" Matsumoto
`String#lines` (with a block) is now implemented in Ruby.