Skip to content

Commit d4a257e

Browse files
committed
We are not likely to ever merge from RubySL again, so no need for merge notes
1 parent bb637c9 commit d4a257e

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

lib/truffle/strscan.rb

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
# Modifications made by the Truffle team are:
2828
#
29-
# Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved. This
29+
# Copyright (c) 2017, 2019 Oracle and/or its affiliates. All rights reserved. This
3030
# code is released under a tri EPL/GPL/LGPL license. You can use it,
3131
# redistribute it and/or modify it under the terms of the:
3232
#
@@ -59,12 +59,10 @@ def pos=(n)
5959
alias_method :pointer=, :pos=
6060

6161
def [](n)
62-
# Truffle: no eager check
6362
if @match
64-
# Truffle: follow MRI
6563
raise TypeError, "no implicit conversion of #{n.class} into Integer" if Range === n
6664
str = @match[n]
67-
str.taint if @string.tainted? # Truffle: propagate taint
65+
str.taint if @string.tainted?
6866
str
6967
end
7068
end
@@ -75,7 +73,6 @@ def bol?
7573

7674
alias_method :beginning_of_line?, :bol?
7775

78-
# Truffle: added
7976
def charpos
8077
@string.byteslice(0, @pos).length
8178
end
@@ -105,7 +102,7 @@ def empty?
105102
end
106103

107104
def eos?
108-
raise ArgumentError, 'uninitialized StringScanner object' unless @string # Truffle
105+
raise ArgumentError, 'uninitialized StringScanner object' unless @string
109106
@pos >= @string.bytesize
110107
end
111108

@@ -114,7 +111,6 @@ def exist?(pattern)
114111
end
115112

116113
def get_byte
117-
# Truffle: correct get_byte with non-ascii strings
118114
_get_byte
119115
end
120116

@@ -139,7 +135,6 @@ def initialize(string, dup=false)
139135
reset_state
140136
end
141137

142-
# Truffle: fix to use self.class instead of hard-coded StringScanner
143138
def inspect
144139
if defined? @string
145140
if eos?
@@ -178,7 +173,7 @@ def match?(pattern)
178173
def matched
179174
if @match
180175
matched = @match.to_s
181-
matched.taint if @string.tainted? # Truffle: propagate taint
176+
matched.taint if @string.tainted?
182177
matched
183178
end
184179
end
@@ -293,8 +288,6 @@ def unscan
293288
def peek(len)
294289
raise ArgumentError if len < 0
295290
return '' if len.zero?
296-
297-
# Truffle: correctly use byte offsets and no rescue
298291
@string.byteslice(pos, len)
299292
end
300293

@@ -307,7 +300,7 @@ def _scan(pattern, advance_pos, getstr, headonly)
307300
unless pattern.kind_of? Regexp
308301
raise TypeError, "bad pattern argument: #{pattern.inspect}"
309302
end
310-
raise ArgumentError, 'uninitialized StringScanner object' unless @string # Truffle
303+
raise ArgumentError, 'uninitialized StringScanner object' unless @string
311304

312305
@match = nil
313306

@@ -337,7 +330,6 @@ def _scan(pattern, advance_pos, getstr, headonly)
337330
end
338331
private :_scan
339332

340-
# Truffle: correct get_byte with non-ascii strings
341333
def _get_byte
342334
if eos?
343335
@match = nil

0 commit comments

Comments
 (0)