MCPcopy Create free account
hub / github.com/dmtcp/dmtcp / GetHeaderGuardCPPVariable

Function GetHeaderGuardCPPVariable

util/cpplint.py:1759–1787  ·  view source on GitHub ↗

Returns the CPP variable that should be used as a header guard. Args: filename: The name of a C++ header file. Returns: The CPP variable that should be used as a header guard in the named file.

(filename)

Source from the content-addressed store, hash-verified

1757
1758
1759def GetHeaderGuardCPPVariable(filename):
1760 """Returns the CPP variable that should be used as a header guard.
1761
1762 Args:
1763 filename: The name of a C++ header file.
1764
1765 Returns:
1766 The CPP variable that should be used as a header guard in the
1767 named file.
1768
1769 """
1770
1771 # Restores original filename in case that cpplint is invoked from Emacs's
1772 # flymake.
1773 filename = re.sub(r'_flymake\.h$', '.h', filename)
1774 filename = re.sub(r'/\.flymake/([^/]*)$', r'/\1', filename)
1775 # Replace 'c++' with 'cpp'.
1776 filename = filename.replace('C++', 'cpp').replace('c++', 'cpp')
1777
1778 fileinfo = FileInfo(filename)
1779 file_path_from_root = fileinfo.RepositoryName()
1780 if _root:
1781 suffix = os.sep
1782 # On Windows using directory separator will leave us with
1783 # "bogus escape error" unless we properly escape regex.
1784 if suffix == '\\':
1785 suffix += '\\'
1786 file_path_from_root = re.sub('^' + _root + suffix, '', file_path_from_root)
1787 return re.sub(r'[^a-zA-Z0-9]', '_', file_path_from_root).upper() + '_'
1788
1789
1790def CheckForHeaderGuard(filename, clean_lines, error):

Callers 2

CheckForHeaderGuardFunction · 0.85
CheckStyleFunction · 0.85

Calls 3

RepositoryNameMethod · 0.95
FileInfoClass · 0.85
replaceMethod · 0.80

Tested by

no test coverage detected