Commits

juster  committed 830ef4b

Remove .awk suffix. Fix quit in tclear. Fix dsort.

  • Participants
  • Parent commits d0fd663

Comments (0)

Files changed (6)

+#!/usr/bin/awk -f
+
+NF < 4 {
+    print "warning: skipped line " NR "." | "cat 1>&2"
+    next
+}
+
+{
+    amt = $4
+    sub(/^\$/, "", amt)
+    adjbals($2, -amt)
+    adjbals($3, amt)
+}
+
+END {
+    for(act in bal){
+        if(bal[act] == 0) delete bal[act]
+        else if(len < length(act)) len = length(act)
+    }
+    for(act in bal){
+        amt = sprintf("%0.2f", bal[act])
+        printf("%-" len "s %8s\n", act, amt) | "sort"
+    }
+}
+
+function adjbals(act, adj)
+{
+    while(1){
+        bal[act] += adj
+        if(!sub(/:[^:]+$/, "", act)) break
+    }
+}

File bal.awk

-#!/usr/bin/awk -f
-
-NF < 4 {
-    print "warning: skipped line " NR "." | "cat 1>&2"
-    next
-}
-
-{
-    amt = $4
-    sub(/^\$/, "", amt)
-    adjbals($2, -amt)
-    adjbals($3, amt)
-}
-
-END {
-    for(act in bal){
-        if(bal[act] == 0) delete bal[act]
-        else if(len < length(act)) len = length(act)
-    }
-    for(act in bal){
-        amt = sprintf("%0.2f", bal[act])
-        printf("%-" len "s %8s\n", act, amt) | "sort"
-    }
-}
-
-function adjbals(act, adj)
-{
-    while(1){
-        bal[act] += adj
-        if(!sub(/:[^:]+$/, "", act)) break
-    }
-}
 #!/bin/sh
-
-case $# in
-0)	set -- '-'
-esac
-
-./expdate.awk | ./dnum | sort -n | cut -d '	' -f 2- | awk -f pretty.awk
+cat $1 | ./expdate.awk | ./dnum | sort -n | cut -d '	' -f 2- | ./pretty.awk
+#!/usr/bin/awk -f
+
+NF < 5 { next }
+NR > 1 && $1 == lastd { $1 = "\"" }
+$1 != "\"" { lastd = $1 }
+
+{
+    for (i = 1; i <= 4; i++) {
+        if (wid[i] < length($i)) wid[i] = length($i)
+        entry[NR,i] = $i
+    }
+
+    if ($5 == "*") { entry[NR,"clear"] = 1; i = 6 }
+    else i = 5
+
+    for (desc = ""; i <= NF; i++) desc = desc $i " "
+    sub(/ $/, "", desc)
+    entry[NR,"desc"] = desc
+}
+
+END {
+    for (i = 1; i <= NR; i++) {
+        printf "%" wid[1] "s ", entry[i,1]
+        printf "%-" wid[2] "s %-" wid[3] "s\t", entry[i,2], entry[i,3]
+        printf "%" wid[4] "s ", sprintf("%0.2f", entry[i,4])
+
+        if (entry[i,"clear"]) printf "* "
+        else printf "  "
+
+        print entry[i,"desc"]
+    }
+}

File pretty.awk

-#!/usr/bin/awk -f
-
-NF < 5 { next }
-NR > 1 && $1 == lastd { $1 = "\"" }
-$1 != "\"" { lastd = $1 }
-
-{
-    for (i = 1; i <= 4; i++) {
-        if (wid[i] < length($i)) wid[i] = length($i)
-        entry[NR,i] = $i
-    }
-
-    if ($5 == "*") { entry[NR,"bal"] = 1; i = 6 }
-    else i = 5
-
-    for (desc = ""; i <= NF; i++) desc = desc $i " "
-    sub(/ $/, "", desc)
-    entry[NR,"desc"] = desc
-}
-
-END {
-    for (i = 1; i <= NR; i++) {
-        printf "%" wid[1] "s ", entry[i,1]
-        printf "%-" wid[2] "s %-" wid[3] "s\t", entry[i,2], entry[i,3]
-        printf "%" wid[4] "s ", sprintf("%0.2f", entry[i,4])
-
-        if (entry[i,"bal"]) printf "* "
-        else printf "  "
-
-        print entry[i,"desc"]
-    }
-}
 #!/bin/sh
 
+printrest()
+{
+	while read ln
+	do
+		echo "$ln"
+	done
+}
+
 PATH="$PATH:."
 IFS='
 '
 ./expdate.awk | while read trans
 do
-	IFS=' 	'
 	if echo "$trans" | fgrep -q '*'
 	then
 		echo "$trans"; continue
 	while :
 	do
 		echo -n "$trans? " 1>&2
-		IFS='
-'
 		read line </dev/tty
 		case "$line" in
 		[yY]*|'')	echo $trans | awk '{ $5 = "* " $5 } 1'; break ;;
 		[nN]*)	echo $trans; break ;;
-		[qQ]*)	exit 0 ;;
+		[qQ]*)	echo $trans; printrest; exit 0 ;;
 		*)		echo "Enter y (default), n, or q." 1>&2
 		esac
 	done