aboutsummaryrefslogtreecommitdiff
path: root/hxtool
diff options
context:
space:
mode:
authorJan Kiszka <jan.kiszka@siemens.com>2010-05-20 09:16:33 +0200
committerBlue Swirl <blauwirbel@gmail.com>2010-05-22 08:34:24 +0000
commit6c913ba5f353741fc8284f54675b26943ecc7b8b (patch)
treef7bc73165c06057fcfb5bc4d0c7b028e3666d254 /hxtool
parent3c4c32101bdb4ee939e40a8e3d3f9d2a5d0ec053 (diff)
hxtool: Add syntax error detection
Add basic imbalance detection for STEXT/ETEXI. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Diffstat (limited to 'hxtool')
-rw-r--r--hxtool16
1 files changed, 15 insertions, 1 deletions
diff --git a/hxtool b/hxtool
index 0fdbc641c6..8f655320be 100644
--- a/hxtool
+++ b/hxtool
@@ -19,11 +19,24 @@ hxtoh()
hxtotexi()
{
flag=0
+ line=1
while read -r str; do
case "$str" in
HXCOMM*)
;;
- STEXI*|ETEXI*) flag=$(($flag^1))
+ STEXI*)
+ if test $flag -eq 1 ; then
+ echo "line $line: syntax error: expected ETEXI, found $str" >&2
+ exit 1
+ fi
+ flag=1
+ ;;
+ ETEXI*)
+ if test $flag -ne 1 ; then
+ echo "line $line: syntax error: expected STEXI, found $str" >&2
+ exit 1
+ fi
+ flag=0
;;
DEFHEADING*)
echo "$(expr "$str" : "DEFHEADING(\(.*\))")"
@@ -32,6 +45,7 @@ hxtotexi()
test $flag -eq 1 && echo "$str"
;;
esac
+ line=$((line+1))
done
}