From 1f6d0d0ff7c0aa3e6b2d3686b7d2e8b9958beaf6 Mon Sep 17 00:00:00 2001 From: Danyil Bohdan Date: Mon, 31 Aug 2015 19:33:39 +0300 Subject: [PATCH] Fixed "awk" parser failing with no mode specified Bumped version to v0.13.1 --- lib/parsers/awk.tcl | 13 +++++++------ sqawk-dev.tcl | 2 +- tests.tcl | 14 ++++++++++++++ 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/lib/parsers/awk.tcl b/lib/parsers/awk.tcl index 4509090..36f8ba3 100644 --- a/lib/parsers/awk.tcl +++ b/lib/parsers/awk.tcl @@ -131,12 +131,13 @@ proc ::sqawk::parsers::awk::splitmerge {str regexp mergeRanges} { # Trim the contents of the variable "record". proc ::sqawk::parsers::awk::trim-record mode { upvar 1 record record - set record [switch -exact -- $mode { - both { string trim $record } - left { string trimleft $record } - right { string trimright $record } - default { error "unknown more: \"$mode\"" } - }] + switch -exact -- $mode { + both { set record [string trim $record] } + left { set record [string trimleft $record] } + right { set record [string trimright $record] } + {} {} + default { error "unknown mode: \"$mode\"" } + } } # Convert raw text data into a list of database rows using regular diff --git a/sqawk-dev.tcl b/sqawk-dev.tcl index be87a0d..671fe79 100755 --- a/sqawk-dev.tcl +++ b/sqawk-dev.tcl @@ -9,7 +9,7 @@ package require sqlite3 package require textutil namespace eval ::sqawk { - variable version 0.13.0 + variable version 0.13.1 } interp alias {} ::source+ {} ::source diff --git a/tests.tcl b/tests.tcl index 2f2c61b..2e4ee1a 100644 --- a/tests.tcl +++ b/tests.tcl @@ -297,6 +297,20 @@ namespace eval ::sqawk::tests { return $result } -result ┌─┬─┬─┐\n│a│b│c│\n├─┼─┼─┤\n│d│e│f│\n├─┼─┼─┤\n│g│h│i│\n└─┴─┴─┘ + tcltest::test test17 {trim option} \ + -setup $setup \ + -body { + with-temp-files filename ch { + set result {} + puts $ch { a } + close $ch + lappend result [sqawk-tcl {select a1 from a} $filename] + lappend result [sqawk-tcl {select a1 from a} trim=left $filename] + lappend result [sqawk-tcl {select a1 from a} trim=both $filename] + } + return $result + } -result {{} a a} + tcltest::test test-nf-1-crop {NF mode crop} \ -setup $setup \ -body {