memhp: consolidate scattered MHPD device declaration
[qemu/ar7.git] / scripts / hxtool
blob04f7d7b0edfc44565f3668c4227666e861c233be
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 printf "line %d: syntax error: expected ETEXI, found '%s'\n" "$line" "$str" >&2
30 exit 1
32 flag=1
34 ETEXI*)
35 if test $flag -ne 1 ; then
36 printf "line %d: syntax error: expected STEXI, found '%s'\n" "$line" "$str" >&2
37 exit 1
39 flag=0
41 SQMP*|EQMP*)
42 if test $flag -eq 1 ; then
43 printf "line %d: syntax error: expected ETEXI, found '%s'\n" "$line" "$str" >&2
44 exit 1
47 DEFHEADING*)
48 printf '%s\n' "$(expr "$str" : "DEFHEADING(\(.*\))")"
50 ARCHHEADING*)
51 printf '%s\n' "$(expr "$str" : "ARCHHEADING(\(.*\),.*)")"
54 test $flag -eq 1 && printf '%s\n' "$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 printf "line %d: syntax error: expected EQMP, found '%s'\n" "$line" "$str" >&2
73 exit 1
75 flag=1
77 EQMP*)
78 if test $flag -ne 1 ; then
79 printf "line %d: syntax error: expected SQMP, found '%s'\n" "$line" "$str" >&2
80 exit 1
82 flag=0
84 STEXI*|ETEXI*)
85 if test $flag -eq 1 ; then
86 printf "line %d: syntax error: expected EQMP, found '%s'\n" "$line" "$str" >&2
87 exit 1
91 test $flag -eq 1 && printf '%s\n' "$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