Browse Source

whitespace (end of line) fixes and fconfigure->chan configure fileevent->chan event, minor expr tweaks

master
Julian Noble 4 weeks ago
parent
commit
fe03c0652b
  1. 8
      src/modules/#modpod-zipper-999999.0a1.0/zipper-999999.0a1.0.tm
  2. 13
      src/modules/punk-0.1.tm
  3. 4
      src/modules/punk/ansi-999999.0a1.0.tm
  4. 44
      src/modules/punk/basictelnet-999999.0a1.0.tm
  5. 2
      src/modules/punk/cap/handlers/templates-999999.0a1.0.tm
  6. 2
      src/modules/punk/char-999999.0a1.0.tm
  7. 2
      src/modules/punk/config-0.1.tm
  8. 4
      src/modules/punk/console-999999.0a1.0.tm
  9. 13
      src/modules/punk/fileline-999999.0a1.0.tm
  10. 30
      src/modules/punk/icomm-999999.0a1.0.tm
  11. 24
      src/modules/punk/lib-999999.0a1.0.tm
  12. 24
      src/modules/punk/repl-999999.0a1.0.tm
  13. 4
      src/modules/punk/sshrun-999999.0a1.0.tm
  14. 14
      src/modules/punk/winrun-999999.0a1.0.tm
  15. 2
      src/modules/punkcheck-0.1.0.tm
  16. 11
      src/modules/shellrun-0.1.1.tm
  17. 12
      src/modules/shellthread-1.6.1.tm
  18. 6
      src/modules/textblock-999999.0a1.0.tm

8
src/modules/#modpod-zipper-999999.0a1.0/zipper-999999.0a1.0.tm

@ -31,8 +31,8 @@ namespace eval zipper {
set v::fd $fd
set v::base [tell $fd]
set v::toc {}
#fconfigure $fd -translation binary -encoding binary
fconfigure $fd -translation binary -encoding iso8859-1
#chan configure $fd -translation binary -encoding binary
chan configure $fd -translation binary -encoding iso8859-1
}
proc emit {s} {
@ -150,7 +150,7 @@ namespace eval zipper {
set len [expr {$cd_end_pos - $cd_start_pos}]
#incr pos -$v::base
set cdr_offset_pos [expr $cd_start_pos -$v::base] ;#review
set cdr_offset_pos [expr {$cd_start_pos -$v::base}] ;#review
#EOCD signature PK\5\6 = 0x06054b50
emit [binary format a2c2ssssiis PK {5 6} 0 0 $ntoc $ntoc $len $cdr_offset_pos 0]
@ -178,7 +178,7 @@ if {[info exists argv0] && [string match zipper-* [file tail $argv0]]} {
if {[file isfile $f]} {
regsub {^\./} $f {} f
set fd [open $f]
fconfigure $fd -translation binary -encoding binary
chan configure $fd -translation binary -encoding binary
zipper::addentry $f [read $fd] [file mtime $f]
close $fd
} elseif {[file isdir $f]} {

13
src/modules/punk-0.1.tm

@ -1234,7 +1234,7 @@ namespace eval punk {
break
}
#leave the - from the end- as part of the offset
set offset [expr $endspec] ;#don't brace!
set offset [expr $endspec] ;#don't brace! (consider: set x --34;puts expr $j;puts expr {$j} )
if {$do_bounds_check && ($offset > 0 || abs($offset) >= $len)} {
set action ?mismatch-list-index-out-of-range
break
@ -3690,7 +3690,8 @@ namespace eval punk {
#todo - some way to restrict mismatch info to simple "mismatch" and avoid overhead of verbose message
#e.g for within pipeswitch block where mismatches are expected and the reasons are less important than moving on quickly
set vidx 0
set mismatches [lmap m $match_state v $var_names {expr {$m == 0} ? {[list mismatch $v]} : {[list match $v]}}]
#set mismatches [lmap m $match_state v $var_names {expr {$m == 0} ? {[list mismatch $v]} : {[list match $v]}}]
set mismatches [lmap m $match_state v $var_names {expr {$m == 0 ? [list mismatch $v] : [list match $v]}}]
set var_display_names [list]
foreach v $var_names {
if {$v eq ""} {
@ -3699,7 +3700,9 @@ namespace eval punk {
lappend var_display_names $v
}
}
set mismatches_display [lmap m $match_state v $var_display_names {expr {$m == 0} ? {$v} : {[expr {$m eq "?"} ? {"?[string repeat { } [expr [string length $v] -1]]"} : {[string repeat " " [string length $v]]} ]}}]
#REVIEW 2025
#set mismatches_display [lmap m $match_state v $var_display_names {expr {$m == 0} ? {$v} : {[expr {$m eq "?"} ? {"?[string repeat { } [expr [string length $v] -1]]"} : {[string repeat " " [string length $v]]} ]}}]
set mismatches_display [lmap m $match_state v $var_display_names {expr {$m == 0 ? $v : [expr {$m eq "?" ? "?[string repeat { } [expr {[string length $v] -1}]]" : [string repeat " " [string length $v]] }]}}]
set msg "\n"
append msg "Unmatched\n"
append msg "Cannot match right hand side to pattern $multivar\n"
@ -5304,6 +5307,8 @@ namespace eval punk {
##if {$body ni $existing} {
set scr [base64::encode -maxlen 0 $cond] ;#will only be decoded if the debug is triggered
#tcllib has some double-substitution going on.. base64 seems easiest and will not impact the speed of normal execution when debug off.
#tclint-disable-next-line
proc ::unknown {args} [string map [list @c@ $cond @b@ $body @scr@ $scr] {
#---------------------------------------
if {![catch {expr {@c@}} res] && $res} {
@ -5368,7 +5373,7 @@ namespace eval punk {
#for var="val {a b c}"
#proc ::punk::val {{v {}}} {tailcall lindex $v}
#proc ::punk::val {{v {}}} {return $v} ;#2023 - approx 2x faster than the tailcall lindex version
#tclint-disable-next-line
proc ::punk::val [list [list v [purelist]]] {return $v}
#----------------

4
src/modules/punk/ansi-999999.0a1.0.tm

@ -7569,11 +7569,11 @@ namespace eval punk::ansi::colour {
}
foreach c {R G B} {
if {$T($c) < [expr {1.0/6.0}]} {
if {$T($c) < (1.0/6.0)} {
set T($c) [expr {$P+($Q-$P)*6.0*$T($c)}]
} elseif {$T($c) < 0.5} {
set T($c) $Q
} elseif {$T($c) < [expr {2.0/3.0}]} {
} elseif {$T($c) < (2.0/3.0)} {
set T($c) [expr {$P+($Q-$P)*(2.0/3.0-$T($c))*6.0}]
} else {
set T($c) $P

44
src/modules/punk/basictelnet-999999.0a1.0.tm

@ -402,7 +402,7 @@ namespace eval punk::basictelnet {
set client_declined "CLI-WONT:[a+ red bold][get_client_option_declined_summary][a]"
set info $server_summary\n$client_summary\n$client_declined\n$info
#set existing_handler [fileevent stdin readable]
#set existing_handler [chan event stdin readable]
set RST "\x1b\[m"
set debug_width 80
@ -412,12 +412,12 @@ namespace eval punk::basictelnet {
#puts -nonewline [punk::ansi::cursor_off]
#use non cursorsave version - slower - but less likely to interfere with cursor operations in data
set existing_input_handler [fileevent $inputchannel readable] ;#stdin
fileevent $inputchannel readable {}
set existing_input_handler [chan event $inputchannel readable] ;#stdin
chan event $inputchannel readable {}
if {[string length $outputchannel]} {
set existing_output_handler [fileevent $outputchannel readable] ;#sock
fileevent $outputchannel readable {}
set existing_output_handler [chan event $outputchannel readable] ;#sock
chan event $outputchannel readable {}
}
if {[catch {
@ -434,9 +434,9 @@ namespace eval punk::basictelnet {
#todo - try? finally?
set writing_debug_frame 0
fileevent $inputchannel readable $existing_input_handler
chan event $inputchannel readable $existing_input_handler
if {[string length $outputchannel]} {
fileevent $outputchannel readable $existing_output_handler
chan event $outputchannel readable $existing_output_handler
}
return
}
@ -529,13 +529,13 @@ namespace eval punk::basictelnet {
#todo - allow telnet with channels other than stdin/stdout - and multiple sessions - per session option_states
reset_option_states
set sock [socket $server $port]
#fconfigure $sock -buffering none -blocking 0 -encoding binary -translation crlf -eofchar {}
#fconfigure $sock -buffering none -blocking 0 -encoding binary -translation binary -eofchar {}
fconfigure $sock -buffering none -blocking 0 -encoding iso8859-1 -translation binary -eofchar {}
fconfigure stdout -buffering none
fileevent $sock readable [list [namespace current]::fromServer $sock]
#chan configure $sock -buffering none -blocking 0 -encoding binary -translation crlf -eofchar {}
#chan configure $sock -buffering none -blocking 0 -encoding binary -translation binary -eofchar {}
chan configure $sock -buffering none -blocking 0 -encoding iso8859-1 -translation binary -eofchar {}
chan configure stdout -buffering none
chan event $sock readable [list [namespace current]::fromServer $sock]
chan configure stdin -blocking 0
fileevent stdin readable [list [namespace current]::toServer $sock]
chan event stdin readable [list [namespace current]::toServer $sock]
variable closed
vwait ::punk::basictelnet::closed($sock)
unset closed($sock)
@ -568,7 +568,7 @@ namespace eval punk::basictelnet {
set input_chunks_waiting(stdin) [lrange $input_chunks_waiting(stdin) 1 end]
}
fileevent stdin readable {}
chan event stdin readable {}
if {$nextwaiting eq ""} {
set chunk [read stdin]
} else {
@ -616,13 +616,13 @@ namespace eval punk::basictelnet {
#Re-enable channel read handler only if no waiting chunks - must process in order
##################################################################################
if {![llength $input_chunks_waiting(stdin)]} {
fileevent stdin readable [list [namespace current]::toServer $sock]
chan event stdin readable [list [namespace current]::toServer $sock]
} else {
#after idle [list [namespace current]::toServer $sock]
tailcall [namespace current]::toServer $sock
}
####################################################
#fileevent stdin readable [list [namespace current]::toServer $sock]
#chan event stdin readable [list [namespace current]::toServer $sock]
} else {
disconnect sock
}
@ -642,7 +642,7 @@ namespace eval punk::basictelnet {
variable encoding_guess
variable debug
variable fromserver_unprocessed
fileevent $sock readable {}
chan event $sock readable {}
variable in_sb
set chunksize 4096 ;#No choice of chunksize can avoid the possibility of splitting a token such as a Telnet protocol command or an ANSI sequence.
#in theory, a split ANSI sequence won't cause a problem - except if we have debug on which could emit a request on stdout (e.g get_cursor_pos)
@ -872,24 +872,24 @@ namespace eval punk::basictelnet {
#after idle [list fileevent $sock readable [list [namespace current]::fromServer $sock]]
#after idle [list chan event $sock readable [list [namespace current]::fromServer $sock]]
if {[string length $fromserver_unprocessed]} {
#review - by throwing to another loop without waiting for readable event - we could spin on same data...?
#after idle [list [namespace current]::fromServer $sock]
fileevent $sock readable [list [namespace current]::fromServer $sock]
chan event $sock readable [list [namespace current]::fromServer $sock]
} else {
fileevent $sock readable [list [namespace current]::fromServer $sock]
chan event $sock readable [list [namespace current]::fromServer $sock]
}
}
proc disconnect {sock} {
variable closed
puts stdout "local disconnect"
catch {fileevent $sock readable {}}
catch {chan event $sock readable {}}
catch {close $sock}
set closed($sock) 1
fileevent stdin readable {}
chan event stdin readable {}
}
proc write string {

2
src/modules/punk/cap/handlers/templates-999999.0a1.0.tm

@ -95,7 +95,7 @@ namespace eval punk::cap::handlers::templates {
} else {
set tm_exists [file exists $tmfile]
}
if {![file exists $tmfile]} {
if {!$tm_exists} {
puts stderr "punk::cap::handlers::templates::capsystem::pkg_register WARNING - unable to determine base folder for package '$pkg' which is attempting to register with punk::cap as a provider of '$capname' capability"
flush stderr
return 0

2
src/modules/punk/char-999999.0a1.0.tm

@ -1181,7 +1181,7 @@ tcl::namespace::eval punk::char {
}
puts "ok.. loading"
set fd [open $file r]
fconfigure $fd -translation binary
chan configure $fd -translation binary
set data [read $fd]
close $fd
set block_count 0

2
src/modules/punk/config-0.1.tm

@ -32,7 +32,7 @@ tcl::namespace::eval punk::config {
if {$exename ne ""} {
set exefolder [file dirname $exename]
#default file logs to logs folder at same level as exe if writable, or empty string
set log_folder [file normalize $exefolder/../logs]
set log_folder [file normalize $exefolder/../logs] ;#~2ms
#tcl::dict::set startup scriptlib $exefolder/scriptlib
#tcl::dict::set startup apps $exefolder/../../punkapps

4
src/modules/punk/console-999999.0a1.0.tm

@ -814,7 +814,7 @@ namespace eval punk::console {
#it *might* be ok to restore entire state on an input channel
#(it's not always on all channels - e.g stdout has -winsize which is read-only)
#Safest to only restore what we think we've modified.
fconfigure $input -blocking [dict get $previous_input_state -blocking]
chan configure $input -blocking [dict get $previous_input_state -blocking]
@ -1947,7 +1947,7 @@ namespace eval punk::console {
set was_raw 1
}
puts -nonewline stdout \033\[6n ;flush stdout
fconfigure stdin -blocking 0
chan configure stdin -blocking 0
set info [read stdin 20] ;#
after 1
if {[string first "R" $info] <=0} {

13
src/modules/punk/fileline-999999.0a1.0.tm

@ -158,7 +158,7 @@ namespace eval punk::fileline::class {
#[para] Constructor for textinfo object which represents a chunk or all of a file
#[para] datachunk should be passed with the file data including line-endings as-is for full functionality. ie use something like:
#[example_begin]
# fconfigure $fd -translation binary
# chan configure $fd -translation binary
# set chunkdata [lb]read $fd[rb]]
#or
# set chunkdata [lb]fileutil::cat <filename> -translation binary[rb]
@ -1221,8 +1221,11 @@ namespace eval punk::fileline::class {
#o_linemap
set oldsize [string length $o_chunk]
set newchunk ""
#review - what was the intention here?
puts stderr "regenerate_chunk -warning code incomplete"
dict for {idx lineinfo} $o_linemap {
set
#???
#set
}
@ -1287,7 +1290,7 @@ namespace eval punk::fileline {
if {$opt_file ne ""} {
set filename $opt_file
set fd [open $filename r]
fconfigure $fd -translation binary -encoding $opt_translation;#should use translation binary to get actual line-endings - but we allow caller to override
chan configure $fd -translation binary -encoding $opt_translation;#should use translation binary to get actual line-endings - but we allow caller to override
#Always read encoding in binary - check for bom below and/or apply chosen opt_encoding
set rawchunk [read $fd]
close $fd
@ -1360,7 +1363,7 @@ namespace eval punk::fileline {
set bomenc "binary" ;# utf-8???
set startdata 3
} elseif {$maybe_bom eq "84319533"} {
if {![dict exists [punk::char::page_names_dict gb18030]]} {
if {![dict exists [punk::char::page_names_dict gb18030] gb18030]} {
puts stderr "WARNING - no direct support for GB18030 (chinese) - falling back to cp936/gbk"
set bomenc cp936
} else {
@ -1485,7 +1488,7 @@ namespace eval punk::fileline {
proc file_boundary_display {filename startbyte endbyte chunksize args} {
set fd [open $filename r] ;#use default error if file not readable
fconfigure $fd -translation binary
chan configure $fd -translation binary
set rawfiledata [read $fd]
close $fd
set textobj [class::textinfo new $rawfiledata]

30
src/modules/punk/icomm-999999.0a1.0.tm

@ -875,9 +875,9 @@ namespace eval ::punk::icomm {
![string equal $encoding $comm($chan,encoding)]} {
# This should not be entered yet
set comm($chan,encoding) $encoding
fconfigure $comm($chan,socket) -encoding $encoding
chan configure $comm($chan,socket) -encoding $encoding
foreach {i sock} [array get comm $chan,peers,*] {
fconfigure $sock -encoding $encoding
chan configure $sock -encoding $encoding
}
}
@ -935,10 +935,10 @@ namespace eval ::punk::icomm {
set nport [incr comm(lastport)]
}
set comm($chan,socket) $ret
fconfigure $ret -translation lf -encoding $comm($chan,encoding)
chan configure $ret -translation lf -encoding $comm($chan,encoding)
# If port was 0, system allocated it for us
set comm($chan,port) [lindex [fconfigure $ret -sockname] 2]
set comm($chan,port) [lindex [chan configure $ret -sockname] 2]
return ""
}
@ -1089,8 +1089,8 @@ namespace eval ::punk::icomm {
# coroutines to hide the CSP and properly handle everything
# event based.
fconfigure $fid -blocking 0
fileevent $fid readable [list ::punk::icomm::commIncomingOffered $chan $fid $addr $remport]
chan configure $fid -blocking 0
chan event $fid readable [list ::punk::icomm::commIncomingOffered $chan $fid $addr $remport]
return
}
@ -1111,8 +1111,8 @@ namespace eval ::punk::icomm {
# Protocol version line has been received, disable event handling
# again.
fileevent $fid readable {}
fconfigure $fid -blocking 1
chan event $fid readable {}
chan configure $fid -blocking 1
# a list of offered proto versions is the first word of first line
# remote id is the second word of first line
@ -1143,7 +1143,7 @@ namespace eval ::punk::icomm {
if {[dict exists $chanconf -sockname]} {
# If the remote host addr isn't our local host addr,
# then add it to the remote id.
if {[string equal [lindex [fconfigure $fid -sockname] 0] $addr]} {
if {[string equal [lindex [chan configure $fid -sockname] 0] $addr]} {
set id $remid
} else {
set id [list $remid $addr]
@ -1215,8 +1215,8 @@ namespace eval ::punk::icomm {
set comm($chan,peers,$id) $fid
}
set comm($chan,fids,$fid) $id
fconfigure $fid -translation lf -encoding $comm($chan,encoding) -blocking 0
fileevent $fid readable [list ::punk::icomm::commCollect $chan $fid]
chan configure $fid -translation lf -encoding $comm($chan,encoding) -blocking 0
chan event $fid readable [list ::punk::icomm::commCollect $chan $fid]
}
# ::punk::icomm::commLostConn --
@ -1324,7 +1324,7 @@ namespace eval ::punk::icomm {
# ::punk::icomm::commCollect --
#
# Internal command. Called from the fileevent to read from fid
# Internal command. Called from the chan event to read from fid
# and append to the buffer. This continues until we get a whole
# command, which we then invoke.
#
@ -1343,9 +1343,9 @@ namespace eval ::punk::icomm {
if {[catch {read $fid} nbuf] || [eof $fid]} {
commDebug {puts stderr "<$chan> collect/lost eof $fid = [eof $fid]"}
commDebug {puts stderr "<$chan> collect/lost nbuf = <$nbuf>"}
commDebug {puts stderr "<$chan> collect/lost [fconfigure $fid]"}
commDebug {puts stderr "<$chan> collect/lost [chan configure $fid]"}
fileevent $fid readable {} ;# be safe
chan event $fid readable {} ;# be safe
commLostConn $chan $fid "target application died or connection lost"
return
}
@ -1995,7 +1995,7 @@ proc ::punk::icomm::initlocal {{tcpport 0}} {
if {[string equal macintosh $::tcl_platform(platform)]} {
::punk::icomm::comm new ::punk::icomm::comm -port 0 -local 0 -listen 1
set ::punk::icomm::comm(localhost) \
[lindex [fconfigure $::punk::icomm::comm(::punk::icomm::comm,socket) -sockname] 0]
[lindex [chan configure $::punk::icomm::comm(::punk::icomm::comm,socket) -sockname] 0]
::punk::icomm::comm config -local 1
} else {
::punk::icomm::comm new ::punk::icomm::comm -port 0 -local 1 -listen 1

24
src/modules/punk/lib-999999.0a1.0.tm

@ -477,7 +477,7 @@ namespace eval punk::lib {
set asegs [split [string map {:: \uFFFF} $abs] \uFFFF]
set acount [llength $asegs]
#puts "alias $abs acount:$acount asegs:$asegs segcount:$segcount segments: $segments"
if {[expr {$acount - 1}] == $segcount} {
if {($acount - 1) == $segcount} {
if {[lrange $asegs 0 end-1] eq $segments} {
if {[string match $glob [lindex $asegs end]]} {
#report this alias in the current namespace - even though there may be no matching command
@ -2760,7 +2760,7 @@ namespace eval punk::lib {
#[example_end]
puts stdout $question
flush stdout
set stdin_state [fconfigure stdin]
set stdin_state [chan configure stdin]
if {[catch {
package require punk::console
set console_raw [tsv::get console is_raw]
@ -2769,7 +2769,7 @@ namespace eval punk::lib {
set console_raw 0
}
try {
fconfigure stdin -blocking 1
chan configure stdin -blocking 1
if {$console_raw} {
punk::console::disableRaw
set answer [gets stdin]
@ -2778,7 +2778,7 @@ namespace eval punk::lib {
set answer [gets stdin]
}
} finally {
fconfigure stdin -blocking [tcl::dict::get $stdin_state -blocking]
chan configure stdin -blocking [tcl::dict::get $stdin_state -blocking]
}
return $answer
}
@ -3630,7 +3630,7 @@ namespace eval punk::lib {
}
set sigma [expr {int(sqrt($s2))}]
set average [expr int($average)]
set average [expr {int($average)}]
return "$average +/- $sigma microseconds per iteration"
}
@ -3820,10 +3820,10 @@ namespace eval punk::lib {
# First, extract right hand part of number, up to and including decimal point
set point [string last "." $number];
if {$point >= 0} {
set PostDecimal [string range $number [expr $point + 1] end];
set PostDecimal [string range $number $point+1 end];
set PostDecimalP 1;
} else {
set point [expr [string length $number] + 1]
set point [expr {[string length $number] + 1}]
set PostDecimal "";
set PostDecimalP 0;
}
@ -3834,16 +3834,16 @@ namespace eval punk::lib {
incr ind;
}
set FirstNonSpace $ind;
set LastSpace [expr $FirstNonSpace - 1];
set LastSpace [expr {$FirstNonSpace - 1}];
set LeadingSpaces [string range $number 0 $LastSpace];
# Now extract the non-fractional part of the number, omitting leading spaces.
set MainNumber [string range $number $FirstNonSpace [expr $point -1]];
set MainNumber [string range $number $FirstNonSpace $point-1];
# Insert commas into the non-fractional part.
set Length [string length $MainNumber];
set Phase [expr $Length % $GroupSize]
set PhaseMinusOne [expr $Phase -1];
set Phase [expr {$Length % $GroupSize}]
set PhaseMinusOne [expr {$Phase -1}];
set DelimitedMain "";
#First we deal with the extra stuff.
@ -3851,7 +3851,7 @@ namespace eval punk::lib {
append DelimitedMain [string range $MainNumber 0 $PhaseMinusOne];
}
set FirstInGroup $Phase;
set LastInGroup [expr $FirstInGroup + $GroupSize -1];
set LastInGroup [expr {$FirstInGroup + $GroupSize -1}];
while {$LastInGroup < $Length} {
if {$FirstInGroup > 0} {
append DelimitedMain $delim;

24
src/modules/punk/repl-999999.0a1.0.tm

@ -127,7 +127,7 @@ namespace eval punk::repl {
puts stderr "\n*> repl background error: '$message'"
#puts stderr "*> [set ::errorInfo]"
puts stderr "*> errorinfo: [dict get $errdict -errorinfo]"
set stdinreader [fileevent stdin readable]
set stdinreader [chan event stdin readable]
if {![string length $stdinreader]} {
puts stderr "*> stdin reader inactive"
} else {
@ -420,14 +420,14 @@ proc repl::start {inchan args} {
puts stderr "-->repl::start active on $inchan $args replthread:[thread::id] codethread:$codethread"
set prompt_config [punk::repl::get_prompt_config]
doprompt "P% "
fileevent $inchan readable [list [namespace current]::repl_handler $inchan $prompt_config]
chan event $inchan readable [list [namespace current]::repl_handler $inchan $prompt_config]
set reading 1
#catch {
# set punk::console::tabwidth [punk::console::get_tabstop_apparent_width]
#}
vwait [namespace current]::done
fileevent $inchan readable {}
chan event $inchan readable {}
#puts stderr "-->start done = $::repl::done"
@ -1327,7 +1327,7 @@ proc repl::repl_handler {inputchan prompt_config} {
set prompt_reset_flag 0
}
fileevent $inputchan readable {}
chan event $inputchan readable {}
upvar ::punk::console::input_chunks_waiting input_chunks_waiting
#note -inputmode not available in Tcl 8.6 for chan configure!
#According to DKF - -buffering option doesn't affect input channels
@ -1542,14 +1542,14 @@ proc repl::repl_handler {inputchan prompt_config} {
#Re-enable channel read handler only if no waiting chunks - must process in order
##################################################################################
if {![llength $input_chunks_waiting($inputchan)]} {
fileevent $inputchan readable [list ::repl::repl_handler $inputchan $prompt_config]
chan event $inputchan readable [list ::repl::repl_handler $inputchan $prompt_config]
} else {
after idle [list ::repl::repl_handler $inputchan $prompt_config]
}
####################################################
} else {
#repl_handler_checkchannel $inputchan
fileevent $inputchan readable {}
chan event $inputchan readable {}
set reading 0
thread::send -async $::repl::codethread {set ::punk::repl::codethread::running 0}
if {$::tcl_interactive} {
@ -1757,7 +1757,7 @@ proc repl::repl_process_data {inputchan chunktype chunk stdinlines prompt_config
# #review
# rputs stderr "->0byte read stdin"
# if {[chan eof $inputchan]} {
# fileevent $inputchan readable {}
# chan event $inputchan readable {}
# set reading 0
# #set running 0
# if {$::tcl_interactive} {
@ -1973,7 +1973,7 @@ proc repl::repl_process_data {inputchan chunktype chunk stdinlines prompt_config
rputs stderr "-------------"
rputs stderr "$::errorInfo"
rputs stderr "-------------"
set stdinreader [fileevent $inputchan readable]
set stdinreader [chan event $inputchan readable]
if {![string length $stdinreader]} {
rputs stderr "*> $inputchan reader inactive"
} else {
@ -2185,7 +2185,7 @@ proc repl::repl_process_data {inputchan chunktype chunk stdinlines prompt_config
#chan configure stdout -buffering none
#JMN
fileevent $inputchan readable {}
chan event $inputchan readable {}
set reading 0
#don't let unknown use 'args' to convert commandstr to list
#===============================================================================
@ -2529,7 +2529,7 @@ proc repl::repl_process_data {inputchan chunktype chunk stdinlines prompt_config
#append commandstr \n
if {$::punk::repl::signal_control_c} {
set ::punk::repl::signal_control_c 0
fileevent $inputchan readable {}
chan event $inputchan readable {}
rputs stderr "* console_control: control-c"
flush stderr
set c [a yellow bold]
@ -2578,7 +2578,7 @@ proc repl::repl_process_data {inputchan chunktype chunk stdinlines prompt_config
}
#fileevent $inputchan readable [list repl::repl_handler $inputchan $prompt_config]
#chan event $inputchan readable [list repl::repl_handler $inputchan $prompt_config]
#catch {puts stderr "zend--->[rep $::arglej]"}
@ -2590,7 +2590,7 @@ proc repl::repl_process_data {inputchan chunktype chunk stdinlines prompt_config
rputs stderr "-------------"
rputs stderr "$::errorInfo"
rputs stderr "-------------"
set stdinreader [fileevent $inputchan readable]
set stdinreader [chan event $inputchan readable]
if {![string length $stdinreader]} {
rputs stderr "*> $inputchan reader inactive"
} else {

4
src/modules/punk/sshrun-999999.0a1.0.tm

@ -306,7 +306,7 @@ namespace eval punk::sshrun {
# }]
variable ssh;
system::_verify_connection $host;
fileevent $ssh($host,F) $readable_writable $script;
chan event $ssh($host,F) $readable_writable $script;
}
proc hfconfigure {host args} {
@ -314,7 +314,7 @@ namespace eval punk::sshrun {
# [call hconfigure [arg host] [arg args]]
variable ssh;
system::_verify_connection $host;
eval fconfigure $ssh($host,F) $args;
eval chan configure $ssh($host,F) $args;
}
proc rexec {host script output_varname} {

14
src/modules/punk/winrun-999999.0a1.0.tm

@ -37,7 +37,7 @@ namespace eval punk::winrun {
}
proc readchild_handler {chan hpid} {
#fileevent $chan readable {}
#chan event $chan readable {}
set data [read $chan 4096]
while {![chan blocked $chan] && ![eof $chan]} {
append data [read $chan 4096]
@ -46,19 +46,19 @@ namespace eval punk::winrun {
flush stdout
if {![eof $chan]} {
puts stdout "not eof $chan [fconfigure $chan] chan blocked:[chan blocked $chan]"
#fileevent $chan readable [list punk::winrun::readchild_handler $chan $hpid]
#chan event $chan readable [list punk::winrun::readchild_handler $chan $hpid]
} else {
#puts "eof: waiting exit process"
set punk::winrun::waitresult [twapi::wait_on_handle $hpid -wait -1]
}
}
proc readchilderr_handler {chan} {
fileevent $chan readable {}
chan event $chan readable {}
set data [read $chan]
puts stderr "err: $data"
flush stderr
if {![eof $chan]} {
fileevent $chan readable [list punk::winrun::readchild_handler $chan]
chan event $chan readable [list punk::winrun::readchild_handler $chan]
}
}
@ -81,7 +81,7 @@ namespace eval punk::winrun {
#after 1000
chan configure $readout -blocking 0
fileevent $readout readable [list readchild_handler $readout $hpid]
chan event $readout readable [list readchild_handler $readout $hpid]
puts stdout "input: [chan configure $writein]"
puts $writein "puts stdout blah;"
flush $writein
@ -106,8 +106,8 @@ namespace eval punk::winrun {
if {$waitresult eq "timeout"} {
puts stderr "tw_run: timeout waiting for process"
}
fileevent $readout readable {}
fileevent $readerr readable {}
chan event $readout readable {}
chan event $readerr readable {}
set code [twapi::get_process_exit_code $hpid]
twapi::close_handle $htid

2
src/modules/punkcheck-0.1.0.tm

@ -86,7 +86,7 @@ namespace eval punkcheck {
set linecount [llength [split $newtdl \n]]
#puts stdout $newtdl
set fd [open $punkcheck_file w]
fconfigure $fd -translation binary
chan configure $fd -translation binary
puts -nonewline $fd $newtdl
close $fd
return [list recordcount [llength $recordlist] linecount $linecount]

11
src/modules/shellrun-0.1.1.tm

@ -283,7 +283,8 @@ namespace eval shellrun {
#exitcode not part of return value for runout - colourcode appropriately
set n $RST
set c ""
if [dict exists $exitinfo exitcode] {
if {[dict exists $exitinfo exitcode]} {
set code [dict get $exitinfo exitcode]
if {$code == 0} {
set c [a+ green]
@ -291,7 +292,7 @@ namespace eval shellrun {
set c [a+ white bold]
}
lappend chunklist [list "info" "$c$exitinfo$n"]
} elseif [dict exists $exitinfo error] {
} elseif {[dict exists $exitinfo error]} {
set c [a+ yellow bold]
lappend chunklist [list "info" "${c}error [dict get $exitinfo error]$n"]
lappend chunklist [list "info" "errorCode [dict get $exitinfo errorCode]"]
@ -398,17 +399,15 @@ namespace eval shellrun {
set n [a]
set c ""
if [dict exists $exitinfo exitcode] {
if {[dict exists $exitinfo exitcode]} {
set code [dict get $exitinfo exitcode]
if {$code == 0} {
set c [a+ green]
} else {
set c [a+ white bold]
}
lappend chunklist [list "info" "$c$exitinfo$n"]
} elseif [dict exists $exitinfo error] {
} elseif {[dict exists $exitinfo error]} {
set c [a+ yellow bold]
lappend chunklist [list "info" "error [dict get $exitinfo error]"]
lappend chunklist [list "info" "errorCode [dict get $exitinfo errorCode]"]

12
src/modules/shellthread-1.6.1.tm

@ -209,10 +209,10 @@ namespace eval shellthread::worker {
variable sysloghost_port
variable sock
if {[string length $sysloghost_port]} {
if {[catch {fconfigure $sock} state]} {
if {[catch {chan configure $sock} state]} {
set sock [udp_open]
fconfigure $sock -buffering none -translation binary
fconfigure $sock -remote $sysloghost_port
chan configure $sock -buffering none -translation binary
chan configure $sock -remote $sysloghost_port
}
}
}
@ -220,7 +220,7 @@ namespace eval shellthread::worker {
variable sock
catch {close $sock}
_initsock
return [fconfigure $sock]
return [chan configure $sock]
}
proc send_info {client_tid ts_sent source msg} {
@ -436,7 +436,7 @@ namespace eval shellthread::manager {
# todo - some protection mechanism for case where target is a file to stop creation of multiple worker threads writing to same file.
# Even if we use open fd,close fd wrapped around writes.. it is probably undesirable to have multiple threads with same target
# On the other hand socket targets such as UDP can happily be written to by multiple threads.
# For now the mechanism is that a call to new_worker (rename to open_worker?) will join the same thread if a sourcetag matches..
# For now the mechanism is that a call to new_worker (rename to open_worker?) will join the same thread if a sourcetag matches.
# but, as sourcetags can get removed(unsubbed via leave_worker) this doesn't guarantee two threads with same -file settings won't fight.
# Also.. the settingsdict is ignored when joining with a tag that exists.. this is problematic.. e.g logrotation where previous file still being written by existing worker
# todo - rename 'sourcetag' concept to 'targettag' ?? the concept is a mixture of both.. it is somewhat analagous to a syslog 'facility'
@ -751,7 +751,7 @@ namespace eval shellthread::manager {
set ts_end_list [dict get $workers $source ts_end_list] ;#ts_end_list is just a list of timestamps of closing calls for this source - only one is needed to close, but they may all come in a flurry.
if {[llength $ts_end_list]} {
set last_end_ts [lindex $ts_end_list end]
if {[expr {(($tsnow - $last_end_ts) / 1000) >= $timeout}]} {
if {(($tsnow - $last_end_ts) / 1000) >= $timeout} {
lappend ts_end_list $ts_now
dict set workers $source ts_end_list $ts_end_list
} else {

6
src/modules/textblock-999999.0a1.0.tm

@ -663,7 +663,7 @@ tcl::namespace::eval textblock {
switch -- $k {
-ansibase_header - -ansibase_body - -ansiborder_header - -ansiborder-body - -ansiborder_footer {
set parts [punk::ansi::ta::split_codes_single $v] ;#caller may have supplied separated codes eg "[a+ Yellow][a+ red]"
set ansi_codes [list] ;
set ansi_codes [list]
foreach {pt code} $parts {
if {$pt ne ""} {
#we don't expect plaintext in an ansibase
@ -1109,7 +1109,7 @@ tcl::namespace::eval textblock {
}
-ansibase {
set parts [punk::ansi::ta::split_codes_single $v] ;#caller may have supplied separated codes eg "[a+ Yellow][a+ red]"
set col_ansibase_items [list] ;
set col_ansibase_items [list]
foreach {pt code} $parts {
if {$pt ne ""} {
#we don't expect plaintext in an ansibase
@ -7852,7 +7852,7 @@ tcl::namespace::eval textblock {
foreach {k v} $optlist {
set k2 [tcl::prefix::match -error "" $optnames $k]
switch -- $k2 {
-etabs - -type - -boxlimits - -boxmap - -joins
-etabs - -type - -boxlimits - -boxmap - -join
- -title - -titlealign - -subtitle - -subtitlealign - -width - -height
- -ansiborder - -ansibase
- -blockalign - -textalign - -ellipsis

Loading…
Cancel
Save