26
26
27
27
# Modifications made by the Truffle team are:
28
28
#
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
30
30
# code is released under a tri EPL/GPL/LGPL license. You can use it,
31
31
# redistribute it and/or modify it under the terms of the:
32
32
#
@@ -59,12 +59,10 @@ def pos=(n)
59
59
alias_method :pointer= , :pos=
60
60
61
61
def []( n )
62
- # Truffle: no eager check
63
62
if @match
64
- # Truffle: follow MRI
65
63
raise TypeError , "no implicit conversion of #{ n . class } into Integer" if Range === n
66
64
str = @match [ n ]
67
- str . taint if @string . tainted? # Truffle: propagate taint
65
+ str . taint if @string . tainted?
68
66
str
69
67
end
70
68
end
@@ -75,7 +73,6 @@ def bol?
75
73
76
74
alias_method :beginning_of_line? , :bol?
77
75
78
- # Truffle: added
79
76
def charpos
80
77
@string . byteslice ( 0 , @pos ) . length
81
78
end
@@ -105,7 +102,7 @@ def empty?
105
102
end
106
103
107
104
def eos?
108
- raise ArgumentError , 'uninitialized StringScanner object' unless @string # Truffle
105
+ raise ArgumentError , 'uninitialized StringScanner object' unless @string
109
106
@pos >= @string . bytesize
110
107
end
111
108
@@ -114,7 +111,6 @@ def exist?(pattern)
114
111
end
115
112
116
113
def get_byte
117
- # Truffle: correct get_byte with non-ascii strings
118
114
_get_byte
119
115
end
120
116
@@ -139,7 +135,6 @@ def initialize(string, dup=false)
139
135
reset_state
140
136
end
141
137
142
- # Truffle: fix to use self.class instead of hard-coded StringScanner
143
138
def inspect
144
139
if defined? @string
145
140
if eos?
@@ -178,7 +173,7 @@ def match?(pattern)
178
173
def matched
179
174
if @match
180
175
matched = @match . to_s
181
- matched . taint if @string . tainted? # Truffle: propagate taint
176
+ matched . taint if @string . tainted?
182
177
matched
183
178
end
184
179
end
@@ -293,8 +288,6 @@ def unscan
293
288
def peek ( len )
294
289
raise ArgumentError if len < 0
295
290
return '' if len . zero?
296
-
297
- # Truffle: correctly use byte offsets and no rescue
298
291
@string . byteslice ( pos , len )
299
292
end
300
293
@@ -307,7 +300,7 @@ def _scan(pattern, advance_pos, getstr, headonly)
307
300
unless pattern . kind_of? Regexp
308
301
raise TypeError , "bad pattern argument: #{ pattern . inspect } "
309
302
end
310
- raise ArgumentError , 'uninitialized StringScanner object' unless @string # Truffle
303
+ raise ArgumentError , 'uninitialized StringScanner object' unless @string
311
304
312
305
@match = nil
313
306
@@ -337,7 +330,6 @@ def _scan(pattern, advance_pos, getstr, headonly)
337
330
end
338
331
private :_scan
339
332
340
- # Truffle: correct get_byte with non-ascii strings
341
333
def _get_byte
342
334
if eos?
343
335
@match = nil
0 commit comments