tcl-hacks

Check-in [b93b861890]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:fix [read] to handle numChars argument
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:b93b8618908a9bffb945b3d5ff1173fdfadd8826
User & Date: aspect 2018-07-07 17:47:32
Context
2018-07-07
17:52
service should report "End" even for early returns check-in: 13b0a1b7a6 user: aspect tags: trunk
17:47
fix [read] to handle numChars argument check-in: b93b861890 user: aspect tags: trunk
2018-06-08
07:23
add TkStyles.kit as well check-in: 48d7578ff0 user: aspect tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to inet/inet.tcl.

64
65
66
67
68
69
70
71
72


73
74



75
76


77
78


79
80
81
82
83
84
85
            chan event $chan readable [list catch [info coroutine]]
            yield
            chan event $chan readable $was
        }
        tailcall ::gets $chan {*}$args
    }

    proc read {chan args} {
        if {![chan configure $chan -blocking]} {


            set was [chan event $chan readable]
            chan event $chan readable [list catch [info coroutine]]



            yield
            chan event $chan readable $was


        }
        tailcall ::read $chan {*}$args


    }

    proc after args {   ;# needs to wrap with [catch] in case the socket is killed while we're waiting
        if {[llength $args] == 1} {
            ::after {*}$args [list catch [info coroutine]]
            yield
        } else {







|
|
>
>

|
>
>
>
|
<
>
>
|
<
>
>







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
            chan event $chan readable [list catch [info coroutine]]
            yield
            chan event $chan readable $was
        }
        tailcall ::gets $chan {*}$args
    }

    proc read {chan {numChars Inf}} {
        if {[chan configure $chan -blocking]} {
            tailcall ::read $chan {*}$numChars
        } else {
            set was [chan event $chan readable]
            chan event $chan readable [list [info coroutine]]
            finally [list chan event $chan readable $was]
            set data ""
            while {[string length $data] < $numChars} {
                yield

                append data [::read $chan $numChars]
                if {[eof $chan]} break
            }

            return $data
        }
    }

    proc after args {   ;# needs to wrap with [catch] in case the socket is killed while we're waiting
        if {[llength $args] == 1} {
            ::after {*}$args [list catch [info coroutine]]
            yield
        } else {