bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#46422: 'pr' screws up tabstops in multicolumn outpt?


From: Leonard Janis Robert König
Subject: bug#46422: 'pr' screws up tabstops in multicolumn outpt?
Date: Wed, 10 Feb 2021 13:42:29 +0100
User-agent: Evolution 3.38.3 (by Flathub.org)

I'm sorry if I this is not a bug but to be expected, but I thnk pr
doesn't get the alignment of tabs in multicolumn output right.

Consider the following test input, where everything from x->x is a tab
(with tabs 8):

123456781234567812345678123456781
x       x       x       x       x
123456781234567812345678123456781
x       x       x       x       x

Run it through multicolumn pr, e.g.,

    pr -t -2 test > out

The output looks like:

123456781234567812345678123456781   123456781234567812345678123456781
x       x       x       x       x   x   x       x       x       x

That is, the x's aren't aligned anymore.  In contrast, on a SunOS 5.10
machine, I get:

123456781234567812345678123456781   123456781234567812345678123456781
        x       x       x       x           x       x       x       x

Basically, SunOS pr notices, that it cannot print "\tx\tx\tx\tx"
anymore, since the separation between the pages messed that up. 
Instead it prints "\t     x\t     x\t     x\t     x".

This bug only occurs with certain page widths, obviously.  A first
workaround can be to use `-s` to separate both columns by tabs. 
Unfortunately, this only works as long as the line lengths actually
allow for the next column to start at a multiple of 8.  E.g., if I pass
`-w 132` as well, this won't work again -- again, SunOS does the
expected thing here.

This seems *kind* of related to multi-column merged output, as was
discussed some years ago here:
https://lists.gnu.org/archive/html/bug-coreutils/2007-03/msg00121.html

Unfortunately the POSIX spec is, in my reading, a bit unclear here. 
But I think the behavior of GNU/pr is rather unexpected when printing
multicolumn source code and not in line what the original authors
intended.

The outline of the fix would be to calculate the starting column
position and then re-tab.  In my case, I could workaround with the
following for now:

    $ pr -e -t test | pr -t -2 > out

What do you think?

~leo



$ pr --version
pr (GNU coreutils) 8.32
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Pete TerMaat and Roland Huebner.
$ uname -a
Linux hoopyfrood 5.10.14-arch1-1 #1 SMP PREEMPT Sun, 07 Feb 2021
22:42:17 +0000 x86_64 GNU/Linux





















































reply via email to

[Prev in Thread] Current Thread [Next in Thread]