Overview
Comment: | Fixed issue with zlib support in TclVFS when using Tcl 8.6+ native "zlib" command |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
468076b014552bf1165993e94fef58d5 |
User & Date: | rkeene on 2010-09-26 04:47:40 |
Other Links: | manifest | tags |
Context
2010-09-26
| ||
04:47 |
Added Index page for KitBuilds directory
Added script to create root of KitBuilds directory check-in: deeb9702c3 user: rkeene tags: trunk | |
04:47 | Fixed issue with zlib support in TclVFS when using Tcl 8.6+ native "zlib" command check-in: 468076b014 user: rkeene tags: trunk | |
04:47 | Updated to include OS and CPU in Kit build info check-in: 0f7ae7bf19 user: rkeene tags: trunk | |
Changes
Added tclvfs/patches/8.6/tclvfs-20080503-supportnativezlib.diff version [60b79c951c].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | Binary files tclvfs-20080503.orig/library/.vfslib.tcl.swp and tclvfs-20080503-1rsk/library/.vfslib.tcl.swp differ diff -uNr tclvfs-20080503.orig/library/vfslib.tcl tclvfs-20080503-1rsk/library/vfslib.tcl --- tclvfs-20080503.orig/library/vfslib.tcl 2006-09-14 16:39:57.000000000 -0500 +++ tclvfs-20080503-1rsk/library/vfslib.tcl 2010-09-17 11:13:15.000000000 -0500 @@ -5,6 +5,14 @@ namespace eval ::vfs { variable zseq 0 ;# used to generate temp zstream cmd names + variable zlibPkg 0 ;# Use Tcl 8.6+ zlib command, or zlib package +} + + +# Work with the Tcl 8.6+ built-in zlib command or the zlib package, if available +catch { + package present zlib + set ::vfs::zlibPkg 1 } # for backwards compatibility @@ -140,10 +148,70 @@ } } + proc vfs::zstream_handler_native {zcmd ifd clen ilen imode cmd fd {a1 ""} {a2 ""}} { + upvar ::vfs::_zstream_pos($fd) pos + + switch -- $cmd { + seek { + switch $a2 { + 1 - current { incr a1 $pos } + 2 - end { incr a1 $ilen } + } + # to seek back, rewind, i.e. start from scratch + if {$a1 < $pos} { + rename $zcmd "" + zlib $imode $zcmd + seek $ifd 0 + set pos 0 + } + # consume data while not yet at seek position + while {$pos < $a1} { + set n [expr {$a1 - $pos}] + if {$n > 4096} { set n 4096 } + # 2003-02-09: read did not work (?), spell it out instead + #read $fd $n + zstream_handler $zcmd $ifd $clen $ilen $imode read $fd $n + } + return $pos + } + read { + set r "" + set n $a1 + #puts stderr " want $n z $zcmd pos $pos ilen $ilen" + if {$n + $pos > $ilen} { set n [expr {$ilen - $pos}] } + while {$n > 0} { + set c [expr {$clen - [tell $ifd]}] + if {$c > 4096} { set c 4096 } + set data [read $ifd $c] + #puts "filled $c [string length $data]" + $zcmd put $data + set data [$zcmd get $n] + #puts stderr " read [string length $data]" + if {$data eq ""} break + append r $data + incr pos [string length $data] + incr n -[string length $data] + } + return $r + } + close { + rename $zcmd "" + close $ifd + unset pos + } + default { error "bad cmd in zstream_handler: $cmd" } + } + } + proc vfs::zstream {mode ifd clen ilen} { - set cname _zstream_[incr ::vfs::zseq] - zlib s$mode $cname - set cmd [list ::vfs::zstream_handler $cname $ifd $clen $ilen s$mode] + if {$::vfs::zlibPkg} { + set cname _zstream_[incr ::vfs::zseq] + zlib s$mode $cname + set cmd [list ::vfs::zstream_handler $cname $ifd $clen $ilen s$mode] + } else { + set cname [zlib stream $mode] + set cmd [list ::vfs::zstream_handler_native $cname $ifd $clen $ilen s$mode] + } set fd [rechan $cmd 2] set ::vfs::_zstream_pos($fd) 0 return $fd |