Skip to content

Commit

Permalink
Fix Python regexp literals
Browse files Browse the repository at this point in the history
Add missing "r" prefixes before literals using regexp escape
sequences.

[ghudson@mit.edu: split into separate commit; rewrote commit message]
  • Loading branch information
pkillarjun authored and greghudson committed May 22, 2024
1 parent 623d649 commit 4b21b2e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/util/cstyle-file.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def check_assignment_in_conditional(line, ln):


def indent(line):
return len(re.match('\s*', line).group(0).expandtabs())
return len(re.match(r'\s*', line).group(0).expandtabs())


def check_unbraced_flow_body(line, ln, lines):
Expand All @@ -220,8 +220,8 @@ def check_unbraced_flow_body(line, ln, lines):
if m and (m.group(1) is None) != (m.group(3) is None):
warn(ln, 'One arm of if/else statement braced but not the other')

if (re.match('\s*(if|else if|for|while)\s*\(.*\)$', line) or
re.match('\s*else$', line)):
if (re.match(r'\s*(if|else if|for|while)\s*\(.*\)$', line) or
re.match(r'\s*else$', line)):
base = indent(line)
# Look at the next two lines (ln is 1-based so lines[ln] is next).
if indent(lines[ln]) > base and indent(lines[ln + 1]) > base:
Expand Down

0 comments on commit 4b21b2e

Please sign in to comment.