summaryrefslogtreecommitdiff
path: root/io.c
Commit message (Collapse)AuthorAgeFilesLines
* sed -i 's|ruby/impl|ruby/internal|'卜部昌平2020-05-111-2/+2
| | | | To fix build failures.
* sed -i s|ruby/3|ruby/impl|g卜部昌平2020-05-111-2/+2
| | | | This shall fix compile errors.
* Refactored rb_readwrite_syserr_failNobuyoshi Nakada2020-04-171-18/+20
| | | | | | * renamed argument `writable` as `waiting` * hosited out creating and raising exception * turned into a `switch`
* Raise EPIPE at broken pipe for the backward compatibilityNobuyoshi Nakada2020-04-151-6/+11
| | | | | | Instead of SignalException for SIGPIPE, raise `Errno::EPIPE` with instance variable `signo` and re-send that signal at exit. [Feature #14413]
* PAGER without fork&exec too [Feature #16754]Nobuyoshi Nakada2020-04-121-5/+19
|
* Silence broken pipe error messages on STDOUT [Feature #14413]Nobuyoshi Nakada2020-04-111-16/+46
| | | | Raise `SignalException` for SIGPIPE to abort when EPIPE occurs.
* Make `#inspect` interruptible in `Kernel#p`Nobuyoshi Nakada2020-04-101-20/+16
| | | | | Only writing the inspected result and a newline is uninterruptible.
* Constified writev function familyNobuyoshi Nakada2020-04-101-3/+3
|
* Merge pull request #2991 from shyouhei/ruby.h卜部昌平2020-04-081-4/+4
| | | Split ruby.h
* Set external encoding correctly for File.open('f', FILE::BINARY) on WindowsJeremy Evans2020-03-271-0/+12
| | | | | | | | | | 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]
* Remove support for passing nil to IO#ungetcJeremy Evans2020-02-271-1/+0
| | | | Fixes [Bug #13675]
* Warn non-nil `$/` [Feature #14240]Nobuyoshi Nakada2020-02-231-2/+2
|
* Warn non-nil `$\` [Feature #14240]Nobuyoshi Nakada2020-02-231-4/+4
|
* Warn non-nil `$,` in `IO#print` tooNobuyoshi Nakada2020-02-231-0/+3
|
* Pass keyword arguments to IOs properly [Bug #16639]Nobuyoshi Nakada2020-02-181-2/+6
|
* Drop executable bit set by 25f2005a638570cce832d218a451072057610f06Nobuyoshi Nakada2020-01-221-0/+0
|
* Also check EWOULDBLOCK as well as EAGAINNobuyoshi Nakada2020-01-211-9/+4
|
* fix load error with EAGAINXia Xionjun2020-01-211-1/+19
| | | | | | | | | | | | | | | 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.
* io.c, ruby.c: include internal/variable.h for rb_gvar_readonly_setterYusuke Endoh2020-01-091-0/+1
| | | | | | Same as 053f78e13988e9253d1f207bf5e23d9505112b32. emscripten requires a prototype declaration of rb_gvar_readonly_setter if it is refered as a function pointer.
* Separate builtin initialization callsNobuyoshi Nakada2019-12-291-6/+0
|
* decouple internal.h headers卜部昌平2019-12-261-22/+39
| | | | | | | | | | | | | | | | | | 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).
* Refined the warning message for $, and $;Nobuyoshi Nakada2019-12-201-1/+1
| | | | [Bug #16438]
* Added rb_warn_deprecatedNobuyoshi Nakada2019-12-191-8/+8
|
* IO#set_encoding_by_bom should err when encoding is already setNobuyoshi Nakada2019-12-151-0/+4
| | | | Except for ASCII-8BIT. [Bug #16422]
* Deprecate taint/trust and related methods, and make the methods no-opsJeremy Evans2019-11-181-8/+0
| | | | | | 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.
* Warn on access/modify of $SAFE, and remove effects of modifying $SAFEJeremy Evans2019-11-181-3/+0
| | | | | | | | | | | | | | | | | 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.
* delete unused functions卜部昌平2019-11-141-16/+0
| | | | | | | | | | | | 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.
* builtin.h must be included *AFTER* vm_core.hNobuyoshi Nakada2019-11-081-15/+19
|
* Renamed `load_*.inc` as `*.rbinc` to utilize a suffix ruleNobuyoshi Nakada2019-11-081-1/+1
|
* Define IO#read/write_nonblock with builtins.Koichi Sasada2019-11-081-6/+11
| | | | | | | 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.
* io.c (rb_update_max_fd): fail with a negative file descripterYusuke Endoh2019-10-131-1/+1
| | | | | | Coverity Scan points out that ext/socket/unixsocket.c may pass -1 to rb_update_max_fd. I'm unsure whether it can happen actually or not, but it would be good for the function to reject a negative value.
* io.c (NUM2IOCTLREQ): Accept a value more than INT_MAXYusuke Endoh2019-10-111-1/+1
| | | | | | | | ioctl accepts int as request arguments on some platforms, but some requests are more than INT_MAX, e.g., RNDGETENTCNT(0x80045200). Passing (0x80045200 | (-1 << 32)) may work around the issue, but it may not work on a platform where ioctl accepts unsigned long. So this change uses NUM2LONG and then casts it to int.
* Make rb_scan_args handle keywords more similar to Ruby methods (#2460)Jeremy Evans2019-09-251-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Cfuncs that use rb_scan_args with the : entry suffer similar keyword argument separation issues that Ruby methods suffer if the cfuncs accept optional or variable arguments. This makes the following changes to : handling. * Treats as **kw, prompting keyword argument separation warnings if called with a positional hash. * Do not look for an option hash if empty keywords are provided. For backwards compatibility, treat an empty keyword splat as a empty mandatory positional hash argument, but emit a a warning, as this behavior will be removed in Ruby 3. The argument number check needs to be moved lower so it can correctly handle an empty positional argument being added. * If the last argument is nil and it is necessary to treat it as an option hash in order to make sure all arguments are processed, continue to treat the last argument as the option hash. Emit a warning in this case, as this behavior will be removed in Ruby 3. * If splitting the keyword hash into two hashes, issue a warning, as we will not be splitting hashes in Ruby 3. * If the keyword argument is required to fill a mandatory positional argument, continue to do so, but emit a warning as this behavior will be going away in Ruby 3. * If keyword arguments are provided and the last argument is not a hash, that indicates something wrong. This can happen if a cfunc is calling rb_scan_args multiple times, and providing arguments that were not passed to it from Ruby. Callers need to switch to the new rb_scan_args_kw function, which allows passing of whether keywords were provided. This commit fixes all warnings caused by the changes above. It switches some function calls to *_kw versions with appropriate kw_splat flags. If delegating arguments, RB_PASS_CALLED_KEYWORDS is used. If creating new arguments, RB_PASS_KEYWORDS is used if the last argument is a hash to be treated as keywords. In open_key_args in io.c, use rb_scan_args_kw. In this case, the arguments provided come from another C function, not Ruby. The last argument may or may not be a hash, so we can't set keyword argument mode. However, if it is a hash, we don't want to warn when treating it as keywords. In Ruby files, make sure to appropriately use keyword splats or literal keywords when calling Cfuncs that now issue keyword argument separation warnings through rb_scan_args. Also, make sure not to pass nil in place of an option hash. Work around Kernel#warn warnings due to problems in the Rubygems override of the method. There is an open pull request to fix these issues in Rubygems, but part of the Rubygems tests for their override fail on ruby-head due to rb_scan_args not recognizing empty keyword splats, which this commit fixes. Implementation wise, adding rb_scan_args_kw is kind of a pain, because rb_scan_args takes a variable number of arguments. In order to not duplicate all the code, the function internals need to be split into two functions taking a va_list, and to avoid passing in a ton of arguments, a single struct argument is used to handle the variables previously local to the function.
* Fixed the function signature to rb_rescue2Nobuyoshi Nakada2019-09-111-1/+2
|
* drop-in type check for rb_define_singleton_method卜部昌平2019-08-291-1/+1
| | | | | | We can check the function pointer passed to rb_define_singleton_method like how we do so in rb_define_method. Doing so revealed many arity mismatches.
* drop-in type check for rb_define_global_function卜部昌平2019-08-291-4/+4
| | | | | | We can check the function pointer passed to rb_define_global_function like we do so in rb_define_method. It turns out that almost anybody is misunderstanding the API.
* delete `$` sign from C identifiers卜部昌平2019-08-271-3/+3
| | | | | They lack portability. See also https://travis-ci.org/shyouhei/ruby/jobs/577164015
* rb_define_hooked_variable now free from ANYARGS卜部昌平2019-08-271-1/+13
| | | | | | | | | After 5e86b005c0f2ef30df2f9906c7e2f3abefe286a2, I now think ANYARGS is dangerous and should be extinct. This commit uses rb_gvar_getter_t / rb_gvar_setter_t for rb_define_hooked_variable / rb_define_virtual_variable which revealed lots of function prototype inconsistencies. Some of them were literally decades old, going back to dda5dc00cff334cac373096d444a0fd59e716124.
* rb_ensure now free from ANYARGS卜部昌平2019-08-271-4/+8
| | | | | | After 5e86b005c0f2ef30df2f9906c7e2f3abefe286a2, I now think ANYARGS is dangerous and should be extinct. This commit deletes ANYARGS from rb_ensure, which also revealed many arity / type mismatches.
* rb_rescue / rb_rescue2 now free from ANYARGS卜部昌平2019-08-271-1/+1
| | | | | | After 5e86b005c0f2ef30df2f9906c7e2f3abefe286a2, I now think ANYARGS is dangerous and should be extinct. This commit deletes ANYARGS from rb_rescue / rb_rescue2, which revealed many arity / type mismatches.
* io.c: make ioctl_req_t int in AndroidYusuke Endoh2019-08-201-1/+1
| | | | | | The second argument of ioctl seems to be int in Android. Android is not a supported platform, but this one-line change allows ruby to build by Android NDK r20.
* io.c: export rb_io_extract_modeencNobuyoshi Nakada2019-08-141-1/+1
| | | | | | * include/ruby/io.h (rb_io_enc_t): add typedef. * io.c (rb_io_extract_modeenc): export.
* UTF LE is fixed at least the first 2 bytesNobuyoshi Nakada2019-08-131-5/+2
| | | | | * io.c (io_strip_bom): if the first 2 bytes are 0xFF0xFE, it should be a little-endian UTF, 16 or 32. [Bug #16099]
* #include <> for system headersNobuyoshi Nakada2019-08-091-1/+1
|
* * expand tabs.git2019-07-311-2/+2
|
* Do not change IO.pipe encodings if encodings explicitly givenJeremy Evans2019-07-301-1/+1
| | | | | | | | This commit makes it so that if the binmode option is given with any encoding arguments, the reader and writer IO objects are not set to binary encoding. Fixes [Bug #12989]
* Passing `binmode: true` to `IO.pipe` should behave like `binmode`Aaron Patterson2019-07-301-0/+6
| | | | | | | | | | | When passing `binmode: true` to `IO.pipe`, it should behave the same way as calling `binmode` on each of the file handles. It should set the file to binmode *and* set the encoding to binary on the file. Before this commit, passing `binmode: true` to `IO.pipe` would make `binmode?` return `true`, but the file's encoding would remain the same as the default encoding. Passing `binmode: true` should make `binmode?` return `true` *and* set the encoding to binary.
* io.c (rb_file_open_internal): initialize all the fieldsYusuke Endoh2019-07-141-0/+2
| | | | Just for case. This will suppress the warning of Coverity Scan.
* * expand tabs.git2019-07-141-1/+1
|
* Avoid io_tell whose return value is not usedYusuke Endoh2019-07-141-1/+1
| | | | | In this case, flush_before_seek is enough. This change will suppress a warning of Coverity Scan.