hxtool: Split srst/erst add checks

Split the SRST/ERST case and add some checks.
This is mainly to make it easier to add some checks in following
patches.

Signed-off-by: Dr. David Alan Gilbert <dave@treblig.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-ID: <20260504174914.122607-3-dave@treblig.org>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
Dr. David Alan Gilbert
2026-05-04 18:49:12 +01:00
committed by Markus Armbruster
parent ca552c4c8f
commit a048b4e796

View File

@@ -2,15 +2,29 @@
hxtoh()
{
flag=1
in_rst=0
while read -r str; do
case $str in
HXCOMM*)
;;
SRST*|ERST*) flag=$(($flag^1))
SRST*)
if [ $in_rst -eq 1 ]
then
echo "Error: SRST inside another RST" >&2
exit 1
fi
in_rst=1
;;
ERST*)
if [ $in_rst -eq 0 ]
then
echo "Error: ERST already outside RST" >&2
exit 1
fi
in_rst=0
;;
*)
test $flag -eq 1 && printf "%s\n" "$str"
test $in_rst -eq 0 && printf "%s\n" "$str"
;;
esac
done