Commit graph

60 commits

Author SHA1 Message Date
nagachika
087e4ed6cc merge revision(s) 35e124832e: [Backport #20755]
[Bug #20755] Frozen string should not be writable via IO::Buffer
2024-10-18 13:57:08 +09:00
nagachika
5777fe5ab5 merge revision(s) 637067440f: [Backport #20752]
[Bug #20752] Slice of readonly `IO::Buffer` also should be readonly
2024-10-18 11:30:05 +09:00
Samuel Williams
bc482e632c Fix size calcuation when offset is given + updated documentation. 2024-10-04 10:09:39 +09:00
Samuel Williams
0e664ebcd3 Fix io_buffer_get_string default length computation. (#8427)
* Fix `io_buffer_get_string` default length computation.

When an offset bigger than the size is given, the resulting length will be
computed incorrectly. Raise an argument error in this case.

* Validate all arguments.
2024-05-18 20:09:56 +09:00
Samuel Williams
67d499a764 Improvements to IO::Buffer read/write/pread/pwrite. (#7826)
- Fix IO::Buffer `read`/`write` to use a minimum length.
2024-05-18 20:09:56 +09:00
Samuel Williams
359e40e3c9 Rename data -> buffer for better readability. (#7836) 2024-05-18 20:09:56 +09:00
Nobuyoshi Nakada
1bfdd68b69 Adjust else style to be consistent in each files [ci skip] 2024-05-18 20:09:56 +09:00
nagachika
8bbf909bb5 merge revision(s) 19346c2336: [Backport #19754]
[Bug #19754] Make `IO::Buffer#get_string` check `offset` range
	 (#8016)

	---
	 io_buffer.c                 | 3 +++
	 test/ruby/test_io_buffer.rb | 8 ++++++++
	 2 files changed, 11 insertions(+)
2023-10-28 11:57:52 +09:00
nagachika
c911cbd6c3 merge revision(s) bd786e7896: [Backport #19084]
Fix mutation on shared strings. (#7837)

	---
	 io_buffer.c                 | 19 ++++++++++++-------
	 test/ruby/test_io_buffer.rb |  4 ----
	 2 files changed, 12 insertions(+), 11 deletions(-)
2023-07-16 16:50:13 +09:00
nagachika
5ad2390b55 merge revision(s) 466aa8010f: [Backport #19546]
Fix incorrect usage of `rb_fiber_scheduler_io_(p)(read|write)`.
	 (#7593)

	---
	 io_buffer.c                  |  8 ++++----
	 scheduler.c                  | 48 ++++++++++++++++++++++----------------------
	 test/fiber/test_io_buffer.rb | 33 ++++++++++++++++++++++++++++++
	 3 files changed, 61 insertions(+), 28 deletions(-)
2023-07-16 16:44:22 +09:00
nagachika
c13757ed9a merge revision(s) 09295ea796: [Backport #19543]
IO::Buffer#resize: Free internal buffer if new size is zero (#7569)

	`#resize(0)` on an IO::Buffer with internal buffer allocated will
	result in calling `realloc(data->base, 0)`. The behavior of `realloc`
	with size = 0 is implementation-defined (glibc frees the object
	and returns NULL, while BSDs return an inaccessible object). And
	thus such usage is deprecated in standard C (upcoming C23 will make it
	UB).

	To avoid this problem, just `free`s the memory when the new size is zero.
	---
	 io_buffer.c                 |  5 +++++
	 test/ruby/test_io_buffer.rb | 18 ++++++++++++++++++
	 2 files changed, 23 insertions(+)
2023-07-16 16:42:12 +09:00
NARUSE, Yui
db28f7003f merge revision(s) 3b567eb491: [Backport #19459]
[Bug #19459] Remove unnecessary always-true checks (#7362)

	`length` is a required argument for `IO::Buffer#read` and
	`IO::Buffer#write` methods, and `argc` is already checked with
	`rb_check_arity`.  Also fix the call-seq of `IO::Buffer#read`.
	---
	 io_buffer.c | 24 +++++++-----------------
	 1 file changed, 7 insertions(+), 17 deletions(-)
2023-03-09 09:35:39 +09:00
Victor Shepelev
c3c116f6a6
[DOC] Document new methods of IO::Buffer and Fiber::Scheduler (#7016)
Co-authored-by: Samuel Williams <samuel.williams@oriontransfer.co.nz>
2022-12-24 11:48:58 +13:00
Samuel Williams
11ad9a42d7
Fix missing handling of offset argument in IO::Buffer pread and pwrite. (#7012) 2022-12-24 07:52:10 +13:00
Nobuyoshi Nakada
f28e79caaa
Use consistent style [ci skip] 2022-12-02 23:46:21 +09:00
Yudai Takada
29e6d97517
Fix typos (#6775)
* s/Innteger/Integer/

* s/diretory/directory/

* s/Bufer/Buffer/

* s/defalt/default/

* s/covearge/coverage/
2022-11-20 21:07:18 -08:00
S-H-GAMELINKS
1f4f6c9832 Using UNDEF_P macro 2022-11-16 18:58:33 +09:00
Yusuke Nakamura
5344618cb7 [DOC] Fix IO::Buffer#slice rdoc position
Before this change, rdoc shows empty in 'slice' method section
2022-11-03 14:40:17 -04:00
Nobuyoshi Nakada
287eac5e8e Fix format specifiers for size_t 2022-10-26 18:57:26 +09:00
Samuel Williams
fc3137ef54
Add support for anonymous shared IO buffers. (#6580) 2022-10-19 18:53:38 +13:00
Samuel Williams
ced1d17280
Improvements to IO::Buffer implementation and documentation. (#6525) 2022-10-12 12:59:05 +13:00
Samuel Williams
411d0eec11
Update IO::Buffer read/write to use rb_thread_io_blocking_region. (#6438) 2022-09-26 19:37:28 +13:00
Samuel Williams
025b8701c0
Add several new methods for getting and setting buffer contents. (#6434) 2022-09-26 18:06:12 +13:00
Nobuyoshi Nakada
e2ccb316b4 [Bug #5317] Use rb_off_t instead of off_t
Get rid of the conflict with system-provided small `off_t`.
2022-09-08 23:01:07 +09:00
Nobuyoshi Nakada
f42230ff22
Adjust styles [ci skip] 2022-07-27 18:42:27 +09:00
Nobuyoshi Nakada
8b9d4b2ce6
Append semicolons [ci skip] 2022-07-27 18:25:29 +09:00
Nobuyoshi Nakada
852ac26e83
Make indents and newlines consistent [ci skip] 2022-07-27 17:45:21 +09:00
Shannon Skipper
2b4a1ad584 Fix a variable name typo in the docs 2022-06-25 11:29:08 +12:00
Nobuyoshi Nakada
b180ffa622
Fix warnings by old gcc
* Use PRIxSIZE instead of "z"
* Fix sign-compare warning
* Suppress unused-but-set-variable warning
2022-06-23 22:52:45 +09:00
Samuel Williams
cea34bd808
Add basic binary operators (and, or, xor, not) to IO::Buffer. (#5893) 2022-05-09 17:19:01 +12:00
Kazuhiro NISHIYAMA
dc9a13abee
Fix rdoc of IO::Buffer [ci skip] 2022-05-09 09:09:29 +09:00
Samuel Williams
ef525b012a
Explicit handling of frozen strings in IO::Buffer#for. (#5892) 2022-05-09 11:03:04 +12:00
Yuta Saito
ae51f304d2 io_buffer.c: use mremap based resizing only when mremap available
some libc implementations (e.g. wasi-libc) define MREMAP_MAYMOVE, but
don't have mremap itself, so guard the use of mremap by HAVE_MREMAP
2022-01-07 02:13:19 +09:00
Samuel Williams
03d97cc966
Remove UTF-8 from documentation. 2022-01-02 21:47:50 +13:00
Victor Shepelev
e7c2d5cc02
[DOC] Adjust IO::Buffer docs (#5374) 2022-01-02 21:43:01 +13:00
Kazuhiro NISHIYAMA
04f07713d1
Fix typos [ci skip] 2021-12-25 10:33:49 +09:00
Samuel Williams
bed920f073
Add fiber scheduler hooks for pread/pwrite, and add support to IO::Buffer. 2021-12-23 12:20:09 +13:00
Samuel Williams
e30920354f
Extended interface for IO::Buffer & documentation. 2021-12-22 10:57:34 +13:00
Samuel Williams
617687df09 Rename IMMUTABLE to READONLY. 2021-12-21 12:25:42 +13:00
Samuel Williams
9fbf94ff04 Improve interface for get/set/copy. 2021-12-21 12:25:42 +13:00
Samuel Williams
2de5dc539b Fix handling of clear with offset and without length. 2021-12-21 12:25:42 +13:00
Samuel Williams
c86bcd434d Mark non-private mapped files as external. 2021-12-21 12:25:42 +13:00
Samuel Williams
da46b8d8e5 Default IO::Buffer#get_string to use BINARY encoding. 2021-12-21 12:25:42 +13:00
Samuel Williams
71bbc40ffa Rename to_str -> get_string and add support for encodings. 2021-12-21 12:25:42 +13:00
Samuel Williams
49166fc74a Improved exception usage/classes. 2021-12-21 12:25:42 +13:00
Samuel Williams
71bf5cef75 Fix handling of frozens strings. 2021-12-21 12:25:42 +13:00
Samuel Williams
9de5c4ec76 Fix mapping invalid non-file object. 2021-12-21 12:25:42 +13:00
Samuel Williams
56811617ab Improve IO::Buffer resize and introduce ownership transfer. 2021-12-20 00:17:17 +13:00
Samuel Williams
f3e30b26c5 Default size for IO::Buffer. 2021-12-19 12:25:38 +13:00
Samuel Williams
235f523a88 Fix spelling of DECLAIR_TYPE. 2021-12-19 00:19:55 +13:00