Check-in [468076b014]
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:468076b014552bf1165993e94fef58d51b7a8add
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  +Binary files tclvfs-20080503.orig/library/.vfslib.tcl.swp and tclvfs-20080503-1rsk/library/.vfslib.tcl.swp differ
            2  +diff -uNr tclvfs-20080503.orig/library/vfslib.tcl tclvfs-20080503-1rsk/library/vfslib.tcl
            3  +--- tclvfs-20080503.orig/library/vfslib.tcl	2006-09-14 16:39:57.000000000 -0500
            4  ++++ tclvfs-20080503-1rsk/library/vfslib.tcl	2010-09-17 11:13:15.000000000 -0500
            5  +@@ -5,6 +5,14 @@
            6  + 
            7  + namespace eval ::vfs {
            8  +     variable zseq 0	;# used to generate temp zstream cmd names
            9  ++    variable zlibPkg 0  ;# Use Tcl 8.6+ zlib command, or zlib package
           10  ++}
           11  ++
           12  ++
           13  ++# Work with the Tcl 8.6+ built-in zlib command or the zlib package, if available
           14  ++catch {
           15  ++	package present zlib
           16  ++	set ::vfs::zlibPkg 1
           17  + }
           18  + 
           19  + # for backwards compatibility
           20  +@@ -140,10 +148,70 @@
           21  + 	}
           22  +     }
           23  + 
           24  ++    proc vfs::zstream_handler_native {zcmd ifd clen ilen imode cmd fd {a1 ""} {a2 ""}} {
           25  ++        upvar ::vfs::_zstream_pos($fd) pos
           26  ++
           27  ++        switch -- $cmd {
           28  ++            seek {
           29  ++                switch $a2 {
           30  ++                    1 - current { incr a1 $pos }
           31  ++                    2 - end { incr a1 $ilen }
           32  ++                }
           33  ++                # to seek back, rewind, i.e. start from scratch
           34  ++                if {$a1 < $pos} {
           35  ++                    rename $zcmd ""
           36  ++                    zlib $imode $zcmd
           37  ++                    seek $ifd 0
           38  ++                    set pos 0
           39  ++                }
           40  ++                # consume data while not yet at seek position
           41  ++                while {$pos < $a1} {
           42  ++                    set n [expr {$a1 - $pos}]
           43  ++                    if {$n > 4096} { set n 4096 }
           44  ++                    # 2003-02-09: read did not work (?), spell it out instead
           45  ++                    #read $fd $n
           46  ++                    zstream_handler $zcmd $ifd $clen $ilen $imode read $fd $n
           47  ++                }
           48  ++                return $pos
           49  ++            }
           50  ++            read {
           51  ++                set r ""
           52  ++                set n $a1
           53  ++                #puts stderr " want $n z $zcmd pos $pos ilen $ilen"
           54  ++                if {$n + $pos > $ilen} { set n [expr {$ilen - $pos}] }
           55  ++                while {$n > 0} {
           56  ++                    set c [expr {$clen - [tell $ifd]}]
           57  ++                    if {$c > 4096} { set c 4096 }
           58  ++                    set data [read $ifd $c]
           59  ++                    #puts "filled $c [string length $data]"
           60  ++                    $zcmd put $data
           61  ++                    set data [$zcmd get $n]
           62  ++                    #puts stderr " read [string length $data]"
           63  ++                    if {$data eq ""} break
           64  ++                    append r $data
           65  ++                    incr pos [string length $data]
           66  ++                    incr n -[string length $data]
           67  ++                }
           68  ++                return $r
           69  ++            }
           70  ++            close {
           71  ++                rename $zcmd ""
           72  ++                close $ifd
           73  ++                unset pos
           74  ++            }
           75  ++            default { error "bad cmd in zstream_handler: $cmd" }
           76  ++        }
           77  ++    }
           78  ++
           79  +     proc vfs::zstream {mode ifd clen ilen} {
           80  +-	set cname _zstream_[incr ::vfs::zseq]
           81  +-	zlib s$mode $cname
           82  +-	set cmd [list ::vfs::zstream_handler $cname $ifd $clen $ilen s$mode]
           83  ++        if {$::vfs::zlibPkg} {
           84  ++            set cname _zstream_[incr ::vfs::zseq]
           85  ++            zlib s$mode $cname
           86  ++            set cmd [list ::vfs::zstream_handler $cname $ifd $clen $ilen s$mode]
           87  ++        } else {
           88  ++            set cname [zlib stream $mode]
           89  ++            set cmd [list ::vfs::zstream_handler_native $cname $ifd $clen $ilen s$mode]
           90  ++        }
           91  + 	set fd [rechan $cmd 2]
           92  + 	set ::vfs::_zstream_pos($fd) 0
           93  + 	return $fd