summaryrefslogtreecommitdiff
path: root/io.c
AgeCommit message (Collapse)Author
2017-04-09io.c: ARGF.file returns $stdin instead of STDIN [ci skip]kazu
For example: `ruby -e '$stdin=open(IO::NULL);p [STDIN,$stdin,ARGF.file]'` prints `[#<IO:<STDIN>>, #<File:/dev/null>, #<File:/dev/null>]` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58288 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-03Fix arguments order of IO#pwritekazu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58241 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-03Add IO#pread and IO#pwrite methodsnobu
These methods are useful for safe/concurrent file I/O in multi-thread/process environments and also fairly standard nowadays especially in systems supporting pthreads. Based on patches by Avseyev <sergey.avseyev@gmail.com> at [ruby-core:79290]. [Feature #4532] * configure.in: check for pwrite(2). pread() is already used internally for IO.copy_stream. * io.c: implement wrappers for pread(2) and pwrite(2) and expose them in IO. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58240 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-22io.c: [DOC] expand docs for IO#putsstomar
[ruby-core:80081] [Bug #13306] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58062 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-17io.c: improve docsstomar
* io.c: [DOC] improve and harmonize docs for IO#read and ARGF#read; fix invalid example code for IO#read to make it syntax highlighted. * io.c: [DOC] various improvements for docs of IO, ARGF, and Kernel: fix indent to ensure correct code block detection; sync "outbuf" paragraph for {IO,ARGF}#read, {IO,ARGF}#readpartial, and IO#sysread; fix formatting of call-seq's; improve Kernel#open example to use nil?; fix RDoc markup and typos. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58008 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-17deduplicate "/", ":" and "\n" stringsnormal
"/" and ":" are always statically registered in symbol.c (Init_op_tbl), and "\n" is a commonly seen in source code. * file.c (Init_File): fstring on File::SEPARATOR and File::PATH_SEPARATOR * io.c (Init_IO): fstring on rb_default_rs ("\n") git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57995 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-15io.c: [DOC] add missing `$`kazu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57977 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-12io.c: [DOC] IO#puts uses IO#writenaruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57944 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-06io.c: [DOC] open mode can be an integer; fix rdoc syntaxstomar
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57790 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-05docs for IO.{write,read}stomar
* io.c: [DOC] improve docs for IO * IO.{write,read}: fix errors (:open_args is not an array of strings, it might include a perm or options hash argument; IO.write has no length argument, drop corresponding statement), improve formatting, call-seq, grammar. * IO#sync=: remove unnecessary "produces no output". * other improvements. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57781 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-05docs for IO#printstomar
* io.c: [DOC] split documentation for IO#print into smaller paragraphs, delete duplicate sentence, fix call-seq. Based on a patch by Dario Daic. [ruby-core:78291] [Bug #12975] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57780 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-03io.c: documentation for putsstomar
* io.c: [DOC] clarify that the 'record separator' between arguments passed to 'puts' is always a newline. Based on a patch by Mark Amery. [ruby-core:65801] [Misc #10403] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57767 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-22eval_error.c: backstrace in reverse ordernobu
* eval_error.c (rb_threadptr_error_print): print backtrace and error message in reverse order if STDERR is unchanged and a tty. [Feature #8661] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57685 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-02io.c: remove rb_ensure usage for rb_str_tmp_frozen_* callsnormal
Using rb_ensure pessimizes the common case and makes the code more difficult to read and follow. If we hit an exceptions during write, just let the GC handle cleanup as the exception is already bad for garbage. * io.c (io_fwrite): call rb_str_tmp_frozen{acquire,release} directly (rb_io_syswrite): ditto (fwrite_do, fwrite_end, swrite_do, swrite_end): remove git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57508 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-30io.c (rb_io_syswrite): avoid leaving garbage after writenormal
As with IO#write, IO#syswrite also generates garbage which can be harmful in hand-coded read-write loops. * io.c (swrite_arg, swrite_do, swrite_end): new (rb_io_syswrite): use new functions to cleanup garbage [ruby-core:78898] [Bug #13085] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-30io.c: recycle garbage on writenormal
* string.c (STR_IS_SHARED_M): new flag to mark shared mulitple times (STR_SET_SHARED): set STR_IS_SHARED_M (rb_str_tmp_frozen_acquire, rb_str_tmp_frozen_release): new functions (str_new_frozen): set/unset STR_IS_SHARED_M as appropriate * internal.h: declare new functions * io.c (fwrite_arg, fwrite_do, fwrite_end): new (io_fwrite): use new functions Introduce rb_str_tmp_frozen_acquire and rb_str_tmp_frozen_release to manage a hidden, frozen string. Reuse one bit of the embed length for shared strings as STR_IS_SHARED_M to indicate a string has been shared multiple times. In the common case, the string is only shared once so the object slot can be reclaimed immediately. minimum results in each 3 measurements. (time and size) Execution time (sec) name trunk built io_copy_stream_write 0.682 0.254 io_copy_stream_write_socket 1.225 0.751 Speedup ratio: compare with the result of `trunk' (greater is better) name built io_copy_stream_write 2.680 io_copy_stream_write_socket 1.630 Memory usage (last size) (B) name trunk built io_copy_stream_write 95436800.000 6512640.000 io_copy_stream_write_socket 117628928.000 7127040.000 Memory consuming ratio (size) with the result of `trunk' (greater is better) name built io_copy_stream_write 14.654 io_copy_stream_write_socket 16.505 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57469 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-25io.c: close before waitnobu
* io.c (io_close_fptr): notify then close, and wait for other threads before free fptr. [ruby-core:79262] [Bug #13158] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57422 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-19Change Kernel#warn to call Warning.warnnobu
This allows Warning.warn to filter/process warning messages generated by Kernel#warn. Currently, Warning.warn can only handle messages generated by the rb_warn/rb_warning C functions. The Kernel#warn API is different than the Warning.warn API, this tries to get similar behavior, but there are probably corner cases where the behavior is different. This makes str_end_with_asciichar in io.c no longer static so it can be called from error.c. [Feature #12944] Author: Jeremy Evans <code@jeremyevans.net> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57370 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-27io.c: fix race between read and closenobu
* io.c (io_fillbuf): fix race between read and close and bail out in the case the IO gets closed before the reading thread achieve the lock. [ruby-core:78845] [Bug #13076] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57224 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-27revert a part of r57199usa
* io.c (io_fillbuf): revert a part of r57199 because it broke IO#getch. see also [Bug #13076] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57206 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-27io.c: use io_close to close ARGFnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57204 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-27io.c: ARGF fd leaknobu
* io.c (argf_next_argv): fix leak of fd after breaking in #each method. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57203 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-26io.c: fix race between read and closenobu
* io.c (io_fillbuf): fix race between read and close, in the case the IO gets closed before the reading thread achieve the lock. [ruby-core:78845] [Bug #13076] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57199 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-22io.c: [DOC] update outdated documentation of ARGF.closerhe
As of Ruby 2.3, IO#close no longer raises IOError if the file is already closed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57149 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-20io.c: update argf linenonobu
* io.c (argf_rewind): rewind line number in non-global ARGF instance. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57125 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-20io.c: update argf linenonobu
* io.c (argf_block_call_line): update line number in non-global ARGF instance. [ruby-core:78728] [Bug #13051] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57124 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-05chomp optionnobu
* io.c (extract_getline_opts): extract chomp option. [Feature #12553] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56581 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-26[DOC] replace Fixnum with Integer [ci skip]nobu
* numeric.c: [DOC] update document for Integer class. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-21prefer rb_syserr_failnobu
* dir.c (dir_initialize, dir_read): prefer rb_syserr_fail over rb_sys_fail. * io.c (ruby_dup, rb_sysopen): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56464 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-13io.c: copy_stream to duplex IOnobu
* io.c (copy_stream_body): use IO to write to copy to duplex IO. http://twitter.com/knu/status/786505317974585344 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56416 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-11io.c: fix typonobu
* io.c (prep_io): fix typo of struct member name. [ruby-core:77550] [Bug #12829] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56393 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-10io.c: reduce isatty on Cygwin [ci skip]nobu
* io.c (prep_io): reduce isatty call (and its system call) on Cygwin. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56383 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-06io.c: use RB_INTEGER_TYPE_Pnobu
* io.c (fptr_finalize): use dedicated macro RB_INTEGER_TYPE_P. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56352 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-05* io.c: Fixed equivalent ruby code with core implemention.hsbt
[fix GH-1429][ci skip] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56344 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-08io.c: check if Integernobu
* io.c (rb_file_initialize): check if fd is an Integer but not a Fixnum. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56112 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-08replace fixnum by integer in documents.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56102 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-30* io.c (nogvl_fsync, nogvl_fdatasync): on Windows, just ignore if theusa
fd is associated to non-disk device. if call fsync and/or fdatasync with such fds, it causes Errno::EBADF exception and the behavior is incomatible with ruby 2.1 and earlier unintendedly introduced. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56036 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-29rb_funcallvnobu
* *.c: rename rb_funcall2 to rb_funcallv, except for extensions which are/will be/may be gems. [Fix GH-1406] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55773 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-07* io.c (rb_io_s_read): add description of pipes to the documentationshugo
of IO.read. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55610 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-07io.c: convert arguments just oncenobu
* io.c (rb_io_s_foreach, rb_io_s_readlines): convert arguments just once before reading, instead of conversions for each lines. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-28* addr2line.c: drop to support ATARI ST platform. It was discontinuedhsbt
more than two decades ago. [fix GH-1350] Patch by @cremno * include/ruby/ruby.h: ditto. * io.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55189 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-21Restore documentation of ARGFnobu
* io.c (Init_IO): [DOC] define dummy ARGF instead of ARGF.class to re-enable the generation of ARGF documentation. [Fix GH-1358] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55095 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-20fix build on no-fork-spawnv platformsnobu
* process.c (rb_execarg_commandline): build command line string from argument vector in rb_execarg. [ruby-core:75611] [Bug #12398] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55091 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-20io.c: conditionally used functionsnobu
* io.c (pipe_atexit): only used on Windows * io.c (rb_execarg_fixup_v): wrapper only used fork or spawnv is available. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55090 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-15io.c: use PRI_OFFT_PREFIX for off_tnobu
* io.c (do_io_advise): use configured PRI_OFFT_PREFIX instead of PRI_OFF_T_PREFIX to format off_t properly on Cygwin. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55009 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-07io.c: remove extra declarationsnobu
* io.c (rb_io_set_encoding): remove extra declarations, rb_std{in,out,err} are defined in this file. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54012 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-06io.c: fix output of Array [ci skip]nobu
* io.c (rb_obj_display): [DOC] fix output of Array, as Array#to_s is same as Array#inspect since 1.9. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54009 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-24parse without $.nobu
* io.c (rb_io_gets_internal): read one line from an IO without setting ARGF.lineno. * parse.y (lex_io_gets): use rb_io_gets_internal not to affect $. global variable. * ruby.c (load_file): no longer reset $. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53913 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-31io.c: rb_io_open_genericnobu
* io.c (rb_io_open_generic): split from rb_io_open without argument conversions. * io.c (rb_io_s_binread): get rid of unnecessary object creation and conversion. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53698 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-31io.c: constifynobu
* io.c (rb_file_open_generic, pipe_open, pipe_open_s): constify convconfig parameter. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53696 b2dd03c8-39d4-4d8f-98ff-823fe69b080e