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
gaoqiong
pybind11
Commits
de2c6df2
Commit
de2c6df2
authored
Dec 13, 2016
by
Wenzel Jakob
Browse files
check-style.sh: check for accidentally committed CRLF line endings
parent
3f1ff3f4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
10 deletions
+24
-10
tools/check-style.sh
tools/check-style.sh
+24
-10
No files found.
tools/check-style.sh
View file @
de2c6df2
...
@@ -5,11 +5,12 @@
...
@@ -5,11 +5,12 @@
# This script currently checks for
# This script currently checks for
#
#
# 1. use of tabs instead of spaces
# 1. use of tabs instead of spaces
# 2. trailing spaces
# 2. MSDOS-style CRLF endings
# 3. missing space between keyword and parenthesis, e.g.: for(, if(, while(
# 3. trailing spaces
# 4. opening brace on its own line. It should always be on the same line as the
# 4. missing space between keyword and parenthesis, e.g.: for(, if(, while(
# if/while/for/do statment.
# 5. Missing space between right parenthesis and brace, e.g. 'for (...){'
# 5. Missing space between right parenthesis and brace, e.g. 'for (...){'
# 6. opening brace on its own line. It should always be on the same line as the
# if/while/for/do statment.
#
#
# Invoke as: tools/check-style.sh
# Invoke as: tools/check-style.sh
#
#
...
@@ -30,11 +31,11 @@ while read -u 3 f; do
...
@@ -30,11 +31,11 @@ while read -u 3 f; do
done
done
found
=
found
=
# The mt=41 sets a red background for matched
trailing space
s
# The mt=41 sets a red background for matched
MS-DOS CRLF line ending
s
exec
3< <
(
GREP_COLORS
=
'mt=41'
grep
'\s\+$
'
include/ tests/
*
.
{
cpp,py,h
}
docs/
*
.rst
-rn
--color
=
always
)
exec
3< <
(
GREP_COLORS
=
'mt=41'
grep
-IUlr
$'
\r
'
include/ tests/
*
.
{
cpp,py,h
}
docs/
*
.rst
--color
=
always
)
while
read
-u
3 f
;
do
while
read
-u
3 f
;
do
if
[
-z
"
$found
"
]
;
then
if
[
-z
"
$found
"
]
;
then
echo
-e
'\e[31m\e[01mError: found
trailing space
s in the following files:\e[0m'
echo
-e
'\e[31m\e[01mError: found
CRLF character
s in the following files:\e[0m'
found
=
1
found
=
1
errors
=
1
errors
=
1
fi
fi
...
@@ -43,10 +44,11 @@ while read -u 3 f; do
...
@@ -43,10 +44,11 @@ while read -u 3 f; do
done
done
found
=
found
=
exec
3< <
(
GREP_COLORS
=
'mt=41'
grep
'^\s*{\s*$'
include/ docs/
*
.rst
-rn
--color
=
always
)
# The mt=41 sets a red background for matched trailing spaces
exec
3< <
(
GREP_COLORS
=
'mt=41'
grep
'\s\+$'
include/ tests/
*
.
{
cpp,py,h
}
docs/
*
.rst
-rn
--color
=
always
)
while
read
-u
3 f
;
do
while
read
-u
3 f
;
do
if
[
-z
"
$found
"
]
;
then
if
[
-z
"
$found
"
]
;
then
echo
-e
'\e[31m\e[01mError:
braces sh
ou
l
d
occur on the same line as the if/while/.. statement. Found issu
es in the following files:
\e[0m'
echo
-e
'\e[31m\e[01mError:
f
ou
n
d
trailing spac
es in the following files:\e[0m'
found
=
1
found
=
1
errors
=
1
errors
=
1
fi
fi
...
@@ -55,7 +57,7 @@ while read -u 3 f; do
...
@@ -55,7 +57,7 @@ while read -u 3 f; do
done
done
found
=
found
=
exec
3< <
(
grep
'\<\(if\|for\|while\)(\|){'
include/ tests/
*
.
{
cpp,py,h
}
-rn
--color
=
always
)
exec
3< <
(
grep
'\<\(if\|for\|while\
|catch\
)(\|){'
include/ tests/
*
.
{
cpp,py,h
}
-rn
--color
=
always
)
while
read
-u
3 line
;
do
while
read
-u
3 line
;
do
if
[
-z
"
$found
"
]
;
then
if
[
-z
"
$found
"
]
;
then
echo
-e
'\e[31m\e[01mError: found the following coding style problems:\e[0m'
echo
-e
'\e[31m\e[01mError: found the following coding style problems:\e[0m'
...
@@ -66,4 +68,16 @@ while read -u 3 line; do
...
@@ -66,4 +68,16 @@ while read -u 3 line; do
echo
"
$line
"
echo
"
$line
"
done
done
found
=
exec
3< <
(
GREP_COLORS
=
'mt=41'
grep
'^\s*{\s*$'
include/ docs/
*
.rst
-rn
--color
=
always
)
while
read
-u
3 f
;
do
if
[
-z
"
$found
"
]
;
then
echo
-e
'\e[31m\e[01mError: braces should occur on the same line as the if/while/.. statement. Found issues in the following files: \e[0m'
found
=
1
errors
=
1
fi
echo
"
$f
"
done
exit
$errors
exit
$errors
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