GNU bug report logs - #46422
'pr' screws up tabstops in multicolumn outpt?

Previous Next

Package: coreutils;

Reported by: Leonard Janis Robert König <ljrk <at> ljrk.org>

Date: Wed, 10 Feb 2021 13:21:02 UTC

Severity: normal

Done: Pádraig Brady <P <at> draigBrady.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Pádraig Brady <P <at> draigBrady.com>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#46422: closed ('pr' screws up tabstops in multicolumn outpt?)
Date: Mon, 15 Feb 2021 21:34:01 +0000
[Message part 1 (text/plain, inline)]
Your message dated Mon, 15 Feb 2021 21:33:03 +0000
with message-id <0a0d4618-ed3f-33c7-d5cf-3e26da29ac9b <at> draigBrady.com>
and subject line Re: bug#46422: [PATCH] Re: bug#46422: 'pr' screws up tabstops in multicolumn outpt?
has caused the debbugs.gnu.org bug report #46422,
regarding 'pr' screws up tabstops in multicolumn outpt?
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
46422: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=46422
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Leonard Janis Robert König <ljrk <at> ljrk.org>
To: bug-coreutils <at> gnu.org
Subject: 'pr' screws up tabstops in multicolumn outpt?
Date: Wed, 10 Feb 2021 13:42:29 +0100
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


















































[Message part 3 (message/rfc822, inline)]
From: Pádraig Brady <P <at> draigBrady.com>
To: Erik Auerswald <auerswal <at> unix-ag.uni-kl.de>
Cc: Leonard Janis Robert König <ljrk <at> ljrk.org>,
 46422-done <at> debbugs.gnu.org
Subject: Re: bug#46422: [PATCH] Re: bug#46422: 'pr' screws up tabstops in
 multicolumn outpt?
Date: Mon, 15 Feb 2021 21:33:03 +0000
On 15/02/2021 07:19, Erik Auerswald wrote:
> On Sun, Feb 14, 2021 at 11:04:21PM +0000, Pádraig Brady wrote:
>> On 14/02/2021 19:22, Erik Auerswald wrote:
>>> May I ask you to test the new patch (v4) as well?
>>
>> This version looks good.
>> I'll probably apply this after a little more local testing.

Pushed at:
https://git.sv.gnu.org/gitweb/?p=coreutils.git;a=commitdiff;h=v8.32-108-gbd6c97dee

Marking this as done.

thanks again,
Pádraig


This bug report was last modified 4 years and 99 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.