Currently `Ripper.slice` raises a FrozenError
```ruby
require 'ripper'
p Ripper.slice('foo', 'ident')
```
```
/path/to/g/lib/ruby/2.6.0/ripper/lexer.rb:193:in `concat': can't modify frozen String (FrozenError)
from /path/to/g/lib/ruby/2.6.0/ripper/lexer.rb:193:in `block in compile'
from /path/to/g/lib/ruby/2.6.0/ripper/lexer.rb:190:in `scan'
from /path/to/g/lib/ruby/2.6.0/ripper/lexer.rb:190:in `compile'
from /path/to/g/lib/ruby/2.6.0/ripper/lexer.rb:169:in `initialize'
from /path/to/g/lib/ruby/2.6.0/ripper/lexer.rb:151:in `new'
from /path/to/g/lib/ruby/2.6.0/ripper/lexer.rb:151:in `token_match'
from /path/to/g/lib/ruby/2.6.0/ripper/lexer.rb:144:in `slice'
from /tmp/tmp.kb4cnhvum2/test.rb:2:in `<main>'
```
This patch will fix the problem.
[Fix GH-1837]
From: Masataka Pocke Kuwabara <kuwabara@pocke.me>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62743 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y: use tSP same as ripper instead of tSPACE.
[ruby-core:86080] [Bug #14597]
* ext/ripper/eventids2.c: tSP is defined in ripper.c now.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62727 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ext/openssl/extconf.rb: on Windows search winsock library
always, regardless pkg-config. direct use of winsock is not
region of OpenSSL. [ruby-core:85895] [Bug #14568]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62637 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Also, as it's in the middle of the list of 4 arguments, 3rd and 4th arguments
(trim_mode, eoutvar) are changed to keyword arguments.
Old ways to specify arguments are deprecated and warned now.
bin/erb: deprecate -S option.
We'll remove all of deprecated ones at Ruby 2.7+.
enc/make_encmake.rb: stopped using deprecated interface
ext/etc/mkconstants.rb: ditto
ext/socket/mkconstants.rb: ditto
sample/ripper/ruby2html.rb: ditto
spec/ruby/library/erb/defmethod/def_erb_method_spec.rb: ditto
spec/ruby/library/erb/new_spec.rb: ditto
test/erb/test_erb.rb: ditto
test/erb/test_erb_command.rb: ditto
tool/generic_erb.rb: ditto
tool/ruby_vm/helpers/dumper.rb: ditto
tool/transcode-tblgen.rb: ditto
lib/rdoc/erbio.rb: ditto
lib/rdoc/generator/darkfish.rb: ditto
[Feature #14256]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62529 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Fixes: r62450 (commit 1aaeeb326e)
("long long is a C99ism")
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62453 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
so SIZEOF_LONG_LONG is not always available.
We have to check its defined?-ness before using.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62450 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ext/socket/lib/socket.rb (Addrinfo#connect_internal): make
protected for Addrinfo#connect_to, instead of private and send.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62449 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
clang 5.+ (tested clang 7.0.0) seems to be attempting division-by-zero
and giving a very large number for static args to rb_funcall.
* include/ruby/ruby.h (rb_varargs_bad_length): relax check for clang
* ext/-test-/funcall/funcall.c: renamed from passing_block.c
define extra_args_name function
* test/-ext-/funcall/test_funcall.rb: new test
[ruby-core:85266] [Bug #14425]
From: Eric Wong <e@80x24.org>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62116 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ext/openssl/lib/openssl/buffering.rb (do_write, puts): output
methods should not be affected by the input record separator.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62038 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ext/socket/getaddrinfo.c (ai_errlist): used only if gai_strerror
is missing.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62015 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
To avoid the unspecified behavior (the evaluation order of arguments).
In `$$ = foo(bar(), baz());`, it is unspecified which `bar` or `baz` is
called earlier.
This commit changes the code to `v1=bar(); v2=baz(); $$ = foo();`.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61991 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
I thought this trick was needed because the result of var_field was
passed to different arguments, as follows:
```
$1 = var_field(p, $1);
$$ = backref_assign_error(p, $1, $1, &@$);
```
Currently the DSL supports that one result is passed to one argument.
However, after the refactoring, I found that `backref_assign_error`
uses only one `$1`.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
`foo!(...)` means Ripper event, and `foo(...)` means C function/macro
call. This is for fail-safe; if I forget `!` accidentally, it would
fail to compile, instead of wrongly adding a new Ripper event.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61962 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Instead of `_foo`. This makes it useful to do word boundary search of
the editor.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61957 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Currently, parse.y actions are hard to read and write because the code
has double meaning (for core parser and for ripper). I think that, if
it is easy to write ripper's code shortly and simply, the double meaning
trick is not needed.
For the sake, this change adds a simple DSL for ripper's code. For
example, in parse.y, we can write:
/*% ripper: stmts_add(stmts_new, void_stmt) %*/
instead of:
$$ = dispatch2(stmts_add, dispatch0(stmts_new),
dispatch0(void_stmt));
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61952 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
NODE_FOR was used both for "for"-statement itself and for
multi-assignment of for-statement (for x, y, in...end).
This change separates the two purposes, NODE_FOR for the former, and
newly introduced NODE_FOR_MASGN for the latter.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61871 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test/-ext-/ast/test_ast.rb: Add tests for Node
code locations. This file tests
1. There are no Node whose code location is default
value (#test_not_cared)
2. There are no Node whose children's code locations
exceed parent's code location (#test_ranges)
* ext/-test-/ast/ast.c, ext/-test-/ast/extconf.rb:
Define AST module to help tests.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61859 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test/-ext-/win32/test_console_attr.rb (reverse_video): fix test
when reverse video is set.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61853 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
For garbage-concious users who use the `outbuf' argument of
`readpartial' to supply a destination buffer, this provides
a drastic reduction in garbage when inflating large inputs
in a streaming fashion.
This results in a anonymous RSS reduction in the reader
similar to the reduction in the writer from r61631.
Results using the test script from r61631
<https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61631>
Before:
writer 7.359999 0.000000 7.359999 ( 7.360639)
writer RssAnon: 4040 kB
reader 6.346667 0.070000 6.416667 ( 7.387654)
reader RssAnon: 98272 kB
After:
writer 7.309999 0.000000 7.309999 ( 7.310651)
writer RssAnon: 4048 kB
reader 6.146666 0.003333 6.149999 ( 7.334868)
reader RssAnon: 4300 kB
* ext/zlib/zlib.c (struct read_raw_arg): new struct
(gzfile_read_raw_partial): use read_raw_arg
(gzfile_read_raw_rescue): ditto
(gzfile_read_raw): accept outbuf, use read_raw_arg
(gzfile_read_raw_ensure): accept outbuf
(gzfile_read_header): ditto
(gzfile_check_footer): ditto
(gzfile_read_more): ditto
(gzfile_read_raw_until_zero): adjust for changes
(gzfile_fill): ditto
(gzfile_readpartial): ditto
(gzfile_read_all): ditto
(gzfile_getc): ditto
(gzfile_reader_end_run): ditto
(gzfile_reader_get_unused): ditto
(rb_gzreader_initialize): ditto
(gzreader_skip_linebreaks): ditto
(gzreader_gets): ditto
(zlib_gunzip_run): ditto
[ruby-core:84660] [Feature #14319]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61665 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Zlib::GzipWriter generated large amounts of garbage from
(struct zstream).input. Reuse the .input field when it is
hidden, and recycle it when its lifetime is over. This change
alone reduced memory usage of the writer from 90MB to 4.5MB.
For the detached buffer of compressed data used by
gzfile_write_raw, we can only clear the string (not recycle it)
since user code may hold references to it (but the data would be
clobbered, anyways). This reduced memory usage slightly by
around 0.5MB (because it's smaller compressed data).
Combined, these changes reduce the anonymous RSS memory of a
dedicated writer process from over 90MB to under 4MB.
before:
# user system total real
writer 7.823332 0.053333 7.876665 ( 7.881464)
writer RssAnon: 92944 kB
reader 6.969999 0.076666 7.046665 ( 7.906377)
reader RssAnon: 109820 kB
after:
writer 7.359999 0.000000 7.359999 ( 7.360639)
writer RssAnon: 4040 kB
reader 6.346667 0.070000 6.416667 ( 7.387654)
reader RssAnon: 98272 kB
Script used:
-------
require 'zlib'
require 'benchmark'
nr = 16384 * 2
def stats(pfx, bm)
str = "#{bm}#{File.readlines("/proc/#$$/status").grep(/^RssAnon:/)[0]}"
puts str.gsub!(/^/m, pfx)
end
rd, wr = IO.pipe
pid = fork do
buf = ((0..255).map(&:chr).join * 128).freeze
rd.close
gzip = Zlib::GzipWriter.new(wr)
bm = Benchmark.measure do
nr.times { gzip.write(buf) }
gzip.close
wr.close
end
stats('writer ', bm)
end
wr.close
buf = ''
gunzip = Zlib::GzipReader.new(rd)
n = 0
bm = Benchmark.measure do
begin
gunzip.readpartial(16384, buf)
n += buf.size
rescue EOFError
break
end while true
end
stats('reader ', bm)
Process.waitall
-------
* ext/zlib/zlib.c (zstream_discard_input): reuse or recycle hidden input
(zstream_reset_input): clear hidden input
(zstream_run): detach input and recycle after use
(gzfile_write_raw): clear buffer after write
[ruby-core:84638] [Feature #14315]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61631 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
No need to reveal strings freshly created with rb_str_new.
* ext/zlib/zlib.c (zstream_detach_input): remove redundant call
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61612 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
NODE_PRELUDE contains a `BEGIN` node, a main node, and compile_option.
This node is assumed that it must be located immediately under the root
NODE_SCOPE, but this strange assumption is not so good, IMO.
This change removes the assumtion; it integrates the former two nodes by
block_append, and moves compile_option into rb_ast_body_t.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61610 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
New IMEMO types were introduced, this just fixes the function that
converts the type to support the new types.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61377 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
It version changed fallback option to keywoad argument
on `Yaml.load` method. It break backword compatiblity.
see detailed discuttion: https://github.com/ruby/psych/issues/340
From: SHIBATA Hiroshi <hsbt@ruby-lang.org>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61336 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
But we couldn't ship strscan (and stringio) gem. Because rubygems.org
still masked them.
https://github.com/rubygems/rubygems.org/pull/1696
I'm going to ship them after it deployed.
From: SHIBATA Hiroshi <hsbt@ruby-lang.org>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61333 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
It needs to support header file installation and uninstallation.
But current RubyGems didn't support it feature yet.
From: SHIBATA Hiroshi <hsbt@ruby-lang.org>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61332 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* tool/gperf.sed: comment out arguments part only, to keep the
following declarations static. [Feature #13883]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61282 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ext/ripper/lib/ripper/lexer.rb (Ripper::Lexer): added allbits?,
anybits? and nobits? methods, as well as Integer. a patch by
aycabta. [Feature #14170]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61205 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* tool/gperf.sed: extracted sed commands to a script. ANSI-C code
produced by gperf 3.1 declares length arguments as `size_t`. it
causes conflict with existing declarations, and needs casts for
a local variable and return statements.
[Feature #13883]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61076 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This change makes method coverage result have not only first lineno of
method defintion, but also code range (i.e. first lineno, first column,
last lineno, and last column).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61026 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This change makes each ISeq keep NODE's code range. This information is
needed for method coverage.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61025 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Traditionally, method coverage measurement was implemented by inserting
`trace2` instruction to the head of method iseq. So, it just measured
methods defined by `def` keyword.
This commit drastically changes the measuring mechanism of method
coverage; at `RUBY_EVENT_CALL`, it keeps a hash from rb_method_entry_t*
to runs (i.e., it counts the runs per method entry), and at
`Coverage.result`, it creates the result hash by enumerating all
`rb_method_entry_t*` objects (by `ObjectSpace.each_object`).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61023 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ext/socket/ifaddr.c (ifaddr_memsize): do not count the whole
rb_ifaddr_t array for each elements. the header size is
included in the first element for the time being.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61006 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ext/socket/ifaddr.c (struct rb_ifaddr_tag): removed set but
unused member root.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61001 b2dd03c8-39d4-4d8f-98ff-823fe69b080e