Граф коммитов

1924 Коммитов

Автор SHA1 Сообщение Дата
Burdette Lamar 7f93b7dc88
[DOC] Fix formatting for What's Here in IO (#5719)
* Fix formatting for What's Here in IO

* Repair formatting in What's Heres in numeric.c

* Fix formatting for What's Here in IO
2022-03-25 15:43:46 -05:00
Burdette Lamar 4bdb4a1873
Close files in examples in io.c (#5615) 2022-03-01 12:07:54 -06:00
Burdette Lamar 26ffda2fd2
[DOC] Enhanced RDoc for some encoding methods (#5598)
In String, treats:

    #b
    #scrub
    #scrub!
    #unicode_normalize
    #unicode_normalize!
    #encode
    #encode!

Also adds a note to IO.new (suggested by @jeremyevans).
2022-02-25 13:12:59 -06:00
Burdette Lamar bec3a1f15a
Enhanced RDoc for io.c (#5573)
Links to options doc added/improved; in particular, new links to new section "Encoding Options" in encoding.rdoc.  Minor inconsistencies ironed out.
2022-02-18 16:17:51 -06:00
Burdette Lamar e9a2b30744
Enhanced RDoc concerning command injection (#5537)
Clarifies security vulnerabilities for commands.

Treats:

    Kernel.system
    Kernel.` (backtick)
    IO.popen
    IO.read
    IO.write
    IO.binread
    IO.binwrite
    IO.readlines
    IO.foreach
2022-02-18 06:46:04 -06:00
Nobuyoshi Nakada 50c972a1ae
[DOC] Simplify operator method references 2022-02-12 12:38:36 +09:00
Peter Zhu f53f49197f [DOC] Replace with IO@Modes 2022-02-07 09:52:06 -05:00
Peter Zhu 9b3115ff64 [DOC] Remove extra period 2022-02-07 09:52:06 -05:00
Peter Zhu a12e2f9aa5 [DOC] Remove extra closing curly bracket 2022-02-07 09:52:06 -05:00
Peter Zhu a32e5e1b97 [DOC] Use RDoc link style for links in the same class/module
I used this regex:

(?<=\[)#(?:class|module)-([A-Za-z]+)-label-([A-Za-z0-9\-\+]+)

And performed a global find & replace for this:

rdoc-ref:$1@$2
2022-02-07 09:52:06 -05:00
Peter Zhu f9a2802bc5 [DOC] Use RDoc link style for links to other classes/modules
I used this regex:

([A-Za-z]+)\.html#(?:class|module)-[A-Za-z]+-label-([A-Za-z0-9\-\+]+)

And performed a global find & replace for this:

rdoc-ref:$1@$2
2022-02-07 09:52:06 -05:00
Peter Zhu ecd469fad0 [DOC] Fix links in documentation for File and IO
Fixes some typos and dead links.
2022-02-07 09:52:06 -05:00
Burdette Lamar 3e6c6c74dd
{DOC] Enhanced RDoc for io.c (#5529)
Changes parameter name from simple opts to open_opts or enc_opts when appropriate; leaves the name unchanged when more than one kind of option is allowed.
2022-02-05 14:05:27 -06:00
Burdette Lamar 06a28ec4d4
[DOC] Enhanced RDoc for io.c (#5527)
Treats:

    IO.binread (abbreviated to be like IO.binwrite).
    IO.write
    IO.binwrite
    IO.copystream
    IO#external_encoding
    IO#internal_encoding
    IO#set_encoding
2022-02-04 16:26:49 -06:00
Burdette Lamar 46f6575157
[DOC] Enhanced RDoc for io.c (#5511)
Treats:

    IO.foreach
    IO.readlines
    IO.read
    IO.binread
2022-02-04 06:55:10 -06:00
Burdette Lamar 99a65e80d5
[DOC] Enhanced RDoc for io.c (#5460)
Treats:

    Kernel#readline
    Kernel#readlines
    Kernel#`cmd`
    IO#advise
    IO.select
    IO#ioctl
    IO#fcntl
    Kernel#syscall
    IO.pipe
2022-01-30 16:17:53 -06:00
Yuta Saito 7ee786388a [wasm] wasm/missing.{c,h}: add missing libc stubs for wasi-libc 2022-01-19 11:19:06 +09:00
Burdette Lamar ab85c5e979
[DOC] Enhanced RDoc for io.c (#5451)
Treats:

    IO#reopen
    IO#printf
    Kernel#printf
    IO#print
    Kernel#print
    IO#putc
    IO.new
    IO#set_encoding_by_bom
    IO.for_fd
2022-01-18 06:25:26 -06:00
Masataka Pocke Kuwabara 28fad7764e Tweak IO documentation for `IO.write('|cmd')` and so on [ci skip] 2022-01-17 00:26:08 +09:00
Burdette Lamar e40f79daa3
Enhanced RDoc for io.c (#5444)
Treated:

    IO#open
    IO#sysopen
    #open
    IO#putc
    IO#puts
    #p
    Kernel#display
2022-01-14 18:33:06 -06:00
Burdette Lamar 6dc4c942a3
File rdoc (#5438)
Treats:

    File introduction
    File.open
    File.new
2022-01-13 18:00:24 -06:00
Burdette Lamar faf79d3a25
Enhanced RDoc for IO.popen (#5430)
* Enhanced RDoc for IO.popen
2022-01-12 17:08:30 -06:00
Burdette Lamar d920535d1b
Enhanced RDoc for IO (#5425)
Treats:

    #pread
    #pwrite
    #binmode
    #binmode?
2022-01-10 17:02:48 -06:00
Burdette Lamar 6931d70e6e
Enhanced RDoc for IO (#5424)
Treats:

    #sysseek
    #syswrite
    #sysread
2022-01-10 15:14:36 -06:00
Burdette Lamar a9dc0c59e3
[DOC] Enhanced RDoc for IO (#5422)
Revises much of the introductory material.

Also treats:

    #close_on_exec
    #close
    #closed?
    #close_read
    #close_write
2022-01-10 12:45:06 -06:00
Samuel Williams 0ca00e2cb7
Move IO write buffer allocation into function. 2022-01-09 00:03:16 +13:00
Burdette Lamar 5ad507d751
Enhanced RDoc for IO (#5402)
Treats:

    #ungetc
    #isatty
    #close_on_exec?
2022-01-06 10:47:51 -06:00
Burdette Lamar 445c055b44
Enhanced RDoc for IO (#5395)
Treats:

    #getc
    #readchar
    #getbyte
    #readbyte
    #ungetbyte
2022-01-05 16:13:06 -06:00
Burdette Lamar 9c15da0fd4
Enhanced RDoc for IO (#5381)
Treats:

    #lineno
    #lineno=
    #readline
    #readlines
    #each_line
    #each_byte
    #each_char
    #each_codepoint
2022-01-04 12:57:45 -06:00
Nobuyoshi Nakada 069cca6f74
Negative RBOOL usage 2022-01-01 17:02:04 +09:00
Samuel Williams 243320d22f
Fix incorrect minimum read length. (#5353) 2022-01-01 20:23:47 +13:00
Burdette Lamar 87c03694e6
Enhanced RDoc for IO (#5367)
Adds sections to class RDoc:

    Lines
        Line Separator
        Line Limit
        Line Number

Revises example text file t.txt to:

    Include paragraphs (separated by double line separator).
    Avoid being too long.

Revises examples that use the changed example file.

There are several other methods that will point to the added sections.
2021-12-30 16:46:24 -06:00
Nobuyoshi Nakada 3238164f9c `ioctl_narg_len` is used only when ioctl(2) is available 2021-12-29 11:40:04 +09:00
Samuel Williams 548c8f5f7a
Prefer to use RTEST when checking result of `rb_io_wait`. (#5341)
* Prefer to use RTEST when checking result of `rb_io_wait`.

* Consistently use false for signifying no events ready.
2021-12-25 02:26:06 +13:00
Nobuyoshi Nakada 4f74153846
Adjust styles [ci skip] 2021-12-24 21:17:27 +09:00
Samuel Williams acfe2f2655
Improvements to `rb_io_wait` return value handling and internal implementation. (#5340) 2021-12-24 23:11:02 +13:00
Burdette Lamar a8f4cc2bfa
[DOC] Enhanced RDoc for IO (#5324)
Treats #gets.
2021-12-23 10:27:10 -06:00
Burdette Lamar 243ecd176d
[DOC] Enhanced RDoc for IO (#5321)
Treats:

    #readpartial
    #read
2021-12-22 14:41:39 -06:00
Nobuyoshi Nakada fdf3996349
Empty and return the buffer if zero size is given [Bug #18421]
In `IO#readpartial` and `IO#read_nonblock`, as well as `IO#read`.
2021-12-22 15:45:59 +09:00
Nobuyoshi Nakada c29c2afafe Refactor setup_narg and extract finish_narg 2021-12-21 13:34:04 +09:00
Burdette Lamar 6ad8cf7071
[DOC] Enhanced RDoc for IO (#5307)
Treated:

    #sync
    #sync=
    #fsync
    #fdatasync
    #fileno
    #pid
    #inspect
    #to_io
2021-12-20 16:28:58 -06:00
Burdette Lamar 3bb6e4f641
[DOC] Enhanced RDoc for IO (#5304)
Treated:

    ::try_convert
    #write
    #<<
    #flush
    #tell
    #seek
    #pos=
    #rewind
    #eof
2021-12-19 22:04:47 -06:00
Burdette Lamar f44367effe
[DOC] Addition to IO introduction (#5299)
Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2021-12-19 09:37:06 -06:00
Samuel Williams 42d3231154
Introduce io_result wrapper for passing `[-errno, size]` in VALUE. 2021-12-18 18:19:30 +13:00
Nobuyoshi Nakada b555e659c4
Do not use `fcopyfile` if appending to non-empty file [Bug #18388]
`fcopyfile` appends `src` to `to` and then truncates `to` to it's
original size.
2021-12-05 18:47:02 +09:00
Nobuyoshi Nakada 37cd35aea8 [win32] Transcode input from console [Bug #18353]
On Windows, as the input from console is encoded in the active
code page, convert the input to the internal encoding.
2021-12-01 18:54:26 +09:00
Samuel Williams 51c67ee61a Don't allow `fd == -1` to propagate to system calls. 2021-11-11 13:35:16 +13:00
Nobuyoshi Nakada 46e46eafd4
size_t is not for file size 2021-11-10 16:41:26 +09:00
Samuel Williams 4b89034218 IO::Buffer for scheduler interface. 2021-11-10 19:21:05 +13:00
Peter Zhu aeae6e2842 [Feature #18290] Remove all usages of rb_gc_force_recycle
This commit removes usages of rb_gc_force_recycle since it is a burden
to maintain and makes changes to the GC difficult.
2021-11-08 14:05:54 -05:00
Nobuyoshi Nakada 049e1f8560
Fix typo 2021-10-26 14:43:12 +09:00
Yusuke Endoh 13068ebe32
process.c: Add Process._fork (#5017)
* process.c: Add Process._fork

This API is supposed for application monitoring libraries to hook fork
event.

[Feature #17795]

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2021-10-25 20:47:19 +09:00
Nobuyoshi Nakada 408605aae7 EWOULDBLOCK is always defined since 74ba9c2488 2021-10-24 19:24:50 +09:00
Nobuyoshi Nakada 3d7c92df08 Extract io_again_p to check if EAGAIN or EWOULDBLOCK 2021-10-24 19:24:50 +09:00
Nobuyoshi Nakada 9822ebee5b suppress warnings by parenthesizing unclear expressions 2021-10-24 19:24:50 +09:00
Nobuyoshi Nakada 606e785fa8
Reuse ractor stderr 2021-10-07 19:57:09 +09:00
Nobuyoshi Nakada a706c09fa6
Adjust styles [ci skip] 2021-10-07 19:57:09 +09:00
S.H dc9112cf10
Using NIL_P macro instead of `== Qnil` 2021-10-03 22:34:45 +09:00
Kazuhiro NISHIYAMA e0c6e8c64a
[DOC] Use `unpack1` instead of `unpack(template)[0]` [ci skip] 2021-09-23 09:20:00 +09:00
S-H-GAMELINKS 032534dbdf Using RB_BIGNUM_TYPE_P macro 2021-09-11 09:13:24 +09:00
Lars Kanis 6594623f62 Fix Marshal.dump(closed_io) to raise TypeError and allow encoding on closed IO
Mashalling a closed IO object raised "closed stream (IOError)" before instead of TypeError.
This changes IO#(in|ex)ternal_encoding to still return the encoding even if the underlying FD is closed.

Fixes bug #18077
2021-08-22 10:33:22 +09:00
Nobuyoshi Nakada a8714b83c4
`popen()` is not available on emscripten 2021-08-16 17:00:19 +09:00
Csaba Henk 8df1ace64a Fix ARGF.read(length) short read [Bug #18074] 2021-08-10 11:32:45 +09:00
Samuel Williams 3a8cadcf8f Reduce chance to receive EBADF when closing an IO from another thread. 2021-08-08 22:12:14 +12:00
S.H 378e8cdad6
Using RBOOL macro 2021-08-02 12:06:44 +09:00
Nobuyoshi Nakada 3b52230452
Define functions using rb_wait_for_single_fd [Bug #18046] 2021-08-01 06:49:07 +09:00
Yusuke Endoh eee709595c io.c: Clarify the behavior of `IO.read` when called as `File.read`
Ditto to `IO.binread`, `IO.write`, `IO.binwrite`, `IO.foreach`, and
`IO.readlines`.
2021-07-16 16:10:54 +09:00
Yusuke Endoh 645616c273 process.c: Call rb_thread_atfork in rb_fork_ruby
All occurrences of rb_fork_ruby are followed by a call rb_thread_fork in
the created child process.

This is refactoring and a potential preparation for [Feature #17795].
(rb_fork_ruby may be wrapped by Process._fork_.)
2021-07-15 16:46:08 +09:00
Nobuyoshi Nakada 59ead88563
[DOC] add notes and examples for pipe [ci skip] 2021-06-30 15:45:21 +09:00
Nobuyoshi Nakada 13939d61b4
Check if closed after each yield [Bug #17661] 2021-06-27 11:18:41 +09:00
Nobuyoshi Nakada 6875408583
Introduced RUBY_CRLF_ENVIRONMENT to simplify repeated condition 2021-06-24 13:01:46 +09:00
Samuel Williams fcc6fd23ec Rework `sysread` to use blocking `read_internal_locktmp`. 2021-06-22 22:48:57 +12:00
Samuel Williams 45e65f302b Deprecate and rework old (fd) centric functions. 2021-06-22 22:48:57 +12:00
Samuel Williams 3deb5d7113 Direct io for accept, send, sendmsg, recvfrom, and related methods. 2021-06-22 22:17:53 +12:00
Burdette Lamar c1741df1a1 What's Here for Numeric and Comparable 2021-06-21 10:38:16 -07:00
Nobuyoshi Nakada e4f891ce8d
Adjust styles [ci skip]
* --braces-after-func-def-line
* --dont-cuddle-else
* --procnames-start-lines
* --space-after-for
* --space-after-if
* --space-after-while
2021-06-17 10:13:40 +09:00
Nobuyoshi Nakada f136c1ec80
Removed redundant NUM2IOCTLREQ definition [Bug #17759]
Fix up c2d9967f78.
2021-06-16 13:33:56 +09:00
Nobuyoshi Nakada c2d9967f78 Configure ioctl request argument type [Bug #17759] 2021-06-16 13:17:19 +09:00
Kazuhiro NISHIYAMA 8560f34246
Fix a typo [ci skip] 2021-05-16 00:07:22 +09:00
Nobuyoshi Nakada 2d67027448 Removed missing/dup2.c
This function should be always available, as POSIX-compliant or
Windows platform are required since 1.9.  Also the code in this
file is MT-unsafe.
2021-05-10 15:59:23 +09:00
Burdette Lamar fd3a20348e
What's Here for class IO (#4440)
* What's Here for class IO
2021-05-04 13:59:33 -05:00
Jeremy Evans c809a8cae8 Fix documentation for IO#unget{byte,c}
Fixes [Bug #14400]
2021-05-04 11:23:57 -07:00
Kenichi Kamiya 52fb0a2932 [Doc] Drop signature around removed IO#codepoints
Follow 43b95bafd5
2021-04-05 11:47:42 +09:00
Samuel Williams a9c5c2d614 Check errno before invoking scheduler in `rb_io_wait_readable/writable`.
See <https://bugs.ruby-lang.org/issues/17527> for more details.
2021-03-30 23:16:59 +13:00
S.H 71ba09632b
Remove unneeded declarations 2021-03-20 21:00:29 +09:00
Samuel Williams 5f69a7f604
Expose scheduler as public interface & bug fixes. (#3945)
* Rename `rb_scheduler` to `rb_fiber_scheduler`.

* Use public interface if available.

* Use `rb_check_funcall` where possible.

* Don't use `unblock` unless the fiber was non-blocking.
2021-02-09 19:39:56 +13:00
Nobuyoshi Nakada bf627e518d
Forward keyword arguments to ARGF from global functions 2021-02-08 11:33:53 +09:00
Yusuke Endoh 33fb87cc9c io.c: popen is not available on emscripten 2021-01-23 13:24:06 +09:00
Marcus Stollsteimer 3108ad7bf3 [DOC] Fix grammar: "is same as" -> "is the same as" 2021-01-05 15:13:53 +01:00
Nobuyoshi Nakada ae1cc3fd4e
Made an internal callback function static 2020-12-20 14:29:31 +09:00
Jeremy Evans 05313c914b Use category: :deprecated in warnings that are related to deprecation
Also document that both :deprecated and :experimental are supported
:category option values.

The locations where warnings were marked as deprecation warnings
was previously reviewed by shyouhei.

Comment a couple locations where deprecation warnings should probably
be used but are not currently used because deprecation warning
enablement has not occurred at the time they are called
(RUBY_FREE_MIN, RUBY_HEAP_MIN_SLOTS, -K).

Add assert_deprecated_warn to test assertions.  Use this to simplify
some tests, and fix failing tests after marking some warnings with
deprecated category.
2020-12-18 09:54:11 -08:00
Nobuyoshi Nakada b419f90a8b
Tweaked `Process::Status.wait`
* revert `rb_last_status_set`
* renamed the new function as `rb_process_status_new`
* `rb_process_status_new` always freezes the return value
* marked `Process::Status.wait` as EXPERIMENTAL, as it has not
  been discussed totally yet.
2020-12-09 11:51:57 +09:00
Samuel Williams 2553c5f94a Add support for non-blocking `Process.wait`. 2020-12-09 08:55:35 +13:00
卜部昌平 43b95bafd5
delete deprecated IO-like methods
This commit deletes
{IO,ARGF,StringIO,Zib::GZipReader}#{bytes,chars,lines,codepoints}, which
have been deprecated since c47c095b97.

Note that String also has those methods.  They are neither depreacted
nor deleted because they are not aliases of counterpart each_something.
2020-12-03 12:47:51 +09:00
Koichi Sasada 5e3259ea74 fix public interface
To make some kind of Ractor related extensions, some functions
should be exposed.

* include/ruby/thread_native.h
  * rb_native_mutex_*
  * rb_native_cond_*
* include/ruby/ractor.h
  * RB_OBJ_SHAREABLE_P(obj)
  * rb_ractor_shareable_p(obj)
  * rb_ractor_std*()
  * rb_cRactor

and rm ractor_pub.h
and rename srcdir/ractor.h to srcdir/ractor_core.h
    (to avoid conflict with include/ruby/ractor.h)
2020-11-18 03:52:41 +09:00
Samuel Williams a08ee8330d Rename to `Fiber#set_scheduler`. 2020-11-07 23:39:50 +13:00
Jeremy Evans 58fd54f914 Fix error in update-deps due to tab/space difference 2020-10-28 15:29:05 -07:00
Stefan Stüben 8c2e5bbf58 Don't redefine #rb_intern over and over again 2020-10-21 12:45:18 +09:00
Koichi Sasada 99310e3eb5 Some global variables can be accessed from ractors
Some global variables should be used from non-main Ractors.
[Bug #17268]

```ruby
     # ractor-local (derived from created ractor): debug
     '$DEBUG' => $DEBUG,
     '$-d' => $-d,

     # ractor-local (derived from created ractor): verbose
     '$VERBOSE' => $VERBOSE,
     '$-w' => $-w,
     '$-W' => $-W,
     '$-v' => $-v,

     # process-local (readonly): other commandline parameters
     '$-p' => $-p,
     '$-l' => $-l,
     '$-a' => $-a,

     # process-local (readonly): getpid
     '$$'  => $$,

     # thread local: process result
     '$?'  => $?,

     # scope local: match
     '$~'  => $~.inspect,
     '$&'  => $&,
     '$`'  => $`,
     '$\''  => $',
     '$+'  => $+,
     '$1'  => $1,

     # scope local: last line
     '$_' => $_,

     # scope local: last backtrace
     '$@' => $@,
     '$!' => $!,

     # ractor local: stdin, out, err
     '$stdin'  => $stdin.inspect,
     '$stdout' => $stdout.inspect,
     '$stderr' => $stderr.inspect,
```
2020-10-20 15:38:54 +09:00
Nobuyoshi Nakada fddffa4c7a
Respect the original styles [ci skip] 2020-10-11 11:57:32 +09:00
Samuel Williams f75009c122 Prefer to use `prep_io` for temporary IO instances. 2020-09-17 00:31:04 +12:00
Samuel Williams 026ba68c10 Fix handling of FMODE_PREP. 2020-09-15 22:53:08 +12:00
Samuel Williams a9b2a96c5c Fix incorrect initialization of `rb_io_t::self`. 2020-09-15 22:53:08 +12:00
Samuel Williams 9e0a48c7a3 Prefer `rb_thread_current_scheduler`. 2020-09-14 16:44:09 +12:00
Samuel Williams 701dcbb3ca Add support for hooking `IO#read`. 2020-09-14 16:44:09 +12:00
Samuel Williams d387029f39 Standardised scheduler interface. 2020-09-14 16:44:09 +12:00
Samuel Williams 905e9c8093 Simplify bitmasks for IO events. 2020-09-14 16:44:09 +12:00
Masaki Matsushita 012785ef35 Check copy_file_range(2) is actually supported.
see also: https://gitlab.com/gitlab-org/gitlab/-/issues/218999#note_363225872
2020-09-12 16:07:35 +09:00
Nobuyoshi Nakada f943566d1c
break around function definition [ci skip] 2020-09-05 00:34:58 +09:00
Koichi Sasada 79df14c04b Introduce Ractor mechanism for parallel execution
This commit introduces Ractor mechanism to run Ruby program in
parallel. See doc/ractor.md for more details about Ractor.
See ticket [Feature #17100] to see the implementation details
and discussions.

[Feature #17100]

This commit does not complete the implementation. You can find
many bugs on using Ractor. Also the specification will be changed
so that this feature is experimental. You will see a warning when
you make the first Ractor with `Ractor.new`.

I hope this feature can help programmers from thread-safety issues.
2020-09-03 21:11:06 +09:00
Masaki Matsushita 56dd578d7e IO.copy_stream: handle EOPNOTSUP instead of ENOTSUP 2020-08-29 16:10:58 +09:00
Masaki Matsushita 93df301048 IO.copy_stream: handle ENOTSUP on copy_file_range(2)
fallback to other methods on ENOTSUP.
some RedHat kernels may return ENOTSUP on an NFS mount.
[Feature #16965]
2020-08-29 15:38:07 +09:00
Peter Zhu 166cacc505
Fix corruption in ARGF.inplace
Extension string stored in `ARGF.inplace` is created using an api
designed for C string constants to create a Ruby string that
points at another Ruby string. When the original string is swept,
the extension string gets corrupted.

Reproduction script (on MacOS):

```ruby
#!/usr/bin/ruby -pi.bak

BEGIN {
  GC.start(full_mark: true)
  arr = []
  1000000.times do |x|
    arr << "fooo#{x}"
  end
}

puts "hello"
```

Co-Authored-By: Matt Valentine-House <31869+eightbitraptor@users.noreply.github.com>
2020-08-12 17:54:09 +09:00
Nobuyoshi Nakada d2bf6133f6
Remove trailing spaces [ci skip] 2020-07-20 13:34:16 +09:00
Samuel Williams f3462d99a3 Rename `rb_current_thread_scheduler` to `rb_thread_scheduler_if_nonblocking`.
Correctly capture thread before releasing GVL and pass as argument to
`rb_thread_scheduler_if_nonblocking`.
2020-07-20 13:20:58 +12:00
卜部昌平 de3e931df7 add UNREACHABLE_RETURN
Not every compilers understand that rb_raise does not return.  When a
function does not end with a return statement, such compilers can issue
warnings.  We would better tell them about reachabilities.
2020-06-29 11:05:41 +09:00
卜部昌平 9e92292e30 rb_io_modestr_fmode: do not goto into a branch
I'm not necessarily against every goto in general, but jumping into a
branch is definitely a bad idea.  Better refactor.
2020-06-29 11:05:41 +09:00
卜部昌平 0e4ee71546 rb_io_each_codepoint: do not goto into a branch
I'm not necessarily against every goto in general, but jumping into a
branch is definitely a bad idea.  Better refactor.
2020-06-29 11:05:41 +09:00
Nobuyoshi Nakada 6f167da65b
Fixed a variable name [Bug #16903]
Fix up of 0e3b0fcdba

From: fd0 (Daisuke Fujimura)
2020-05-21 10:47:41 +09:00
Samuel Williams 0e3b0fcdba
Thread scheduler for light weight concurrency. 2020-05-14 22:10:55 +12:00
卜部昌平 9e41a75255 sed -i 's|ruby/impl|ruby/internal|'
To fix build failures.
2020-05-11 09:24:08 +09:00
卜部昌平 d7f4d732c1 sed -i s|ruby/3|ruby/impl|g
This shall fix compile errors.
2020-05-11 09:24:08 +09:00
Nobuyoshi Nakada b5132d91c0
Refactored rb_readwrite_syserr_fail
* renamed argument `writable` as `waiting`
* hosited out creating and raising exception
* turned into a `switch`
2020-04-17 14:08:54 +09:00
Nobuyoshi Nakada 155f64e3c4
Raise EPIPE at broken pipe for the backward compatibility
Instead of SignalException for SIGPIPE, raise `Errno::EPIPE` with
instance variable `signo` and re-send that signal at exit.
[Feature #14413]
2020-04-15 21:05:39 +09:00
Nobuyoshi Nakada e6551d835f PAGER without fork&exec too [Feature #16754] 2020-04-12 14:58:13 +09:00
Nobuyoshi Nakada 6f28ebd585
Silence broken pipe error messages on STDOUT [Feature #14413]
Raise `SignalException` for SIGPIPE to abort when EPIPE occurs.
2020-04-11 09:30:19 +09:00
Nobuyoshi Nakada 63a5412db7
Make `#inspect` interruptible in `Kernel#p`
Only writing the inspected result and a newline is
uninterruptible.
2020-04-10 10:52:33 +09:00
Nobuyoshi Nakada 614d816a1f
Constified writev function family 2020-04-10 10:37:15 +09:00
卜部昌平 9e6e39c351
Merge pull request #2991 from shyouhei/ruby.h
Split ruby.h
2020-04-08 13:28:13 +09:00
Jeremy Evans e1e4ea8fa9 Set external encoding correctly for File.open('f', FILE::BINARY) on Windows
Previously, the external encoding was only set correctly for
File::BINARY if keyword arguments were provided.  This copies
the logic for the keyword arguments case to the no keyword
arguments case.  Possibly it should be refactored into a
separate function.

Fixes [Bug #16737]
2020-03-27 11:31:19 -07:00
Jeremy Evans 54499d7810 Remove support for passing nil to IO#ungetc
Fixes [Bug #13675]
2020-02-27 10:17:54 -08:00
Nobuyoshi Nakada 8a7e0aaaef
Warn non-nil `$/` [Feature #14240] 2020-02-23 13:37:40 +09:00
Nobuyoshi Nakada 6298ec2875
Warn non-nil `$\` [Feature #14240] 2020-02-23 13:37:40 +09:00
Nobuyoshi Nakada 588a86e32c
Warn non-nil `$,` in `IO#print` too 2020-02-23 13:37:40 +09:00
Nobuyoshi Nakada 041c2932e3
Pass keyword arguments to IOs properly [Bug #16639] 2020-02-18 14:35:46 +09:00
Nobuyoshi Nakada 913dc64eb6
Drop executable bit set by 25f2005a63 2020-01-22 08:54:49 +09:00
Nobuyoshi Nakada 5798d35ff6
Also check EWOULDBLOCK as well as EAGAIN 2020-01-21 22:45:10 +09:00
Xia Xionjun 25f2005a63 fix load error with EAGAIN
This is a fix related to the following issue.
rails/rails#33464

Not only in rails apps, some little ruby app with only 2 or 3 ruby
files reproduce the problem during many years.

When I edit linux ruby files by vs code via samba on windows, and
then I execute the ruby files on linux, "require_relative" will
sometimes not work properly.

My solution is to wait a monument if the required relative file is
busy.
2020-01-21 22:41:45 +09:00
Yusuke Endoh c6b26f5ccf io.c, ruby.c: include internal/variable.h for rb_gvar_readonly_setter
Same as 053f78e139.
emscripten requires a prototype declaration of rb_gvar_readonly_setter
if it is refered as a function pointer.
2020-01-09 23:57:46 +09:00
Nobuyoshi Nakada d7bef803ac Separate builtin initialization calls 2019-12-29 12:34:55 +09:00
卜部昌平 5e22f873ed decouple internal.h headers
Saves comitters' daily life by avoid #include-ing everything from
internal.h to make each file do so instead.  This would significantly
speed up incremental builds.

We take the following inclusion order in this changeset:

1.  "ruby/config.h", where _GNU_SOURCE is defined (must be the very
    first thing among everything).
2.  RUBY_EXTCONF_H if any.
3.  Standard C headers, sorted alphabetically.
4.  Other system headers, maybe guarded by #ifdef
5.  Everything else, sorted alphabetically.

Exceptions are those win32-related headers, which tend not be self-
containing (headers have inclusion order dependencies).
2019-12-26 20:45:12 +09:00
Nobuyoshi Nakada 2b2030f265
Refined the warning message for $, and $;
[Bug #16438]
2019-12-20 15:09:23 +09:00
Nobuyoshi Nakada c6c67254fb
Added rb_warn_deprecated 2019-12-19 09:52:17 +09:00
Nobuyoshi Nakada e8c62836a6
IO#set_encoding_by_bom should err when encoding is already set
Except for ASCII-8BIT.  [Bug #16422]
2019-12-15 23:13:16 +09:00
Jeremy Evans ffd0820ab3 Deprecate taint/trust and related methods, and make the methods no-ops
This removes the related tests, and puts the related specs behind
version guards.  This affects all code in lib, including some
libraries that may want to support older versions of Ruby.
2019-11-18 01:00:25 +02:00
Jeremy Evans c5c05460ac Warn on access/modify of $SAFE, and remove effects of modifying $SAFE
This removes the security features added by $SAFE = 1, and warns for access
or modification of $SAFE from Ruby-level, as well as warning when calling
all public C functions related to $SAFE.

This modifies some internal functions that took a safe level argument
to no longer take the argument.

rb_require_safe now warns, rb_require_string has been added as a
version that takes a VALUE and does not warn.

One public C function that still takes a safe level argument and that
this doesn't warn for is rb_eval_cmd.  We may want to consider
adding an alternative method that does not take a safe level argument,
and warn for rb_eval_cmd.
2019-11-18 01:00:25 +02:00
卜部昌平 c9ffe751d1 delete unused functions
Looking at the list of symbols inside of libruby-static.a, I found
hundreds of functions that are defined, but used from nowhere.

There can be reasons for each of them (e.g. some functions are
specific to some platform, some are useful when debugging, etc).
However it seems the functions deleted here exist for no reason.

This changeset reduces the size of ruby binary from 26,671,456
bytes to 26,592,864 bytes on my machine.
2019-11-14 20:35:48 +09:00
Nobuyoshi Nakada 99b1c19be4
builtin.h must be included *AFTER* vm_core.h 2019-11-08 16:31:57 +09:00
Nobuyoshi Nakada 20971799f2
Renamed `load_*.inc` as `*.rbinc` to utilize a suffix rule 2019-11-08 16:30:28 +09:00
Koichi Sasada 365557f111 Define IO#read/write_nonblock with builtins.
IO#read/write_nonblock methods are defined in prelude.rb with
special private method __read/write_nonblock to reduce keyword
parameters overhead. We can move them into io.rb with builtin
functions.
2019-11-08 10:03:19 +09:00