2009-03-28 14:44:27 +08:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
hxtoh()
|
|
|
|
{
|
|
|
|
flag=1
|
2009-03-29 17:06:43 +08:00
|
|
|
while read -r str; do
|
2009-03-28 14:44:27 +08:00
|
|
|
case $str in
|
|
|
|
HXCOMM*)
|
|
|
|
;;
|
|
|
|
STEXI*|ETEXI*) flag=$(($flag^1))
|
|
|
|
;;
|
|
|
|
*)
|
2009-03-29 18:50:43 +08:00
|
|
|
test $flag -eq 1 && printf "%s\n" "$str"
|
2009-03-28 14:44:27 +08:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
hxtotexi()
|
|
|
|
{
|
|
|
|
flag=0
|
2010-05-20 15:16:33 +08:00
|
|
|
line=1
|
2009-03-29 17:06:43 +08:00
|
|
|
while read -r str; do
|
2009-03-28 14:44:27 +08:00
|
|
|
case "$str" in
|
|
|
|
HXCOMM*)
|
|
|
|
;;
|
2010-05-20 15:16:33 +08: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 14:44:27 +08:00
|
|
|
;;
|
|
|
|
DEFHEADING*)
|
2009-07-02 05:13:34 +08:00
|
|
|
echo "$(expr "$str" : "DEFHEADING(\(.*\))")"
|
2009-03-28 14:44:27 +08:00
|
|
|
;;
|
|
|
|
*)
|
2009-07-02 05:13:34 +08:00
|
|
|
test $flag -eq 1 && echo "$str"
|
2009-03-28 14:44:27 +08:00
|
|
|
;;
|
|
|
|
esac
|
2010-05-20 15:16:33 +08:00
|
|
|
line=$((line+1))
|
2009-03-28 14:44:27 +08:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
"-h") hxtoh ;;
|
|
|
|
"-t") hxtotexi ;;
|
|
|
|
*) exit 1 ;;
|
|
|
|
esac
|
2009-03-28 16:13:56 +08:00
|
|
|
|
|
|
|
exit 0
|