Yukihiro "Matz" Matsumoto
169114666a
mruby-io: fix Win32 declaration bugs
2024-05-14 01:34:43 +09:00
Yukihiro "Matz" Matsumoto
37e7c071c2
mruby-io: adjust local variable declarations
2024-05-14 01:22:04 +09:00
Yukihiro "Matz" Matsumoto
492d8331e1
mruby-io/ext/io.h: reorder struct mrb_io to reduce the size; #6231
...
The `sizeof(struct mrb_io)` is reduced from 32 bytes to 24 bytes on
x86_64-linux.
2024-04-10 13:35:03 +09:00
Asmod4n
96b5cd757d
Add a way to let other gems handle closing of FDs
2024-04-07 13:46:11 +02:00
Yukihiro "Matz" Matsumoto
87b358a342
Including header files in include/* by <>
2024-03-26 13:59:59 +09:00
dearblue
5caf8e14cf
Retrieving the IO exception class with presym
2024-01-20 22:33:43 +09:00
Yukihiro "Matz" Matsumoto
b06fdb4bfa
mruby-io/file.c: reduce the scope of local variables
2024-01-06 08:30:56 +09:00
Yukihiro "Matz" Matsumoto
e1b6501183
mruby-io: fix local variable initialization redundancy
2024-01-05 13:03:33 +09:00
Yukihiro "Matz" Matsumoto
f1b8d38eb5
mruby-io: narrow a local variable scope
2024-01-05 13:02:39 +09:00
Yukihiro "Matz" Matsumoto
20dd737a4a
mruby-io (io_s_popen): remove fflush(stdin)
...
Flushing input I/O should be useless.
2024-01-05 13:00:55 +09:00
John Bampton
19d0ea803d
Fix pre-commit failure from prettier
2023-12-31 21:57:58 +10:00
Yukihiro "Matz" Matsumoto
72ca266ed7
mruby-io: rename some functions with io_buf prefix
...
Now all functions with `io_buf` takes `mrb_io_buf` as an argument.
Renamed functions (old names):
- io_init_buf (io_buf_init)
- io_fill_buf (io_buf_fill)
- io_fill_buf_comp (io_buf_fill_comp) for UTF-8 encoding
2023-12-20 08:59:46 +09:00
Yukihiro "Matz" Matsumoto
84fb9f40f0
mruby-io: some functions take mrb_io_buf as an argument
...
- io_buf_reset
- io_buf_shift
- io_buf_cat
- io_buf_cat_all
2023-12-20 08:59:46 +09:00
Yukihiro "Matz" Matsumoto
054f5b5284
mruby-io (io_eof): avoid unnecessary read(2) call
2023-12-20 08:59:46 +09:00
Yukihiro "Matz" Matsumoto
2e8bede6ea
mruby-io (io_read): small refactoring; ref #6118
...
If `outbuf` is `nil` we allocate a buffer string, if `outbuf` is a
string, we resize it to zero length. In the function `io_read`, this
condition is done twice, so we refactor out to `io_reset_outbuf()`.
2023-12-20 08:59:46 +09:00
Yukihiro "Matz" Matsumoto
2e24c94873
Merge pull request #6120 from dearblue/file-EBADF
...
Set `EBADF` if `check_file_descriptor()` fails
2023-12-20 08:59:29 +09:00
dearblue
5e3e75ed7b
Set EBADF if check_file_descriptor() fails
2023-12-17 10:50:59 +09:00
dearblue
7611dc8338
Fixed IO#read with buf.
...
I hit the following two problems.
- `io.read(0, buf)` always returned a new empty string object.
- `io.read(num, buf)` was appending data to the given `buf`.
This also meant that `buf` was never empty if EOF was reached.
2023-12-16 14:42:52 +09:00
Yukihiro "Matz" Matsumoto
956379928c
mruby-io/io.c: fix possible short integer overflow
2023-11-19 07:47:23 +09:00
Yukihiro "Matz" Matsumoto
698da0982f
mruby-io/io.c: fix fsize_t and mrb_ssize mixture
2023-11-19 07:45:29 +09:00
dearblue
88bc8c9144
Add "x" mode option for IO.open
...
From CRuby 2.6 feature.
This is the "x" mode (`O_EXCL`; exclusive create) of `fopen(3)` introduced in C11.
ref. https://bugs.ruby-lang.org/issues/11258
2023-10-15 16:41:48 +09:00
dearblue
782fd7e014
Integrate error handling for IO.open
2023-10-15 16:32:01 +09:00
Ray Chason
23e9befbc0
Changes to cross-compile with DJGPP
2023-06-17 17:20:33 -04:00
Yukihiro "Matz" Matsumoto
53de96426a
mruby-io/io.c (io_init): File.new should not take blocks
2023-05-23 15:34:37 +09:00
Yukihiro "Matz" Matsumoto
67187881c2
mruby-io/io.c (io_init_copy): copy flags before io_buf_init()
2023-05-23 15:17:13 +09:00
Yukihiro "Matz" Matsumoto
c32f7915fb
reformat else clause indentation style
2023-05-20 00:21:01 +09:00
Yukihiro "Matz" Matsumoto
eea72ec84a
fix spaces in the type cast expressions (cosmetic changes)
2023-05-18 23:29:16 +09:00
masahino
ad318e55c0
fix typo MRB_NO_IO_POEPN -> MRB_NO_IO_POPEN
2023-05-02 07:34:30 +09:00
Yukihiro "Matz" Matsumoto
68d67aee0e
mruby-io/io.c: need to adjust buffer limit before searching; fix #5991
2023-04-26 09:09:05 +09:00
Yukihiro "Matz" Matsumoto
01e5f2a3c8
mruby-io/io.c: fix indent
2023-04-25 23:27:59 +09:00
Yukihiro "Matz" Matsumoto
2f0265d078
mruby-io/io.c (check_file_descriptor): stop "unused label" warning
2023-03-10 08:52:05 +09:00
Yukihiro "Matz" Matsumoto
9a3199cadd
mruby-io/file.c: atime, ctime, mtime to return Bigint if possible
2023-03-10 08:52:05 +09:00
Yukihiro "Matz" Matsumoto
011edf6e99
mruby-io/file.c: hide internal methods in backtraces
2023-03-03 14:23:10 +09:00
Yukihiro "Matz" Matsumoto
5237b2cccc
mruby-io/file.c: atime, ctime, mtime check mrb_int overflow
...
When `sizeof(time_t)` is different from `mrb_int`, overflow may happen.
2023-03-03 14:21:05 +09:00
Yukihiro "Matz" Matsumoto
0e51da81bb
mruby-io/file.rb (inspect): include path in the #inspect output
2023-03-03 13:33:30 +09:00
Yukihiro "Matz" Matsumoto
a956ef35a4
mruby-io/file.c: atime, ctime, mtime should raise error
...
For fstat(3) failure.
2023-03-03 13:33:29 +09:00
Yukihiro "Matz" Matsumoto
9c6848a594
mruby-io/io.c (check_file_descriptor): only check EBADF
2023-03-03 13:33:29 +09:00
Yukihiro "Matz" Matsumoto
0529f5fc31
mruby-io/test/file.rb: add tests for File#atime, File#ctime
2023-03-03 13:33:29 +09:00
Yukihiro "Matz" Matsumoto
321cfe9760
mruby-io/file.c: add File#atime and File#ctime
2023-03-03 13:33:29 +09:00
Yukihiro "Matz" Matsumoto
31c1b7bc78
mruby-file: File#mtime has been available for long time
2023-03-03 13:33:29 +09:00
Yukihiro "Matz" Matsumoto
84a4d340a6
mruby-io/file.c (_mtime): return nil instead of false
...
As a Ruby convention, a method should return nil (not false) for the
exceptional value, e.g. String#index. File#_mtime should follow the
convention too.
2023-03-03 13:33:29 +09:00
Yukihiro "Matz" Matsumoto
d86c4a795d
mruby-io does not provide to_path method for implicit conversion
...
mruby does not use implicit type conversion by `to_xxx` (e.g. to_int,
to_str, etc.)
2023-03-03 13:33:29 +09:00
Yukihiro "Matz" Matsumoto
aefc5befbd
mruby-io/io.c: fix issues with gets; fix #5913
...
- gets with RS multiple times
- gets with RS with limit
- gets with limit bigger than buffer size
2023-01-23 07:30:40 +09:00
Yukihiro "Matz" Matsumoto
be5266fbe6
mruby-io/test: test gets with RS multiple times; ref #5913
2023-01-23 07:26:40 +09:00
dearblue
b0e537c05c
Replaced NO_IO_POPEN with MRB_NO_IO_POPEN
...
ref. commit 9deb52c7b2
2023-01-22 09:20:10 +09:00
Yukihiro "Matz" Matsumoto
9deb52c7b2
mruby-io/io.c: allow disabling popen
...
When `MRB_NO_IO_POPEN` is defined (or iPhone is target), `IO#popen`
will be disabled.
2023-01-17 18:25:23 +09:00
Yukihiro "Matz" Matsumoto
e2ffcbab6e
mruby-io/io.c: cast return pointer from malloc/realloc for C++
2023-01-09 19:58:30 +09:00
Yukihiro "Matz" Matsumoto
8b7e240e67
mruby-io/io.c: improve code around io_cloexec_open()
2023-01-09 19:43:37 +09:00
Yukihiro "Matz" Matsumoto
91727f38de
mruby-io/io.c: change the implementation of read buffers
...
The original implementations used plain Ruby strings referenced from
instance variable (`@buf`) as buffers. We replaced those buffers by C
structure (`struct mrb_io_buf`) referenced directly from `fptr`.
The result is significant improvement of both performance and memory
consumption. Our simple benchmarks (reading `README.md` 10,000 times)
runs 5+ times faster, and `mrbtest` test suites consumes 85% less
memory.
Recent changes on `mruby-io` is preparation for this improvement.
2023-01-09 10:18:35 +09:00
Yukihiro "Matz" Matsumoto
e45e57fe22
mruby-io: update ISO section numbers
2023-01-07 16:39:59 +09:00