Skip to content

Commit fca27d7

Browse files
committed
Regenerate literals with updated kpeg
This kpeg does not emit trailing whitespace which will prevent nobu from getting free commits when he cleans up whitespace in ruby trunk.
1 parent 3210043 commit fca27d7

File tree

2 files changed

+29
-23
lines changed

2 files changed

+29
-23
lines changed

lib/rdoc/markdown/literals_1_8.rb

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
##
44
# Provides Literals appropriate for your ruby version.
55
#--
6-
# This set of literals is for ruby 1.8 regular expressions.
6+
# This set of literals is for Ruby 1.8 regular expressions.
77
class RDoc::Markdown::Literals
88
# :stopdoc:
99

@@ -19,8 +19,7 @@ def initialize(str, debug=false)
1919
# Prepares for parsing +str+. If you define a custom initialize you must
2020
# call this method before #parse
2121
def setup_parser(str, debug=false)
22-
@string = str
23-
@pos = 0
22+
set_string str, 0
2423
@memoizations = Hash.new { |h,k| h[k] = {} }
2524
@result = nil
2625
@failed_rule = nil
@@ -33,7 +32,6 @@ def setup_parser(str, debug=false)
3332
attr_reader :failing_rule_offset
3433
attr_accessor :result, :pos
3534

36-
3735
def current_column(target=pos)
3836
if c = string.rindex("\n", target-1)
3937
return target - c - 1
@@ -67,6 +65,13 @@ def get_text(start)
6765
@string[start..@pos-1]
6866
end
6967

68+
# Sets the string and current parsing position for the parser.
69+
def set_string string, pos
70+
@string = string
71+
@string_size = string ? string.size : 0
72+
@pos = pos
73+
end
74+
7075
def show_pos
7176
width = 10
7277
if @pos < width
@@ -173,19 +178,19 @@ def scan(reg)
173178
return nil
174179
end
175180

176-
if "".respond_to? :getbyte
181+
if "".respond_to? :ord
177182
def get_byte
178-
if @pos >= @string.size
183+
if @pos >= @string_size
179184
return nil
180185
end
181186

182-
s = @string.getbyte @pos
187+
s = @string[@pos].ord
183188
@pos += 1
184189
s
185190
end
186191
else
187192
def get_byte
188-
if @pos >= @string.size
193+
if @pos >= @string_size
189194
return nil
190195
end
191196

@@ -234,8 +239,7 @@ def external_invoke(other, rule, *args)
234239
old_pos = @pos
235240
old_string = @string
236241

237-
@pos = other.pos
238-
@string = other.string
242+
set_string other.string, other.pos
239243

240244
begin
241245
if val = __send__(rule, *args)
@@ -246,8 +250,7 @@ def external_invoke(other, rule, *args)
246250
end
247251
val
248252
ensure
249-
@pos = old_pos
250-
@string = old_string
253+
set_string old_string, old_pos
251254
end
252255
end
253256

lib/rdoc/markdown/literals_1_9.rb

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ def initialize(str, debug=false)
2323
# Prepares for parsing +str+. If you define a custom initialize you must
2424
# call this method before #parse
2525
def setup_parser(str, debug=false)
26-
@string = str
27-
@pos = 0
26+
set_string str, 0
2827
@memoizations = Hash.new { |h,k| h[k] = {} }
2928
@result = nil
3029
@failed_rule = nil
@@ -37,7 +36,6 @@ def setup_parser(str, debug=false)
3736
attr_reader :failing_rule_offset
3837
attr_accessor :result, :pos
3938

40-
4139
def current_column(target=pos)
4240
if c = string.rindex("\n", target-1)
4341
return target - c - 1
@@ -71,6 +69,13 @@ def get_text(start)
7169
@string[start..@pos-1]
7270
end
7371

72+
# Sets the string and current parsing position for the parser.
73+
def set_string string, pos
74+
@string = string
75+
@string_size = string ? string.size : 0
76+
@pos = pos
77+
end
78+
7479
def show_pos
7580
width = 10
7681
if @pos < width
@@ -177,19 +182,19 @@ def scan(reg)
177182
return nil
178183
end
179184

180-
if "".respond_to? :getbyte
185+
if "".respond_to? :ord
181186
def get_byte
182-
if @pos >= @string.size
187+
if @pos >= @string_size
183188
return nil
184189
end
185190

186-
s = @string.getbyte @pos
191+
s = @string[@pos].ord
187192
@pos += 1
188193
s
189194
end
190195
else
191196
def get_byte
192-
if @pos >= @string.size
197+
if @pos >= @string_size
193198
return nil
194199
end
195200

@@ -238,8 +243,7 @@ def external_invoke(other, rule, *args)
238243
old_pos = @pos
239244
old_string = @string
240245

241-
@pos = other.pos
242-
@string = other.string
246+
set_string other.string, other.pos
243247

244248
begin
245249
if val = __send__(rule, *args)
@@ -250,8 +254,7 @@ def external_invoke(other, rule, *args)
250254
end
251255
val
252256
ensure
253-
@pos = old_pos
254-
@string = old_string
257+
set_string old_string, old_pos
255258
end
256259
end
257260

0 commit comments

Comments
 (0)