hxtool: Add syntax error detection
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 2/2 hxtool: Add syntax error detection
From: Jan Kiszka <[email protected]>
Add basic imbalance detection for STEXT/ETEXI.
--- hxtool | 16 +++++++++++++++- 1 files changed, 15 insertions(+), 1 deletions(-)
hxtool +15 -1
@@ -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 }
Signature · 1 line
1.6.0.2
Blue Swirl
AppliedThanks, applied.
Quoted 51 lines · Jan Kiszka
From: Jan Kiszka <[email protected]>
Add basic imbalance detection for STEXT/ETEXI.
Signed-off-by Jan Kiszka <[email protected]>---
hxtool | 16 +++++++++++++++-1 files changed, 15 insertions(+), 1 deletions(-)hxtool +0
-0@@ -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(\(.*\))")"hxtool +0
-0@@ -32,6 +45,7 @@ hxtotexi()test $flag -eq 1 && echo "$str"
;;
esac
+ line=$((line+1))
done
}--
1.6.0.2