2009-03-28 06:44:27 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
2026-05-04 18:49:13 +01:00
|
|
|
print_if_not_rst()
|
|
|
|
|
{
|
|
|
|
|
test $in_rst -eq 0 && printf "%s\n" "$str"
|
|
|
|
|
}
|
|
|
|
|
|
2009-03-28 06:44:27 +00:00
|
|
|
hxtoh()
|
|
|
|
|
{
|
2026-05-04 18:49:12 +01:00
|
|
|
in_rst=0
|
2026-05-04 18:49:13 +01:00
|
|
|
# .name for HMP
|
|
|
|
|
seen_name=0
|
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*)
|
|
|
|
|
;;
|
2026-05-04 18:49:12 +01:00
|
|
|
SRST*)
|
|
|
|
|
if [ $in_rst -eq 1 ]
|
|
|
|
|
then
|
|
|
|
|
echo "Error: SRST inside another RST" >&2
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
2026-05-04 18:49:13 +01:00
|
|
|
# consume the name
|
|
|
|
|
seen_name=0
|
2026-05-04 18:49:12 +01:00
|
|
|
in_rst=1
|
|
|
|
|
;;
|
|
|
|
|
ERST*)
|
|
|
|
|
if [ $in_rst -eq 0 ]
|
|
|
|
|
then
|
|
|
|
|
echo "Error: ERST already outside RST" >&2
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
in_rst=0
|
2009-03-28 06:44:27 +00:00
|
|
|
;;
|
2026-05-04 18:49:13 +01:00
|
|
|
# Note the space at the start - we need to exclude something.name
|
|
|
|
|
( .name*)
|
|
|
|
|
if [ $seen_name -eq 1 ]
|
|
|
|
|
then
|
|
|
|
|
echo "Error: Seen another .name, maybe missing docs?" >&2
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
seen_name=1
|
|
|
|
|
print_if_not_rst
|
|
|
|
|
;;
|
2009-03-28 06:44:27 +00:00
|
|
|
*)
|
2026-05-04 18:49:13 +01:00
|
|
|
print_if_not_rst
|
2009-03-28 06:44:27 +00:00
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
done
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
|
"-h") hxtoh ;;
|
|
|
|
|
*) exit 1 ;;
|
2019-07-15 18:06:04 +04:00
|
|
|
esac < "$2"
|
2009-03-28 08:13:56 +00:00
|
|
|
|
|
|
|
|
exit 0
|