@@ -362,25 +362,26 @@ def parse(text, filename, line_no, type, &include_callback)
362362
363363 private def normalize_comment_lines ( lines )
364364 blank_line_regexp = /\A \s *\z /
365+ lines = lines . dup
366+ lines . shift while lines . first &.match? ( blank_line_regexp )
367+ lines . pop while lines . last &.match? ( blank_line_regexp )
368+
365369 min_spaces = lines . map do |l |
366- l [ /\A */ ] . size unless l . match? ( blank_line_regexp )
370+ l . match ( /\A *(?= \S )/ ) &. end ( 0 )
367371 end . compact . min
368372 if min_spaces && min_spaces > 0
369- lines = lines . map { |l | l [ min_spaces ..] || '' }
373+ lines . map { |l | l [ min_spaces ..] || '' }
370374 else
371- lines = lines . dup
375+ lines
372376 end
373- lines . shift while lines . first &.match? ( blank_line_regexp )
374- lines . pop while lines . last &.match? ( blank_line_regexp )
375- lines
376377 end
377378
378379 # Take value lines of multiline directive
379380
380381 private def take_multiline_directive_value_lines ( directive , filename , line_no , lines , base_indent_size , indent_regexp , has_param )
381382 return [ ] if lines . empty?
382383
383- first_indent_size = lines . first [ indent_regexp ] . size
384+ first_indent_size = lines . first . match ( indent_regexp ) . end ( 0 )
384385
385386 # Blank line or unindented line is not part of multiline-directive value
386387 return [ ] if first_indent_size <= base_indent_size
@@ -391,9 +392,9 @@ def parse(text, filename, line_no, type, &include_callback)
391392 # line3
392393 #
393394 value_lines = lines . take_while do |l |
394- l . rstrip [ indent_regexp ] . size > base_indent_size
395+ l . rstrip . match ( indent_regexp ) . end ( 0 ) > base_indent_size
395396 end
396- min_indent = value_lines . map { |l | l [ indent_regexp ] . size } . min
397+ min_indent = value_lines . map { |l | l . match ( indent_regexp ) . end ( 0 ) } . min
397398 value_lines . map { |l | l [ min_indent ..] }
398399 else
399400 # Take indented lines accepting blank lines between them
0 commit comments