Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
yangql
googletest
Commits
1f7bb45e
"ci/env-linux.sh" did not exist on "66a036959f09071fa0d5f7af4a5cbf470a2c6137"
Commit
1f7bb45e
authored
Aug 14, 2012
by
vladlosev
Browse files
Prevents pump.py from splitting long IWYU pragma lines.
parent
4c975121
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
15 deletions
+23
-15
scripts/pump.py
scripts/pump.py
+23
-15
No files found.
scripts/pump.py
View file @
1f7bb45e
...
...
@@ -704,14 +704,14 @@ def RunCode(env, code_node, output):
RunAtomicCode
(
env
,
atomic_code
,
output
)
def
IsComment
(
cur_line
):
def
Is
SingleLine
Comment
(
cur_line
):
return
'//'
in
cur_line
def
IsInPreprocessorDire
va
tive
(
prev_lines
,
cur_line
):
def
IsInPreprocessorDire
c
tive
(
prev_lines
,
cur_line
):
if
cur_line
.
lstrip
().
startswith
(
'#'
):
return
True
return
prev_lines
!=
[]
and
prev_lines
[
-
1
].
endswith
(
'
\\
'
)
return
prev_lines
and
prev_lines
[
-
1
].
endswith
(
'
\\
'
)
def
WrapComment
(
line
,
output
):
...
...
@@ -768,7 +768,7 @@ def WrapCode(line, line_concat, output):
output
.
append
(
prefix
+
cur_line
.
strip
())
def
WrapPreprocessorDire
va
tive
(
line
,
output
):
def
WrapPreprocessorDire
c
tive
(
line
,
output
):
WrapCode
(
line
,
'
\\
'
,
output
)
...
...
@@ -776,29 +776,37 @@ def WrapPlainCode(line, output):
WrapCode
(
line
,
''
,
output
)
def
IsHeaderGuardOrInclude
(
line
):
def
IsMultiLineIWYUPragma
(
line
):
return
re
.
search
(
r
'/\* IWYU pragma: '
,
line
)
def
IsHeaderGuardIncludeOrOneLineIWYUPragma
(
line
):
return
(
re
.
match
(
r
'^#(ifndef|define|endif\s*//)\s*[\w_]+\s*$'
,
line
)
or
re
.
match
(
r
'^#include\s'
,
line
))
re
.
match
(
r
'^#include\s'
,
line
)
or
# Don't break IWYU pragmas, either; that causes iwyu.py problems.
re
.
search
(
r
'// IWYU pragma: '
,
line
))
def
WrapLongLine
(
line
,
output
):
line
=
line
.
rstrip
()
if
len
(
line
)
<=
80
:
output
.
append
(
line
)
elif
IsComment
(
line
):
if
IsHeaderGuard
Or
Include
(
line
):
# The style guide made an exception to allow long header guard lines
#
and
includes.
elif
Is
SingleLine
Comment
(
line
):
if
IsHeaderGuardInclude
OrOneLineIWYUPragma
(
line
):
# The style guide made an exception to allow long header guard lines
,
# includes
and IWYU pragmas
.
output
.
append
(
line
)
else
:
WrapComment
(
line
,
output
)
elif
IsInPreprocessorDire
va
tive
(
output
,
line
):
if
IsHeaderGuard
Or
Include
(
line
):
# The style guide made an exception to allow long header guard lines
#
and
includes.
elif
IsInPreprocessorDire
c
tive
(
output
,
line
):
if
IsHeaderGuardInclude
OrOneLineIWYUPragma
(
line
):
# The style guide made an exception to allow long header guard lines
,
# includes
and IWYU pragmas
.
output
.
append
(
line
)
else
:
WrapPreprocessorDirevative
(
line
,
output
)
WrapPreprocessorDirective
(
line
,
output
)
elif
IsMultiLineIWYUPragma
(
line
):
output
.
append
(
line
)
else
:
WrapPlainCode
(
line
,
output
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment