mirror of
https://github.com/irssi/irssi.git
synced 2026-08-08 19:30:15 +02:00
fix clang-format-xs boot code
This commit is contained in:
parent
00146211d0
commit
0157a4424b
2 changed files with 27 additions and 4 deletions
|
|
@ -6,14 +6,22 @@ srcdir=$(dirname "$(readlink -f "$0")")
|
||||||
test -z "$srcdir" && srcdir=.
|
test -z "$srcdir" && srcdir=.
|
||||||
|
|
||||||
CLANG_FORMAT=${CLANG_FORMAT:-clang-format}
|
CLANG_FORMAT=${CLANG_FORMAT:-clang-format}
|
||||||
|
if [[ "$CLANG_FORMAT" = *-xs\ * ]]; then
|
||||||
|
CLANG_FORMAT=${CLANG_FORMAT/-xs / }
|
||||||
|
elif [[ "$CLANG_FORMAT" = *-xs ]]; then
|
||||||
|
CLANG_FORMAT=${CLANG_FORMAT%-xs}
|
||||||
|
fi
|
||||||
|
|
||||||
|
clang_format_version=$($CLANG_FORMAT --version 2>/dev/null | perl -ne '/(\d+)/ && print $1 or print 0')
|
||||||
|
|
||||||
options=()
|
options=()
|
||||||
files=()
|
files=()
|
||||||
lines=()
|
lines=()
|
||||||
inplace=0;xml=0;
|
inplace=0;xml=0;list_ignored=0;
|
||||||
filename=tmp.1.c
|
filename=tmp.1.c
|
||||||
offsets=
|
offsets=
|
||||||
off_opts=()
|
off_opts=()
|
||||||
opts=$(getopt -n clang-format-xs -s bash -a -o in -l Werror,assume-filename:,cursor:,dry-run,dump-config,fallback-style:,ferror-limit:,help,length:,lines:,offset:,output-replacement-xmls,sort-includes,style:,verbose,version -- "$@")
|
opts=$(getopt -n clang-format-xs -s bash -a -o in -l Werror,assume-filename:,cursor:,dry-run,dump-config,fallback-style:,ferror-limit:,help,length:,lines:,offset:,output-replacement-xmls,sort-includes,list-ignored,style:,verbose,version -- "$@")
|
||||||
if [ $? -ne 0 ]; then exit 1; fi
|
if [ $? -ne 0 ]; then exit 1; fi
|
||||||
eval set -- "$opts"; unset opts
|
eval set -- "$opts"; unset opts
|
||||||
while :; do
|
while :; do
|
||||||
|
|
@ -47,6 +55,11 @@ while :; do
|
||||||
shift
|
shift
|
||||||
continue
|
continue
|
||||||
;;
|
;;
|
||||||
|
--list-ignored)
|
||||||
|
list_ignored=1
|
||||||
|
shift
|
||||||
|
continue
|
||||||
|
;;
|
||||||
-i)
|
-i)
|
||||||
inplace=1
|
inplace=1
|
||||||
shift
|
shift
|
||||||
|
|
@ -75,6 +88,10 @@ fi
|
||||||
if [[ $xml = 1 ]]; then
|
if [[ $xml = 1 ]]; then
|
||||||
options_o=("-output-replacements-xml" "${options[@]}")
|
options_o=("-output-replacements-xml" "${options[@]}")
|
||||||
fi
|
fi
|
||||||
|
if [[ $list_ignored = 1 ]]; then
|
||||||
|
options_o=("-list-ignored" "${options[@]}")
|
||||||
|
fi
|
||||||
|
|
||||||
options_o+=("${off_opts[@]}")
|
options_o+=("${off_opts[@]}")
|
||||||
|
|
||||||
do_xs() {
|
do_xs() {
|
||||||
|
|
@ -92,7 +109,13 @@ do_xs() {
|
||||||
rm "$1".1.c
|
rm "$1".1.c
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ ${#files[@]} -eq 0 ]]; then
|
if [[ $list_ignored = 1 ]]; then
|
||||||
|
if [[ $clang_format_version -lt 19 ]]; then
|
||||||
|
: # true
|
||||||
|
else
|
||||||
|
$CLANG_FORMAT "${options_o[@]}" -- "${files[@]}"
|
||||||
|
fi
|
||||||
|
elif [[ ${#files[@]} -eq 0 ]]; then
|
||||||
case "$filename" in
|
case "$filename" in
|
||||||
*.xs)
|
*.xs)
|
||||||
cat > "$filename".1.xs
|
cat > "$filename".1.xs
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ while (<>) {
|
||||||
$prot = 2;
|
$prot = 2;
|
||||||
$in_code = 0;
|
$in_code = 0;
|
||||||
}
|
}
|
||||||
elsif (/^((PP)?CODE|PREINIT):/) {
|
elsif (/^((PP)?CODE|PREINIT|BOOT):/) {
|
||||||
$prot = 1;
|
$prot = 1;
|
||||||
$in_code = 3;
|
$in_code = 3;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue