Skip to content

Commit a6a0027

Browse files
committed
suppress warnings when running the '-w'
--HG-- extra : convert_revision : svn%3Aacbfec75-9323-0410-a652-858a13e371e0/trunk%40941
1 parent 77f2677 commit a6a0027

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

lib/html5/html5parser.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ def initialize(options = {})
4646
@tree = TreeBuilders::REXML::TreeBuilder
4747

4848
options.each {|name, value| instance_variable_set("@#{name}", value) }
49-
49+
@lowercase_attr_name = nil unless instance_variable_defined?(:@lowercase_attr_name)
50+
@lowercase_element_name = nil unless instance_variable_defined?(:@lowercase_element_name)
5051
@tree = @tree.new
5152

5253
@phases = @@phases.inject({}) do |phases, phase_name|

lib/html5/html5parser/in_body_phase.rb

+14-2
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,25 @@ def initialize(parser, tree)
5151

5252
# for special handling of whitespace in <pre>
5353
@processSpaceCharactersDropNewline = false
54-
alias processSpaceCharactersNonPre processSpaceCharacters
54+
if $-w
55+
$-w = false
56+
alias processSpaceCharactersNonPre processSpaceCharacters
57+
$-w = true
58+
else
59+
alias processSpaceCharactersNonPre processSpaceCharacters
60+
end
5561
end
5662

5763
def processSpaceCharactersDropNewline(data)
5864
# #Sometimes (start of <pre> blocks) we want to drop leading newlines
5965

60-
alias processSpaceCharacters processSpaceCharactersNonPre
66+
if $-w
67+
$-w = false
68+
alias processSpaceCharacters processSpaceCharactersNonPre
69+
$-w = true
70+
else
71+
alias processSpaceCharacters processSpaceCharactersNonPre
72+
end
6173

6274
if (data.length > 0 and data[0] == ?\n &&
6375
%w[pre textarea].include?(@tree.openElements.last.name) && !@tree.openElements.last.hasContent)

lib/html5/inputstream.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ def char
297297
end
298298

299299
when 0xC0 .. 0xFF
300-
if @win1252
300+
if instance_variable_defined?(:@win1252) && @win1252
301301
"\xC3" + (c-64).chr # convert to utf-8
302302
elsif @buffer[@tell-1 .. @tell+3] =~ /^
303303
( [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte

0 commit comments

Comments
 (0)