Merge remote-tracking branch 'remotes/dgilbert/tags/pull-hmp-20180216' into staging
[qemu.git] / scripts / hxtool
blob7d7c4289e32926ccc026bcb0ecd63c64cfedd87a
1 #!/bin/sh
3 hxtoh()
5 flag=1
6 while read -r str; do
7 case $str in
8 HXCOMM*)
9 ;;
10 STEXI*|ETEXI*) flag=$(($flag^1))
13 test $flag -eq 1 && printf "%s\n" "$str"
15 esac
16 done
19 print_texi_heading()
21 if test "$*" != ""; then
22 title="$*"
23 printf "@subsection %s\n" "${title%:}"
27 hxtotexi()
29 flag=0
30 line=1
31 while read -r str; do
32 case "$str" in
33 HXCOMM*)
35 STEXI*)
36 if test $flag -eq 1 ; then
37 printf "line %d: syntax error: expected ETEXI, found '%s'\n" "$line" "$str" >&2
38 exit 1
40 flag=1
42 ETEXI*)
43 if test $flag -ne 1 ; then
44 printf "line %d: syntax error: expected STEXI, found '%s'\n" "$line" "$str" >&2
45 exit 1
47 flag=0
49 DEFHEADING*)
50 print_texi_heading "$(expr "$str" : "DEFHEADING(\(.*\))")"
52 ARCHHEADING*)
53 print_texi_heading "$(expr "$str" : "ARCHHEADING(\(.*\),.*)")"
56 test $flag -eq 1 && printf '%s\n' "$str"
58 esac
59 line=$((line+1))
60 done
63 case "$1" in
64 "-h") hxtoh ;;
65 "-t") hxtotexi ;;
66 *) exit 1 ;;
67 esac
69 exit 0