KOBAYASHI Shuji
cd4daf78ec
Use FrozenError instead of RuntimeError in String#rstrip!
2019-03-15 22:49:40 +09:00
KOBAYASHI Shuji
e3b339bec6
Fix missing assertions in mruby-string-ext test
2019-03-12 21:47:33 +09:00
Yukihiro "Matz" Matsumoto
b5d43a16a3
Removed String#try_convert method from mruby-string-ext gem.
...
Because `try_convert` method rarely used in production. For mruby users,
we have `__to_str` utility method to check string type.
2018-11-19 12:08:28 +09:00
Yukihiro "Matz" Matsumoto
ff08856fe3
Remove implicit conversion using to_str method; fix #3854
...
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-19 12:05:46 +09:00
Yukihiro "Matz" Matsumoto
afca99a40b
Remove implicit conversion using to_int method.
...
The ISO standard does not include implicit type conversion using
`to_int`. This implicit conversion often causes vulnerability.
There will be no more attacks like #4120 .
In addition, we have added internal convenience method `__to_int` which
does type check and conversion (from floats).
2018-11-19 11:28:51 +09:00
Yukihiro "Matz" Matsumoto
485955eccc
String#{squeeze,delete,count} to use bitmap for matching; ref #4163
2018-11-15 04:51:27 +09:00
Yukihiro "Matz" Matsumoto
4550f4e381
Pattern length may overflow uint16_t; fixed #4163
...
The issue is reported by `https://hackerone.com/dgaletic `.
2018-11-15 02:03:54 +09:00
Yukihiro "Matz" Matsumoto
f2084f300b
Add tests for empty patterns for tr and count; #4156 #4157
2018-11-02 08:58:21 +09:00
Yukihiro "Matz" Matsumoto
8e59695625
Empty pattern string for String#tr should remove characters; fix #4157
2018-11-02 08:55:17 +09:00
Yukihiro "Matz" Matsumoto
65b04066a2
Empty pattern string can generate TR_UNINITIALIZED pattern; fix #4156
2018-11-02 08:54:24 +09:00
Yukihiro "Matz" Matsumoto
7ad53273a2
Silence Appveyor's VC compilation warnings.
2018-11-01 22:52:12 +09:00
Yukihiro "Matz" Matsumoto
cca5e0977c
VS 2017 C does not understand inline struct initialization; ref #4153
2018-10-30 09:01:12 +09:00
take-cheeze
52d55e6069
Keep tr_pattern static
2018-10-29 13:21:36 +09:00
Yukihiro "Matz" Matsumoto
e6841abad6
Fixed a String#squeeze bug in handling iso-8859-1 strings; ref #4127
2018-09-27 21:43:35 +09:00
Yukihiro "Matz" Matsumoto
01c2f59e14
Revert "Fix comparisons in str_squeeze."
...
This reverts commit 7b04fcd092 .
The issue was addressed by 9e3cbaa . No longer needed.
2018-09-26 12:35:25 +09:00
Yukihiro "Matz" Matsumoto
9e3cbaaacd
Avoid using memmove() for performance; fix #4130
2018-09-26 12:20:37 +09:00
Yukihiro "Matz" Matsumoto
fb49a94314
Rename tr_pattern_free() to tr_free_pattern().
2018-09-26 12:17:38 +09:00
Takeshi Watanabe
67897195de
Fix leak in mrb_str_count
2018-09-25 11:48:59 +09:00
Clayton Smith
7b04fcd092
Fix comparisons in str_squeeze.
2018-09-24 18:16:12 -04:00
Yukihiro "Matz" Matsumoto
346f154ece
Implement String#delete and #delete!; ref #4086
...
mruby restriction:
In mruby, `String#delete` only takes single pattern argument.
2018-09-21 00:03:07 +09:00
Yukihiro "Matz" Matsumoto
58f7f2361a
Implement String#count; ref #4086
...
mruby restriction:
In mruby, `String#count` does not take multiple pattern arguments,
but only one pattern.
2018-09-21 00:03:07 +09:00
Yukihiro "Matz" Matsumoto
68523b4ec4
Add String#squeeze and #squeeze!; ref #4086
...
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-21 00:03:07 +09:00
Yukihiro "Matz" Matsumoto
c0ae8a96a1
Add String#tr_s and String#tr_s!; ref #4086
2018-09-21 00:03:07 +09:00
Yukihiro "Matz" Matsumoto
58ba38fe1e
Add String#tr and #tr! to mruby-string-ext gem; fix #4086
...
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-09-21 00:03:07 +09:00
Yukihiro "Matz" Matsumoto
891839b976
New bytecode implementation of mruby VM.
2018-07-30 22:57:54 +09:00
Yukihiro "Matz" Matsumoto
2213deeeaa
Implement String#upto in Ruby.
...
Avoid using `mrb_yield` in C code. The function is not recommended.
Because it doesn't work well with fibers.
2018-04-21 22:30:54 +09:00
Yukihiro "Matz" Matsumoto
8b92ab5c7b
CRuby2.6 stops deprecating String#lines with a block.
...
`String#lines` (with a block) is now implemented in Ruby.
2018-04-19 17:33:00 +09:00
Yukihiro "Matz" Matsumoto
c79e81ebc3
String#lines with a block is deprecated style.
2018-04-19 09:07:11 +09:00
Yukihiro "Matz" Matsumoto
bbb0882343
Modifying frozen objects will raise FrozenError.
...
`FrozenError` is a subclass of `RuntimeError` which used to be
raised. [Ruby2.5]
2017-12-12 18:41:18 +09:00
Yukihiro "Matz" Matsumoto
f1207573bd
Uninitialized value returned.
2017-12-08 09:50:02 +09:00
YAMAMOTO Masaya
625f9f6fa3
Merge branch 'master' of github.com:mruby/mruby
2017-11-04 01:23:12 +09:00
Yukihiro "Matz" Matsumoto
3c20c96f84
Use a new function: mrb_get_argc(); ref #3826
2017-10-17 15:23:32 +09:00
Yukihiro "Matz" Matsumoto
4122c320bb
Add {String,Symbol}#casecmp?; CRuby2.4
2017-10-17 13:26:37 +09:00
Yukihiro "Matz" Matsumoto
332d8d2a1c
Add String#delete_{prefix,suffix}; CRuby2.5
2017-10-17 11:19:12 +09:00
YAMAMOTO Masaya
9c1f21aaa1
Support MRB_WIHTOUT_FLOAT to mruby-string-ext
2017-10-16 18:09:56 +09:00
Tomasz Dąbrowski
2640896911
fix: mrbgems\mruby-string-ext\src\string.c(49): warning C4244: '=': conversion from 'mrb_int' to 'int', possible loss of data
2017-09-27 22:22:04 +02:00
Tomasz Dąbrowski
8d816fa142
fix: mrbgems\mruby-string-ext\src\string.c(30): warning C4244: '=': conversion from 'mrb_int' to 'long', possible loss of data
2017-09-27 22:22:04 +02:00
Tomasz Dąbrowski
d3819620ce
fix: mrbgems\mruby-string-ext\src\string.c(38): warning C4244: '=': conversion from 'mrb_int' to 'char', possible loss of data
2017-09-27 22:22:04 +02:00
Yukihiro "Matz" Matsumoto
198c898817
Rename mrb_str_concat2 to mrb_str_concat_m.
...
According to the naming convention a function that implements
a method should be suffixed by `_m`.
2017-08-18 22:17:47 +09:00
Yukihiro "Matz" Matsumoto
615e7e44e3
Avoid using snprintf(3) in case MRB_DISABLE_STDIO; fix #3714
2017-06-20 09:39:33 +09:00
Asmod4n
abca63c73b
Save gc_arena after buffer got allocated
...
Latest fix was freeing the buffer while it was still in use.
Fixes #3712
2017-06-19 20:27:38 +02:00
Yukihiro "Matz" Matsumoto
0411cea2df
Use MRB_PRId instead of d for mrb_int decimal specifier; ref #3701
2017-06-16 11:50:38 +09:00
Yukihiro "Matz" Matsumoto
e96f254ead
Use mrb_str_new() instead of malloc(); ref #3701
...
Otherwise the function may terminate and cause memory leaks.
2017-06-16 11:46:40 +09:00
Yukihiro "Matz" Matsumoto
473b2bb20d
Should not use sizeof(buf) when buf is char*; #3701
2017-06-16 11:42:51 +09:00
ksss
4d9ca27ba6
Use malloc instead of dynamic allocation
2017-06-14 18:28:39 +09:00
ksss
432a813905
Fix arena overflow error
2017-06-14 18:12:56 +09:00
ksss
19785f43d1
Reimplement String#upto
2017-06-14 17:30:31 +09:00
ksss
98f9c33fe0
String#concat: Try to convert when not string
2017-05-21 10:30:27 +09:00
Yukihiro "Matz" Matsumoto
3e07a2d77c
Silence warnings caused by implicit type casting.
2017-04-25 21:00:16 +09:00
Yukihiro "Matz" Matsumoto
77331d127b
Unify else clause style
2017-04-03 16:56:27 +09:00