Skip to content

Commit eccfd66

Browse files
committed
upstream: update hxtool
Change-Id: Ie94426766f3a59af46ddee6d3e53a56e9f8766a3
1 parent 1cea2fb commit eccfd66

File tree

1 file changed

+60
-2
lines changed

1 file changed

+60
-2
lines changed

hxtool

+60-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ hxtoh()
77
case $str in
88
HXCOMM*)
99
;;
10-
STEXI*|ETEXI*) flag=$(($flag^1))
10+
STEXI*|ETEXI*|SQMP*|EQMP*) flag=$(($flag^1))
1111
;;
1212
*)
1313
test $flag -eq 1 && printf "%s\n" "$str"
@@ -19,11 +19,30 @@ hxtoh()
1919
hxtotexi()
2020
{
2121
flag=0
22+
line=1
2223
while read -r str; do
2324
case "$str" in
2425
HXCOMM*)
2526
;;
26-
STEXI*|ETEXI*) flag=$(($flag^1))
27+
STEXI*)
28+
if test $flag -eq 1 ; then
29+
echo "line $line: syntax error: expected ETEXI, found $str" >&2
30+
exit 1
31+
fi
32+
flag=1
33+
;;
34+
ETEXI*)
35+
if test $flag -ne 1 ; then
36+
echo "line $line: syntax error: expected STEXI, found $str" >&2
37+
exit 1
38+
fi
39+
flag=0
40+
;;
41+
SQMP*|EQMP*)
42+
if test $flag -eq 1 ; then
43+
echo "line $line: syntax error: expected ETEXI, found $str" >&2
44+
exit 1
45+
fi
2746
;;
2847
DEFHEADING*)
2948
echo "$(expr "$str" : "DEFHEADING(\(.*\))")"
@@ -32,12 +51,51 @@ hxtotexi()
3251
test $flag -eq 1 && echo "$str"
3352
;;
3453
esac
54+
line=$((line+1))
55+
done
56+
}
57+
58+
hxtoqmp()
59+
{
60+
IFS=
61+
flag=0
62+
line=1
63+
while read -r str; do
64+
case "$str" in
65+
HXCOMM*)
66+
;;
67+
SQMP*)
68+
if test $flag -eq 1 ; then
69+
echo "line $line: syntax error: expected EQMP, found $str" >&2
70+
exit 1
71+
fi
72+
flag=1
73+
;;
74+
EQMP*)
75+
if test $flag -ne 1 ; then
76+
echo "line $line: syntax error: expected SQMP, found $str" >&2
77+
exit 1
78+
fi
79+
flag=0
80+
;;
81+
STEXI*|ETEXI*)
82+
if test $flag -eq 1 ; then
83+
echo "line $line: syntax error: expected EQMP, found $str" >&2
84+
exit 1
85+
fi
86+
;;
87+
*)
88+
test $flag -eq 1 && echo "$str"
89+
;;
90+
esac
91+
line=$((line+1))
3592
done
3693
}
3794

3895
case "$1" in
3996
"-h") hxtoh ;;
4097
"-t") hxtotexi ;;
98+
"-q") hxtoqmp ;;
4199
*) exit 1 ;;
42100
esac
43101

0 commit comments

Comments
 (0)