summaryrefslogtreecommitdiffhomepage
path: root/src/string.c
AgeCommit message (Collapse)Author
2019-08-15Remove unneeded `#include` in `src/string.c`KOBAYASHI Shuji
2019-08-14Extract initialization code of shared and fshared string to functionKOBAYASHI Shuji
2019-08-14Small refactoring on #4630Yukihiro "Matz" Matsumoto
2019-08-13Extract `struct RString` initialization code to functionKOBAYASHI Shuji
2019-08-12Merge pull request #4626 from ↵Yukihiro "Matz" Matsumoto
shuujii/mrb_str_modify_keep_ascii-can-embed-one-more-byte `mrb_str_modify_keep_ascii` can embed one more byte
2019-08-12Replacing region may overwrap with the target region; fix #4627Yukihiro "Matz" Matsumoto
2019-08-11Add `NUL` always to short strings; ref 98fc887Yukihiro "Matz" Matsumoto
2019-08-11`mrb_str_modify_keep_ascii` can embed one more byteKOBAYASHI Shuji
The condition to make an embedded string was incorrect. Because there were several similar codes, extracted into `RSTR_EMBEDDABLE_P` macro.
2019-08-07Update `mrb_to_str` and related functions.Yukihiro "Matz" Matsumoto
Contrary to the name, `mrb_to_str` just checks type, no conversion.
2019-08-07Reorganize `mrb_string_value_cstr` and related functions.Yukihiro "Matz" Matsumoto
`mrb_string_value_cstr` and `mrb_string_value_len`: obsolete `mrb_string_cstr`: new function to retrieve NULL terminated C string `RSTRING_CSTR`: wrapper macro of `mrb_string_cstr`
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-22Set `MRB_STR_ASCII` flag in `String#inspect`KOBAYASHI Shuji
`String#inspect` can set `MRB_STR_ASCII` flag to receiver and return value because it checks character byte length.
2019-07-17Avoid `MRB_INLINE` for `mrb_str_modify()`; ref #4579Yukihiro "Matz" Matsumoto
Functions that are called infrequently need not to be inline.
2019-07-16Copy receiver's `MRB_STR_ASCII` flag in some methods of `String`KOBAYASHI Shuji
2019-07-16Merge pull request #4579 from ↵Yukihiro "Matz" Matsumoto
shuujii/keep-MRB_STR_ASCII-flag-in-some-methods-of-String Keep `MRB_STR_ASCII` flag in some methods of `String`
2019-07-15Add `MRB_API` to `mrb_str_modify_keep_ascii()`KOBAYASHI Shuji
2019-07-14Keep `MRB_STR_ASCII` flag in some methods of `String`KOBAYASHI Shuji
2019-07-14Improve `utf8len()` performance with UTF-8dearblue
2019-07-13Change type of a variable for signedness mismatch; ref #4573Yukihiro "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-05Read/write `MRB_STR_ASCII` flag only when `MRB_UTF8_STRING` is definedKOBAYASHI Shuji
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-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-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-25Fix `mrb_str_to_str()` to handle symbols.Yukihiro "Matz" Matsumoto
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-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-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-08Use `mrb_string_value_cstr` in `mrb_str_to_dbl`KOBAYASHI Shuji
2019-05-07Refactor `mrb_str_to_cstr` and `mrb_string_value_cstr`KOBAYASHI Shuji
- Extract null byte check to function. - Avoid string allocation if null byte is included. - Use `str_new` instead of `mrb_str_dup` + `mrb_str_modify`
2019-05-02Merge pull request #4417 from ↵Yukihiro "Matz" Matsumoto
shuujii/unify-overflow-error-class-for-conversion-to-integer-to-RangeError Unify overflow error class for conversion to integer to `RangeError`
2019-05-02Unify overflow error class for conversion to integer to `RangeError`KOBAYASHI Shuji
2019-05-01Remove unneeded `argc` check in `mrb_str_aref_m()`KOBAYASHI Shuji
2019-04-24Remove unnecessary `mrb_regexp_check()` and related functions.Yukihiro "Matz" Matsumoto
2019-04-09Extract frozen checking to functionKOBAYASHI Shuji
2019-03-26Fix missing `MRB_API` prefix for functions below; clse #4267Yukihiro "Matz" Matsumoto
Functions to add prototypes to headers: * mrb_ary_splice() * mrb_notimplement() * mrb_vformat() * mrb_cstr_to_dbl() * mrb_cstr_to_inum() Functions to be made `static` (`MRB_API` was not needed): * mrb_mod_module_function() * mrb_obj_hash() * mrb_str_len_to_inum() Functions to remove `MRB_API` from definitions (referenced from within `libmruby`): * mrb_mod_cv_defined() * mrb_mod_cv_get() * mrb_f_send()
2019-03-25Use uppercase version of `ctype` macros e.g. `ISSPACE`; fix #4338Yukihiro "Matz" Matsumoto
2019-02-06Reduce invocation of `mrb_convert_type()` from `mrb_str_to_str()`.Yukihiro "Matz" Matsumoto