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*)
|
|
|
|
;;
|
2020-01-24 19:26:00 +03:00
|
|
|
STEXI*|ETEXI*|SRST*|ERST*) 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
|
|
|
|
}
|
|
|
|
|
2017-01-04 15:50:37 +03:00
|
|
|
print_texi_heading()
|
|
|
|
{
|
|
|
|
if test "$*" != ""; then
|
2017-10-02 17:03:00 +03:00
|
|
|
title="$*"
|
|
|
|
printf "@subsection %s\n" "${title%:}"
|
2017-01-04 15:50:37 +03:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2009-03-28 09:44:27 +03:00
|
|
|
hxtotexi()
|
|
|
|
{
|
|
|
|
flag=0
|
2020-01-24 19:26:00 +03:00
|
|
|
rstflag=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*)
|
2020-01-24 19:26:00 +03:00
|
|
|
if test $rstflag -eq 1 ; then
|
|
|
|
printf "line %d: syntax error: expected ERST, found '%s'\n" "$line" "$str" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
2010-05-20 11:16:33 +04:00
|
|
|
if test $flag -eq 1 ; then
|
2016-10-16 17:28:18 +03:00
|
|
|
printf "line %d: syntax error: expected ETEXI, found '%s'\n" "$line" "$str" >&2
|
2010-05-20 11:16:33 +04:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
flag=1
|
|
|
|
;;
|
|
|
|
ETEXI*)
|
2020-01-24 19:26:00 +03:00
|
|
|
if test $rstflag -eq 1 ; then
|
|
|
|
printf "line %d: syntax error: expected ERST, found '%s'\n" "$line" "$str" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
2010-05-20 11:16:33 +04:00
|
|
|
if test $flag -ne 1 ; then
|
2016-10-16 17:28:18 +03:00
|
|
|
printf "line %d: syntax error: expected STEXI, found '%s'\n" "$line" "$str" >&2
|
2010-05-20 11:16:33 +04:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
flag=0
|
2009-03-28 09:44:27 +03:00
|
|
|
;;
|
2020-01-24 19:26:00 +03:00
|
|
|
SRST*)
|
|
|
|
if test $rstflag -eq 1 ; then
|
|
|
|
printf "line %d: syntax error: expected ERST, found '%s'\n" "$line" "$str" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if test $flag -eq 1 ; then
|
|
|
|
printf "line %d: syntax error: expected ETEXI, found '%s'\n" "$line" "$str" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
rstflag=1
|
|
|
|
;;
|
|
|
|
ERST*)
|
|
|
|
if test $flag -eq 1 ; then
|
|
|
|
printf "line %d: syntax error: expected ETEXI, found '%s'\n" "$line" "$str" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if test $rstflag -ne 1 ; then
|
|
|
|
printf "line %d: syntax error: expected SRST, found '%s'\n" "$line" "$str" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
rstflag=0
|
|
|
|
;;
|
2009-03-28 09:44:27 +03:00
|
|
|
DEFHEADING*)
|
2017-01-04 15:50:37 +03:00
|
|
|
print_texi_heading "$(expr "$str" : "DEFHEADING(\(.*\))")"
|
2009-03-28 09:44:27 +03:00
|
|
|
;;
|
2011-12-19 10:19:31 +04:00
|
|
|
ARCHHEADING*)
|
2017-01-04 15:50:37 +03:00
|
|
|
print_texi_heading "$(expr "$str" : "ARCHHEADING(\(.*\),.*)")"
|
2011-12-19 10:19:31 +04:00
|
|
|
;;
|
2009-03-28 09:44:27 +03:00
|
|
|
*)
|
2016-10-16 17:28:18 +03:00
|
|
|
test $flag -eq 1 && printf '%s\n' "$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
|
|
|
|
}
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
"-h") hxtoh ;;
|
|
|
|
"-t") hxtotexi ;;
|
|
|
|
*) exit 1 ;;
|
|
|
|
esac
|
2009-03-28 11:13:56 +03:00
|
|
|
|
|
|
|
exit 0
|