bug-coreutils
[Top][All Lists]
Advanced

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

[PATCH] pr: ensure the page header line is of the required format


From: Jim Meyering
Subject: [PATCH] pr: ensure the page header line is of the required format
Date: Wed, 06 Jan 2010 19:33:19 +0100

Denis, thanks for the report and patch.

Here are two patches.
First, Denis' fix, and then the one to update NEWS
and adjust the test to pass again.

Denis, let me know soon if you'd prefer a different
name/email-address on the git commit.  Once I push it,
it cannot be changed.


>From 6363c1abbcb2cc8402ea66683d70a204f8a7eba2 Mon Sep 17 00:00:00 2001
From: Denis McKeon <address@hidden>
Date: Wed, 6 Jan 2010 19:21:34 +0100
Subject: [PATCH 1/2] pr: ensure the page header line is of the required format

Before this change, with too long a file name, the name would
abut the date field on the left and possibly also the "Page N"
field on the right, rather than leaving a one-space separator
in each case.
* src/pr.c (print_header): Ensure that there is at least one
space before and after the file name part of the header line.
---
 src/pr.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/pr.c b/src/pr.c
index a1b44e3..db34817 100644
--- a/src/pr.c
+++ b/src/pr.c
@@ -2403,6 +2403,9 @@ print_header (void)
   lhs_spaces = available_width >> 1;
   rhs_spaces = available_width - lhs_spaces;

+  lhs_spaces = 0 < lhs_spaces ? lhs_spaces : 1;
+  rhs_spaces = 0 < rhs_spaces ? 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, " ",
--
1.6.6.387.g2649b1


>From f20f56ad939aa02b4286a03fb2f68ed4e49315c6 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Wed, 6 Jan 2010 19:28:21 +0100
Subject: [PATCH 2/2] tests: adapt pr tests to accommodate corrected formatting

* NEWS (Bug fixes): Mention it.
* tests/pr/W20l24f-ll: s/xPage/ x Page/
---
 NEWS                |    3 +++
 tests/pr/W20l24f-ll |   18 +++++++++---------
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/NEWS b/NEWS
index 686ed56..9143e40 100644
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,9 @@ GNU coreutils NEWS                                    -*- 
outline -*-
   symlinks when the 'LINK target' directive was given to dircolors.
   [bug introduced in fileutils-4.0]

+  pr's page header was improperly formatted for long file names
+  [bug introduced in fileutils-7.2]
+
   rm -r --one-file-system works once again.
   The rewrite to make rm use fts introduced a regression whereby
   a commmand of the above form would fail for all subdirectories.
diff --git a/tests/pr/W20l24f-ll b/tests/pr/W20l24f-ll
index 92d08af..ecc9a7a 100644
--- a/tests/pr/W20l24f-ll
+++ b/tests/pr/W20l24f-ll
@@ -1,6 +1,6 @@


--- Date/Time --xPage 1
+-- Date/Time -- x Page 1


 1<<<  -Test: FF's in
@@ -19,13 +19,13 @@
 14<<<  123456789 123
 

--- Date/Time --xPage 2
+-- Date/Time -- x Page 2



 

--- Date/Time --xPage 3
+-- Date/Time -- x Page 3


 15<<<  xyzxyzxyz XYZ
@@ -44,13 +44,13 @@
 28<<<  trunc
 

--- Date/Time --xPage 4
+-- Date/Time -- x Page 4



 

--- Date/Time --xPage 5
+-- Date/Time -- x Page 5


 29<<<xyzxyzxyz XYZXY
@@ -69,19 +69,19 @@
 42<<<  123456789 abc
 

--- Date/Time --xPage 6
+-- Date/Time -- x Page 6



 

--- Date/Time --xPage 7
+-- Date/Time -- x Page 7



 

--- Date/Time --xPage 8
+-- Date/Time -- x Page 8


 43<<<  xyzxyzxyz XYZ
@@ -100,7 +100,7 @@
 56<<<  123456789 abc
 

--- Date/Time --xPage 9
+-- Date/Time -- x Page 9


 57<<<  xyzxyzxyz XYZ
--
1.6.6.387.g2649b1




reply via email to

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