From 2e2c9047c3a8b5b6fdcdcd4585d5b114f31cd386 Mon Sep 17 00:00:00 2001 From: asmodai Date: Wed, 12 Jan 2000 09:51:43 +0000 Subject: Virgin import of FSF groff v1.15 --- contrib/groff/grolj4/grolj4.man | 12 +++++++++++- contrib/groff/grolj4/lj4.cc | 32 ++++++++++++++++++++++++++------ 2 files changed, 37 insertions(+), 7 deletions(-) (limited to 'contrib/groff/grolj4') diff --git a/contrib/groff/grolj4/grolj4.man b/contrib/groff/grolj4/grolj4.man index d4b3561..9a7c7fd 100644 --- a/contrib/groff/grolj4/grolj4.man +++ b/contrib/groff/grolj4/grolj4.man @@ -1,5 +1,5 @@ .ig \"-*- nroff -*- -Copyright (C) 1994, 1995 Free Software Foundation, Inc. +Copyright (C) 1994, 1995, 1999 Free Software Foundation, Inc. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice @@ -30,6 +30,10 @@ grolj4 \- groff driver for HP Laserjet 4 family [ .B \-lv ] [ +.B \-d +[\c +.IR n ] +] [ .BI \-c n ] [ .BI \-p paper_size @@ -68,6 +72,12 @@ copies of each page. .B \-l Print the document with a landscape orientation. .TP +.BI "\-d [" n ] +Use duplex mode +.IR n : +1\ is long-side binding; 2\ is short-side binding; +default is\ 1. +.TP .BI \-p size Set the paper size to .IR size , diff --git a/contrib/groff/grolj4/lj4.cc b/contrib/groff/grolj4/lj4.cc index 8856f75..002503a 100644 --- a/contrib/groff/grolj4/lj4.cc +++ b/contrib/groff/grolj4/lj4.cc @@ -23,8 +23,6 @@ TODO option to use beziers for circle/ellipse/arc option to use lines for spline (for LJ3) -duplex option -duplex short/long edge options left/top offset registration output bin selection option paper source option @@ -56,6 +54,7 @@ static struct { static int paper_size = -1; static int landscape_flag = 0; +static int duplex_flag = 0; // An upper limit on the paper size in centipoints, // used for setting HPGL picture frame. @@ -157,7 +156,7 @@ class lj4_printer : public printer { public: lj4_printer(); ~lj4_printer(); - void set_char(int, font *, const environment *, int); + void set_char(int, font *, const environment *, int, const char *name); void draw(int code, int *p, int np, const environment *env); void begin_page(int); void end_page(int page_length); @@ -233,6 +232,8 @@ lj4_printer::lj4_printer() else x_offset = paper_table[paper_size].x_offset_portrait; x_offset = (x_offset * font::res) / 300; + if (duplex_flag) + printf("\033&l%dS", duplex_flag); } lj4_printer::~lj4_printer() @@ -261,7 +262,7 @@ int is_unprintable(unsigned char c) return c < 32 && (c == 0 || (7 <= c && c <= 15) || c == 27); } -void lj4_printer::set_char(int index, font *f, const environment *env, int w) +void lj4_printer::set_char(int index, font *f, const environment *env, int w, const char *name) { int code = f->get_code(index); @@ -602,11 +603,29 @@ int main(int argc, char **argv) setbuf(stderr, stderr_buf); font::set_unknown_desc_command_handler(handle_unknown_desc_command); int c; - while ((c = getopt(argc, argv, "F:p:lvw:c:")) != EOF) + extern int optopt, optind; + while ((c = getopt(argc, argv, ":F:p:d:lvw:c:")) != EOF) switch(c) { case 'l': landscape_flag = 1; break; + case ':': + if (optopt == 'd') { + fprintf(stderr, "duplex assumed to be long-side\n"); + duplex_flag = 1; + } else + fprintf(stderr, "option -%c requires an operand\n", optopt); + fflush(stderr); + break; + case 'd': + if (!isdigit(*optarg)) // this ugly hack prevents -d without + optind--; // args from messing up the arg list + duplex_flag = atoi(optarg); + if (duplex_flag != 1 && duplex_flag != 2) { + fprintf(stderr, "odd value for duplex; assumed to be long-side\n"); + duplex_flag = 1; + } + break; case 'p': { int n = lookup_paper_size(optarg); @@ -669,7 +688,8 @@ int main(int argc, char **argv) static void usage() { fprintf(stderr, - "usage: %s [-lv] [-c n] [-p paper_size] [-w n] [-F dir] [files ...]\n", + "usage: %s [-lv] [-d [n]] [-c n] [-p paper_size]\n" + " [-w n] [-F dir] [files ...]\n", program_name); exit(1); } -- cgit v1.1