Yukihiro "Matz" Matsumoto
3bedd22d55
Add assertion to make sure new capacity does not overflow.
2016-12-13 10:50:04 +09:00
Yukihiro "Matz" Matsumoto
3a7c369536
Make sure str->capa is under MRB_INT_MAX; fix #3342
2016-12-13 10:48:36 +09:00
Yukihiro "Matz" Matsumoto
92c843dd07
rename prefix RBASIC_ to MRB_; ref #3340
2016-12-12 00:54:36 +09:00
Takashi Kokubun
10bb7ad693
Implement Object#freeze
2016-12-11 03:44:15 +09:00
Felix Jones
2827655b9c
Removed unnecessary const macro - const keyword is already a dependency
2016-12-08 12:38:00 +00:00
Yasuhiro Matsumoto
c27dbfedf4
disable define const on VS
2016-12-08 15:56:50 +09:00
Felix Jones
fe86cf4c91
Removed the errno declaration from string.c
2016-12-07 14:17:09 +00:00
Felix Jones
6187c21bd9
Wrapped string.c errno with ifndef macro for platforms that use inbuilt errno macro
2016-12-07 12:46:47 +00:00
Yukihiro "Matz" Matsumoto
5c651d6ce9
add MRB_API to mrb_float_read(); ref #3270
2016-12-03 18:55:52 +09:00
Yukihiro "Matz" Matsumoto
a0fbc46ccd
Import locale insensitive strtod() from Ruby1.8; fix #3270
...
The function was renamed to `mrb_float_read(const char*, char**)`.
2016-12-03 18:47:04 +09:00
Clayton Smith
76a1bdfa29
Get String length after args in String#chomp!
...
Fixes RCE issue
Reported by @bouk
2016-11-24 10:28:21 -05:00
Tomasz Dąbrowski
1af9e363f2
Fixes for compiling mruby as C++
2016-11-24 09:28:00 +09:00
Yukihiro "Matz" Matsumoto
57900d809f
String#include? does not take integers
2016-11-17 18:02:10 +09:00
Tomasz Dąbrowski
8e0dc6fa8d
Correct argument specifications for few methods:
...
- Struct#values_at
- Module#define_method
- String#chop
- String#chop!
2016-11-16 15:46:28 +01:00
Yukihiro "Matz" Matsumoto
afbe211c60
mrb_str_strlen() should be MRB_API; ref #3216
2016-09-27 10:29:56 +09:00
Kouhei Sutou
91bd3ebd32
Remove needless MRB_API
...
ref #3215
If a function (such as mrb_read_irep_file()) is declared without MRB_API
in header file (such as include/mruby/dump.h), implementation of the
function in source file (such as src/load.c) should also defined without
MRB_API.
If MRB_API is mismatch, Visual C++ reports link error with C2375 error
code: https://msdn.microsoft.com/en-us/library/5k6kw95a.aspx
2016-09-25 21:47:49 +09:00
Yukihiro "Matz" Matsumoto
62b06ab4d4
[cppcheck] mrb_str_rindex() remove unnecessary len update by chars2bytes()
2016-02-05 21:54:07 +09:00
Yukihiro "Matz" Matsumoto
25e4ec3f37
cache UTF8 status for utf8_strlen(); ref #980
2016-02-04 23:33:16 +09:00
Syohei YOSHIDA
787685a0b9
Fix all zero string case
2016-01-14 11:07:07 +09:00
Yukihiro "Matz" Matsumoto
9145aed85e
bytes2chars() conversion to fail if target byte offset is not on the character boundary; ref #3067
...
that means String#index matches first byte of a multi-byte character. this behavior is different
from CRuby, but a compromise for mruby which does not have encoding stuffs.
2016-01-05 18:05:25 +09:00
ksss
6c1b6ef7a5
Use memchr for performance
...
```ruby
s = "b"
str = ("a" * 100 + s)
t = Time.now
str.index(s)
puts Time.now - t
```
before => 0.000788
after => 0.000508
---
```ruby
s = "b"
str = ("a" * 100 * 1024 * 1024 + s)
t = Time.now
str.index(s)
puts Time.now - t
```
before => 0.225474
after => 0.008658
2015-12-31 17:52:22 +09:00
Yasuhiro Matsumoto
7cc33af2dc
fix build on VS2012
2015-12-22 17:46:20 +09:00
Yukihiro "Matz" Matsumoto
f54a98ff15
mrb_str_len_to_inum(): fixed a bug with MRB_INT_MIN conversion; fix #3048
2015-12-16 14:49:43 +09:00
Yukihiro "Matz" Matsumoto
d18c55fca7
mrb_str_len_to_inum(): fixed a bug with underscores in digits; fix #3049
2015-12-16 14:49:08 +09:00
Yukihiro "Matz" Matsumoto
2a234a93d7
mrb_str_len_to_inum(): string may not be NUL terminated; ref #3043
2015-12-14 10:59:56 +09:00
Yukihiro "Matz" Matsumoto
19c744e14d
mrb_str_len_to_inum(): fixed a bug with separating _ in the digits; ref #3043
2015-12-14 10:59:56 +09:00
Yukihiro "Matz" Matsumoto
26a25e1666
mrb_str_len_to_inum: should not raise "string contains null byte" error on "0x"; fix #3043
2015-12-12 16:33:48 +09:00
Yukihiro "Matz" Matsumoto
ad333cd191
mrb_str_len_to_inum: converting may not be terminated by NUL; fix #3044
2015-12-12 16:33:48 +09:00
Yukihiro "Matz" Matsumoto
9a21aa2d3c
preserve original string for error message
2015-12-01 21:42:07 +09:00
Yukihiro "Matz" Matsumoto
ca417dac26
mrb_str_len_to_inum(): inspect string in error message
2015-12-01 21:41:53 +09:00
Yukihiro "Matz" Matsumoto
36fabe104b
new API function mrb_string_value_len()
2015-12-01 16:18:01 +09:00
Yukihiro "Matz" Matsumoto
0701236dac
mrb_str_to_inum(): should treat null byte in strings properly; fix #3040
2015-12-01 16:11:47 +09:00
Yukihiro "Matz" Matsumoto
d3a56a6949
mrb_cstr_to_inum(): should ignore trailing white spaces even when badcheck set
2015-12-01 11:14:22 +09:00
Yukihiro "Matz" Matsumoto
dbb8cf637e
mrb_str_to_inum(): should raise error when string contains null byte
2015-12-01 11:13:32 +09:00
Yukihiro "Matz" Matsumoto
9f2fca6ebe
mrb_str_to_inum(): no need to call mrb_string_value_cstr() here; ref 05411ee
2015-12-01 10:54:00 +09:00
Yukihiro "Matz" Matsumoto
05411ee15e
mrb_string_value_cstr() should not raise error for frozen strings
...
cf. http://qiita.com/tsahara@github/items/b2a442af95ac893e10a1 (Japanese).
2015-12-01 10:45:43 +09:00
Yukihiro "Matz" Matsumoto
5c405dea3d
include changed from by quotes ("") to by brackets (<>); close #3032
2015-11-27 17:48:23 +09:00
Seba Gamboa
e871b77f41
Increasing docs coverage
2015-10-20 12:16:46 -03:00
Yasuhiro Matsumoto
d5f145076c
chop with utf-8. fix #2967
2015-09-29 21:22:45 +09:00
takahashim
074c6e2678
fix String#inspect with MRB_UTF8_STRING
...
cf. #2963
2015-09-27 13:43:45 +09:00
Yukihiro "Matz" Matsumoto
524a038876
inspect prints valid UTF-8 character without escaping
2015-09-25 23:09:46 +09:00
Yukihiro "Matz" Matsumoto
c069e5ff40
add boundary check to utf8len() to avoid oob memory access
2015-09-25 23:08:37 +09:00
Yukihiro "Matz" Matsumoto
798ec3aff4
UTF-8 string support in core
...
define MRB_UTF8_STRING (in mrbconf.h) to enable UTF-8 support.
2015-09-24 02:37:33 +09:00
Yukihiro "Matz" Matsumoto
6a06a3e48d
String#rindex should no longer take integer argument
2015-09-23 01:06:26 +09:00
Yukihiro "Matz" Matsumoto
2cb6c27781
String#index should no longer take integer argument
2015-09-22 19:10:48 +09:00
Jun Hiroe
ce6297aa04
Fix indents
2015-09-19 06:38:28 +09:00
Yasuhiro Matsumoto
8277e950ee
Support windows locale
...
Add mrb_utf8_from_locale, mrb_utf8_free, mrb_locale_from_utf8, mrb_locale_free. Just works for windows.
2015-09-11 11:12:03 +09:00
Yukihiro "Matz" Matsumoto
e35c3aff83
unsigned long may be smaller than mrb_int; use uint64_t instead; fix #2935
2015-09-03 00:14:37 +09:00
Yukihiro "Matz" Matsumoto
14f0e4a4e4
update string.h.md; ref #2931
2015-09-02 15:09:50 +09:00
Yukihiro "Matz" Matsumoto
1a45447b8b
add String#freeze to the core
2015-08-27 17:54:30 +09:00