cryptop.list: Fix column width calculation.
authorMark Wooding <mdw@distorted.org.uk>
Tue, 18 Sep 2012 19:33:27 +0000 (20:33 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Thu, 20 Sep 2012 00:10:18 +0000 (01:10 +0100)
Confusion over where the calculated column widths went caused the final
line's values to be ignored.  Simplify and fix.

cryptop.list

index 538b623..d5f448f 100755 (executable)
@@ -137,8 +137,7 @@ cd $KEYS
 ## names into explicit `NAME+0' forms.  Decide whether we need a width-
 ## measuring pass.
 calcwd=nil
-cc=$cols
-wdcols=""
+cc=$cols cols=""
 while :; do
 
   ## Pick off the next column name.  If none are left, leave the loop.
@@ -159,11 +158,11 @@ while :; do
   case "$col" in
     *[:=+]*)
       wd=${col#*[:=+]}
-      wdcols=${wdcols:+$wdcols,}$col
+      cols=${cols:+$cols,}$col
       checknumber "column width" "$wd"
       ;;
     *)
-      wdcols=${wdcols:+$wdcols,}$col+0
+      cols=${cols:+$cols,}$col+0
       ;;
   esac
 
@@ -209,8 +208,8 @@ while :; do
     ## Now iterate over the columns.  If we're calculating widths, use the
     ## ones we worked out last time, and clear the list so we can build a new
     ## one as we go.
-    case $calcwd in t) cols=$wdcols ;; esac
-    cc=$cols wdcols="" sep=""
+    cc=$cols sep=""
+    case $calcwd in t) cols="" ;; esac
     while :; do
 
       ## Pick off the next column spec.
@@ -234,12 +233,12 @@ while :; do
       ## idea of the column width.  If we're printing, work out a format.
       case $calcwd,$col in
        t,*[:=]*)
-         wdcols=${wdcols:+$wdcols,}$col
+         cols=${cols:+$cols,}$col
          ;;
        t,*+*)
          colwd=$(( $(echo "$value" | wc -c) - 1 ))
          if [ $colwd -gt $wd ]; then wd=$colwd; fi
-         wdcols=${wdcols:+$wdcols,}$name+$wd
+         cols=${cols:+$cols,}$name+$wd
          ;;
        nil,*[=+]*)
          fmt="%-${wd}.${wd}s"