summaryrefslogtreecommitdiffhomepage
path: root/src/string.c
AgeCommit message (Collapse)Author
2021-12-31Merge pull request #5619 from dearblue/propertiesYukihiro "Matz" Matsumoto
Get object properties after `mrb_get_args()`
2021-12-30Get object properties after `mrb_get_args()`dearblue
ref. #5613 I checked with Valgrind, and the methods that can cause use-after-free are `Array#rotate`, `Array#rotate!`, and `String#byteslice`. Since `String#rindex` uses `RSTRING_LEN()` indirectly inside the function, no reference to the out-of-bounds range is generated.
2021-12-29string.c: reorganize `str_convert_range` using `mrb_ensure_int_type`Yukihiro "Matz" Matsumoto
2021-12-29string.c: use `mrb_as_int` macro.Yukihiro "Matz" Matsumoto
2021-10-23string.c: use FNV1a algorithm for the string hash function.Yukihiro "Matz" Matsumoto
2021-10-03mruby/ops.h: add new instructions `OP_GETIDX` and `OP_SETIDX`.Yukihiro "Matz" Matsumoto
Which represent `obj[int]` and `obj[int]=val` respectively where `obj` is either `string`, `array` or `hash`, so that index access could be faster. When `obj` is not assumed type or `R(a+1)` is not integer, the instructions fallback to method calls.
2021-09-09string.c: check integer overflow in `str_replace_partial`.Yukihiro "Matz" Matsumoto
2021-09-09string.c: check integer overflow in `mrb_str_aset()`.Yukihiro "Matz" Matsumoto
2021-09-07object.c: rename `mrb_to_int` to `mrb_to_integer`.Yukihiro "Matz" Matsumoto
Consistent naming: `integer` to represent integer packed in `mrb_value` instead of `int`.
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.c: need to adjust index for UTF-8.Yukihiro "Matz" Matsumoto
2021-09-01string.c: implement `__sub_replace()` in C.Yukihiro "Matz" Matsumoto
To reduce number of string allocation.
2021-09-01mruby.h: obsolete `mrb_to_str()`.Yukihiro "Matz" Matsumoto
Replace them by `mrb_ensure_string_type()`.
2021-08-21Organize the include of header filesdearblue
- `#include <math.h>` is done in `mruby.h`. Eliminate the need to worry about the `MRB_NO_FLOAT` macro. - Include mruby header files before standard header files. If the standard header file is already placed before `mruby.h`, the standard header file added in the future tends to be placed before `mruby.h`. This change should some reduce the chances of macros that must be defined becoming undefined in C++ or including problematic header files in a particular mruby build configuration.
2021-08-18string.c: `mrb_str_to_cstr()` should always return a mutable string.Yukihiro "Matz" Matsumoto
2021-08-03Replace `mrb_fixnum_value()` with `mrb_int_value()`.Yukihiro "Matz" Matsumoto
Use `mrb_fixnum_value()` only when you are absolutely sure that the value is within `Fixnum` range, i.e. 31 bits signed integer at least.
2021-08-03Replace `fixnum` references with `int`.Yukihiro "Matz" Matsumoto
The `Fixnum` class is no longer provided by `mruby`.
2021-07-25Remove redundant include headers.Yukihiro "Matz" Matsumoto
- stdlib.h - stddef.h - stdint.h - stdarg.h - limits.h - float.h
2021-06-20Added `MRB_OBJ_ALLOC()` macro that does not require a castdearblue
The `MRB_OBJ_ALLOC()` macro function returns a pointer of the type corresponding to the constant literal defined in `enum mrb_vtype`.
2021-06-08string.c: make `mrb_str_len_{inum,dbl}()` static.Yukihiro "Matz" Matsumoto
2021-06-08string.c: remove two unused functions.Yukihiro "Matz" Matsumoto
* `mrb_cstr_to_inum()` * `mrb_cstr_to_dbl()`
2021-06-08string.c: add `base>36` check to `String#to_i`.Yukihiro "Matz" Matsumoto
2021-05-24strtod.c: new public domain implementation of `strtod`; ref #5448Yukihiro "Matz" Matsumoto
Instead of using copyrighted `strtod`, now use the public domain implementation of `strtod` by Yasuhiro Matsumoto (@mattn). The function has been renamed to `mrb_float_read()`; ref #5460 as well.
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-17Rename `mrb_fixnum_to_str` to `mrb_integer_to_str`.Yukihiro "Matz" Matsumoto
2021-05-03symbol.c: remove `id2name` reference from documents.Yukihiro "Matz" Matsumoto
2021-04-28string.{c,rb}: fix type of return values from some methods as Ruby3.0Yukihiro "Matz" Matsumoto
When the receiver is the instance of subclass of `String`. - `String#each_char` - `String#each_line` - `String#partition`
2021-04-16feat(CI): add the GitHub Super LinterJohn Bampton
The GitHub Super Linter is a more robust and better supported tool than the current GitHub Actions we are using. Running these checks: ERROR_ON_MISSING_EXEC_BIT: true VALIDATE_BASH: true VALIDATE_BASH_EXEC: true VALIDATE_EDITORCONFIG: true VALIDATE_MARKDOWN: true VALIDATE_SHELL_SHFMT: true VALIDATE_YAML: true https://github.com/marketplace/actions/super-linter https://github.com/github/super-linter Added the GitHub Super Linter badge to the README. Also updated the pre-commit framework and added more documentation on pre-commit. Added one more pre-commit check: check-executables-have-shebangs Added one extra check for merge conflicts to our GitHub Actions. EditorConfig and Markdown linting. Minor grammar and spelling fixes. Update linter.yml
2021-01-26Revert "Minimize the changes in #5277"Yukihiro "Matz" Matsumoto
This reverts commit dc51d89ac22acc60b9bfeed87115863565b74085.
2021-01-22Minimize the changes in #5277Yukihiro "Matz" Matsumoto
Instead of including `mruby/presym.h` everywhere, we provided the fallback `mruby/presym.inc` under `include/mruby` directory, and specify `-I<build-dir>/include` before `-I<top-dir>/include` in `presym.rake`. So even when someone drops `-I<build-dir>/include` in compiler options, it just compiles without failure.
2021-01-11Avoid including `presym.inc` in existing header filesKOBAYASHI Shuji
Addressed an issue where existing programs linking `libmruby.a` could only be built by adding `<build-dir>/include` to compiler's include path.
2021-01-09Detect invalid first byte of UTF-8 char; fix #5269Yukihiro "Matz" Matsumoto
The first byte of UTF-8 character should not be `80..c1`.
2021-01-02Use Jenkins One At A Time Hash for `mrb_str_hash()`.Yukihiro "Matz" Matsumoto
2021-01-02Avoid `uint64_t` in string-to-integer conversion; ref #5201Yukihiro "Matz" Matsumoto
2021-01-02Reduce strength of the hash function; ref #5201Yukihiro "Matz" Matsumoto
Also avoid using `uint64_t`.
2020-12-23Fix the integer overflow in `mrb_str_len_to_inum()`.Yukihiro "Matz" Matsumoto
2020-12-13Fix spellingJohn Bampton
2020-11-22Remove `mrb_str_buf_new()` and `MRB_STR_BUF_MIN_SIZE`; close #5171Yukihiro "Matz" Matsumoto
2020-11-18Use `mrb_int_value()` instead of `mrb_fixnum_value()`; fix #5142Yukihiro "Matz" Matsumoto
2020-11-17Revert half of 9fbf0ef8.Yukihiro "Matz" Matsumoto
I misunderstand the meaning of #4483. Sorry.
2020-11-17Refactoring integer ranges.Yukihiro "Matz" Matsumoto
- Remove `mrb_ssize` - Fix `MRB_FIXNUM_{MIN,MAX}` to 32 bits on `MRB_NAN_BOXING`
2020-10-12Unify `mrb_str_to_str` to `mrb_obj_as_string`.Yukihiro "Matz" Matsumoto
Redirect `mrb_str_to_str` to `mrb_obj_as_string` via C macro. Inspired by #5082
2020-10-12Restore old function names for compatibility; fix #5070Yukihiro "Matz" Matsumoto
Rename new functions: - `mrb_convert_type(mrb,val,type,tname,method)` => `mrb_type_convert(mrb,val,type,tname,method)` - `mrb_check_convert_type(mrb,val,type,tname,method)` => `mrb_type_convert_check(mrb,val,type,tname,method)` Old names are defined by macros (support `tname` drop and `char*` => `mrb_sym` conversion).
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 `MRB_TT_FIXNUM` to `MRB_TT_INTEGER`.Yukihiro "Matz" Matsumoto
We still have `#define MRB_TT_FIXNUM MRB_TT_INTEGER` for compatibility.
2020-10-12Integrate `Fixnum` class into `Integer` classdearblue
* The `Fixnum` constant is now an alias for the `Integer` class. * Remove `struct mrb_state::fixnum_class` member. If necessary, use `struct mrb_state::integer_class` instead.
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-10-12Replace entire `irep->pool`.Yukihiro "Matz" Matsumoto
Changes: - `pool format is completely replaced - supported types: `STR`, `INT32`, `INT64`, `FLOAT` - `FLOAT` may be replaced by binary representation in the future - insert `NUL` after string literals in `mrb` files - `irep->pool` no longer store values in `mrb_value` - instead it stores in `mrb_pool_value` - less allocation - `mrb_irep` can be stored in ROM
2020-10-12Change the arguments of following implicit conversion functions:Yukihiro "Matz" Matsumoto
- `mrb_convert_type` - `mrb_check_convert_type` Those function no longer take `tname` string representation of desired type, and take method symbols instead of `const char*` names. This is incompatible change. I hope no third-party gems use those functions.
2020-09-18Remove redundant type-checkWataru Ashihara
since mrb_str_to_str() also does it.