summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2017-07-26lib/net/imap.rb: support CHANGEDSINCE and MODSEQshugo
Patch by plehoux (Philippe-Antoine Lehoux). [ruby-core:64272] [Feature #10119] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59424 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-24optparse.rb: case-sensitive candidatenobu
* lib/optparse.rb (candidate): short options are case-sensitive by the default, should not match case-different options.. https://github.com/mernen/completion-ruby/pull/9#issuecomment-317287946 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59412 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-21optparse.rb: [DOC] fix keysnobu
* lib/optparse.rb (getopts): [DOC] parameter keys are strings, not symbols. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59383 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-20Use `unpack1` instead of `unpack` and `[0]`kazu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59381 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-20logger.rb: Fix handling prognamesonots
Because progname was memoized with ||= a logger call that involved outputting false would be nil. Example code: logger = Logger.new(STDOUT) logger.info(false) # => nil Perform an explicit nil check instead of ||= so that false will be output. patched by Gavin Miller <gavingmiller@gmail.com> [Fix GH-1667] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59380 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-19lib/net/pop.rb: support timeout for TLS handshakeshugo
Patch by ahorek (Pavel Rosický). [ruby-core:80490] [Feature #13389] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59373 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-19lib/net/imap.rb: Ignore trailing space for Microsoft Exchange Servershugo
Based on the patch by keysen (Jérémy Carlier). [ruby-core:81641] [Bug #13649] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59372 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-18webrick: fix SNI supportnormal
* lib/webrick/https.rb: check ssl context of virtual host. * lib/webrick/ssl.rb: ensure to return ssl context. * test/webrick/test_https.rb: test returned cert is correct. [Feature #13729][ruby-dev:50173] Author: Tietew <tietew@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59351 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-14Alias Set#to_s to #inspect [ruby-core:81753] [Feature #13676]knu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59332 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-12optparse.rb: get rid of evalnobu
* lib/optparse.rb: try Float() and Integer() instead of eval, which does too much things. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59312 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-07webrick: add Server Name Indication (SNI)normal
* lib/webrick/https.rb: servername_cb implementation. * lib/webrick/ssl.rb: abstract servername_cb. * test/webrick/test_https.rb: test. [ruby-dev:50165] [Feature #13729] Author: Tietew <tietew@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59281 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-06Fix DecimalInteger converting to octal bugnobu
Previously if the input started with a '0' then it will be converted as octal even though it has been specified as a decimal. This commit forces the number to be interpreted as a decimal. [ruby-core:81927] [Bug #13722] [Fix GH-1665] Author: william <william.mccumstie@outlook.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59273 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-05un.rb: use OpenSSL::PKey.read instead of OpenSSL::PKey::RSA.newrhe
Also, error out if --ssl-private-key option is not given, since specifying only the certificate makes no sense. [Feature #13714] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59268 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-05un.rb: support httpsnobu
* lib/un.rb: add https support. based on the patch by Flavio Castelli <flavio@castelli.name> in [ruby-core:81901]. [Feature #13714] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59265 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-24Delegate to `eql?` [Fix GH-1564]nobu
* lib/delegate.rb (eql?): Delegate to `eql?` of the inner object. based on the patch by giginet <giginet.net@gmail.com>. [ruby-core:76950] [Bug #12684] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59167 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-22Fix exception type in option type checkerglass
* lib/shell/system-command.rb (SystemCommand#initialize): `def_e2message` wraps error message, but does not define new exception * test/shell/test_command_processor.rb: add a test This patch is authored by Kenichi Kamiya <kachick1@gmail.com> close #1657 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59145 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-19Make string literal to frozen object on gemspec of defulte gems.hsbt
Added following gemspecs. * extensions: date, dbm, etc, fiddle, gdbm, sdbm, stringio, strscan, zlib * pure ruby libraries: cmath, csv, fileutils, scanf, webrick psych and rdoc is out of scope of this commit. I will merge after upstream was change to `frozen_string_literal: true`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59115 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-15Don't pollute toplevel by an IRB internal methoda_matsuda
There actually are some libraries that requires 'irb' such as byebug, and when 'irb' is required, it requires irb/src_encoding.rb, then it defines the toplevel default_src_encoding method that is visible from anywhere in the end users' apps. Here's a quick oneliner that shows what's happening. % ruby -rpry-byebug -e 'p private_methods(false)' [:include, :using, :define_method, :public, :private, :DelegateClass, :default_src_encoding] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59090 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-09Fix typo.a_matsuda
Patch by: Sarah Duve Signed-off-by: Akira Matsuda <ronnie@dio.jp> [Fix GH-1643] [ci skip] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59049 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-07rexml: add close tag check on end of document to StreamParserkou
[ruby-core:81593] [Bug #13636] Reported by Anton Sivakov. Thanks!!! git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59033 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-28suppress warning: ambiguous first argument; put parentheses or a space even ↵naruse
after `-' operator Introduced at r58905 http://rubyci.s3.amazonaws.com/ubuntu/ruby-trunk/log/20170526T153003Z.diff.html.gz git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58948 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-27erb.rb: Use str_uplus instead of rb_str_dupk0kubun
to skip unnecessary string allocation on frozen_string_literal: false. str_uplus can bypass calling rb_str_dup when OBJ_FROZEN is true. * Before erb_render 1.064 * Afete erb_render 0.909 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58916 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-26erb.rb: Tiny improvement of compiling costk0kubun
by reducing string allocation. * Before app_erb 0.687 * After app_erb 0.679 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58908 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-26erb.rb: [DOC] Follow compiled code's changek0kubun
introduced in r58905. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58907 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-26erb.rb: Generate static string with opt_str_uminusk0kubun
to skip object allocation for static string. We can't always enable frozen_string_literal pragma because we can't freeze string literals embedded by user for backward compatibility. So we need to use fstring for each static string. Since adding ".freeze" to string literals in #content_dump is slow on compiling, I used unary "-" operator instead. benchmark/bm_app_erb_render.rb: Added rendering-only benchmark to test rendering performance on production environment. This benchmark is created to reproduce the behavior on Sinatra (Tilt). Thus it doesn't use ERB#result to skip parsing compiled code. It doesn't use ERB#def_method too to regard `title` and `content` as local variables. If we use #def_method, `title` and `content` needs to be method call. I wanted to avoid it. This patch's benchmark results is: * Before app_erb_render 1.250 app_erb 0.704 * After app_erb_render 1.066 app_erb 0.686 This patch optimizes rendering performance (app_erb_render) without spoiling (total of rendering +) compiling performance (app_erb). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58905 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-26erb.rb: Use script encoding instead of force_encodingk0kubun
The original intention of introducing `_erbout.force_encoding` in r21170 was: - "returns a string in the same character encoding as the input string." - "When the input string has a magic comment, however, it returns a string in the encoding specified by the magic comment." And they are tested by test/erb/test_erb_m17n.rb well and this patch passes the test. Since magic comment is always added in ERB compiled code, using ''.dup instead of String.new will set correct encoding without calling force_encoding method. The benchmark results are: * Before $ ./ruby benchmark/run.rb --matzruby=./ruby -m bm_app_erb MatzRuby: ruby 2.5.0dev (2017-05-26 skip-force-enc.. 58903) [x86_64-linux] last_commit=Skip force_encoding in compiled code of erb Ruby: app_erb: matz 0.715 * After $ ./ruby benchmark/run.rb --matzruby=./ruby -m bm_app_erb MatzRuby: ruby 2.5.0dev (2017-05-26 skip-force-enc.. 58903) [x86_64-linux] last_commit=Skip force_encoding in compiled code of erb Ruby: app_erb: matz 0.672 And perf(1) results are: * Before $ sudo perf stat ./ruby benchmark/bm_app_erb.rb Performance counter stats for './ruby benchmark/bm_app_erb.rb': 709.571746 task-clock (msec) # 1.000 CPUs utilized 5 context-switches # 0.007 K/sec 1 cpu-migrations # 0.001 K/sec 1,337 page-faults # 0.002 M/sec 3,088,936,521 cycles # 4.353 GHz <not supported> stalled-cycles-frontend <not supported> stalled-cycles-backend 4,849,564,282 instructions # 1.57 insns per cycle 1,027,042,087 branches # 1447.411 M/sec 19,983,456 branch-misses # 1.95% of all branches 0.709747823 seconds time elapsed * After $ sudo perf stat ./ruby benchmark/bm_app_erb.rb Performance counter stats for './ruby benchmark/bm_app_erb.rb': 693.494673 task-clock (msec) # 1.000 CPUs utilized 7 context-switches # 0.010 K/sec 1 cpu-migrations # 0.001 K/sec 1,316 page-faults # 0.002 M/sec 3,025,639,349 cycles # 4.363 GHz <not supported> stalled-cycles-frontend <not supported> stalled-cycles-backend 4,694,848,271 instructions # 1.55 insns per cycle 994,496,704 branches # 1434.037 M/sec 19,693,239 branch-misses # 1.98% of all branches 0.693724345 seconds time elapsed [fix GH-1147] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58904 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-26* lib/uri/common.rb: [DOC] add rdoc to describesonots
URI.unescape is obsolete [ci-skip] [fix GH-1630] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58899 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-25erb.rb: Add ERB#result_with_hashk0kubun
[ruby-core:55985] [Feature #8631] [fix GH-1623] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58891 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-22lib/net/protocol.rb: account read_bytes before caller sees itnormal
Users may modify the chunk yielded to them in Net::HTTPResponse#read_body. This will allow users to reduce memory usage by calling String#clear on the buffer once they're done using it. * lib/net/protocol.rb (read): increment read_bytes earlier (read_all): ditto * test/net/http/test_httpresponse.rb (test_read_body_block_mod): new test git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58846 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-22net/imap: separate @continuation_request_exception from @exceptionshugo
Otherwise literal data will be sent even if NO response is returned because @exception is set to nil in receive_responses. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58844 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-22erb.rb: Skip creating regexpk0kubun
if stags and etags are not changed from default. :putobject insn (of regexp) will be used instead of :toregexp insn. This means that the regexp won't be compiled for every `SimpleScanner#scan` call. It may not be a good idea to apply this kind of optimization for all cases. But I applied this because it is default scanner and used frequently and has relatively large impact for benchmark like this: * Before app_erb 1.023 * After app_erb 0.781 This commit fixes only the bottleneck of performance regression introduced in r53412. For maintainability, I won't fix other small regressions like additional overhead of method calls. [ruby-core:73820] [Bug #12074] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58842 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-21lib/net/protocol: clear short-lived read buffernormal
Using a parallel Net::HTTP downloader, this reduced memory usage from around 120MB to 50MB on my 32-bit x86 system. * lib/net/protocol.rb (rbuf_fill): clear temporary buffer Test script I used: require 'net/http' require 'uri' require 'digest/sha1' url = 'http://80x24.org/git-i-forgot-to-pack/objects/pack/pack-97b25a76c03b489d4cbbd85b12d0e1ad28717e55.idx' uri = URI(url) use_ssl = "https" == uri.scheme thrs = 30.times.map do Thread.start do cur = Thread.current.object_id Net::HTTP.start(uri.host, uri.port, use_ssl: use_ssl) do |http| req = Net::HTTP::Get.new(uri) http.request(req) do |res| dig = Digest::SHA1.new res.read_body do |buf| dig.update(buf) #buf.clear # most Ruby programmers don't do this :< end warn "#{Time.now} #{cur} #{dig.hexdigest}\n" end end :done end end p thrs.map(&:value) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58840 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-21Remove redundant square bracketskazu
Use character class directly instead of character class in character class. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58827 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-20erb.rb: Allow trimming CR in all trim_modesk0kubun
to unify a behavior with r58823 and r58825. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58826 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-20erb.rb: Allow explicit trimming carriage returnk0kubun
when trim_mode is "-", for Windows environments. [ruby-core:39625] [Bug #5339] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58825 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-20erb.rb: Allow trimming carriage returnk0kubun
when trim_mode is "<>", for Windows environments. [Bug #11464] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58823 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-20erb.rb: Prevent potential unexpected rescuek0kubun
of LoadError in some method calls, not from `require "strscan"`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-20erb.rb: Drop unused scanner implementationk0kubun
Original `SimpleScanner` was used only in tests. Since `SimpleScanner` and `SimpleScanner2` work in the same way, I want to drop the one which can't be used in a normal situation. The only difference was `SimpleScanner` can be loaded without strscan dependency but I think there's no situation that strscan is unavailable because it's a standard library. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58819 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-20prime.rb: remove alias after timeout teststomar
* test/test_prime.rb: remove alias after timeout test. * lib/prime.rb: fix typo. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58813 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-20lib/prime: Fix primality of some large integers [#13492].marcandre
* lib/prime.rb: Use accurate sqrt to insure all factors are tested. Patch by Marcus Stollsteimer. * test/test_prime.rb: Adapt test for timeout git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58809 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-19Merge gemspec from ruby/fileutils.hsbt
* Replaced homepage option to source code location as github. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58808 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-19Define classes for r58800naruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58803 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-19Net::HTTP::STATUS_CODES is added as HTTP Status Code Repository [Misc #12935]naruse
Note that 418 I'm a teapot doesn't exist because RFC 2324 and RFC 7168 are not registered in IANA repository. https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58801 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-19Add more HTTP status classesnaruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58800 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-19Net::HTTP#start now pass :ENV to p_addr by default [Bug #13351]naruse
To avoid this, pass nil explicitly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58798 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-19tempfile.rb: do not call File.identical? on closed streamnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58794 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-19* remove trailing spaces.svn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58793 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-19net/imap: Net::IMAP#append should not block when NO response is receivedshugo
[ruby-dev:50129] [Bug#13579] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58792 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-19tempfile.rb: remove in Tempfile.createnobu
* lib/tempfile.rb (Tempfile.create): should not fail even if the temporary file has been removed in the block, just ignore. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58791 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-18Improve CSV parsing performance.hsbt
Patch by @joshpencheon (Josh Pencheon) [fix GH-1607] #### benchmark-ips results ``` trunk: Warming up -------------------------------------- 4.000 i/100ms Calculating ------------------------------------- 39.661 (±10.1%) i/s - 2.352k in 60.034781s with-patch: Warming up -------------------------------------- 5.000 i/100ms Calculating ------------------------------------- 60.521 (± 9.9%) i/s - 3.595k in 60.047157s ``` #### memory_profiler resuts ``` trunk: allocated memory by class ----------------------------------- 35588490 String 7454320 Array 294000 MatchData 37340 Regexp 11840 Hash 2400 CSV 1600 Proc 1280 Method 800 StringIO with-patch: allocated memory by class ----------------------------------- 18788490 String 3454320 Array 294000 MatchData 37340 Regexp 11840 Hash 2400 CSV 1600 Proc 1280 Method 800 StringIO ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58777 b2dd03c8-39d4-4d8f-98ff-823fe69b080e