Skip to content

Commit

Permalink
Fixed "awk" parser failing with no mode specified
Browse files Browse the repository at this point in the history
Bumped version to v0.13.1
  • Loading branch information
dbohdan committed Aug 31, 2015
1 parent dab1f7e commit 1f6d0d0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
13 changes: 7 additions & 6 deletions lib/parsers/awk.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion sqawk-dev.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions tests.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 1f6d0d0

Please sign in to comment.