Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grpc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tci-gateway-module
Grpc
Commits
3c5def57
Commit
3c5def57
authored
9 years ago
by
David Garcia Quintas
Browse files
Options
Downloads
Patches
Plain Diff
addressed pr comments
parent
5b385dcb
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tools/distrib/check_include_guards.py
+15
-12
15 additions, 12 deletions
tools/distrib/check_include_guards.py
with
15 additions
and
12 deletions
tools/distrib/check_include_guards.py
+
15
−
12
View file @
3c5def57
...
@@ -95,56 +95,59 @@ class GuardValidator(object):
...
@@ -95,56 +95,59 @@ class GuardValidator(object):
fcontents
=
load
(
fpath
)
fcontents
=
load
(
fpath
)
match
=
self
.
ifndef_re
.
search
(
fcontents
)
match
=
self
.
ifndef_re
.
search
(
fcontents
)
if
match
.
lastindex
!=
1
:
if
match
.
lastindex
is
None
:
# No ifndef. Request manual addition with hints
# No ifndef. Request manual addition with hints
self
.
fail
(
fpath
,
match
.
re
,
match
.
string
,
''
,
''
,
False
)
self
.
fail
(
fpath
,
match
.
re
,
match
.
string
,
''
,
''
,
False
)
return
False
# failed
# Does the guard end with a '_H'?
# Does the guard end with a '_H'?
running_guard
=
match
.
group
(
1
)
running_guard
=
match
.
group
(
1
)
if
not
running_guard
.
endswith
(
'
_H
'
):
if
not
running_guard
.
endswith
(
'
_H
'
):
fcontents
=
self
.
fail
(
fpath
,
match
.
re
,
match
.
string
,
match
.
group
(
1
),
fcontents
=
self
.
fail
(
fpath
,
match
.
re
,
match
.
string
,
match
.
group
(
1
),
valid_guard
,
fix
)
valid_guard
,
fix
)
save
(
fpath
,
fcontents
)
if
fix
:
save
(
fpath
,
fcontents
)
# Is it the expected one based on the file path?
# Is it the expected one based on the file path?
if
running_guard
!=
valid_guard
:
if
running_guard
!=
valid_guard
:
fcontents
=
self
.
fail
(
fpath
,
match
.
re
,
match
.
string
,
match
.
group
(
1
),
fcontents
=
self
.
fail
(
fpath
,
match
.
re
,
match
.
string
,
match
.
group
(
1
),
valid_guard
,
fix
)
valid_guard
,
fix
)
save
(
fpath
,
fcontents
)
if
fix
:
save
(
fpath
,
fcontents
)
# Is there a #define? Is it the same as the #ifndef one?
# Is there a #define? Is it the same as the #ifndef one?
match
=
self
.
define_re
.
search
(
fcontents
)
match
=
self
.
define_re
.
search
(
fcontents
)
if
match
.
lastindex
!=
1
:
if
match
.
lastindex
is
None
:
# No define. Request manual addition with hints
# No define. Request manual addition with hints
self
.
fail
(
fpath
,
match
.
re
,
match
.
string
,
''
,
''
,
False
)
self
.
fail
(
fpath
,
match
.
re
,
match
.
string
,
''
,
''
,
False
)
return
False
# failed
# Is the #define guard the same as the #ifndef guard?
# Is the #define guard the same as the #ifndef guard?
if
match
.
group
(
1
)
!=
running_guard
:
if
match
.
group
(
1
)
!=
running_guard
:
fcontents
=
self
.
fail
(
fpath
,
match
.
re
,
match
.
string
,
match
.
group
(
1
),
fcontents
=
self
.
fail
(
fpath
,
match
.
re
,
match
.
string
,
match
.
group
(
1
),
valid_guard
,
fix
)
valid_guard
,
fix
)
save
(
fpath
,
fcontents
)
if
fix
:
save
(
fpath
,
fcontents
)
# Is there a properly commented #endif?
# Is there a properly commented #endif?
endif_re
=
self
.
endif_cpp_re
if
cpp_header
else
self
.
endif_c_re
endif_re
=
self
.
endif_cpp_re
if
cpp_header
else
self
.
endif_c_re
matches
=
endif_re
.
findall
(
fcontents
)
flines
=
fcontents
.
rstrip
().
splitlines
()
if
not
matches
:
match
=
endif_re
.
search
(
flines
[
-
1
])
if
not
match
:
# No endif. Check if we have the last line as just '#endif' and if so
# No endif. Check if we have the last line as just '#endif' and if so
# replace it with a properly commented one.
# replace it with a properly commented one.
flines
=
fcontents
.
splitlines
()
if
flines
[
-
1
]
==
'
#endif
'
:
if
flines
[
-
1
]
==
'
#endif
'
:
flines
[
-
1
]
=
(
'
#endif
'
+
flines
[
-
1
]
=
(
'
#endif
'
+
(
'
// {}
\n
'
.
format
(
valid_guard
)
if
cpp_header
(
'
// {}
\n
'
.
format
(
valid_guard
)
if
cpp_header
else
'
/* {} */
\n
'
.
format
(
valid_guard
)))
else
'
/* {} */
\n
'
.
format
(
valid_guard
)))
fcontents
=
'
\n
'
.
join
(
flines
)
if
fix
:
save
(
fpath
,
fcontents
)
fcontents
=
'
\n
'
.
join
(
flines
)
save
(
fpath
,
fcontents
)
else
:
else
:
# something else is wrong, bail out
# something else is wrong, bail out
self
.
fail
(
fpath
,
endif_re
,
match
.
string
,
''
,
''
,
False
)
self
.
fail
(
fpath
,
endif_re
,
match
.
string
,
''
,
''
,
False
)
elif
match
es
[
-
1
]
!=
running_guard
:
elif
match
.
group
(
1
)
!=
running_guard
:
# Is the #endif guard the same as the #ifndef and #define guards?
# Is the #endif guard the same as the #ifndef and #define guards?
fcontents
=
self
.
fail
(
fpath
,
endif_re
,
fcontents
,
matches
[
-
1
],
fcontents
=
self
.
fail
(
fpath
,
endif_re
,
fcontents
,
matches
[
-
1
],
valid_guard
,
fix
)
valid_guard
,
fix
)
save
(
fpath
,
fcontents
)
if
fix
:
save
(
fpath
,
fcontents
)
return
not
self
.
failed
# Did the check succeed? (ie, not failed)
return
not
self
.
failed
# Did the check succeed? (ie, not failed)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment