Skip to content

Commit

Permalink
Merge pull request google#139 from Nazg-Gul/root_windows_fix
Browse files Browse the repository at this point in the history
Fix regex escape issue when using --root on Windows
  • Loading branch information
eglaysher authored Jun 30, 2016
2 parents bb4780e + 3b0ea89 commit 450aa46
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cpplint/cpplint.py
Original file line number Diff line number Diff line change
Expand Up @@ -1746,7 +1746,12 @@ def GetHeaderGuardCPPVariable(filename):
fileinfo = FileInfo(filename)
file_path_from_root = fileinfo.RepositoryName()
if _root:
file_path_from_root = re.sub('^' + _root + os.sep, '', file_path_from_root)
suffix = os.sep
# On Windows using directory separator will leave us with
# "bogus escape error" unless we properly escape regex.
if suffix == '\\':
suffix += '\\'
file_path_from_root = re.sub('^' + _root + suffix, '', file_path_from_root)
return re.sub(r'[^a-zA-Z0-9]', '_', file_path_from_root).upper() + '_'


Expand Down

0 comments on commit 450aa46

Please sign in to comment.