aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-03-30 19:47:48 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-03-30 19:47:48 +0000
commitb1938d01834105572311aa9b06d667939309bee7 (patch)
tree9517f74166bc2092376ceb274bb4e8fdd03eb66c
parent08b72b8f1a54d84a06924f40ca973826190c215b (diff)
downloadmandoc-b1938d01834105572311aa9b06d667939309bee7.tar.gz
mandoc-b1938d01834105572311aa9b06d667939309bee7.tar.zst
mandoc-b1938d01834105572311aa9b06d667939309bee7.zip
Implement the roff(7) .ll (line length) request.
Found by naddy@ in the textproc/enchant(1) port. Of course, do not use this in new manuals.
-rw-r--r--TODO5
-rw-r--r--man.c4
-rw-r--r--man.h3
-rw-r--r--man_html.c3
-rw-r--r--man_macro.c3
-rw-r--r--man_term.c14
-rw-r--r--man_validate.c3
-rw-r--r--mdoc.c4
-rw-r--r--mdoc.h3
-rw-r--r--mdoc_argv.c3
-rw-r--r--mdoc_html.c14
-rw-r--r--mdoc_macro.c3
-rw-r--r--mdoc_man.c12
-rw-r--r--mdoc_term.c20
-rw-r--r--mdoc_validate.c3
-rw-r--r--roff.719
-rw-r--r--term.h7
-rw-r--r--term_ascii.c18
-rw-r--r--term_ps.c19
19 files changed, 129 insertions, 31 deletions
diff --git a/TODO b/TODO
index c9f1bbc5..e619f272 100644
--- a/TODO
+++ b/TODO
@@ -1,6 +1,6 @@
************************************************************************
* Official mandoc TODO.
-* $Id: TODO,v 1.167 2014/03/08 21:54:39 schwarze Exp $
+* $Id: TODO,v 1.168 2014/03/30 19:47:48 schwarze Exp $
************************************************************************
************************************************************************
@@ -27,9 +27,6 @@ None known.
- .fc (field control)
found by naddy@ in xloadimage(1)
-- .ll (line length)
- found by naddy@ in textproc/enchant(1) Sat, 12 Oct 2013 03:27:10 +0200
-
- .nr third argument (auto-increment step size, requires \n+)
found by bentley@ in sbcl(1) Mon, 9 Dec 2013 18:36:57 -0700
diff --git a/man.c b/man.c
index 30e1ed1b..f87a2ac0 100644
--- a/man.c
+++ b/man.c
@@ -1,4 +1,4 @@
-/* $Id: man.c,v 1.127 2014/03/23 20:57:27 schwarze Exp $ */
+/* $Id: man.c,v 1.128 2014/03/30 19:47:48 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -45,7 +45,7 @@ const char *const __man_macronames[MAN_MAX] = {
"fi", "RE", "RS", "DT",
"UC", "PD", "AT", "in",
"ft", "OP", "EX", "EE",
- "UR", "UE"
+ "UR", "UE", "ll"
};
const char * const *man_macronames = __man_macronames;
diff --git a/man.h b/man.h
index fb280bc3..26c2747b 100644
--- a/man.h
+++ b/man.h
@@ -1,4 +1,4 @@
-/* $Id: man.h,v 1.63 2014/03/23 12:26:58 schwarze Exp $ */
+/* $Id: man.h,v 1.64 2014/03/30 19:47:48 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -57,6 +57,7 @@ enum mant {
MAN_EE,
MAN_UR,
MAN_UE,
+ MAN_ll,
MAN_MAX
};
diff --git a/man_html.c b/man_html.c
index 4deb1cb3..9cd9b286 100644
--- a/man_html.c
+++ b/man_html.c
@@ -1,4 +1,4 @@
-/* $Id: man_html.c,v 1.91 2014/03/08 15:50:41 schwarze Exp $ */
+/* $Id: man_html.c,v 1.92 2014/03/30 19:47:48 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -119,6 +119,7 @@ static const struct htmlman mans[MAN_MAX] = {
{ man_literal_pre, NULL }, /* EE */
{ man_UR_pre, NULL }, /* UR */
{ NULL, NULL }, /* UE */
+ { man_ign_pre, NULL }, /* ll */
};
/*
diff --git a/man_macro.c b/man_macro.c
index 782f8322..aa1dd2c8 100644
--- a/man_macro.c
+++ b/man_macro.c
@@ -1,4 +1,4 @@
-/* $Id: man_macro.c,v 1.80 2013/12/31 23:23:10 schwarze Exp $ */
+/* $Id: man_macro.c,v 1.81 2014/03/30 19:47:48 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2012, 2013 Ingo Schwarze <schwarze@openbsd.org>
@@ -91,6 +91,7 @@ const struct man_macro __man_macros[MAN_MAX] = {
{ in_line_eoln, MAN_BSCOPE }, /* EE */
{ blk_exp, MAN_BSCOPE | MAN_EXPLICIT }, /* UR */
{ blk_close, 0 }, /* UE */
+ { in_line_eoln, 0 }, /* ll */
};
const struct man_macro * const man_macros = __man_macros;
diff --git a/man_term.c b/man_term.c
index 4e894e79..a548c154 100644
--- a/man_term.c
+++ b/man_term.c
@@ -1,4 +1,4 @@
-/* $Id: man_term.c,v 1.142 2014/03/08 16:22:04 schwarze Exp $ */
+/* $Id: man_term.c,v 1.143 2014/03/30 19:47:48 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -84,6 +84,7 @@ static int pre_ft(DECL_ARGS);
static int pre_ign(DECL_ARGS);
static int pre_in(DECL_ARGS);
static int pre_literal(DECL_ARGS);
+static int pre_ll(DECL_ARGS);
static int pre_sp(DECL_ARGS);
static void post_IP(DECL_ARGS);
@@ -133,6 +134,7 @@ static const struct termact termacts[MAN_MAX] = {
{ pre_literal, NULL, 0 }, /* EE */
{ pre_UR, post_UR, 0 }, /* UR */
{ NULL, NULL, 0 }, /* UE */
+ { pre_ll, NULL, MAN_NOTEXT }, /* ll */
};
@@ -237,6 +239,16 @@ pre_ign(DECL_ARGS)
/* ARGSUSED */
static int
+pre_ll(DECL_ARGS)
+{
+
+ (*p->setwidth)(p, n->nchild ? a2width(p, n->child->string) : 0);
+ return(0);
+}
+
+
+/* ARGSUSED */
+static int
pre_I(DECL_ARGS)
{
diff --git a/man_validate.c b/man_validate.c
index 647dbcca..2f433661 100644
--- a/man_validate.c
+++ b/man_validate.c
@@ -1,4 +1,4 @@
-/* $Id: man_validate.c,v 1.89 2014/03/23 11:25:26 schwarze Exp $ */
+/* $Id: man_validate.c,v 1.90 2014/03/30 19:47:48 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -124,6 +124,7 @@ static const struct man_valid man_valids[MAN_MAX] = {
{ NULL, posts_fi }, /* EE */
{ NULL, posts_ur }, /* UR */
{ NULL, NULL }, /* UE */
+ { NULL, NULL }, /* ll */
};
diff --git a/mdoc.c b/mdoc.c
index 4be40838..b46225af 100644
--- a/mdoc.c
+++ b/mdoc.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc.c,v 1.211 2014/03/23 12:44:56 schwarze Exp $ */
+/* $Id: mdoc.c,v 1.212 2014/03/30 19:47:48 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -72,7 +72,7 @@ const char *const __mdoc_macronames[MDOC_MAX] = {
/* LINTED */
"Dx", "%Q", "br", "sp",
/* LINTED */
- "%U", "Ta"
+ "%U", "Ta", "ll",
};
const char *const __mdoc_argnames[MDOC_ARG_MAX] = {
diff --git a/mdoc.h b/mdoc.h
index 5a615151..ac8bed8d 100644
--- a/mdoc.h
+++ b/mdoc.h
@@ -1,4 +1,4 @@
-/* $Id: mdoc.h,v 1.126 2014/03/23 12:44:56 schwarze Exp $ */
+/* $Id: mdoc.h,v 1.127 2014/03/30 19:47:48 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -140,6 +140,7 @@ enum mdoct {
MDOC_sp,
MDOC__U,
MDOC_Ta,
+ MDOC_ll,
MDOC_MAX
};
diff --git a/mdoc_argv.c b/mdoc_argv.c
index 3bb07f55..92e9ae70 100644
--- a/mdoc_argv.c
+++ b/mdoc_argv.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_argv.c,v 1.90 2014/03/23 11:25:26 schwarze Exp $ */
+/* $Id: mdoc_argv.c,v 1.91 2014/03/30 19:47:48 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2012 Ingo Schwarze <schwarze@openbsd.org>
@@ -267,6 +267,7 @@ static const struct mdocarg mdocargs[MDOC_MAX] = {
{ ARGSFL_NONE, NULL }, /* sp */
{ ARGSFL_NONE, NULL }, /* %U */
{ ARGSFL_NONE, NULL }, /* Ta */
+ { ARGSFL_NONE, NULL }, /* ll */
};
diff --git a/mdoc_html.c b/mdoc_html.c
index a7aa722d..99eed7d4 100644
--- a/mdoc_html.c
+++ b/mdoc_html.c
@@ -1,6 +1,7 @@
-/* $Id: mdoc_html.c,v 1.186 2013/12/24 20:45:27 schwarze Exp $ */
+/* $Id: mdoc_html.c,v 1.187 2014/03/30 19:47:48 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
+ * Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -95,6 +96,7 @@ static int mdoc_it_pre(MDOC_ARGS);
static int mdoc_lb_pre(MDOC_ARGS);
static int mdoc_li_pre(MDOC_ARGS);
static int mdoc_lk_pre(MDOC_ARGS);
+static int mdoc_ll_pre(MDOC_ARGS);
static int mdoc_mt_pre(MDOC_ARGS);
static int mdoc_ms_pre(MDOC_ARGS);
static int mdoc_nd_pre(MDOC_ARGS);
@@ -242,6 +244,7 @@ static const struct htmlmdoc mdocs[MDOC_MAX] = {
{mdoc_sp_pre, NULL}, /* sp */
{mdoc__x_pre, mdoc__x_post}, /* %U */
{NULL, NULL}, /* Ta */
+ {mdoc_ll_pre, NULL}, /* ll */
};
static const char * const lists[LIST_MAX] = {
@@ -1599,12 +1602,19 @@ mdoc_sm_pre(MDOC_ARGS)
/* ARGSUSED */
static int
+mdoc_ll_pre(MDOC_ARGS)
+{
+
+ return(0);
+}
+
+/* ARGSUSED */
+static int
mdoc_pp_pre(MDOC_ARGS)
{
print_otag(h, TAG_P, 0, NULL);
return(0);
-
}
/* ARGSUSED */
diff --git a/mdoc_macro.c b/mdoc_macro.c
index 09c111d1..a9c3f063 100644
--- a/mdoc_macro.c
+++ b/mdoc_macro.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_macro.c,v 1.129 2014/01/21 10:26:53 schwarze Exp $ */
+/* $Id: mdoc_macro.c,v 1.130 2014/03/30 19:47:48 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012, 2013 Ingo Schwarze <schwarze@openbsd.org>
@@ -211,6 +211,7 @@ const struct mdoc_macro __mdoc_macros[MDOC_MAX] = {
{ in_line_eoln, 0 }, /* sp */
{ in_line_eoln, 0 }, /* %U */
{ phrase_ta, MDOC_CALLABLE | MDOC_PARSED | MDOC_JOIN }, /* Ta */
+ { in_line_eoln, 0 }, /* ll */
};
const struct mdoc_macro * const mdoc_macros = __mdoc_macros;
diff --git a/mdoc_man.c b/mdoc_man.c
index e4db5aed..a953e755 100644
--- a/mdoc_man.c
+++ b/mdoc_man.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_man.c,v 1.59 2014/03/23 11:25:26 schwarze Exp $ */
+/* $Id: mdoc_man.c,v 1.60 2014/03/30 19:47:48 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
*
@@ -90,6 +90,7 @@ static int pre_in(DECL_ARGS);
static int pre_it(DECL_ARGS);
static int pre_lk(DECL_ARGS);
static int pre_li(DECL_ARGS);
+static int pre_ll(DECL_ARGS);
static int pre_nm(DECL_ARGS);
static int pre_no(DECL_ARGS);
static int pre_ns(DECL_ARGS);
@@ -241,6 +242,7 @@ static const struct manact manacts[MDOC_MAX + 1] = {
{ NULL, pre_sp, post_sp, NULL, NULL }, /* sp */
{ NULL, NULL, post_percent, NULL, NULL }, /* %U */
{ NULL, NULL, NULL, NULL, NULL }, /* Ta */
+ { NULL, pre_ll, post_sp, NULL, NULL }, /* ll */
{ NULL, NULL, NULL, NULL, NULL }, /* ROOT */
};
@@ -1406,6 +1408,14 @@ pre_lk(DECL_ARGS)
}
static int
+pre_ll(DECL_ARGS)
+{
+
+ print_line(".ll", 0);
+ return(1);
+}
+
+static int
pre_li(DECL_ARGS)
{
diff --git a/mdoc_term.c b/mdoc_term.c
index b27dc4ae..5e1a10e8 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_term.c,v 1.259 2014/02/16 12:33:39 schwarze Exp $ */
+/* $Id: mdoc_term.c,v 1.260 2014/03/30 19:47:48 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -104,6 +104,7 @@ static int termp_ft_pre(DECL_ARGS);
static int termp_in_pre(DECL_ARGS);
static int termp_it_pre(DECL_ARGS);
static int termp_li_pre(DECL_ARGS);
+static int termp_ll_pre(DECL_ARGS);
static int termp_lk_pre(DECL_ARGS);
static int termp_nd_pre(DECL_ARGS);
static int termp_nm_pre(DECL_ARGS);
@@ -244,6 +245,7 @@ static const struct termact termacts[MDOC_MAX] = {
{ termp_sp_pre, NULL }, /* sp */
{ NULL, termp____post }, /* %U */
{ NULL, NULL }, /* Ta */
+ { termp_ll_pre, NULL }, /* ll */
};
@@ -384,8 +386,10 @@ print_mdoc_node(DECL_ARGS)
if (MDOC_EOS & n->flags)
p->flags |= TERMP_SENTENCE;
- p->offset = offset;
- p->rmargin = rmargin;
+ if (MDOC_ll != n->tok) {
+ p->offset = offset;
+ p->rmargin = rmargin;
+ }
}
@@ -615,6 +619,16 @@ print_bvspace(struct termp *p,
/* ARGSUSED */
static int
+termp_ll_pre(DECL_ARGS)
+{
+
+ (*p->setwidth)(p, n->nchild ? a2width(p, n->child->string) : 0);
+ return(0);
+}
+
+
+/* ARGSUSED */
+static int
termp_it_pre(DECL_ARGS)
{
const struct mdoc_node *bl, *nn;
diff --git a/mdoc_validate.c b/mdoc_validate.c
index 8449bd67..42187700 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_validate.c,v 1.205 2014/03/23 15:14:50 schwarze Exp $ */
+/* $Id: mdoc_validate.c,v 1.206 2014/03/30 19:47:48 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -304,6 +304,7 @@ static const struct valids mdoc_valids[MDOC_MAX] = {
{ NULL, posts_sp }, /* sp */
{ NULL, posts_text1 }, /* %U */
{ NULL, NULL }, /* Ta */
+ { NULL, NULL }, /* ll */
};
#define RSORD_MAX 14 /* Number of `Rs' blocks. */
diff --git a/roff.7 b/roff.7
index 49ad11ee..bc505c81 100644
--- a/roff.7
+++ b/roff.7
@@ -1,4 +1,4 @@
-.\" $Id: roff.7,v 1.49 2014/03/17 06:57:48 schwarze Exp $
+.\" $Id: roff.7,v 1.50 2014/03/30 19:47:48 schwarze Exp $
.\"
.\" Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
.\" Copyright (c) 2010, 2011, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -15,7 +15,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: March 17 2014 $
+.Dd $Mdocdate: March 30 2014 $
.Dt ROFF 7
.Os
.Sh NAME
@@ -874,6 +874,21 @@ Otherwise, it only terminates the
and arguments following it or the
.Sq \&..
request are discarded.
+.Ss \&ll
+Change the output line length.
+Its syntax is as follows:
+.Pp
+.D1 Pf . Cm \&ll Op Ar width
+.Pp
+If the
+.Ar width
+argument is omitted, the line length is reset to its previous value.
+The default setting for terminal output is 78n.
+Using this request in new manuals is discouraged for several reasons,
+among others because it overrides the
+.Xr mandoc 1
+.Fl O Cm width
+command line option.
.Ss \&ne
Declare the need for the specified minimum vertical space
before the next trap or the bottom of the page.
diff --git a/term.h b/term.h
index 8cad4be8..b19ee411 100644
--- a/term.h
+++ b/term.h
@@ -1,7 +1,7 @@
-/* $Id: term.h,v 1.97 2013/12/25 00:39:31 schwarze Exp $ */
+/* $Id: term.h,v 1.98 2014/03/30 19:47:48 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2011, 2012, 2013 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -57,6 +57,7 @@ struct termp {
int mdocstyle; /* imitate mdoc(7) output */
size_t defindent; /* Default indent for text. */
size_t defrmargin; /* Right margin of the device. */
+ size_t lastrmargin; /* Right margin before the last ll. */
size_t rmargin; /* Current right margin. */
size_t maxrmargin; /* Max right margin. */
size_t maxcols; /* Max size of buf. */
@@ -94,6 +95,7 @@ struct termp {
void (*end)(struct termp *);
void (*endline)(struct termp *);
void (*advance)(struct termp *, size_t);
+ void (*setwidth)(struct termp *, size_t);
size_t (*width)(const struct termp *, int);
double (*hspan)(const struct termp *,
const struct roffsu *);
@@ -112,6 +114,7 @@ void term_begin(struct termp *, term_margin,
term_margin, const void *);
void term_end(struct termp *);
+void term_setwidth(struct termp *, size_t);
size_t term_hspan(const struct termp *,
const struct roffsu *);
size_t term_vspan(const struct termp *,
diff --git a/term_ascii.c b/term_ascii.c
index d6531167..09f052c3 100644
--- a/term_ascii.c
+++ b/term_ascii.c
@@ -1,6 +1,7 @@
-/* $Id: term_ascii.c,v 1.22 2014/03/23 11:25:26 schwarze Exp $ */
+/* $Id: term_ascii.c,v 1.23 2014/03/30 19:47:48 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
+ * Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -57,6 +58,7 @@ static void ascii_begin(struct termp *);
static void ascii_end(struct termp *);
static void ascii_endline(struct termp *);
static void ascii_letter(struct termp *, int);
+static void ascii_setwidth(struct termp *, size_t);
#ifdef USE_WCHAR
static void locale_advance(struct termp *, size_t);
@@ -75,7 +77,7 @@ ascii_init(enum termenc enc, char *outopts)
p = mandoc_calloc(1, sizeof(struct termp));
p->tabwidth = 5;
- p->defrmargin = 78;
+ p->defrmargin = p->lastrmargin = 78;
p->begin = ascii_begin;
p->end = ascii_end;
@@ -86,6 +88,7 @@ ascii_init(enum termenc enc, char *outopts)
p->advance = ascii_advance;
p->endline = ascii_endline;
p->letter = ascii_letter;
+ p->setwidth = ascii_setwidth;
p->width = ascii_width;
#ifdef USE_WCHAR
@@ -157,6 +160,17 @@ locale_alloc(char *outopts)
return(ascii_init(TERMENC_LOCALE, outopts));
}
+static void
+ascii_setwidth(struct termp *p, size_t width)
+{
+ size_t lastwidth;
+
+ lastwidth = p->defrmargin;
+ p->rmargin = p->maxrmargin = p->defrmargin =
+ width ? width : p->lastrmargin;
+ p->lastrmargin = lastwidth;
+}
+
/* ARGSUSED */
static size_t
ascii_width(const struct termp *p, int c)
diff --git a/term_ps.c b/term_ps.c
index c8010591..9e0743a0 100644
--- a/term_ps.c
+++ b/term_ps.c
@@ -1,6 +1,7 @@
-/* $Id: term_ps.c,v 1.56 2014/03/23 11:25:26 schwarze Exp $ */
+/* $Id: term_ps.c,v 1.57 2014/03/30 19:47:48 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
+ * Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -75,6 +76,7 @@ struct termp_ps {
size_t bottom; /* body bottom (AFM units) */
size_t height; /* page height (AFM units */
size_t width; /* page width (AFM units) */
+ size_t lastwidth; /* page width before last ll */
size_t left; /* body left (AFM units) */
size_t header; /* header pos (AFM units) */
size_t footer; /* footer pos (AFM units) */
@@ -104,6 +106,7 @@ __attribute__((__format__ (__printf__, 2, 3)))
static void ps_printf(struct termp *, const char *, ...);
static void ps_putchar(struct termp *, char);
static void ps_setfont(struct termp *, enum termfont);
+static void ps_setwidth(struct termp *, size_t);
static struct termp *pspdf_alloc(char *);
static void pdf_obj(struct termp *, size_t);
@@ -449,6 +452,7 @@ pspdf_alloc(char *outopts)
p->endline = ps_endline;
p->hspan = ps_hspan;
p->letter = ps_letter;
+ p->setwidth = ps_setwidth;
p->width = ps_width;
toks[0] = "paper";
@@ -517,7 +521,7 @@ pspdf_alloc(char *outopts)
lineheight = PNT2AFM(p, ((double)p->ps->scale * 1.4));
- p->ps->width = (size_t)pagex;
+ p->ps->width = p->ps->lastwidth = (size_t)pagex;
p->ps->height = (size_t)pagey;
p->ps->header = pagey - (marginy / 2) - (lineheight / 2);
p->ps->top = pagey - marginy;
@@ -531,6 +535,17 @@ pspdf_alloc(char *outopts)
}
+static void
+ps_setwidth(struct termp *p, size_t width)
+{
+ size_t lastwidth;
+
+ lastwidth = p->ps->width;
+ p->ps->width = width ? width : p->ps->lastwidth;
+ p->ps->lastwidth = lastwidth;
+}
+
+
void
pspdf_free(void *arg)
{