mirror of
https://github.com/irssi/irssi.git
synced 2024-11-03 04:27:19 -05:00
Merge pull request #1230 from ailin-nemui/fix-clang-format-xs-opts
fix clang-format-xs option parser by using getopt
This commit is contained in:
commit
e0292665c1
98
.github/workflows/clangformat/clang-format-xs
vendored
98
.github/workflows/clangformat/clang-format-xs
vendored
@ -9,58 +9,60 @@ CLANG_FORMAT=${CLANG_FORMAT:-clang-format}
|
|||||||
options=()
|
options=()
|
||||||
files=()
|
files=()
|
||||||
lines=()
|
lines=()
|
||||||
no_options=0;inplace=0;xml=0;keep_offset=0;keep_length=0;keep=0;
|
inplace=0;xml=0;
|
||||||
filename=tmp.1.c
|
filename=tmp.1.c
|
||||||
offsets=
|
offsets=
|
||||||
karg=
|
|
||||||
off_opts=()
|
off_opts=()
|
||||||
for arg in "$@"; do
|
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 -- "$@")
|
||||||
if [[ $keep = 1 ]]; then
|
if [ $? -ne 0 ]; then exit 1; fi
|
||||||
if [[ "$karg" = "-offset" ]]; then
|
eval set -- "$opts"; unset opts
|
||||||
offsets="$offsets${offsets:+ }$arg"
|
while :; do
|
||||||
off_opts+=("$karg" "$arg")
|
case "$1" in
|
||||||
elif [[ "$karg" = "-length" ]]; then
|
--offset)
|
||||||
offsets="$offsets:$arg"
|
offsets="$offsets${offsets:+ }$2"
|
||||||
off_opts+=("$karg" "$arg")
|
off_opts+=("$1" "$2")
|
||||||
elif [[ "$karg" = "-assume-filename" ]]; then
|
shift 2
|
||||||
filename="$arg"
|
continue
|
||||||
options+=("$karg" "$arg")
|
;;
|
||||||
else
|
--length)
|
||||||
options+=("$karg" "$arg")
|
offsets="$offsets:$2"
|
||||||
fi
|
off_opts+=("$1" "$2")
|
||||||
keep=0
|
shift 2
|
||||||
elif [[ $no_options = 0 ]]; then
|
continue
|
||||||
case "$arg" in
|
;;
|
||||||
-assume-filename=*)
|
--assume-filename)
|
||||||
filename="${arg#-assume-filename=}"
|
filename="$2"
|
||||||
;;
|
options+=("$1" "$2")
|
||||||
-lines=*)
|
shift 2
|
||||||
lines+=("${arg#-lines=}")
|
continue
|
||||||
;;
|
;;
|
||||||
*)
|
--lines)
|
||||||
;;
|
lines+=("$2")
|
||||||
esac
|
shift 2
|
||||||
case "$arg" in
|
continue
|
||||||
--) no_options=1
|
;;
|
||||||
;;
|
--output-replacements-xml)
|
||||||
-i) inplace=1
|
xml=1
|
||||||
;;
|
shift
|
||||||
-output-replacements-xml)
|
continue
|
||||||
xml=1
|
;;
|
||||||
;;
|
-i)
|
||||||
-offset|-length|-cursor|-assume-filename|-fallback-style|-style)
|
inplace=1
|
||||||
keep=1
|
shift
|
||||||
karg="$arg"
|
continue
|
||||||
;;
|
;;
|
||||||
-*) options+=("$arg")
|
--)
|
||||||
;;
|
shift
|
||||||
*) files+=("$arg")
|
break
|
||||||
;;
|
;;
|
||||||
esac
|
*)
|
||||||
else
|
options+=("$1")
|
||||||
files+=("$arg")
|
shift
|
||||||
fi
|
continue
|
||||||
|
;;
|
||||||
|
esac
|
||||||
done
|
done
|
||||||
|
files=("$@")
|
||||||
|
|
||||||
export IN_LINES="${lines[*]}"
|
export IN_LINES="${lines[*]}"
|
||||||
export OFFSETS="$offsets"
|
export OFFSETS="$offsets"
|
||||||
|
Loading…
Reference in New Issue
Block a user