|
|
1.1 root 1: #!/bin/sh
2:
3: hxtoh()
4: {
5: flag=1
6: while read -r str; do
7: case $str in
8: HXCOMM*)
9: ;;
10: STEXI*|ETEXI*|SQMP*|EQMP*) flag=$(($flag^1))
11: ;;
12: *)
13: test $flag -eq 1 && printf "%s\n" "$str"
14: ;;
15: esac
16: done
17: }
18:
19: hxtotexi()
20: {
21: flag=0
22: line=1
23: while read -r str; do
24: case "$str" in
25: HXCOMM*)
26: ;;
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
46: ;;
47: DEFHEADING*)
48: echo "$(expr "$str" : "DEFHEADING(\(.*\))")"
49: ;;
1.1.1.2 ! root 50: ARCHHEADING*)
! 51: echo "$(expr "$str" : "ARCHHEADING(\(.*\),.*)")"
! 52: ;;
1.1 root 53: *)
54: test $flag -eq 1 && echo "$str"
55: ;;
56: esac
57: line=$((line+1))
58: done
59: }
60:
61: hxtoqmp()
62: {
63: IFS=
64: flag=0
65: line=1
66: while read -r str; do
67: case "$str" in
68: HXCOMM*)
69: ;;
70: SQMP*)
71: if test $flag -eq 1 ; then
72: echo "line $line: syntax error: expected EQMP, found $str" >&2
73: exit 1
74: fi
75: flag=1
76: ;;
77: EQMP*)
78: if test $flag -ne 1 ; then
79: echo "line $line: syntax error: expected SQMP, found $str" >&2
80: exit 1
81: fi
82: flag=0
83: ;;
84: STEXI*|ETEXI*)
85: if test $flag -eq 1 ; then
86: echo "line $line: syntax error: expected EQMP, found $str" >&2
87: exit 1
88: fi
89: ;;
90: *)
91: test $flag -eq 1 && echo "$str"
92: ;;
93: esac
94: line=$((line+1))
95: done
96: }
97:
98: case "$1" in
99: "-h") hxtoh ;;
100: "-t") hxtotexi ;;
101: "-q") hxtoqmp ;;
102: *) exit 1 ;;
103: esac
104:
105: exit 0
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.