Change expressions from infix to prefix notation
patch 16034f2b6f19369d43dc6b1c91c184734f75185a
Author: Enrique D. Bosch <presidev@AT@gmail.com>
Date: Wed Jan 11 01:00:25 CET 2017
* Change expressions from infix to prefix notation
diff -rN -u old-idlebiff/idlebiff new-idlebiff/idlebiff
--- old-idlebiff/idlebiff 2024-05-06 10:21:08.392564442 +0200
+++ new-idlebiff/idlebiff 2024-05-06 10:21:08.392564442 +0200
@@ -26,6 +26,9 @@
package require png
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 }
namespace eval static \
{
@@ -96,13 +99,13 @@
set png_chk_w [ dict get $pnginfo width ]
set png_chk_h [ dict get $pnginfo height ]
- set size_not_same [ expr $png_up_w!=$png_down_w || $png_down_w!=$png_chk_w || $png_up_h!=$png_down_h || $png_down_h!=$png_chk_h ]
+ 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 }
wm title . idlebiff
wm iconname . idlebiff
- append geom [ expr $png_up_w + 10 ] x [ expr $png_up_h + 10 ]
- if { $conf(pos_x) && $conf(pos_y) } { append geom + $conf(pos_x) + $conf(pos_y) }
+ 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) }
wm geometry . $geom
wm resizable . 0 0
wm overrideredirect . $conf(nodecor)
@@ -164,14 +167,14 @@
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 [ expr $sep - 1 ] ]
- set val [ string range $lin [ expr $sep + 1 ] end ]
+ set key [ string range $lin 0 [ - $sep 1 ] ]
+ set val [ string range $lin [ + $sep 1 ] end ]
set conf([ string trim $key]) [ string trim $val ]
}
}
@@ -182,7 +185,7 @@
variable ::shared::criteria
variable ::shared::rexp_chk
- if { [ info exists conf(criteria) ] && $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 }
}
@@ -272,7 +275,7 @@
{
variable ::static::tag
- if { $tag == 10000 } { set tag 1 }
+ if [ == $tag 10000 ] { set tag 1 }
append tcom $prefix [ format %04d $tag ] " " $com
imap_command $con $tcom
incr tag
@@ -362,7 +365,7 @@
if [ regexp -nocase -lineanchor $rexp_chk $linea ] \
{
- if { $args eq "logindisabled" } { set cap(logindisabled_chk) 1 } \
+ if [ eq $args logindisabled ] { set cap(logindisabled_chk) 1 } \
else { set cap(chk) 1 }
foreach capname $args \
{
@@ -471,8 +474,8 @@
if [ catch { set linea [ read_line $con ] } ] return
set prim [ string range $linea 0 0 ]
- if { $prim eq "+" } { set idle 1 } \
- elseif $idle { if { $prim eq "*" } { idle_cycle $con 1 } } \
+ if [ eq $prim + ] { set idle 1 } \
+ elseif $idle { if [ eq $prim * ] { idle_cycle $con 1 } } \
else { parse_search $con $linea }
}
@@ -492,13 +495,13 @@
if $cap(esearch) { set pmsgs $res } else { incr pmsgs [ llength $res ] }
set search_resp 1
}
- if { $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
@@ -519,7 +522,7 @@
recon $con
return -code error
}
- if { $r < 1 && [ eof $con ] } \
+ if [ and [ < $r 1 ] [ eof $con ] ] \
{
recon $con
return -code error
@@ -545,16 +548,22 @@
variable ::static::ccsp
array set ca $cert
- if { $conf(tls_ca_subject) ne "" && $type eq "verify" && $ca(subject) eq $ca(issuer) } \
+ if [ info exists conf(tls_ca_subject) ] \
{
- array set csu [ parse_cert_subject $ca(subject) ]
- if !$ccsp \
+ if [ and [ ne $conf(tls_ca_subject) "" ] [ eq $type "verify" ] [ eq $ca(subject) $ca(issuer) ] ] \
{
- array set ccsu [ parse_cert_subject $conf(tls_ca_subject) ]
- set ccsp 1
+ array set csu [ parse_cert_subject $ca(subject) ]
+ 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 }
+ }
}
- foreach i [ array names ccsu ] \
- { if { ![ info exists csu($i) ] || $csu($i)!=$ccsu($i) } { error cert } }
}
}
@@ -566,7 +575,7 @@
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)\" \