@@ -170,7 +170,7 @@ def heredoc_queue
170170 # \v == vertical tab
171171 # \f == form feed
172172 # \p{Zs} == ASCII + Unicode non-linebreaking whitespace
173- WHITESPACE_RE = %r{[\t \v \f \p {Zs}]}
173+ WHITESPACE_RE = RUBY_VERSION == '1.8.7' ? %r{[ \t \v \f ]} : %r{[\t \v \f \p {Zs}]}
174174
175175 # Internal: Access the internal token storage.
176176 #
@@ -266,7 +266,7 @@ def tokenise(code)
266266 else
267267 heredoc_tag = heredoc_queue . shift
268268 heredoc_name = heredoc_tag [ %r{\A "?(.+?)"?(:.+?)?(/.*)?\Z } , 1 ]
269- str_contents = StringScanner . new ( code [ i + length ..-1 ] ) . scan_until ( %r{\| ?\s *-?\s *#{ heredoc_name } } )
269+ str_contents = StringScanner . new ( code [ ( i + length ) ..-1 ] ) . scan_until ( %r{\| ?\s *-?\s *#{ heredoc_name } } )
270270 interpolate_heredoc ( str_contents , heredoc_tag )
271271 length += str_contents . size
272272 end
@@ -282,8 +282,8 @@ def tokenise(code)
282282 unless heredoc_queue . empty?
283283 heredoc_tag = heredoc_queue . shift
284284 heredoc_name = heredoc_tag [ %r{\A "?(.+?)"?(:.+?)?(/.*)?\Z } , 1 ]
285- str_contents = StringScanner . new ( code [ i + length ..-1 ] ) . scan_until ( %r{\| ?\s *-?\s *#{ heredoc_name } } )
286- _ = code [ 0 ..i + length ] . split ( "\n " )
285+ str_contents = StringScanner . new ( code [ ( i + length ) ..-1 ] ) . scan_until ( %r{\| ?\s *-?\s *#{ heredoc_name } } )
286+ _ = code [ 0 ..( i + length ) ] . split ( "\n " )
287287 interpolate_heredoc ( str_contents , heredoc_tag )
288288 length += str_contents . size
289289 end
@@ -557,8 +557,8 @@ def get_heredoc_segment(string, eos_text, interpolate = true)
557557
558558 str = string . scan_until ( regexp )
559559 begin
560- str =~ %r{\A (?<value> .*?)(?<terminator> [$]+|\| ?\s *-?#{ Regexp . escape ( eos_text ) } )\Z }m
561- [ Regexp . last_match ( :value ) , Regexp . last_match ( :terminator ) ]
560+ str =~ %r{\A (.*?)([$]+|\| ?\s *-?#{ Regexp . escape ( eos_text ) } )\Z }m
561+ [ Regexp . last_match ( 1 ) , Regexp . last_match ( 2 ) ]
562562 rescue
563563 [ nil , nil ]
564564 end
0 commit comments