On 08/23/2011 06:58 AM, [email protected] wrote:
> The issue:
> Running pr(1) with eith the -t or -T options appears to negate the --page
> option's :LAST_PAGE optional argument.  The documentation does not mention
> this effect; either the documentation or the program should be updated to
> address this.
> 
> Illustration of issue:
> 
> $ wc -l foo
> 144 foo
> $ pr +1:1 foo | wc -l
> 66
> $ pr +1:1 -t foo | wc -l
> 144
> $ pr +1:1 -T foo | wc -l
> 144
> 
> Version and system info:
> 
> $ pr --version | head -n1
> pr (GNU coreutils) 7.4
> $ uname -a
> Linux thinkcentre 2.6.32-33-generic #72-Ubuntu SMP Fri Jul 29 21:08:37 UTC 
> 2011 i686 GNU/Linux

This looks like a bug, since `pr +2 -T` does skip the first page.
I.E. -tT should be independent of those page ranges.

The following seems to work, and pass tests.
cheers,
Pádraig.

diff --git a/src/pr.c b/src/pr.c
index 771418c..d1adc55 100644
--- a/src/pr.c
+++ b/src/pr.c
@@ -1887,7 +1887,7 @@ print_page (void)
       print_a_FF = false;
     }

-  if (last_page_number < page_number)
+  if (last_page_number < ++page_number)
     return false;              /* Stop printing with LAST_PAGE */

   reset_status ();             /* Change ON_HOLD to OPEN. */
@@ -2399,7 +2399,7 @@ print_header (void)
   /* The translator must ensure that formatting the translation of
      "Page %"PRIuMAX does not generate more than (sizeof page_text - 1)
      bytes.  */
-  sprintf (page_text, _("Page %"PRIuMAX), page_number++);
+  sprintf (page_text, _("Page %"PRIuMAX), page_number);
   available_width = header_width_available - mbswidth (page_text, 0);
   available_width = MAX (0, available_width);
   lhs_spaces = available_width >> 1;



Reply via email to