]> git.proxmox.com Git - mirror_qemu.git/blame - scripts/hxtool
trace: avoid SystemTap dtrace(1) warnings on empty files
[mirror_qemu.git] / scripts / hxtool
CommitLineData
5824d651
BS
1#!/bin/sh
2
3hxtoh()
4{
5 flag=1
fb21ced7 6 while read -r str; do
5824d651
BS
7 case $str in
8 HXCOMM*)
9 ;;
44d619be 10 STEXI*|ETEXI*) flag=$(($flag^1))
5824d651
BS
11 ;;
12 *)
004efc96 13 test $flag -eq 1 && printf "%s\n" "$str"
5824d651
BS
14 ;;
15 esac
16 done
17}
18
43f187a5
PB
19print_texi_heading()
20{
21 if test "$*" != ""; then
de6b4f90
MA
22 title="$*"
23 printf "@subsection %s\n" "${title%:}"
43f187a5
PB
24 fi
25}
26
5824d651
BS
27hxtotexi()
28{
29 flag=0
6c913ba5 30 line=1
fb21ced7 31 while read -r str; do
5824d651
BS
32 case "$str" in
33 HXCOMM*)
34 ;;
6c913ba5
JK
35 STEXI*)
36 if test $flag -eq 1 ; then
5a1de0b3 37 printf "line %d: syntax error: expected ETEXI, found '%s'\n" "$line" "$str" >&2
6c913ba5
JK
38 exit 1
39 fi
40 flag=1
41 ;;
42 ETEXI*)
43 if test $flag -ne 1 ; then
5a1de0b3 44 printf "line %d: syntax error: expected STEXI, found '%s'\n" "$line" "$str" >&2
6c913ba5
JK
45 exit 1
46 fi
47 flag=0
5824d651
BS
48 ;;
49 DEFHEADING*)
43f187a5 50 print_texi_heading "$(expr "$str" : "DEFHEADING(\(.*\))")"
5824d651 51 ;;
a3adb7ad 52 ARCHHEADING*)
43f187a5 53 print_texi_heading "$(expr "$str" : "ARCHHEADING(\(.*\),.*)")"
a3adb7ad 54 ;;
5824d651 55 *)
5a1de0b3 56 test $flag -eq 1 && printf '%s\n' "$str"
5824d651
BS
57 ;;
58 esac
6c913ba5 59 line=$((line+1))
5824d651
BS
60 done
61}
62
63case "$1" in
64"-h") hxtoh ;;
65"-t") hxtotexi ;;
66*) exit 1 ;;
67esac
5c2f8d2d
BS
68
69exit 0