Yukihiro "Matz" Matsumoto
e39e4ea26d
string.c (chars2bytes): small refactoring
2024-01-10 11:09:47 +09:00
Yukihiro "Matz" Matsumoto
1d243bc58b
string.c (bytes2chars): takes a string object instead of char*
2024-01-10 10:53:26 +09:00
Yukihiro "Matz" Matsumoto
59a1d74937
string.c: inline str_range_to_bytes
2024-01-09 18:22:38 +09:00
Yukihiro "Matz" Matsumoto
9135f0991b
string.c: avoid RSTRING_CHAR_LEN() if possible
...
Current code scan the string twice (once from RSTRING_CHAR_LEN, and once
from chars2bytes), but those scans are not necessary. Just point the end
of the string.
2024-01-09 11:44:12 +09:00
Yukihiro "Matz" Matsumoto
f3ebef1172
mruby-string (chars2bytes): reduce the scope of local variables
2024-01-09 11:00:44 +09:00
Yukihiro "Matz" Matsumoto
f1d01a6107
string.c (mrb_utf8len): should return 1 for invalid chars; ref #6143
2024-01-09 10:39:03 +09:00
Yukihiro "Matz" Matsumoto
64a4bf0e28
string.c: avoid infinite loop; fix #6143
...
`mrb_utf8len` returns 0 for invalid characters.
2024-01-09 10:37:52 +09:00
Yukihiro "Matz" Matsumoto
a5e83075d4
string.c: reduce the scope of a local variable
2024-01-09 08:22:26 +09:00
Yukihiro "Matz" Matsumoto
c080d16150
string.c: use presym to define String class
2023-11-01 22:23:35 +09:00
Yukihiro "Matz" Matsumoto
7a08c7042f
string.c: move __ENCODING__ from kernel.c
2023-10-25 15:05:10 +09:00
Yukihiro "Matz" Matsumoto
0443f14fd0
array.c,hash.c,numeric.c,string.c: use mrb_define_method_id()
...
For primary class libraries.
2023-10-23 15:23:08 +09:00
John Bampton
24ac7a547a
Fix spelling
2023-10-04 01:17:23 +10:00
Yukihiro "Matz" Matsumoto
0e98508c33
string.c (mrb_string_value_cstr): RSTR_PTR(s) may be NULL; fix #6067
2023-09-28 09:26:02 +09:00
Yukihiro "Matz" Matsumoto
4c7fab6126
string.c (check_null_byte): str may point NULL buffer; ref #6067
2023-09-28 09:24:30 +09:00
Yukihiro "Matz" Matsumoto
2e3b482aa9
array.c, string.c: remove length limits on UNIX-ish OSes
...
- Linux
- MacOS
- FreeBSD
- OpenBSD
Send us a pull-request if you want to add your favorite OS here.
The size limitation will be done by malloc(3) on those OSes.
2023-09-23 19:57:44 +09:00
Yukihiro "Matz" Matsumoto
d6d434eb3f
Inline loop variables everywhere
2023-07-13 08:05:00 +09:00
Yukihiro "Matz" Matsumoto
e84060a900
string.c: rename function str_check_too_big -> str_check_length
2023-05-30 08:40:16 +09:00
Yukihiro "Matz" Matsumoto
f813b5d1d8
string.c (str_new): add string length check
2023-05-29 23:18:44 +09:00
Yukihiro "Matz" Matsumoto
aecaaf011f
string.c (mrb_str_resize): refactor string length check
2023-05-29 23:18:19 +09:00
Yukihiro "Matz" Matsumoto
2f7f797473
remove extra spaces before ;
2023-05-22 12:05:35 +09:00
Yukihiro "Matz" Matsumoto
eea72ec84a
fix spaces in the type cast expressions (cosmetic changes)
2023-05-18 23:29:16 +09:00
dearblue
8665f88791
Allow an empty string for String#bytesplice
2023-04-15 21:26:01 +09:00
dearblue
59931e95c4
Prohibit string lengths less than 0 in String#bytesplice
2023-04-15 21:26:00 +09:00
dearblue
5bc3a48ecb
Handling negative indices in String#bytesplice
2023-04-15 21:25:59 +09:00
dearblue
dcced0016c
Countermeasure to overflow for String#bytesplice
2023-04-15 21:25:58 +09:00
dearblue
73b6c6619c
Need type check for replace by String#bytesplice
2023-04-15 21:25:57 +09:00
dearblue
2e9ac8f448
Returns self for String#bytesplice
2023-04-15 21:25:56 +09:00
Yukihiro "Matz" Matsumoto
64536b866b
string.c (str_escape): simplify the logic
2023-04-07 13:53:19 +09:00
Yukihiro "Matz" Matsumoto
d41ea96c2a
string.c: fix boundary check in String#bytesplice
...
It should be able to append to the receiver.
2023-01-29 17:10:15 +09:00
Yukihiro "Matz" Matsumoto
a2e2e83012
string.c: move String#bytesplice to the core
2023-01-28 16:43:40 +09:00
Yukihiro "Matz" Matsumoto
4462e3d8b3
string.c: add assertion for positive length
2023-01-08 16:36:20 +09:00
Yukihiro "Matz" Matsumoto
9c5dc42e59
small cosmetic changes.
...
I prefer `i++` style unless absolutely necessary.
This commit is an addition to 41e4148.
2022-11-19 17:11:56 +09:00
Yukihiro "Matz" Matsumoto
4a888a34bb
readfloat.c (mrb_read_float): a new function.
...
We no longer use `mrb_float_read()` that depends on `errno`.
2022-11-07 16:09:31 +09:00
dearblue
97c075ad68
Reduce memory copy in mrb_str_inspect() with UTF-8
2022-11-04 22:13:07 +09:00
Yukihiro "Matz" Matsumoto
61f447e5df
string.c (mrb_byte_hash): separate byte hashing functions.
2022-08-06 06:43:41 +09:00
Yukihiro "Matz" Matsumoto
c4cb416460
string.c: new configuration MRB_STR_LENGTH_MAX.
...
The default value is 1MB. If you want to avoid the limitation, set this
value to 0.
2022-07-25 10:58:02 +09:00
Yukihiro "Matz" Matsumoto
03ae46e88d
string.c: keep values in local variables to reduce member access.
2022-06-30 10:12:24 +09:00
Yukihiro "Matz" Matsumoto
0b7822581f
string.c (str_rindex): use more local variables; ref #5734
2022-06-27 19:04:36 +09:00
Stephen Jothen
103f8bcad0
Fix out of bounds access by memcmp in String#rindex
2022-06-25 15:09:35 +02:00
Yukihiro "Matz" Matsumoto
82b87be4df
string.c (mrb_utf8len): retry 7cdef2b0.
...
C++ requires `extern` declaration before variable definition.
2022-05-29 22:18:59 +09:00
Yukihiro "Matz" Matsumoto
82f0ba14a9
Revert "string.c: share UTF-8 length table with mruby-string-ext."
...
This reverts commit 7cdef2b03e .
This sharing does not with C++ compilers.
2022-05-25 16:07:52 +09:00
Yukihiro "Matz" Matsumoto
7cdef2b03e
string.c: share UTF-8 length table with mruby-string-ext.
2022-05-25 11:25:43 +09:00
Yukihiro "Matz" Matsumoto
bb99d7b2ca
string.c (mrb_utf8len): reduce UTF-8 table size.
2022-05-25 08:04:19 +09:00
Yukihiro "Matz" Matsumoto
d7731a95ab
string.c (mrb_str_rindex_m): avoid RSTRING_CHAR_LEN() if possible.
...
Since it scans the string. Use char_backtrack() instead for negative
offset (counting from the tail).
2022-05-24 08:47:07 +09:00
Yukihiro "Matz" Matsumoto
9475521fa3
string.c (char_adjust): simplify and unroll function.
2022-05-23 23:12:40 +09:00
Yukihiro "Matz" Matsumoto
4769ace7e1
string.c (char_backtrack): simplify the code using utf8_islead().
2022-05-23 23:12:40 +09:00
Yukihiro "Matz" Matsumoto
916fd642fa
string.c (mrb_utf8len): unroll a for loop.
2022-05-21 16:14:16 +09:00
Yukihiro "Matz" Matsumoto
54bbc062fb
string.c (index,rindex) use single byte version for ASCII strings.
2022-05-21 08:51:11 +09:00
Yukihiro "Matz" Matsumoto
038aa6beb2
strinc.rb (sub, gsub): use byte index instead of char index.
2022-05-19 10:14:59 +09:00
Yukihiro "Matz" Matsumoto
c2648ad95d
string.c: add byteindex and byterindex methods.
2022-05-16 16:00:00 +09:00