audio: don't use 'Yoda conditions'
[qemu/ar7.git] / scripts / hxtool
blob995bb7f08c2b7632e019ff273990ce308527aaeb
1 #!/bin/sh
3 hxtoh()
5 flag=1
6 while read -r str; do
7 case $str in
8 HXCOMM*)
9 ;;
10 STEXI*|ETEXI*|SQMP*|EQMP*) flag=$(($flag^1))
13 test $flag -eq 1 && printf "%s\n" "$str"
15 esac
16 done
19 hxtotexi()
21 flag=0
22 line=1
23 while read -r str; do
24 case "$str" in
25 HXCOMM*)
27 STEXI*)
28 if test $flag -eq 1 ; then
29 echo "line $line: syntax error: expected ETEXI, found $str" >&2
30 exit 1
32 flag=1
34 ETEXI*)
35 if test $flag -ne 1 ; then
36 echo "line $line: syntax error: expected STEXI, found $str" >&2
37 exit 1
39 flag=0
41 SQMP*|EQMP*)
42 if test $flag -eq 1 ; then
43 echo "line $line: syntax error: expected ETEXI, found $str" >&2
44 exit 1
47 DEFHEADING*)
48 echo "$(expr "$str" : "DEFHEADING(\(.*\))")"
50 ARCHHEADING*)
51 echo "$(expr "$str" : "ARCHHEADING(\(.*\),.*)")"
54 test $flag -eq 1 && echo "$str"
56 esac
57 line=$((line+1))
58 done
61 hxtoqmp()
63 IFS=
64 flag=0
65 line=1
66 while read -r str; do
67 case "$str" in
68 HXCOMM*)
70 SQMP*)
71 if test $flag -eq 1 ; then
72 echo "line $line: syntax error: expected EQMP, found $str" >&2
73 exit 1
75 flag=1
77 EQMP*)
78 if test $flag -ne 1 ; then
79 echo "line $line: syntax error: expected SQMP, found $str" >&2
80 exit 1
82 flag=0
84 STEXI*|ETEXI*)
85 if test $flag -eq 1 ; then
86 echo "line $line: syntax error: expected EQMP, found $str" >&2
87 exit 1
91 test $flag -eq 1 && echo "$str"
93 esac
94 line=$((line+1))
95 done
98 case "$1" in
99 "-h") hxtoh ;;
100 "-t") hxtotexi ;;
101 "-q") hxtoqmp ;;
102 *) exit 1 ;;
103 esac
105 exit 0