Skip to content

Commit 923ba93

Browse files
committed
byteslice is always defined on Ruby 1.9
1 parent 936dd60 commit 923ba93

File tree

2 files changed

+3
-21
lines changed

2 files changed

+3
-21
lines changed

lib/rdoc/markup/parser.rb

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ def initialize
8080
@current_token = nil
8181
@debug = false
8282
@have_encoding = Object.const_defined? :Encoding
83-
@have_byteslice = ''.respond_to? :byteslice
8483
@input = nil
8584
@input_encoding = nil
8685
@line = 0
@@ -324,15 +323,7 @@ def build_verbatim margin
324323
# The character offset for the input string at the given +byte_offset+
325324

326325
def char_pos byte_offset
327-
if @have_byteslice then
328-
@input.byteslice(0, byte_offset).length
329-
elsif @have_encoding then
330-
matched = @binary_input[0, byte_offset]
331-
matched.force_encoding @input_encoding
332-
matched.length
333-
else
334-
byte_offset
335-
end
326+
@input.byteslice(0, byte_offset).length
336327
end
337328

338329
##
@@ -430,11 +421,6 @@ def setup_scanner input
430421
@line_pos = 0
431422
@input = input.dup
432423

433-
if @have_encoding and not @have_byteslice then
434-
@input_encoding = @input.encoding
435-
@binary_input = @input.force_encoding Encoding::BINARY
436-
end
437-
438424
@s = StringScanner.new input
439425
end
440426

@@ -556,4 +542,3 @@ def unget
556542
end
557543

558544
end
559-

test/test_rdoc_markup_parser.rb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ class TestRDocMarkupParser < RDoc::TestCase
88
def setup
99
super
1010

11-
@have_byteslice = ''.respond_to? :byteslice
12-
1311
@RMP = @RM::Parser
1412
end
1513

@@ -30,7 +28,7 @@ def test_char_pos
3028

3129
s.scan(/\S+/)
3230

33-
if @have_byteslice or @have_encoding then
31+
if @have_encoding then
3432
assert_equal 3, parser.char_pos(s.pos)
3533
else
3634
assert_equal 4, parser.char_pos(s.pos)
@@ -1626,7 +1624,7 @@ def test_token_pos
16261624

16271625
s.scan(/\S+/)
16281626

1629-
if @have_encoding or @have_byteslice then
1627+
if @have_encoding then
16301628
assert_equal [3, 0], parser.token_pos(s.pos)
16311629
else
16321630
assert_equal [4, 0], parser.token_pos(s.pos)
@@ -1678,4 +1676,3 @@ def util_parser
16781676
end
16791677

16801678
end
1681-

0 commit comments

Comments
 (0)