patch d6716f5f719e0e6b712139717e6df63ca44fd4db Author: Enrique D. Bosch Date: Tue Sep 5 22:19:09 CEST 2017 * Fix style to avoid double substitution diff -rN -u old-idlebiff/idlebiff new-idlebiff/idlebiff --- old-idlebiff/idlebiff 2024-05-19 05:03:41.589373288 +0200 +++ new-idlebiff/idlebiff 2024-05-19 05:03:41.593373297 +0200 @@ -27,8 +27,8 @@ package require tooltip namespace path ::tcl::mathop -proc and { args } { set a 1; foreach b $args { set a [ expr $a && $b ]; if !$a { return 0 } }; return $a } -proc or { args } { set a 0; foreach b $args { set a [ expr $a || $b ]; if $a { return 1 } }; return $a } +proc and args { set a 1; foreach b $args { set a [ expr $a && $b ]; if { !$a } { return 0 } }; return $a } +proc or args { set a 0; foreach b $args { set a [ expr $a || $b ]; if { $a } { return 1 } }; return $a } namespace eval static \ { @@ -68,7 +68,7 @@ variable new_messages 0 } -proc define_pixmaps { } \ +proc define_pixmaps {} \ { variable ::shared::img_up variable ::shared::img_down @@ -80,7 +80,7 @@ set img_chk [ image create photo -format png -file $conf(png_chk) ] } -proc icon { } \ +proc icon {} \ { variable ::shared::img_up variable ::shared::img_down @@ -100,12 +100,12 @@ set png_chk_h [ dict get $pnginfo height ] set size_not_same [ or [ != $png_up_w $png_down_w ] [ != $png_down_w $png_chk_w ] [ != $png_up_h $png_down_h ] [ != $png_down_h $png_chk_h ] ] - if $size_not_same { error } + if { $size_not_same } { error } wm title . idlebiff wm iconname . idlebiff append geom [ + $png_up_w 10 ] x [ + $png_up_h 10 ] - if [ and $conf(pos_x) $conf(pos_y) ] { append geom + $conf(pos_x) + $conf(pos_y) } + if {[ and $conf(pos_x) $conf(pos_y) ]} { append geom + $conf(pos_x) + $conf(pos_y) } wm geometry . $geom wm resizable . 0 0 wm overrideredirect . $conf(nodecor) @@ -131,9 +131,9 @@ variable ::shared::conf upvar #0 pass pass - if $bad { set textbad "WRONG PASSWORD\n" } \ - else { set textbad "" } - if !$conf(tls) { set nv "\nWARNING: INSECURE CONNECTION" } + if { $bad } { set textbad "WRONG PASSWORD\n" } \ + else { set textbad {} } + if { !$conf(tls) } { set nv "\nWARNING: INSECURE CONNECTION" } toplevel .tl message .tl.msg -bg black -fg yellow -width 400 -justify center \ @@ -159,19 +159,19 @@ variable ::shared::new_messages .frame.canvas.button configure -image $img - if $conf(tip) { tooltip::tooltip .frame.canvas $new_messages } + if { $conf(tip) } { tooltip::tooltip .frame.canvas $new_messages } } -proc read_conf { } \ +proc read_conf {} \ { upvar #0 argv arg argc argn variable ::shared::conf - if [ == $argn 1 ] { set config $arg } else { set config "$::env(HOME)/.idlebiffrc" } + if {[ == $argn 1 ]} { set config $arg } else { set config "$::env(HOME)/.idlebiffrc" } set cf [ open $config ] - while { [ >= [ gets $cf lin ] 0 ] } \ + while {[ >= [ gets $cf lin ] 0 ]} \ { - if [ == [ string index [ string trim $lin ] 0 ] # ] continue + if {[ == [ string index [ string trim $lin ] 0 ] # ]} continue set sep [ string first = $lin ] set key [ string range $lin 0 [ - $sep 1 ] ] set val [ string range $lin [ + $sep 1 ] end ] @@ -179,25 +179,25 @@ } } -proc set_params { } \ +proc set_params {} \ { variable ::shared::conf variable ::shared::criteria variable ::shared::rexp_chk - if [ info exists conf(criteria) ] { if [ ne $conf(criteria) "" ] { set criteria $conf(criteria) } } \ + if {[ info exists conf(criteria) ]} { if {[ ne $conf(criteria) {} ]} { set criteria $conf(criteria) } } \ else { set criteria UNSEEN } set rexp_chk {(?: |\[)capability } } -proc set_search_params { } \ +proc set_search_params {} \ { variable ::shared::cap variable ::shared::search variable ::shared::rexpsearch variable ::shared::criteria - if $cap(esearch) \ + if { $cap(esearch) } \ { set search "SEARCH RETURN (COUNT) $criteria" set rexpsearch {^\* esearch \(tag [^)]*\) count (.*)$} @@ -209,7 +209,7 @@ } } -proc set_timeout { } \ +proc set_timeout {} \ { variable ::shared::conf variable ::shared::tevent @@ -225,12 +225,12 @@ incr teidf } -proc cancel_timeout { } \ +proc cancel_timeout {} \ { variable ::shared::tevent variable ::shared::teidi - if [ info exists tevent($teidi) ] \ + if {[ info exists tevent($teidi) ]} \ { after cancel $tevent($teidi) unset tevent($teidi) @@ -240,7 +240,7 @@ proc exec_terse { com args } \ { - if [ catch { set res [ eval "$com [ join $args]" ] } ] \ + if {[ catch { set res [ eval "$com [ join $args]" ] } ]} \ { set terse [ split $::errorInfo "\n" ] puts [ join [ lrange $terse 0 0 ] ] @@ -262,8 +262,8 @@ proc imap_command { con com } \ { -# if [regexp {.*LOGIN.*} $com] {puts "C: [string range $com 0 10]"} else {puts "C: $com"} - if [ catch { puts $con $com } ] \ +# if {[regexp {.*LOGIN.*} $com]} {puts "C: [string range $com 0 10]"} else {puts "C: $com"} + if {[ catch { puts $con $com } ]} \ { recon $con return @@ -275,8 +275,8 @@ { variable ::static::tag - if [ == $tag 10000 ] { set tag 1 } - append tcom $prefix [ format %04d $tag ] " " $com + if {[ == $tag 10000 ]} { set tag 1 } + append tcom $prefix [ format %04d $tag ] { } $com imap_command $con $tcom incr tag } @@ -302,10 +302,10 @@ variable ::shared::conf variable ::shared::cap - if $cap(logindisabled) { error logindisabled } + if { $cap(logindisabled) } { error logindisabled } - if $retr { unset conf(pass) } - if ![ info exists conf(pass) ] { set conf(pass) [ get_password $retr ] } + if { $retr } { unset conf(pass) } + if { ![ info exists conf(pass) ] } { set conf(pass) [ get_password $retr ] } imap_command_tagged $con A "LOGIN $conf(user) $conf(pass)" } @@ -322,7 +322,7 @@ exit 0 } -proc force_down { } \ +proc force_down {} \ { variable ::shared::img_down @@ -363,13 +363,13 @@ variable ::shared::cap variable ::shared::rexp_chk - if [ regexp -nocase -lineanchor $rexp_chk $linea ] \ + if {[ regexp -nocase -lineanchor $rexp_chk $linea ]} \ { - if [ eq $args logindisabled ] { set cap(logindisabled_chk) 1 } \ + if {[ eq $args logindisabled ]} { set cap(logindisabled_chk) 1 } \ else { set cap(chk) 1 } foreach capname $args \ { - if !$cap($capname) \ + if { !$cap($capname) } \ { set rexp_cap " ${capname}(?: |]|$)" set cap($capname) [ regexp -nocase -lineanchor $rexp_cap $linea ] @@ -387,7 +387,7 @@ after cancel $ka set idle 0 exit_idle $con - if $check { do_search $con } \ + if { $check } { do_search $con } \ else { enter_idle $con } set ka [ after ${conf(keepalive)}000 { idle_cycle $con 0 } ] } @@ -398,7 +398,7 @@ variable ::shared::ka variable ::shared::cap - if !$cap(idle) { error noidle } + if { !$cap(idle) } { error noidle } fileevent $con readable { parse_idle_check $con } enter_mailbox $con set_search_params @@ -412,9 +412,9 @@ set linea [ read_line $con ] check_cap $linea logindisabled - if [ ok_untagged $linea ] \ + if {[ ok_untagged $linea ]} \ { - if $cap(logindisabled_chk) \ + if { $cap(logindisabled_chk) } \ { fileevent $con readable { parse_login $con } login $con 0 @@ -433,9 +433,9 @@ set linea [ read_line $con ] check_cap $linea logindisabled - if [ ok_tagged $linea A ] \ + if {[ ok_tagged $linea A ]} \ { - if $cap(logindisabled_chk) \ + if { $cap(logindisabled_chk) } \ { fileevent $con readable { parse_login $con } login $con 0 @@ -449,33 +449,33 @@ set linea [ read_line $con ] check_cap $linea idle esearch - if [ ok_tagged $linea A ] \ + if {[ ok_tagged $linea A ]} \ { - if $cap(chk) { init_idle $con } \ + if { $cap(chk) } { init_idle $con } \ else \ { fileevent $con readable { parse_cap $con } imap_command_tagged $con A CAPABILITY } } \ - elseif [ no_tagged $linea ] { login $con 1 } + elseif {[ no_tagged $linea ]} { login $con 1 } } proc parse_cap con \ { set linea [ read_line $con ] check_cap $linea idle esearch - if [ ok_tagged $linea A ] { init_idle $con } + if {[ ok_tagged $linea A ]} { init_idle $con } } proc parse_idle_check con \ { variable ::shared::idle - if [ catch { set linea [ read_line $con ] } ] return + if {[ catch { set linea [ read_line $con ] } ]} return set prim [ string range $linea 0 0 ] - if [ eq $prim + ] { set idle 1 } \ - elseif $idle { if [ eq $prim * ] { idle_cycle $con 1 } } \ + if {[ eq $prim + ]} { set idle 1 } \ + elseif { $idle } { if {[ eq $prim * ]} { idle_cycle $con 1 } } \ else { parse_search $con $linea } } @@ -490,39 +490,39 @@ variable ::static::pmsgs variable ::static::search_resp - if [ regexp -lineanchor -nocase $rexpsearch $linea -> res ] \ + if {[ regexp -lineanchor -nocase $rexpsearch $linea -> res ]} \ { - if $cap(esearch) { set pmsgs $res } else { incr pmsgs [ llength $res ] } + if { $cap(esearch) } { set pmsgs $res } else { incr pmsgs [ llength $res ] } set search_resp 1 } - if [ and $search_resp [ ok_tagged $linea A ] ] \ + if {[ and $search_resp [ ok_tagged $linea A ] ]} \ { enter_idle $con set new_messages $pmsgs set pmsgs 0 set search_resp 0 - if [ > $new_messages 0 ] \ + if {[ > $new_messages 0 ]} \ { set current $img_up } \ else { set current $img_down } update_img $current } - if [ no_tagged $linea ] { error search } + if {[ no_tagged $linea ]} { error search } } proc read_line con \ { cancel_timeout - if [ catch { set r [ gets $con line ] } ] \ + if {[ catch { set r [ gets $con line ] } ]} \ { recon $con return -code error } - if [ regexp -lineanchor -nocase {^\* bye(?: .*|$)} $line ] \ + if {[ regexp -lineanchor -nocase {^\* bye(?: .*|$)} $line ]} \ { recon $con return -code error } - if [ and [ < $r 1 ] [ eof $con ] ] \ + if {[ and [ < $r 1 ] [ eof $con ] ]} \ { recon $con return -code error @@ -548,34 +548,34 @@ variable ::static::ccsp array set ca $cert - if [ info exists conf(tls_ca_subject) ] \ + if {[ info exists conf(tls_ca_subject) ]} \ { - if [ and [ ne $conf(tls_ca_subject) "" ] [ eq $type "verify" ] [ eq $ca(subject) $ca(issuer) ] ] \ + if {[ and [ ne $conf(tls_ca_subject) {} ] [ eq $type verify ] [ eq $ca(subject) $ca(issuer) ] ]} \ { array set csu [ parse_cert_subject $ca(subject) ] - if !$ccsp \ + if { !$ccsp } \ { array set ccsu [ parse_cert_subject $conf(tls_ca_subject) ] set ccsp 1 } foreach i [ array names ccsu ] \ { - if ![ info exists csu($i) ] { error cert } - if [ ne $csu($i) $ccsu($i) ] { error cert } + if { ![ info exists csu($i) ] } { error cert } + if {[ ne $csu($i) $ccsu($i) ]} { error cert } } } } } -proc init_tls { } \ +proc init_tls {} \ { variable ::shared::conf variable ::shared::sock - if $conf(tls) \ + if { $conf(tls) } \ { set tlsv [ package require tls ] - if [ >= $tlsv 1.6.4 ] { set tls1x {-tls1.1 1 -tls1.2 1} } \ + if {[ >= $tlsv 1.6.4 ]} { set tls1x {-tls1.1 1 -tls1.2 1} } \ else { set tls1x {} } set sock "::tls::socket -ssl2 0 -ssl3 0 -tls1 1 $tls1x \ -cafile \"$conf(tls_ca_file)\" \ @@ -590,16 +590,16 @@ else { set sock socket } } -proc init { } \ +proc init {} \ { upvar #0 con con variable ::shared::conf variable ::shared::sock set con [ exec_terse $sock -async $conf(host) $conf(port) ] - fconfigure $con -blocking 0 -buffering line -translation "crlf crlf" + fconfigure $con -blocking 0 -buffering line -translation {crlf crlf} fileevent $con readable { parse_greeting $con } - if $conf(initial_noop) { imap_command_tagged $con N NOOP } + if { $conf(initial_noop) } { imap_command_tagged $con N NOOP } } read_conf