[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 2/2] hxtool: Add syntax error detection
From: |
Jan Kiszka |
Subject: |
[Qemu-devel] [PATCH 2/2] hxtool: Add syntax error detection |
Date: |
Thu, 20 May 2010 09:16:33 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 |
From: Jan Kiszka <address@hidden>
Add basic imbalance detection for STEXT/ETEXI.
Signed-off-by: Jan Kiszka <address@hidden>
---
hxtool | 16 +++++++++++++++-
1 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/hxtool b/hxtool
index 0fdbc64..8f65532 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
}
--
1.6.0.2
- [Qemu-devel] [PATCH 2/2] hxtool: Add syntax error detection,
Jan Kiszka <=