From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from krisdoz.my.domain (schwarze@localhost [127.0.0.1]) by krisdoz.my.domain (8.14.5/8.14.5) with ESMTP id s2ULS2jH023458 for ; Sun, 30 Mar 2014 17:28:02 -0400 (EDT) Received: (from schwarze@localhost) by krisdoz.my.domain (8.14.5/8.14.3/Submit) id s2ULS1uT013760; Sun, 30 Mar 2014 17:28:01 -0400 (EDT) Date: Sun, 30 Mar 2014 17:28:01 -0400 (EDT) Message-Id: <201403302128.s2ULS1uT013760@krisdoz.my.domain> X-Mailinglist: mdocml-source Reply-To: source@mdocml.bsd.lv MIME-Version: 1.0 From: schwarze@mdocml.bsd.lv To: source@mdocml.bsd.lv Subject: mdocml: Support relative arguments to .ll (increase or decrease line X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Log Message: ----------- Support relative arguments to .ll (increase or decrease line length). Modified Files: -------------- mdocml: man_term.c mdoc_term.c roff.7 term.c term.h term_ascii.c term_ps.c Revision Data ------------- Index: term.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/term.c,v retrieving revision 1.218 retrieving revision 1.219 diff -Lterm.c -Lterm.c -u -p -r1.218 -r1.219 --- term.c +++ term.c @@ -623,6 +623,36 @@ encode(struct termp *p, const char *word } } +void +term_setwidth(struct termp *p, const char *wstr) +{ + struct roffsu su; + size_t width; + int iop; + + if (NULL != wstr) { + switch (*wstr) { + case ('+'): + iop = 1; + wstr++; + break; + case ('-'): + iop = -1; + wstr++; + break; + default: + iop = 0; + break; + } + if ( ! a2roffsu(wstr, &su, SCALE_MAX)) { + wstr = NULL; + iop = 0; + } + } + width = (NULL != wstr) ? term_hspan(p, &su) : 0; + (*p->setwidth)(p, iop, width); +} + size_t term_len(const struct termp *p, size_t sz) { Index: term.h =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/term.h,v retrieving revision 1.98 retrieving revision 1.99 diff -Lterm.h -Lterm.h -u -p -r1.98 -r1.99 --- term.h +++ term.h @@ -95,7 +95,7 @@ struct termp { void (*end)(struct termp *); void (*endline)(struct termp *); void (*advance)(struct termp *, size_t); - void (*setwidth)(struct termp *, size_t); + void (*setwidth)(struct termp *, int, size_t); size_t (*width)(const struct termp *, int); double (*hspan)(const struct termp *, const struct roffsu *); @@ -114,7 +114,7 @@ void term_begin(struct termp *, term_ term_margin, const void *); void term_end(struct termp *); -void term_setwidth(struct termp *, size_t); +void term_setwidth(struct termp *, const char *); size_t term_hspan(const struct termp *, const struct roffsu *); size_t term_vspan(const struct termp *, Index: roff.7 =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/roff.7,v retrieving revision 1.50 retrieving revision 1.51 diff -Lroff.7 -Lroff.7 -u -p -r1.50 -r1.51 --- roff.7 +++ roff.7 @@ -878,12 +878,14 @@ request are discarded. Change the output line length. Its syntax is as follows: .Pp -.D1 Pf . Cm \&ll Op Ar width +.D1 Pf . Cm \&ll Op Oo +|- Oc Ns 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. +If a sign is given, the line length is added to or subtracted from; +otherwise, it is set to the provided value. Using this request in new manuals is discouraged for several reasons, among others because it overrides the .Xr mandoc 1 Index: man_term.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man_term.c,v retrieving revision 1.143 retrieving revision 1.144 diff -Lman_term.c -Lman_term.c -u -p -r1.143 -r1.144 --- man_term.c +++ man_term.c @@ -242,7 +242,7 @@ static int pre_ll(DECL_ARGS) { - (*p->setwidth)(p, n->nchild ? a2width(p, n->child->string) : 0); + term_setwidth(p, n->nchild ? n->child->string : NULL); return(0); } Index: term_ascii.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/term_ascii.c,v retrieving revision 1.23 retrieving revision 1.24 diff -Lterm_ascii.c -Lterm_ascii.c -u -p -r1.23 -r1.24 --- term_ascii.c +++ term_ascii.c @@ -58,7 +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); +static void ascii_setwidth(struct termp *, int, size_t); #ifdef USE_WCHAR static void locale_advance(struct termp *, size_t); @@ -161,14 +161,18 @@ locale_alloc(char *outopts) } static void -ascii_setwidth(struct termp *p, size_t width) +ascii_setwidth(struct termp *p, int iop, size_t width) { - size_t lastwidth; - lastwidth = p->defrmargin; - p->rmargin = p->maxrmargin = p->defrmargin = - width ? width : p->lastrmargin; - p->lastrmargin = lastwidth; + p->rmargin = p->defrmargin; + if (0 < iop) + p->defrmargin += width; + else if (0 > iop) + p->defrmargin -= width; + else + p->defrmargin = width ? width : p->lastrmargin; + p->lastrmargin = p->rmargin; + p->rmargin = p->maxrmargin = p->defrmargin; } /* ARGSUSED */ Index: mdoc_term.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_term.c,v retrieving revision 1.260 retrieving revision 1.261 diff -Lmdoc_term.c -Lmdoc_term.c -u -p -r1.260 -r1.261 --- mdoc_term.c +++ mdoc_term.c @@ -622,7 +622,7 @@ static int termp_ll_pre(DECL_ARGS) { - (*p->setwidth)(p, n->nchild ? a2width(p, n->child->string) : 0); + term_setwidth(p, n->nchild ? n->child->string : NULL); return(0); } Index: term_ps.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/term_ps.c,v retrieving revision 1.57 retrieving revision 1.58 diff -Lterm_ps.c -Lterm_ps.c -u -p -r1.57 -r1.58 --- term_ps.c +++ term_ps.c @@ -106,7 +106,7 @@ __attribute__((__format__ (__printf__, 2 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 void ps_setwidth(struct termp *, int, size_t); static struct termp *pspdf_alloc(char *); static void pdf_obj(struct termp *, size_t); @@ -536,12 +536,17 @@ pspdf_alloc(char *outopts) static void -ps_setwidth(struct termp *p, size_t width) +ps_setwidth(struct termp *p, int iop, size_t width) { size_t lastwidth; lastwidth = p->ps->width; - p->ps->width = width ? width : p->ps->lastwidth; + if (0 < iop) + p->ps->width += width; + else if (0 > iop) + p->ps->width -= width; + else + p->ps->width = width ? width : p->ps->lastwidth; p->ps->lastwidth = lastwidth; } -- To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv