From: Jan Kiszka Date: Thu, 20 May 2010 07:16:33 +0000 (+0200) Subject: hxtool: Add syntax error detection X-Git-Tag: v0.13.0-rc0~452 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6c913ba5f353741fc8284f54675b26943ecc7b8b;p=thirdparty%2Fqemu.git hxtool: Add syntax error detection Add basic imbalance detection for STEXT/ETEXI. Signed-off-by: Jan Kiszka Signed-off-by: Blue Swirl --- diff --git a/hxtool b/hxtool index 0fdbc641c64..8f655320be4 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 }