@@ -269,10 +269,10 @@ def pull_event
269
269
@source . ensure_buffer
270
270
if @document_status == nil
271
271
start_position = @source . position
272
- if @source . match ( "<?" , true )
272
+ if @source . match? ( "<?" , true )
273
273
return process_instruction
274
- elsif @source . match ( "<!" , true )
275
- if @source . match ( "--" , true )
274
+ elsif @source . match? ( "<!" , true )
275
+ if @source . match? ( "--" , true )
276
276
md = @source . match ( /(.*?)-->/um , true )
277
277
if md . nil?
278
278
raise REXML ::ParseException . new ( "Unclosed comment" , @source )
@@ -281,10 +281,10 @@ def pull_event
281
281
raise REXML ::ParseException . new ( "Malformed comment" , @source )
282
282
end
283
283
return [ :comment , md [ 1 ] ]
284
- elsif @source . match ( "DOCTYPE" , true )
284
+ elsif @source . match? ( "DOCTYPE" , true )
285
285
base_error_message = "Malformed DOCTYPE"
286
- unless @source . match ( /\s +/um , true )
287
- if @source . match ( ">" )
286
+ unless @source . match? ( /\s +/um , true )
287
+ if @source . match? ( ">" )
288
288
message = "#{ base_error_message } : name is missing"
289
289
else
290
290
message = "#{ base_error_message } : invalid name"
@@ -293,10 +293,10 @@ def pull_event
293
293
raise REXML ::ParseException . new ( message , @source )
294
294
end
295
295
name = parse_name ( base_error_message )
296
- if @source . match ( /\s *\[ /um , true )
296
+ if @source . match? ( /\s *\[ /um , true )
297
297
id = [ nil , nil , nil ]
298
298
@document_status = :in_doctype
299
- elsif @source . match ( /\s *>/um , true )
299
+ elsif @source . match? ( /\s *>/um , true )
300
300
id = [ nil , nil , nil ]
301
301
@document_status = :after_doctype
302
302
@source . ensure_buffer
@@ -308,9 +308,9 @@ def pull_event
308
308
# For backward compatibility
309
309
id [ 1 ] , id [ 2 ] = id [ 2 ] , nil
310
310
end
311
- if @source . match ( /\s *\[ /um , true )
311
+ if @source . match? ( /\s *\[ /um , true )
312
312
@document_status = :in_doctype
313
- elsif @source . match ( /\s *>/um , true )
313
+ elsif @source . match? ( /\s *>/um , true )
314
314
@document_status = :after_doctype
315
315
@source . ensure_buffer
316
316
else
@@ -320,7 +320,7 @@ def pull_event
320
320
end
321
321
args = [ :start_doctype , name , *id ]
322
322
if @document_status == :after_doctype
323
- @source . match ( /\s */um , true )
323
+ @source . match? ( /\s */um , true )
324
324
@stack << [ :end_doctype ]
325
325
end
326
326
return args
@@ -331,14 +331,14 @@ def pull_event
331
331
end
332
332
end
333
333
if @document_status == :in_doctype
334
- @source . match ( /\s */um , true ) # skip spaces
334
+ @source . match? ( /\s */um , true ) # skip spaces
335
335
start_position = @source . position
336
- if @source . match ( "<!" , true )
337
- if @source . match ( "ELEMENT" , true )
336
+ if @source . match? ( "<!" , true )
337
+ if @source . match? ( "ELEMENT" , true )
338
338
md = @source . match ( /(.*?)>/um , true )
339
339
raise REXML ::ParseException . new ( "Bad ELEMENT declaration!" , @source ) if md . nil?
340
340
return [ :elementdecl , "<!ELEMENT" + md [ 1 ] ]
341
- elsif @source . match ( "ENTITY" , true )
341
+ elsif @source . match? ( "ENTITY" , true )
342
342
match_data = @source . match ( Private ::ENTITYDECL_PATTERN , true )
343
343
unless match_data
344
344
raise REXML ::ParseException . new ( "Malformed entity declaration" , @source )
@@ -370,7 +370,7 @@ def pull_event
370
370
end
371
371
match << '%' if ref
372
372
return match
373
- elsif @source . match ( "ATTLIST" , true )
373
+ elsif @source . match? ( "ATTLIST" , true )
374
374
md = @source . match ( Private ::ATTLISTDECL_END , true )
375
375
raise REXML ::ParseException . new ( "Bad ATTLIST declaration!" , @source ) if md . nil?
376
376
element = md [ 1 ]
@@ -390,10 +390,10 @@ def pull_event
390
390
end
391
391
end
392
392
return [ :attlistdecl , element , pairs , contents ]
393
- elsif @source . match ( "NOTATION" , true )
393
+ elsif @source . match? ( "NOTATION" , true )
394
394
base_error_message = "Malformed notation declaration"
395
- unless @source . match ( /\s +/um , true )
396
- if @source . match ( ">" )
395
+ unless @source . match? ( /\s +/um , true )
396
+ if @source . match? ( ">" )
397
397
message = "#{ base_error_message } : name is missing"
398
398
else
399
399
message = "#{ base_error_message } : invalid name"
@@ -405,7 +405,7 @@ def pull_event
405
405
id = parse_id ( base_error_message ,
406
406
accept_external_id : true ,
407
407
accept_public_id : true )
408
- unless @source . match ( /\s *>/um , true )
408
+ unless @source . match? ( /\s *>/um , true )
409
409
message = "#{ base_error_message } : garbage before end >"
410
410
raise REXML ::ParseException . new ( message , @source )
411
411
end
@@ -419,7 +419,7 @@ def pull_event
419
419
end
420
420
elsif match = @source . match ( /(%.*?;)\s */um , true )
421
421
return [ :externalentity , match [ 1 ] ]
422
- elsif @source . match ( /\] \s *>/um , true )
422
+ elsif @source . match? ( /\] \s *>/um , true )
423
423
@document_status = :after_doctype
424
424
return [ :end_doctype ]
425
425
end
@@ -428,16 +428,16 @@ def pull_event
428
428
end
429
429
end
430
430
if @document_status == :after_doctype
431
- @source . match ( /\s */um , true )
431
+ @source . match? ( /\s */um , true )
432
432
end
433
433
begin
434
434
start_position = @source . position
435
- if @source . match ( "<" , true )
435
+ if @source . match? ( "<" , true )
436
436
# :text's read_until may remain only "<" in buffer. In the
437
437
# case, buffer is empty here. So we need to fill buffer
438
438
# here explicitly.
439
439
@source . ensure_buffer
440
- if @source . match ( "/" , true )
440
+ if @source . match? ( "/" , true )
441
441
@namespaces_restore_stack . pop
442
442
last_tag = @tags . pop
443
443
md = @source . match ( Private ::CLOSE_PATTERN , true )
@@ -452,7 +452,7 @@ def pull_event
452
452
raise REXML ::ParseException . new ( message , @source )
453
453
end
454
454
return [ :end_element , last_tag ]
455
- elsif @source . match ( "!" , true )
455
+ elsif @source . match? ( "!" , true )
456
456
md = @source . match ( /([^>]*>)/um )
457
457
#STDERR.puts "SOURCE BUFFER = #{source.buffer}, #{source.buffer.size}"
458
458
raise REXML ::ParseException . new ( "Malformed node" , @source ) unless md
@@ -470,7 +470,7 @@ def pull_event
470
470
end
471
471
raise REXML ::ParseException . new ( "Declarations can only occur " +
472
472
"in the doctype declaration." , @source )
473
- elsif @source . match ( "?" , true )
473
+ elsif @source . match? ( "?" , true )
474
474
return process_instruction
475
475
else
476
476
# Get the next tag
@@ -651,7 +651,7 @@ def need_source_encoding_update?(xml_declaration_encoding)
651
651
def parse_name ( base_error_message )
652
652
md = @source . match ( Private ::NAME_PATTERN , true )
653
653
unless md
654
- if @source . match ( /\S /um )
654
+ if @source . match? ( /\S /um )
655
655
message = "#{ base_error_message } : invalid name"
656
656
else
657
657
message = "#{ base_error_message } : name is missing"
@@ -693,34 +693,34 @@ def parse_id_invalid_details(accept_external_id:,
693
693
accept_public_id :)
694
694
public = /\A \s *PUBLIC/um
695
695
system = /\A \s *SYSTEM/um
696
- if ( accept_external_id or accept_public_id ) and @source . match ( /#{ public } /um )
697
- if @source . match ( /#{ public } (?:\s +[^'"]|\s *[\[ >])/um )
696
+ if ( accept_external_id or accept_public_id ) and @source . match? ( /#{ public } /um )
697
+ if @source . match? ( /#{ public } (?:\s +[^'"]|\s *[\[ >])/um )
698
698
return "public ID literal is missing"
699
699
end
700
- unless @source . match ( /#{ public } \s +#{ PUBIDLITERAL } /um )
700
+ unless @source . match? ( /#{ public } \s +#{ PUBIDLITERAL } /um )
701
701
return "invalid public ID literal"
702
702
end
703
703
if accept_public_id
704
- if @source . match ( /#{ public } \s +#{ PUBIDLITERAL } \s +[^'"]/um )
704
+ if @source . match? ( /#{ public } \s +#{ PUBIDLITERAL } \s +[^'"]/um )
705
705
return "system ID literal is missing"
706
706
end
707
- unless @source . match ( /#{ public } \s +#{ PUBIDLITERAL } \s +#{ SYSTEMLITERAL } /um )
707
+ unless @source . match? ( /#{ public } \s +#{ PUBIDLITERAL } \s +#{ SYSTEMLITERAL } /um )
708
708
return "invalid system literal"
709
709
end
710
710
"garbage after system literal"
711
711
else
712
712
"garbage after public ID literal"
713
713
end
714
- elsif accept_external_id and @source . match ( /#{ system } /um )
715
- if @source . match ( /#{ system } (?:\s +[^'"]|\s *[\[ >])/um )
714
+ elsif accept_external_id and @source . match? ( /#{ system } /um )
715
+ if @source . match? ( /#{ system } (?:\s +[^'"]|\s *[\[ >])/um )
716
716
return "system literal is missing"
717
717
end
718
- unless @source . match ( /#{ system } \s +#{ SYSTEMLITERAL } /um )
718
+ unless @source . match? ( /#{ system } \s +#{ SYSTEMLITERAL } /um )
719
719
return "invalid system literal"
720
720
end
721
721
"garbage after system literal"
722
722
else
723
- unless @source . match ( /\A \s *(?:PUBLIC|SYSTEM)\s /um )
723
+ unless @source . match? ( /\A \s *(?:PUBLIC|SYSTEM)\s /um )
724
724
return "invalid ID type"
725
725
end
726
726
"ID type is missing"
@@ -729,15 +729,15 @@ def parse_id_invalid_details(accept_external_id:,
729
729
730
730
def process_instruction
731
731
name = parse_name ( "Malformed XML: Invalid processing instruction node" )
732
- if @source . match ( /\s +/um , true )
732
+ if @source . match? ( /\s +/um , true )
733
733
match_data = @source . match ( /(.*?)\? >/um , true )
734
734
unless match_data
735
735
raise ParseException . new ( "Malformed XML: Unclosed processing instruction" , @source )
736
736
end
737
737
content = match_data [ 1 ]
738
738
else
739
739
content = nil
740
- unless @source . match ( "?>" , true )
740
+ unless @source . match? ( "?>" , true )
741
741
raise ParseException . new ( "Malformed XML: Unclosed processing instruction" , @source )
742
742
end
743
743
end
@@ -767,17 +767,17 @@ def parse_attributes(prefixes)
767
767
expanded_names = { }
768
768
closed = false
769
769
while true
770
- if @source . match ( ">" , true )
770
+ if @source . match? ( ">" , true )
771
771
return attributes , closed
772
- elsif @source . match ( "/>" , true )
772
+ elsif @source . match? ( "/>" , true )
773
773
closed = true
774
774
return attributes , closed
775
775
elsif match = @source . match ( QNAME , true )
776
776
name = match [ 1 ]
777
777
prefix = match [ 2 ]
778
778
local_part = match [ 3 ]
779
779
780
- unless @source . match ( /\s *=\s */um , true )
780
+ unless @source . match? ( /\s *=\s */um , true )
781
781
message = "Missing attribute equal: <#{ name } >"
782
782
raise REXML ::ParseException . new ( message , @source )
783
783
end
@@ -793,7 +793,7 @@ def parse_attributes(prefixes)
793
793
message = "Missing attribute value end quote: <#{ name } >: <#{ quote } >"
794
794
raise REXML ::ParseException . new ( message , @source )
795
795
end
796
- @source . match ( /\s */um , true )
796
+ @source . match? ( /\s */um , true )
797
797
if prefix == "xmlns"
798
798
if local_part == "xml"
799
799
if value != Private ::XML_PREFIXED_NAMESPACE
0 commit comments