dot/xinitrc: Use $(( ... )) consistently for arithmetic evaluation.
authorMark Wooding <mdw@distorted.org.uk>
Sat, 23 Apr 2016 11:41:39 +0000 (12:41 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sat, 23 Apr 2016 11:41:39 +0000 (12:41 +0100)
dot/xinitrc

index 9bf7a85..7f6d415 100755 (executable)
@@ -275,14 +275,14 @@ declare -i panelwd=64 xbound=$(( XWIDTH - panelwd ))
 
 declare -i lim=XSCR0_WIDTH
 if (( lim > xbound )); then lim=xbound; fi
-declare -i ecols="(lim - t_wd - e_hextra)/e_colwd"
+declare -i ecols=$(( (lim - t_wd - e_hextra)/e_colwd ))
 if (( ecols < 2 && lim > 2*e_colwd + e_hextra )); then ecols=2
 elif (( ecols < 1 )); then ecols=1
 fi
 
 declare -i \
-  emacsx="ecols*e_colchars + e_cextra" \
-  emacsy="(XHEIGHT - e_vextra)/e_lineht"
+  emacsx=$(( ecols*e_colchars + e_cextra )) \
+  emacsy=$(( (XHEIGHT - e_vextra)/e_lineht ))
 
 start-emacs () {
   GDK_NATIVE_WINDOWS=1 run bgclients noip \
@@ -302,9 +302,10 @@ start-emacs () {
 start-xterms () {
 
   ## Initialize some parameters.
-  declare -i x="ecols*e_colwd + e_hextra + XSCR0_X" xb=xbound
+  declare -i x=$(( ecols*e_colwd + e_hextra + XSCR0_X )) xb=xbound
   declare -i n=0 pgx=0 l h y ht scr=0 ll=lim
-  declare -i hstd="35*t_lineht + t_vextra" hmin="25*t_lineht + t_vextra"
+  declare -i hstd=$(( 35*t_lineht + t_vextra ))
+  declare -i hmin=$(( 25*t_lineht + t_vextra ))
   declare -i scrx scry scrwd scrht
 
   eval "scrx=\$XSCR${scr}_X scry=\$XSCR${scr}_Y
@@ -314,7 +315,7 @@ start-xterms () {
   while :; do
 
     ## Start a new iteration.
-    if ((x + t_wd > ll)); then
+    if (( x + t_wd > ll )); then
       scr=$(( scr + 1 ))
       if (( scr >= XNSCR )); then
        if (( n >= 3 )); then break; fi
@@ -330,21 +331,21 @@ start-xterms () {
 
     ## Make large xterms.
     y=scry ht=scrht
-    while ((ht - hstd >= hmin)); do
+    while (( ht - hstd >= hmin )); do
       run bgclients $term $geom 80x35+$x+$y
-      y="y + hstd" ht="ht - hstd" n="n + 1"
+      y=$(( y + hstd )) ht=$(( ht - hstd )) n=$(( n + 1 ))
     done
 
     ## Fill the remaining space.
-    if ((ht >= 2 * hmin)); then h="ht - hmin"; else h=ht; fi
-    l="(h - t_vextra)/t_lineht" h="l * t_lineht + t_vextra"
+    if (( ht >= 2*hmin )); then h=$(( ht - hmin )); else h=ht; fi
+    l=$(( (h - t_vextra)/t_lineht )) h=$(( l*t_lineht + t_vextra ))
     run bgclients $term $geom 80x$l+$x+$y
-    y="y + h" ht="ht - h" n="n + 1"
+    y=$(( y + h )) ht=$(( ht - h )) n=$(( n + 1 ))
     if ((ht >= hmin)); then
       run bgclients $term $geom 80x25+$x+$y
-      n="n + 1"
+      n=$(( n + 1 ))
     fi
-    x="x + t_wd"
+    x=$(( x + t_wd ))
   done
 }