From patchwork Thu May 20 07:16:33 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 53051 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B56E2B7D43 for ; Thu, 20 May 2010 18:51:06 +1000 (EST) Received: from localhost ([127.0.0.1]:37930 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OF1T4-0002ID-H7 for incoming@patchwork.ozlabs.org; Thu, 20 May 2010 04:51:02 -0400 Received: from [140.186.70.92] (port=55408 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OF1RX-0001xe-J8 for qemu-devel@nongnu.org; Thu, 20 May 2010 04:49:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OF1RV-000676-RK for qemu-devel@nongnu.org; Thu, 20 May 2010 04:49:27 -0400 Received: from fmmailgate03.web.de ([217.72.192.234]:57950) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OEzzf-0001u9-HV for qemu-devel@nongnu.org; Thu, 20 May 2010 03:16:35 -0400 Received: from smtp02.web.de ( [172.20.0.184]) by fmmailgate03.web.de (Postfix) with ESMTP id 6468A151058D3 for ; Thu, 20 May 2010 09:16:34 +0200 (CEST) Received: from [88.65.39.229] (helo=[192.168.1.10]) by smtp02.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.110 #4) id 1OEzzd-00019m-00 for qemu-devel@nongnu.org; Thu, 20 May 2010 09:16:33 +0200 Message-ID: <4BF4E1D1.1010507@web.de> Date: Thu, 20 May 2010 09:16:33 +0200 From: Jan Kiszka 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 MIME-Version: 1.0 To: qemu-devel References: <4BF4E1A9.9010405@web.de> In-Reply-To: <4BF4E1A9.9010405@web.de> X-Enigmail-Version: 0.95.7 X-Sender: jan.kiszka@web.de X-Provags-ID: V01U2FsdGVkX1+7isz+sb3wNAlPvB8lyNi/SnyAzCvZGLeNMEDR tWgwD2WAEOdDErW1j0l7cuf8vRUsYIrR6Ykngq7eO3kA6XNoAx f81yA0+7U= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 Subject: [Qemu-devel] [PATCH 2/2] hxtool: Add syntax error detection X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Jan Kiszka Add basic imbalance detection for STEXT/ETEXI. Signed-off-by: Jan Kiszka --- 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 }