servo: Merge #9889 - Handle escaped strings in rust linting, tidy.py (from MichaelRFairhurst:github-bug-9806-tidy-linting-string-contents); r=ecoal95

A little annoying to read since we have to escape for python (\\) and
then escape for re (\\\\) and then even at times escape for single
quotes immediately after, (\\\\\), but tidy.py now strips strings even
if they have escapes before linting.

Fixes #9806 -- basically the problem is that the PR which first revealed this had an escape in one of its strings which included an = sign. The escape meant the string wasn't escaped before it looked for spaces around spaces.

Source-Repo: https://github.com/servo/servo
Source-Revision: f1bb0b0fa3eacac718a825c103cbdd1a0365fbf9
This commit is contained in:
Mike Fairhurst
2016-03-11 04:37:43 +05:00
parent 0c4779017a
commit 067fa5b6a9

View File

@@ -291,7 +291,7 @@ def check_rust(file_name, lines):
# get rid of strings and chars because cases like regex expression, keep attributes
if not line_is_attribute(line):
line = re.sub('".*?"|\'.*?\'', '', line)
line = re.sub(r'"(\\.|[^\\"])*?"|' + r"'(\\.|[^\\'])*?'", '', line)
# get rid of comments
line = re.sub('//.*?$|/\*.*?$|^\*.*?$', '', line)
@@ -347,6 +347,7 @@ def check_rust(file_name, lines):
for match in re.finditer(pattern, line):
if not filter_func(match, line):
continue
yield (idx + 1, message.format(*match.groups(), **match.groupdict()))
# check alphabetical order of extern crates