2009-03-28 09:44:27 +03:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
hxtoh()
|
|
|
|
{
|
|
|
|
flag=1
|
2009-03-29 13:06:43 +04:00
|
|
|
while read -r str; do
|
2009-03-28 09:44:27 +03:00
|
|
|
case $str in
|
|
|
|
HXCOMM*)
|
|
|
|
;;
|
2010-05-31 21:43:31 +04:00
|
|
|
STEXI*|ETEXI*|SQMP*|EQMP*) flag=$(($flag^1))
|
2009-03-28 09:44:27 +03:00
|
|
|
;;
|
|
|
|
*)
|
2009-03-29 14:50:43 +04:00
|
|
|
test $flag -eq 1 && printf "%s\n" "$str"
|
2009-03-28 09:44:27 +03:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
hxtotexi()
|
|
|
|
{
|
|
|
|
flag=0
|
2010-05-20 11:16:33 +04:00
|
|
|
line=1
|
2009-03-29 13:06:43 +04:00
|
|
|
while read -r str; do
|
2009-03-28 09:44:27 +03:00
|
|
|
case "$str" in
|
|
|
|
HXCOMM*)
|
|
|
|
;;
|
2010-05-20 11:16:33 +04:00
|
|
|
STEXI*)
|
|
|
|
if test $flag -eq 1 ; then
|
|
|
|
echo "line $line: syntax error: expected ETEXI, found $str" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
flag=1
|
|
|
|
;;
|
|
|
|
ETEXI*)
|
|
|
|
if test $flag -ne 1 ; then
|
|
|
|
echo "line $line: syntax error: expected STEXI, found $str" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
flag=0
|
2009-03-28 09:44:27 +03:00
|
|
|
;;
|
2010-05-31 21:43:31 +04:00
|
|
|
SQMP*|EQMP*)
|
|
|
|
if test $flag -eq 1 ; then
|
|
|
|
echo "line $line: syntax error: expected ETEXI, found $str" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
;;
|
2009-03-28 09:44:27 +03:00
|
|
|
DEFHEADING*)
|
2009-07-02 01:13:34 +04:00
|
|
|
echo "$(expr "$str" : "DEFHEADING(\(.*\))")"
|
2009-03-28 09:44:27 +03:00
|
|
|
;;
|
2011-12-19 10:19:31 +04:00
|
|
|
ARCHHEADING*)
|
|
|
|
echo "$(expr "$str" : "ARCHHEADING(\(.*\),.*)")"
|
|
|
|
;;
|
2009-03-28 09:44:27 +03:00
|
|
|
*)
|
2009-07-02 01:13:34 +04:00
|
|
|
test $flag -eq 1 && echo "$str"
|
2009-03-28 09:44:27 +03:00
|
|
|
;;
|
|
|
|
esac
|
2010-05-20 11:16:33 +04:00
|
|
|
line=$((line+1))
|
2009-03-28 09:44:27 +03:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2010-05-31 21:43:31 +04:00
|
|
|
hxtoqmp()
|
|
|
|
{
|
|
|
|
IFS=
|
|
|
|
flag=0
|
2010-06-02 11:06:03 +04:00
|
|
|
line=1
|
2010-05-31 21:43:31 +04:00
|
|
|
while read -r str; do
|
|
|
|
case "$str" in
|
|
|
|
HXCOMM*)
|
|
|
|
;;
|
|
|
|
SQMP*)
|
|
|
|
if test $flag -eq 1 ; then
|
|
|
|
echo "line $line: syntax error: expected EQMP, found $str" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
flag=1
|
|
|
|
;;
|
|
|
|
EQMP*)
|
|
|
|
if test $flag -ne 1 ; then
|
|
|
|
echo "line $line: syntax error: expected SQMP, found $str" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
flag=0
|
|
|
|
;;
|
|
|
|
STEXI*|ETEXI*)
|
|
|
|
if test $flag -eq 1 ; then
|
|
|
|
echo "line $line: syntax error: expected EQMP, found $str" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
test $flag -eq 1 && echo "$str"
|
|
|
|
;;
|
|
|
|
esac
|
2010-06-02 11:06:03 +04:00
|
|
|
line=$((line+1))
|
2010-05-31 21:43:31 +04:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2009-03-28 09:44:27 +03:00
|
|
|
case "$1" in
|
|
|
|
"-h") hxtoh ;;
|
|
|
|
"-t") hxtotexi ;;
|
2010-05-31 21:43:31 +04:00
|
|
|
"-q") hxtoqmp ;;
|
2009-03-28 09:44:27 +03:00
|
|
|
*) exit 1 ;;
|
|
|
|
esac
|
2009-03-28 11:13:56 +03:00
|
|
|
|
|
|
|
exit 0
|