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