Bug 1566952: Part 0 - Fix comment processing in multi-line directives. r=ahal

The current comment processing code strips whitespace from a line, calculates
comment offsets based on the unstripped version, and then strips those offsets
from the stripped version. That means that, for multi-line directives, which
typically have two spaces at the front, the offsets are wrong and lines with
comments end up with a trailing "# " that the expression parser doesn't
understand.

This patch fixes the comment parser to correctly use the stripped line for
offset calculations instead.

Differential Revision: https://phabricator.services.mozilla.com/D38724

--HG--
extra : rebase_source : 9f19314ccab3fb2fa68642ff0aef978cb5c3e13c
This commit is contained in:
Kris Maglione 2019-07-17 14:19:59 -07:00
Родитель 088b7f4827
Коммит 73e321aadc
1 изменённых файлов: 2 добавлений и 2 удалений

Просмотреть файл

@ -67,11 +67,11 @@ def read_ini(fp, variables=None, default='DEFAULT', defaults_only=False,
while comment_start == sys.maxsize and inline_prefixes:
next_prefixes = {}
for prefix, index in inline_prefixes.items():
index = line.find(prefix, index+1)
index = stripped.find(prefix, index+1)
if index == -1:
continue
next_prefixes[prefix] = index
if index == 0 or (index > 0 and line[index-1].isspace()):
if index == 0 or (index > 0 and stripped[index-1].isspace()):
comment_start = min(comment_start, index)
inline_prefixes = next_prefixes