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)
| 1757 | |
| 1758 | |
| 1759 | def 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 | |
| 1790 | def CheckForHeaderGuard(filename, clean_lines, error): |
no test coverage detected