[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [Groff] Page classes in groff output to support reordering o
From: |
Paco Andres Verdu |
Subject: |
RE: [Groff] Page classes in groff output to support reordering o |
Date: |
Sun, 23 Jul 2000 12:55:19 +0200 (CEST) |
On Fri, 21 Jul 2000 address@hidden wrote:
> One feature of groff which could be useful for this is the possibility of
> selecting which pages get output by groff: the -o option does this.
> For instance, -o1,3,5,7,9 would output these odd-numbered pages,
> -o2,4,6,8 these even-numbered pages, etc. If anything, I would agree
> that an extension to this option which gave ALL odd, or ALL even
> pages without explicit listing, could be useful. However, this is already
> possible in psutils [psselect] so I don't see its necessity as pressing.
Some time ago I added a step extension to the -o option, the format
of the -o option with this extension is -o page_list[:step], that way you
could put -o 1-:2 to get all the odd pages in the document, and -o 2-:2 to
get all the even pages. Of course you can use any positive number for this
parameter, but 2 is the most useful one.
Since I'm not using the -Tps output device I can't use psutils to
accomplish the same result, that's why I added this extension.
Unfortunately I never modified the groff man page to reflect this
extension, not being a fluent english writer, documenting things is usually
harder than writing the code, and releasing this change was a low priority
task, I'm now too busy to devote any significant time to this. Maybe
somebody could add the necessary explanation to the man page if you find the
extension useful enough to be included in groff.
I've attached a patch with my changes to this message, feel free to
contact me if you have any problem with it.
Greetings
Paco
--
Saludos
-----------------------------------------------------------------------------
Paco Andrés Verdú address@hidden
Alicante (Spain)
--- groff-cvs/groff/src/roff/troff/input.cc Sun Jun 18 21:04:40 2000
+++ groff-current/src/roff/troff/input.cc Sat Mar 25 14:31:14 2000
@@ -5425,20 +5386,21 @@
class page_range {
int first;
int last;
+ int step;
public:
page_range *next;
- page_range(int, int, page_range *);
+ page_range(int, int, int, page_range *);
int contains(int n);
};
-page_range::page_range(int i, int j, page_range *p)
-: first(i), last(j), next(p)
+page_range::page_range(int i, int j, int s, page_range *p)
+: first(i), last(j), step(s), next(p)
{
}
int page_range::contains(int n)
{
- return n >= first && (last <= 0 || n <= last);
+ return n >= first && (last <= 0 || n <= last) && (((n-first)%step) == 0);
}
page_range *output_page_list = 0;
@@ -5453,37 +5415,57 @@
return 0;
}
+// Modifyed by Paco Andres <address@hidden> to add the step parameter,
+// reformatting and some comments
static void parse_output_page_list(char *p)
{
for (;;) {
- int i;
+ int i; // Start page
if (*p == '-')
- i = 1;
- else if (csdigit(*p)) {
- i = 0;
- do
- i = i*10 + *p++ - '0';
- while (csdigit(*p));
- }
+ i = 1; // start at 1 if only the ending page is specified
else
- break;
- int j;
+ if (csdigit(*p)) {
+ i = 0;
+ do
+ i = i*10 + (*p++ - '0');
+ while (csdigit(*p));
+ } // if (csdigit(*p))
+ else
+ break;
+
+ int j; // Ending page
if (*p == '-') {
p++;
j = 0;
if (csdigit(*p)) {
- do
- j = j*10 + *p++ - '0';
- while (csdigit(*p));
- }
- }
+ do
+ j = j*10 + ( *p++ - '0');
+ while (csdigit(*p));
+ } // if (csdigit(*p))
+ } // if (*p == '-')
else
j = i;
+
+
+ int step; // Stepping
+ if (*p == ':') {
+ p++;
+ step = 0;
+ if (csdigit(*p)) {
+ do
+ step = step*10 + (*p++ - '0');
+ while (csdigit(*p));
+ } // if (csdigit(*p))
+ } // if (*p == ':')
+ else
+ step = 1;
+ if (step == 0) step = 1;
+
if (j == 0)
last_page_number = -1;
else if (last_page_number >= 0 && j > last_page_number)
last_page_number = j;
- output_page_list = new page_range(i, j, output_page_list);
+ output_page_list = new page_range(i, j, step, output_page_list);
if (*p != ',')
break;
++p;