mirror of
https://github.com/irssi/irssi.git
synced 2024-09-01 04:14:16 -04: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
88
.github/workflows/clangformat/clang-format-xs
vendored
88
.github/workflows/clangformat/clang-format-xs
vendored
@ -9,58 +9,60 @@ CLANG_FORMAT=${CLANG_FORMAT:-clang-format}
|
||||
options=()
|
||||
files=()
|
||||
lines=()
|
||||
no_options=0;inplace=0;xml=0;keep_offset=0;keep_length=0;keep=0;
|
||||
inplace=0;xml=0;
|
||||
filename=tmp.1.c
|
||||
offsets=
|
||||
karg=
|
||||
off_opts=()
|
||||
for arg in "$@"; do
|
||||
if [[ $keep = 1 ]]; then
|
||||
if [[ "$karg" = "-offset" ]]; then
|
||||
offsets="$offsets${offsets:+ }$arg"
|
||||
off_opts+=("$karg" "$arg")
|
||||
elif [[ "$karg" = "-length" ]]; then
|
||||
offsets="$offsets:$arg"
|
||||
off_opts+=("$karg" "$arg")
|
||||
elif [[ "$karg" = "-assume-filename" ]]; then
|
||||
filename="$arg"
|
||||
options+=("$karg" "$arg")
|
||||
else
|
||||
options+=("$karg" "$arg")
|
||||
fi
|
||||
keep=0
|
||||
elif [[ $no_options = 0 ]]; then
|
||||
case "$arg" in
|
||||
-assume-filename=*)
|
||||
filename="${arg#-assume-filename=}"
|
||||
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 [ $? -ne 0 ]; then exit 1; fi
|
||||
eval set -- "$opts"; unset opts
|
||||
while :; do
|
||||
case "$1" in
|
||||
--offset)
|
||||
offsets="$offsets${offsets:+ }$2"
|
||||
off_opts+=("$1" "$2")
|
||||
shift 2
|
||||
continue
|
||||
;;
|
||||
-lines=*)
|
||||
lines+=("${arg#-lines=}")
|
||||
--length)
|
||||
offsets="$offsets:$2"
|
||||
off_opts+=("$1" "$2")
|
||||
shift 2
|
||||
continue
|
||||
;;
|
||||
--assume-filename)
|
||||
filename="$2"
|
||||
options+=("$1" "$2")
|
||||
shift 2
|
||||
continue
|
||||
;;
|
||||
--lines)
|
||||
lines+=("$2")
|
||||
shift 2
|
||||
continue
|
||||
;;
|
||||
--output-replacements-xml)
|
||||
xml=1
|
||||
shift
|
||||
continue
|
||||
;;
|
||||
-i)
|
||||
inplace=1
|
||||
shift
|
||||
continue
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
;;
|
||||
*)
|
||||
options+=("$1")
|
||||
shift
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
case "$arg" in
|
||||
--) no_options=1
|
||||
;;
|
||||
-i) inplace=1
|
||||
;;
|
||||
-output-replacements-xml)
|
||||
xml=1
|
||||
;;
|
||||
-offset|-length|-cursor|-assume-filename|-fallback-style|-style)
|
||||
keep=1
|
||||
karg="$arg"
|
||||
;;
|
||||
-*) options+=("$arg")
|
||||
;;
|
||||
*) files+=("$arg")
|
||||
;;
|
||||
esac
|
||||
else
|
||||
files+=("$arg")
|
||||
fi
|
||||
done
|
||||
files=("$@")
|
||||
|
||||
export IN_LINES="${lines[*]}"
|
||||
export OFFSETS="$offsets"
|
||||
|
Loading…
Reference in New Issue
Block a user