Skip to content
Tcl Source Code View Ticket
Login

View Ticket

concatenating binary array with empty string yields the empty string

Closed / Fixedba921a8d98e02a96617835bfdc3437e2a4db9e1bCreated 8 years agoUpdated 8 years ago
Descriptionwiki2018-07-22 20:35:20
The result of the following script is the empty string:

proc main {} {
    set data [binary format a* hello]
    puts $data
    puts $data[set data {}]
}

main
Referenced by1
  • 9819e2fe99[ba921a8d98] Make sure [string cat] includes all data from all bytearrays. check-in2018-07-26 16:14:44
pooryorickwiki2018-07-22 20:46:33

Fixed in [f274e1f1baf02516].

dgpplain2018-07-25 19:27:40
Fix isn't right yet:

% proc demo {} {
    set data [binary format a* hello]
    return [encoding convertto $data]$data
}
% demo
hellolr
%
anonymoushtml2018-07-25 21:34:47

Just for the records, a variant of the original snippet without [puts]:

proc main {} {
    set data [binary format a* hello]
    return [expr {$data}][set data {}]
}
main

dgpplain2018-07-26 16:18:17
Test and fix committed.
Log in (anonymous is fine) to add a comment.