Index: modules/chan/base.tcl ================================================================== --- modules/chan/base.tcl +++ modules/chan/base.tcl @@ -1,15 +1,15 @@ -#! /usr/bin/env tclsh - # # ## ### ##### ######## ############# # copyright # # 2018 # # Poor Yorick # # ## ### ##### ######## ############# - +package require ego +tcllib::ego .new ::tcllib::chan::base +::tcllib::chan::base .eval { proc .init {_ channame args} { $_ .vars chan close if {$channame ni [::chan names]} { error [list {unknown channel} $channame] @@ -109,7 +109,11 @@ ::chan @name@ [$_ $ chan] {*}$args }] .my .method $name } } [namespace current]] - +} +namespace eval ::tcllib::chan { + namespace export base +} +package provide {chan base} 0.1 Index: modules/chan/coroutine.tcl ================================================================== --- modules/chan/coroutine.tcl +++ modules/chan/coroutine.tcl @@ -7,11 +7,12 @@ # # Poor Yorick # # ## ### ##### ######## ############# package require coroutine - +package require ego +namespace eval ::tcllib::chan::coroutine { proc [namespace current] chan { if {![string match ::* $chan]} { set chan [uplevel 1 [list ::namespace which $chan]] } @@ -33,5 +34,11 @@ proc read {_ args} { $_ .vars chan tailcall ::coroutine::util::read $chan {*}$args } +} + +package provide {chan coroutine} 0.1 +namespace eval ::tcllib::chan { + namespace export coroutine +} Index: modules/chan/getslimit.tcl ================================================================== --- modules/chan/getslimit.tcl +++ modules/chan/getslimit.tcl @@ -1,15 +1,14 @@ -#! /usr/bin/env tclsh - # # ## ### ##### ######## ############# # copyright # # 2018 # # Poor Yorick # # ## ### ##### ######## ############# - +package require ego +namespace eval ::tcllib::chan::getslimit { variable buf bufcount eof getslimit proc [namespace current] chan { if {![string match ::* $chan]} { set chan [uplevel 1 [list ::namespace which $chan]] @@ -47,11 +46,11 @@ } elseif {[llength $args]} { dict size $args foreach {key val} $args[set args {}] { if {$key eq {-getslimit}} { set getslimit $val - } else { + } else { lappend args $key $val } } if {[llength $args]} { uplevel 1 [list $_ .prototype configure {*}$args] @@ -70,11 +69,11 @@ return [expr {$eof || ( [$_ .prototype eof] && $bufcount == 0 )}] } proc gets {_ args} { - $_ .vars buf bufcount chan eof getslimit + $_ .vars buf bufcount chan eof getslimit switch [llength $args] { 1 { lassign $args varname upvar 1 $varname resvar } @@ -128,11 +127,11 @@ } } proc read {_ args} { - $_ .vars buf eof bufcount + $_ .vars buf eof bufcount if {$eof} { return {} } if {$bufcount} { if {[llength $args]} { @@ -153,8 +152,12 @@ } else { set res [$_ .prototype read {*}$args] } return $res } - +} package provide tcllib::chan::getslimit 1 +package provide {chan getslimit} 0.1 +namespace eval ::tcllib::chan { + namespace export getslimit +} Index: modules/chan/pkgIndex.tcl ================================================================== --- modules/chan/pkgIndex.tcl +++ modules/chan/pkgIndex.tcl @@ -1,33 +1,5 @@ -#! /usr/bin/env tclsh - if {![package vsatisfies [package provide Tcl] 8.6]} {return} -package ifneeded {chan getslimit} 0.1 [list ::apply {dir { - package require ego - namespace eval ::tcllib::chan::getslimit [list ::source $dir/getslimit.tcl] - package provide {chan getslimit} 0.1 - namespace eval ::tcllib::chan { - namespace export getslimit - } -}} $dir] - - -package ifneeded {chan base} 0.1 [list ::apply {dir { - package require ego - tcllib::ego .new ::tcllib::chan::base - ::tcllib::chan::base .eval [list ::source $dir/base.tcl] - namespace eval ::tcllib::chan { - namespace export base - } - package provide {chan base} 0.1 -}} $dir] - - -package ifneeded {chan coroutine} 0.1 [list ::apply {dir { - package require ego - namespace eval ::tcllib::chan::coroutine [list ::source $dir/coroutine.tcl] - package provide {chan coroutine} 0.1 - namespace eval ::tcllib::chan { - namespace export coroutine - } -}} $dir] +package ifneeded {chan getslimit} 0.1 [list ::source [file join $dir getslimit.tcl]] +package ifneeded {chan base} 0.1 [list ::source [file join $dir base.tcl]] +package ifneeded {chan coroutine} 0.1 [list ::source [file join $dir coroutine.tcl]] Index: modules/ego/ego.tcl ================================================================== --- modules/ego/ego.tcl +++ modules/ego/ego.tcl @@ -1,25 +1,24 @@ -#! /bin/env tclsh - # # ## ### ##### ######## ############# # copyright # # 2018 # # Poor Yorick # # ## ### ##### ######## ############# +namespace eval ::tcllib::ego { namespace ensemble create namespace export * proc .method {_ name args} { if {![llength $args]} { lappend args $name } set args [linsert $args[set args {}] 1 $_] set map [namespace ensemble configure $_ -map] - dict set map $name $args + dict set map $name $args uplevel 1 [list ::namespace ensemble configure $_ -map $map] return } .method [namespace current] .method @@ -50,20 +49,20 @@ proc .eval {_ args} { ::tailcall ::namespace eval [$_ .namespace] {*}$args } -.method [namespace current] .eval +.method [namespace current] .eval proc .insert {_ name} { set unknown1 [namespace ensemble configure $_ -unknown] set prototype1 [namespace ensemble configure $_ -prototype] if {[llength $unknown1]} { namespace ensemble configure $name -prototype $prototype1 \ - -unknown $unknown1 + -unknown $unknown1 } namespace enemble configure $_ -prototype [list ::lindex $name] -unknown $unknown1 return } @@ -70,17 +69,17 @@ proc .name _ { return $_ } -.method [namespace current] .name +.method [namespace current] .name proc .namespace _ { namespace ensemble configure $_ -namespace } -.method [namespace current] .namespace +.method [namespace current] .namespace proc .new {_ name args} { global env set ns [uplevel 1 [list ::namespace eval $name { @@ -98,24 +97,24 @@ set map [namespace ensemble configure $_ -map] set prototypes {} while {[dict exists $map .prototype]} { set prototypes [list $map {*}$prototypes[set prototypes {}]] - lassign [dict get $map .prototype] prototype + lassign [dict get $map .prototype] prototype set map [namespace ensemble configure $prototype -map] } set map {} - foreach {key val} [namespace ensemble configure $prototype -map] { + foreach {key val} [namespace ensemble configure $prototype -map] { if {$key ne {.prototype}} { if {[lindex $val 1] eq $_} { set val [lreplace $val[set val {}] 1 1 $ns] } } else { error [list {how did we get to here?}] } - lappend map $key $val + lappend map $key $val } namespace ensemble configure $ns -map $map set prototype $ns @@ -123,27 +122,27 @@ $ns .specialize dict unset map .prototype dict for {name cmd} $map { if {[lindex $cmd 1] eq $_} { # remove the original name from index 1 because .method is - # going to add it back + # going to add it back $ns .method $name {*}[lreplace $cmd[set cmd {}] 1 1] } else { $ns .routine $name {*}$cmd } } } - interp alias {} ${ns}::.my {} $ns + interp alias {} ${ns}::.my {} $ns if {[llength $args]} { tailcall $ns .init {*}$args } else { return $ns } } -.method [namespace current] .new +.method [namespace current] .new proc .ondelete {_ trace args} { if {[llength $args] == 1} { lassign $args script @@ -171,19 +170,19 @@ set map [namespace ensemble configure $_ -map] dict set map $name $args uplevel 1 [list ::namespace ensemble configure $_ -map $map] return } -.method [namespace current] .routine +.method [namespace current] .routine proc .specialize {_ args} { - set ns [$_ .namespace] + set ns [$_ .namespace] while {[namespace which [set name ${ns}::[ info cmdcount]_prototype]] ne {}} {} rename $_ $name - + set new [namespace eval ${ns} [ list namespace ensemble create -command $_ -map [list \ .prototype [list $name] ] -unknown [ list ::apply {{_ name args} { @@ -197,11 +196,11 @@ namespace delete $ns } }} $ns] return } -.method [namespace current] .specialize +.method [namespace current] .specialize proc .vars {_ args} { set vars {} foreach arg $args { @@ -211,15 +210,17 @@ } lappend vars $source $target } uplevel 1 [list ::namespace upvar $_ {*}$vars] } -.method [namespace current] .vars +.method [namespace current] .vars proc = {_ name val} { set [$_ .namespace]::$name $val } -.method [namespace current] = +.method [namespace current] = +} +package provide ego 0.1 Index: modules/ego/pkgIndex.tcl ================================================================== --- modules/ego/pkgIndex.tcl +++ modules/ego/pkgIndex.tcl @@ -1,8 +1,5 @@ #! /usr/bin/env tclsh if {![package vsatisfies [package provide Tcl] 8.6]} {return} -package ifneeded ego 0.1 [list ::apply {dir { - namespace eval ::tcllib::ego [list ::source $dir/ego.tcl] - package provide ego 0.1 -}} $dir] +package ifneeded ego 0.1 [list ::source [file join $dir ego.tcl]] Index: modules/httpd/httpd.test ================================================================== --- modules/httpd/httpd.test +++ modules/httpd/httpd.test @@ -17,18 +17,23 @@ support { use [file join ${TCLLIBMOD} cmdline cmdline.tcl] cmdline use [file join ${TCLLIBMOD} fileutil fileutil.tcl] fileutil use [file join ${TCLLIBMOD} sha1 sha1.tcl] sha1 + use [file join ${TCLLIBMOD} namespacex namespacex.tcl] namespacex + use [file join ${TCLLIBMOD} ego ego.tcl] ego + use [file join ${TCLLIBMOD} chan base.tcl] {chan base} + use [file join ${TCLLIBMOD} chan getslimit.tcl] {chan getslimit} + use [file join ${TCLLIBMOD} mime qp.tcl] {mime qp} + use [file join ${TCLLIBMOD} mime mime.tcl] mime use [file join ${TCLLIBMOD} uri uri.tcl] uri - use [file join ${TCLLIBMOD} ncgi ncgi.tcl] ncgi use [file join ${TCLLIBMOD} dns ip.tcl] ip use [file join ${TCLLIBMOD} nettool nettool.tcl] nettool use [file join ${TCLLIBMOD} coroutine coroutine.tcl] coroutine use [file join ${TCLLIBMOD} cron cron.tcl] cron - use [file join ${TCLLIBMOD} virtchannel_core core.tcl] tcl::chan::core - use [file join ${TCLLIBMOD} virtchannel_core events.tcl] tcl::chan::events + #use [file join ${TCLLIBMOD} virtchannel_core core.tcl] tcl::chan::core + #use [file join ${TCLLIBMOD} virtchannel_core events.tcl] tcl::chan::events use [file join ${TCLLIBMOD} virtchannel_base memchan.tcl] tcl::chan::memchan use [file join ${MODDIR} clay clay.tcl] clay } testing { Index: modules/mime/mime.test ================================================================== --- modules/mime/mime.test +++ modules/mime/mime.test @@ -15,20 +15,24 @@ source [file join \ [file dirname [file dirname [file dirname [ file normalize [info script]/...]]]]/devtools/testutilities.tcl] testsNeedTcl 8.5 -testsNeedTcltest 2 +testsNeedTcltest 2 support { # This code loads md5x, i.e. md5 v2. Proper testing should do one # run using md5 v1, aka md5.tcl as well. use md5/md5x.tcl md5 - use namespacex/namespacex.tcl namespacex + use ego/ego.tcl ego + use chan/base.tcl {chan base} + use chan/getslimit.tcl {chan getslimit} + } testing { + useLocal qp.tcl {mime qp} useLocal mime.tcl mime } package require {chan base} @@ -229,11 +233,11 @@ } set tok [.new {} -string $msg] set partToks [$tok property parts] - set res {} + set res {} foreach childTok $partToks { lappend res [[$childTok body raw] read] } set res }} [list part1 part2 part3] @@ -449,11 +453,11 @@ test mime-4.13 {Test qp::encode in no_softbreak mode} {cleanly { qp encode {This is a very long string into which we do not want inserted softbreaks as we want one very long line returned even though that's probably not how we whould be doing it (see RFC2047) but we don't want to break backward compatibility} 0 1 }} {This is a very long string into which we do not want inserted softbreaks as we want one very long line returned even though that's probably not how we whould be doing it (see RFC2047) but we don't want to break backward compatibility} - + test mime-5.1 {Test word_encode with quoted-printable method} {cleanly { word_encode iso8859-1 quoted-printable {Test de contrôle effectué} }} =?ISO-8859-1?Q?Test_de_contr=F4le_effectu=E9?= @@ -662,11 +666,11 @@ {(a b)} 11 {(=?ISO-8859-1?Q?a?=x=?ISO-8859-2?Q?_b?=)} {(ax b)} 12 {a b c} {a b c} - 13 {} + 13 {} {} } { test mime-6.$n {Test field_decode (from RFC 2047, part 8)} {cleanly { field_decode $encoded }} $expected ; # {} @@ -699,11 +703,11 @@ set mi [makeFile {} mime.txt] with.$name $in -canonical text/plain { ::tcllib::chan::base .new chan1 [open $mi w] chan1 configure -translation binary - $tok serialize -chan chan1 + $tok serialize -chan chan1 chan1 close with.$name $mi { set newdata [[$tok body raw] read] set res [string compare $data $newdata] @@ -821,19 +825,19 @@ \r so plain " set tok [.new {} -string $msg] - [$tok body raw] read + [$tok body raw] read } "so plain\n" # ------------------------------------------------------------------------- test mime-14.0 {cleanly { hostname argument to parseaddress }} { - set parsed [parseaddress hostname fakedomain.fake {Here }] + set parsed [parseaddress hostname fakedomain.fake {Here }] list [llength $parsed] [lindex $parsed 0] } [list 1 [list address h@fakedomain.fake comment {} domain {} error {} \ friendly Here group {} local h memberP 0 phrase Here \ proper {Here } route {}]] @@ -976,19 +980,19 @@ test mime-17.9 { header supplied by a component message, retrieved by lowercase name } { set mime [.new {} -string {Content-Disposition: form-data; name="field2"}] - $mime header get content-disposition + $mime header get content-disposition } {form-data {name field2}} test mime-17.10 { Content-Type is not automatically added to a subordinate } { set mime [.new {} -string {Content-Disposition: form-data; name="field2"}] - $mime header get content-disposition + $mime header get content-disposition } {form-data {name field2}} test mime-18.1 { non-seekable channel @@ -1017,11 +1021,11 @@ set mime [.new {} -spec http -string {}] $mime cookie set one two set res [$mime serialize] $mime .destroy return $res - + } "Set-Cookie: one=two\r \t; HttpOnly\r \r " @@ -1031,11 +1035,11 @@ set mime [.new {} -spec http -string {}] $mime cookie set one two path /three/four set res [$mime serialize] $mime .destroy return $res - + } "Set-Cookie: one=two\r \t; path=/three/four\r \t; HttpOnly\r \r "