Skip to content

Commit fb11310

Browse files
author
devkadirselcuk
authored
Merge pull request ruby#71 from ruby/master
[pull] master from ruby:master
2 parents 614691a + 23a84d5 commit fb11310

File tree

26 files changed

+214
-413
lines changed

26 files changed

+214
-413
lines changed

doc/rdoc/markup_reference.rb

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,37 @@
662662
# # [<tt>Two words</tt>] <tt>Two words</tt> in labeled list item.
663663
# # ====== <tt>Two words</tt> in heading
664664
#
665+
# ==== Escaping Text Markup
666+
#
667+
# Text markup can be escaped with a backslash, as in \<tt>, which was obtained
668+
# with <tt>\\<tt></tt>. Except in verbatim sections and between \<tt> tags,
669+
# to produce a backslash you have to double it unless it is followed by a
670+
# space, tab or newline. Otherwise, the HTML formatter will discard it, as it
671+
# is used to escape potential links:
672+
#
673+
# * The \ must be doubled if not followed by white space: \\.
674+
# * But not in \<tt> tags: in a Regexp, <tt>\S</tt> matches non-space.
675+
# * This is a link to {ruby-lang}[https://www.ruby-lang.org].
676+
# * This is not a link, however: \{ruby-lang.org}[https://www.ruby-lang.org].
677+
# * This will not be linked to \RDoc::RDoc#document
678+
#
679+
# generates:
680+
#
681+
# * The \ must be doubled if not followed by white space: \\.
682+
# * But not in \<tt> tags: in a Regexp, <tt>\S</tt> matches non-space.
683+
# * This is a link to {ruby-lang}[https://www.ruby-lang.org]
684+
# * This is not a link, however: \{ruby-lang.org}[https://www.ruby-lang.org]
685+
# * This will not be linked to \RDoc::RDoc#document
686+
#
687+
# Inside \<tt> tags, more precisely, leading backslashes are removed only if
688+
# followed by a markup character (<tt><*_+</tt>), a backslash, or a known link
689+
# reference (a known class or method). So in the example above, the backslash
690+
# of <tt>\S</tt> would be removed if there was a class or module named +S+ in
691+
# the current context.
692+
#
693+
# This behavior is inherited from RDoc version 1, and has been kept for
694+
# compatibility with existing RDoc documentation.
695+
#
665696
# ==== Character Conversions
666697
#
667698
# Certain combinations of characters may be converted to special characters;

enumerator.c

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1796,7 +1796,8 @@ lazy_initialize(int argc, VALUE *argv, VALUE self)
17961796
* Expands +lazy+ enumerator to an array.
17971797
* See Enumerable#to_a.
17981798
*/
1799-
static VALUE lazy_to_a(VALUE self)
1799+
static VALUE
1800+
lazy_to_a(VALUE self)
18001801
{
18011802
}
18021803
#endif
@@ -2753,7 +2754,8 @@ lazy_with_index(int argc, VALUE *argv, VALUE obj)
27532754
*
27542755
* Like Enumerable#chunk, but chains operation to be lazy-evaluated.
27552756
*/
2756-
static VALUE lazy_chunk(VALUE self)
2757+
static VALUE
2758+
lazy_chunk(VALUE self)
27572759
{
27582760
}
27592761

@@ -2763,7 +2765,8 @@ static VALUE lazy_chunk(VALUE self)
27632765
*
27642766
* Like Enumerable#chunk_while, but chains operation to be lazy-evaluated.
27652767
*/
2766-
static VALUE lazy_chunk_while(VALUE self)
2768+
static VALUE
2769+
lazy_chunk_while(VALUE self)
27672770
{
27682771
}
27692772

@@ -2774,7 +2777,8 @@ static VALUE lazy_chunk_while(VALUE self)
27742777
*
27752778
* Like Enumerable#slice_after, but chains operation to be lazy-evaluated.
27762779
*/
2777-
static VALUE lazy_slice_after(VALUE self)
2780+
static VALUE
2781+
lazy_slice_after(VALUE self)
27782782
{
27792783
}
27802784

@@ -2785,7 +2789,8 @@ static VALUE lazy_slice_after(VALUE self)
27852789
*
27862790
* Like Enumerable#slice_before, but chains operation to be lazy-evaluated.
27872791
*/
2788-
static VALUE lazy_slice_before(VALUE self)
2792+
static VALUE
2793+
lazy_slice_before(VALUE self)
27892794
{
27902795
}
27912796

@@ -2795,7 +2800,8 @@ static VALUE lazy_slice_before(VALUE self)
27952800
*
27962801
* Like Enumerable#slice_when, but chains operation to be lazy-evaluated.
27972802
*/
2798-
static VALUE lazy_slice_when(VALUE self)
2803+
static VALUE
2804+
lazy_slice_when(VALUE self)
27992805
{
28002806
}
28012807
# endif
@@ -3562,7 +3568,8 @@ product_each(VALUE obj, struct product_state *pstate)
35623568
VALUE eobj = RARRAY_AREF(enums, pstate->index);
35633569

35643570
rb_block_call(eobj, id_each_entry, 0, NULL, product_each_i, (VALUE)pstate);
3565-
} else {
3571+
}
3572+
else {
35663573
rb_funcallv(pstate->block, id_call, pstate->argc, pstate->argv);
35673574
}
35683575

@@ -3677,7 +3684,8 @@ enumerator_s_product(VALUE klass, VALUE enums)
36773684

36783685
if (rb_block_given_p()) {
36793686
return enum_product_run(obj, rb_block_proc());
3680-
} else {
3687+
}
3688+
else {
36813689
return obj;
36823690
}
36833691
}

ext/extmk.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,17 @@ def system(*args)
6666

6767
def atomic_write_open(filename)
6868
filename_new = filename + ".new.#$$"
69-
open(filename_new, "wb") do |f|
69+
clean = false
70+
File.open(filename_new, "wbx") do |f|
71+
clean = true
7072
yield f
7173
end
7274
if File.binread(filename_new) != (File.binread(filename) rescue nil)
7375
File.rename(filename_new, filename)
74-
else
76+
clean = false
77+
end
78+
ensure
79+
if clean
7580
File.unlink(filename_new)
7681
end
7782
end

include/ruby/internal/encoding/encoding.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -643,10 +643,12 @@ rb_enc_code_to_mbclen(int c, rb_encoding *enc)
643643
* Identical to rb_enc_uint_chr(), except it writes back to the passed buffer
644644
* instead of allocating one.
645645
*
646-
* @param[in] c Code point.
647-
* @param[out] buf Return buffer.
648-
* @param[in] enc Target encoding scheme.
649-
* @post `c` is encoded according to `enc`, then written to `buf`.
646+
* @param[in] c Code point.
647+
* @param[out] buf Return buffer.
648+
* @param[in] enc Target encoding scheme.
649+
* @retval <= 0 `c` is invalid in `enc`.
650+
* @return otherwise Number of bytes written to `buf`.
651+
* @post `c` is encoded according to `enc`, then written to `buf`.
650652
*
651653
* @internal
652654
*

io.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11776,12 +11776,16 @@ seek_before_access(VALUE argp)
1177611776
* IO.read('| cat t.txt')
1177711777
* # => "First line\nSecond line\n\nThird line\nFourth line\n"
1177811778
*
11779-
* With only argument +path+ given, reads and returns the entire content
11779+
* With only argument +path+ given, reads in text mode and returns the entire content
1178011780
* of the file at the given path:
1178111781
*
1178211782
* IO.read('t.txt')
1178311783
* # => "First line\nSecond line\n\nThird line\nFourth line\n"
1178411784
*
11785+
* On Windows, text mode can terminate reading and leave bytes in the file
11786+
* unread when encountering certain special bytes. Consider using
11787+
* IO.binread if all bytes in the file should be read.
11788+
*
1178511789
* For both forms, command and path, the remaining arguments are the same.
1178611790
*
1178711791
* With argument +length+, returns +length+ bytes if available:
@@ -14500,9 +14504,11 @@ set_LAST_READ_LINE(VALUE val, ID _x, VALUE *_y)
1450014504
* Either of the following may be suffixed to any of the string read/write modes above:
1450114505
*
1450214506
* - <tt>'t'</tt>: Text data; sets the default external encoding to +Encoding::UTF_8+;
14503-
* on Windows, enables conversion between EOL and CRLF.
14507+
* on Windows, enables conversion between EOL and CRLF and enables interpreting +0x1A+
14508+
* as an end-of-file marker.
1450414509
* - <tt>'b'</tt>: Binary data; sets the default external encoding to +Encoding::ASCII_8BIT+;
14505-
* on Windows, suppresses conversion between EOL and CRLF.
14510+
* on Windows, suppresses conversion between EOL and CRLF and disables interpreting +0x1A+
14511+
* as an end-of-file marker.
1450614512
*
1450714513
* If neither is given, the stream defaults to text data.
1450814514
*

lib/bundler/definition.rb

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -739,16 +739,24 @@ def converge_specs(specs)
739739
specs[dep].any? {|s| s.satisfies?(dep) && (!dep.source || s.source.include?(dep.source)) }
740740
end
741741

742+
@specs_that_changed_sources = []
743+
742744
specs.each do |s|
743-
# Replace the locked dependency's source with the equivalent source from the Gemfile
744745
dep = @dependencies.find {|d| s.satisfies?(d) }
745746

746-
s.source = (dep && dep.source) || sources.get(s.source) || sources.default_source
747+
# Replace the locked dependency's source with the equivalent source from the Gemfile
748+
s.source = if dep && dep.source
749+
gemfile_source = dep.source
750+
lockfile_source = s.source
751+
752+
@specs_that_changed_sources << s if gemfile_source != lockfile_source
747753

748-
next if @unlock[:sources].include?(s.source.name)
754+
gemfile_source
755+
else
756+
sources.get_with_fallback(s.source)
757+
end
749758

750-
# If the spec is from a path source and it doesn't exist anymore
751-
# then we unlock it.
759+
next if @unlock[:sources].include?(s.source.name)
752760

753761
# Path sources have special logic
754762
if s.source.instance_of?(Source::Path) || s.source.instance_of?(Source::Gemspec)
@@ -824,9 +832,18 @@ def source_requirements
824832
end
825833
source_requirements[:default_bundler] = source_requirements["bundler"] || sources.default_source
826834
source_requirements["bundler"] = sources.metadata_source # needs to come last to override
835+
verify_changed_sources!
827836
source_requirements
828837
end
829838

839+
def verify_changed_sources!
840+
@specs_that_changed_sources.each do |s|
841+
if s.source.specs.search(s.name).empty?
842+
raise GemNotFound, "Could not find gem '#{s.name}' in #{s.source}"
843+
end
844+
end
845+
end
846+
830847
def requested_groups
831848
values = groups - Bundler.settings[:without] - @optional_groups + Bundler.settings[:with]
832849
values &= Bundler.settings[:only] unless Bundler.settings[:only].empty?

lib/bundler/lazy_specification.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,6 @@ def materialize_for_installation
9393
__materialize__(candidates)
9494
end
9595

96-
def materialize_for_resolution
97-
return self unless Gem::Platform.match_spec?(self)
98-
99-
candidates = source.specs.search(self)
100-
101-
__materialize__(candidates)
102-
end
103-
10496
def __materialize__(candidates)
10597
@specification = begin
10698
search = candidates.reverse.find do |spec|

lib/bundler/resolver.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ def self.resolve(requirements, source_requirements = {}, base = [], gem_version_
2828
def initialize(source_requirements, base, gem_version_promoter, additional_base_requirements, platforms, metadata_requirements)
2929
@source_requirements = source_requirements
3030
@metadata_requirements = metadata_requirements
31+
@base = base
3132
@resolver = Molinillo::Resolver.new(self, self)
3233
@search_for = {}
3334
@base_dg = Molinillo::DependencyGraph.new
34-
@base = base.materialized_for_resolution do |ls|
35+
base.each do |ls|
3536
dep = Dependency.new(ls.name, ls.version)
3637
@base_dg.add_vertex(ls.name, DepProxy.get_proxy(dep, ls.platform), true)
3738
end

lib/bundler/source_list.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ def get(source)
101101
source_list_for(source).find {|s| equivalent_source?(source, s) }
102102
end
103103

104+
def get_with_fallback(source)
105+
get(source) || default_source
106+
end
107+
104108
def lock_sources
105109
lock_other_sources + lock_rubygems_sources
106110
end

lib/bundler/spec_set.rb

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,6 @@ def materialized_for_all_platforms
8282
end
8383
end
8484

85-
def materialized_for_resolution
86-
materialized = @specs.map do |s|
87-
spec = s.materialize_for_resolution
88-
yield spec if spec
89-
spec
90-
end.compact
91-
SpecSet.new(materialized)
92-
end
93-
9485
def incomplete_ruby_specs?(deps)
9586
self.class.new(self.for(deps, true, [Gem::Platform::RUBY])).incomplete_specs.any?
9687
end

0 commit comments

Comments
 (0)