Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
codes
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
38
Issues
38
List
Boards
Labels
Milestones
Merge Requests
8
Merge Requests
8
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
codes
codes
Commits
bc70924c
Commit
bc70924c
authored
Mar 16, 2015
by
Jonathan Jenkins
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
uncrustify config and reformatting tool
parent
92c48921
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1652 additions
and
0 deletions
+1652
-0
reformat.sh
reformat.sh
+104
-0
uc-codes.cfg
uc-codes.cfg
+1548
-0
No files found.
reformat.sh
0 → 100755
View file @
bc70924c
#!/bin/bash
script_dir
=
"
$(
cd
"
$(
dirname
"
${
BASH_SOURCE
[0]
}
"
)
"
&&
pwd
)
"
function
error
()
{
echo
"ERROR:
$@
"
>
&2
exit
1
}
function
usage
()
{
cat
\
<<
EOF
USAGE: reformat.sh [-x] [-i] [-c CFG] [-b FILE] {-a | FILE...}
-i: perform in-place (will ask to confirm if being done recursively)
-c CFG: use CFG as the uncrustify config (default:
$script_dir
/uc-codes.cfg)
-b FILE[,...]: add FILE to the blacklist of directories (in the form *FILE/*)
multiple files can be added by separating with commas
-a: perform recursively on all files ending in .c or .h
if -a not provided, then perform on all files passed in
-x: instead of formatting, check if output format is the same as input
EOF
}
function
build_blacklist
()
{
for
x
in
$@
;
do
echo
-n
"-and -not -path
\*
$x
/
\*
"
done
}
function
getfiles
()
{
find
.
\(
-name
\*
.c
-or
-name
\*
.h
\)
$(
build_blacklist
$@
)
}
cfg
=
$script_dir
/uc-codes.cfg
which uncrustify
>
/dev/null 2>&1
||
error
"uncrustify not found"
do_inplace
=
no
do_recursive
=
no
do_check
=
no
blacklist
=
while
getopts
":ib:ax"
opt
;
do
case
$opt
in
i
)
do_inplace
=
yes
;;
b
)
blacklist
=
$(
cat
$OPTARG
|
sed
s/,/ /g
)
;;
c
)
cfg
=
$OPTARG
;;
a
)
do_recursive
=
yes
;;
x
)
do_check
=
yes
;;
\?
)
usage
error
"invalid argument: -
$OPTARG
"
;;
esac
done
shift
$((
OPTIND-1
))
[[
-e
$cfg
]]
||
(
usage
&&
error
"config file
$cfg
not found"
)
[[
$#
-gt
0
&&
$do_recursive
==
yes
]]
&&
\
usage
&&
error
"no file args expected in recursive mode"
[[
$#
-eq
0
&&
$do_recursive
==
no
]]
&&
\
usage
&&
error
"expected file args in non-recursive mode"
if
[[
$do_recursive
==
yes
]]
;
then
file_list
=
"
$(
getfiles
$blacklist
)
"
else
file_list
=
"
$@
"
fi
if
[[
$do_recursive
==
yes
&&
$do_inplace
==
yes
]]
;
then
echo
-n
"Do recursive in-place reformat? (y/n) "
read
answer
[[
$answer
=
~
"[^y].*"
]]
&&
echo
"...aborting reformat"
&&
exit
1
fi
[[
$do_inplace
==
yes
]]
\
&&
output_arg
=
"--replace"
\
||
output_arg
=
if
[[
$do_check
==
yes
]]
;
then
check_arg
=
--check
output_arg
=
echo
"checking format..."
else
check_arg
=
fi
function
echolines
()
{
for
x
in
$@
;
do
echo
$x
;
done
}
echolines
$file_list
| uncrustify
$check_arg
-c
$cfg
$output_arg
-F
-
uc-codes.cfg
0 → 100644
View file @
bc70924c
This diff is collapsed.
Click to expand it.
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