[include-guards] Fix regular expression (#33270)

It's completely legitimate to have a zero in a filename/include guard.

<!--

If you know who should review your pull request, please assign it to
that
person, otherwise the pull request would get assigned randomly.

If your pull request is for a specific language, please add the
appropriate
lang label.

-->
pull/33277/head
Craig Tiller 2 years ago committed by GitHub
parent e0ba7b720a
commit 272a89ad2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      tools/distrib/check_include_guards.py

@ -44,11 +44,11 @@ def save(fpath, contents):
class GuardValidator(object):
def __init__(self):
self.ifndef_re = re.compile(r'#ifndef ([A-Z][A-Z_1-9]*)')
self.define_re = re.compile(r'#define ([A-Z][A-Z_1-9]*)')
self.ifndef_re = re.compile(r'#ifndef ([A-Z][A-Z_0-9]*)')
self.define_re = re.compile(r'#define ([A-Z][A-Z_0-9]*)')
self.endif_c_core_re = re.compile(
r'#endif /\* (?: *\\\n *)?([A-Z][A-Z_1-9]*) (?:\\\n *)?\*/$')
self.endif_re = re.compile(r'#endif // ([A-Z][A-Z_1-9]*)')
r'#endif /\* (?: *\\\n *)?([A-Z][A-Z_0-9]*) (?:\\\n *)?\*/$')
self.endif_re = re.compile(r'#endif // ([A-Z][A-Z_0-9]*)')
self.comments_then_includes_re = re.compile(
r'^((//.*?$|/\*.*?\*/|[ \r\n\t])*)(([ \r\n\t]|#include .*)*)(#ifndef [^\n]*\n#define [^\n]*\n)',
re.DOTALL | re.MULTILINE)

Loading…
Cancel
Save