[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
grops(1) feature request
From: |
Ruslan Ermilov |
Subject: |
grops(1) feature request |
Date: |
Wed, 13 Dec 2000 16:53:51 +0200 |
User-agent: |
Mutt/1.2.5i |
GROFF VERSION:
1.16.1
MACHINE:
i386
OS:
FreeBSD 4.2-STABLE
COMPILER:
gcc version 2.95.2 19991024 (release)
INPUT FILES:
COMMAND LINE:
echo | groff -Tps > 1.ps
echo | groff -Tps -P-pa4 > 2.ps
diff 1.ps 2.ps
DESCRIPTION OF INCORRECT BEHAVIOUR:
grops(1) does not allow run-time configuration of page length as
grolj4(1) and grolbp(1) do. It also does not provide -p option.
Ideally, all these postprocessors should have the ability to set
paper size from the system-wide file, e.g. /etc/papersize.
Currently, only grolbp(1) allows this.
SUGGESTED FIX:
Index: ps.cc
===================================================================
RCS file: /home/ncvs/src/contrib/groff/grops/ps.cc,v
retrieving revision 1.1.1.3
diff -p -c -r1.1.1.3 ps.cc
*** ps.cc 2000/12/05 18:49:34 1.1.1.3
--- ps.cc 2000/12/13 14:44:26
*************** static int guess_flag = 0;
*** 38,43 ****
--- 38,52 ----
static int bflag = 0;
unsigned broken_flags = 0;
+ static struct {
+ const char *name;
+ int size;
+ } paper_table[] = {
+ { "letter", 792000 },
+ { "A4", 841890 },
+ };
+ static int paper_length = -1;
+
#define DEFAULT_LINEWIDTH 40 /* in ems/1000 */
#define MAX_LINE_LENGTH 72
#define FILL_MAX 1000
*************** void ps_font::handle_unknown_font_comman
*** 404,409 ****
--- 413,427 ----
}
}
+ static
+ int lookup_paper_length(const char *s)
+ {
+ for (int i = 0; i < sizeof(paper_table)/sizeof(paper_table[0]); i++) {
+ if (strcasecmp(s, paper_table[i].name) == 0)
+ return paper_table[i].size;
+ }
+ return -1;
+ }
static void handle_unknown_desc_command(const char *command, const char *arg,
const char *filename, int lineno)
{
*************** static void handle_unknown_desc_command(
*** 414,419 ****
--- 432,450 ----
else if (!bflag)
broken_flags = atoi(arg);
}
+ else if (strcmp(command, "papersize") == 0) {
+ if (arg == 0)
+ error_with_file_and_line(filename, lineno,
+ "`papersize' command requires an argument");
+ else if (paper_length < 0) {
+ int n = lookup_paper_length(arg);
+ if (n < 0)
+ error_with_file_and_line(filename, lineno,
+ "unknown paper size `%1'", arg);
+ else
+ paper_length = n;
+ }
+ }
}
struct style {
*************** class ps_printer : public printer {
*** 453,459 ****
int res;
int space_char_index;
int pages_output;
- int paper_length;
int equalise_spaces;
enum { SBUF_SIZE = 256 };
char sbuf[SBUF_SIZE];
--- 484,489 ----
*************** ps_printer::ps_printer()
*** 544,550 ****
res = r;
out.set_fixed_point(point);
space_char_index = font::name_to_index("space");
! paper_length = font::paperlength;
if (paper_length == 0)
paper_length = 11*font::res;
equalise_spaces = font::res >= 72000;
--- 574,581 ----
res = r;
out.set_fixed_point(point);
space_char_index = font::name_to_index("space");
! if (paper_length < 0)
! paper_length = font::paperlength;
if (paper_length == 0)
paper_length = 11*font::res;
equalise_spaces = font::res >= 72000;
*************** int main(int argc, char **argv)
*** 1475,1481 ****
static char stderr_buf[BUFSIZ];
setbuf(stderr, stderr_buf);
int c;
! while ((c = getopt(argc, argv, "F:glmc:w:vb:")) != EOF)
switch(c) {
case 'v':
{
--- 1506,1512 ----
static char stderr_buf[BUFSIZ];
setbuf(stderr, stderr_buf);
int c;
! while ((c = getopt(argc, argv, "F:glmc:p:w:vb:")) != EOF)
switch(c) {
case 'v':
{
*************** int main(int argc, char **argv)
*** 1499,1504 ****
--- 1530,1544 ----
case 'm':
manual_feed_flag = 1;
break;
+ case 'p':
+ {
+ int n = lookup_paper_length(optarg);
+ if (n < 0)
+ error("unknown paper size `%1'", optarg);
+ else
+ paper_length = n;
+ break;
+ }
case 'F':
font::command_line_font_dir(optarg);
break;
--
Ruslan Ermilov Oracle Developer/DBA,
address@hidden Sunbay Software AG,
address@hidden FreeBSD committer,
+380.652.512.251 Simferopol, Ukraine
http://www.FreeBSD.org The Power To Serve
http://www.oracle.com Enabling The Information Age
- grops(1) feature request,
Ruslan Ermilov <=