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:
base='123456789_123456789_123456789_123456789_1234567'
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
|