Package: rs
Version: 20101029-1
Tags: patch
When using -z to compress column width, the loop does not reset the
maximum width for each column, but instead accumulates the maximum width
of all preceeding columns.
For example, the following input
1
a wide column
2
3
4
a
another wide column
b
c
d
passed into rs -ze 0 5 gives
1 a wide column 2 3 4
a another wide column b c d
with the third, fourth, and fifth columns having inherited the maximum
width of the wider second column. I would have expected them to have the
same width as the narrow first column.
With the patch below the output is what I would expect:
1 a wide column 2 3 4
a another wide column b c d
--- rs-20101029.orig/rs.c
+++ rs-20101029/rs.c
@@ -290,6 +290,7 @@
if (flags & SQUEEZE) {
if (flags & TRANSPOSE)
for (ep = elem, i = 0; i < ocols; i++) {
+ max = 0;
for (j = 0; j < orows; j++)
if ((n = strlen(*ep++)) > max)
max = n;
@@ -297,6 +298,7 @@
}
else
for (ep = elem, i = 0; i < ocols; i++) {
+ max = 0;
for (j = i; j < nelem; j += ocols)
if ((n = strlen(ep[j])) > max)
max = n;
--
http://rjy.org.uk/
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]