bugGNU Core Utilities - Bugs: bug #28492, pr header lacks spaces around long...


You are not allowed to post comments on this tracker with your current authentication level.

bug #28492: pr header lacks spaces around long file names

Submitted by:  None
Submitted on:  Wed 06 Jan 2010 12:53:34 AM UTC  
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  Eric Blake <ericb>
Open/Closed:  Open

Thu 07 Jan 2010 04:42:40 AM UTC, comment #2:

Patched in git, will be in coreutils 8.3.

Eric Blake <ericb>
Project AdministratorIn charge of this item.
Wed 06 Jan 2010 02:42:51 AM UTC, comment #1:

Thanks for the report (although the mailing list tends to be the preferred medium for potential patches). You are indeed correct that this is a violation of POSIX.

Your patch is reversed in sense (you want the original file to be listed first, not second). Also, your attempt at an electronic copyright disclaimer does not hold enough weight to work with the FSF; fortunately, though, your contribution is small enough to not need copyright assignment in the first place.

Eric Blake <ericb>
Project AdministratorIn charge of this item.
Wed 06 Jan 2010 12:53:34 AM UTC, original submission:

Printing a file whose path or name is longer than 48 chars
leaves the file name adjoining the <date> and/or <page>
elements of the header.

Names shorter than 48 chars are centered between spaces in
the available width.

Names longer than 48 chars lack padding spaces.

Names longer than 50 chars appear without spaces in a wider format header.

Repeat by:

longs=$( echo ${base}{8,89,89_,89_1} )
for f in ${longs} ; do echo >> $f; done
pr ${longs} | cat -s

produces (modulo date formats and 'Page' translation):

2010-01-05 16:48 123456789_123456789_123456789_123456789_12345678 Page 1

2010-01-05 16:48123456789_123456789_123456789_123456789_123456789 Page 1

2010-01-05 16:48123456789_123456789_123456789_123456789_123456789_Page 1

2010-01-05 16:48123456789_123456789_123456789_123456789_123456789_1Page 1

POSIX appears to specify a printf format for pr headers equivalent to:

"\n\n%s %s Page %d\n\n\n",
<output of date>, <file>, <page number>

which shows explicit spaces around the file name field.

I added statements to pr.c to coerce the spacing to be greater than 0,
but there may certainly be a more elegant approach that considers
the issues of headers for multiple columns.

--- pr.c 2010-01-05 16:27:54.000000000 -0800
+++ pr.orig.c 2010-01-05 15:10:50.000000000 -0800
@@ -2403,9 +2403,6 @@
lhs_spaces = available_width >> 1;
rhs_spaces = available_width - lhs_spaces;

- lhs_spaces = lhs_spaces > 0 ? lhs_spaces : 1;
- rhs_spaces = rhs_spaces > 0 ? rhs_spaces : 1;
printf ("\n\n%*.*s%s%*.*s%s%*.*s%s\n\n\n",
chars_per_margin, chars_per_margin, " ",
date_text, lhs_spaces, lhs_spaces, " ",
file_text, rhs_spaces, rhs_spaces, " ", page_text);

I am entitled to copyright of this bug report and patch, but
disclaim any such interest, and place them in the public domain,
with the intent that GNU/FSF may use them as they please.

best wishes,
Denis McKeon



No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by ericb (Posted a comment)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.




    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2010-01-07 ericb StatusNone => Fixed
        Assigned toNone => ericb

    Back to the top

    Powered by Savane 3.3