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