* mdocml: Implement the roff(7) .ll (line length) request.
@ 2014-03-30 19:47 schwarze
0 siblings, 0 replies; only message in thread
From: schwarze @ 2014-03-30 19:47 UTC (permalink / raw)
To: source
Log Message:
-----------
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.
Modified Files:
--------------
mdocml:
TODO
man.c
man.h
man_html.c
man_macro.c
man_term.c
man_validate.c
mdoc.c
mdoc.h
mdoc_argv.c
mdoc_html.c
mdoc_macro.c
mdoc_man.c
mdoc_term.c
mdoc_validate.c
roff.7
term.h
term_ascii.c
term_ps.c
Revision Data
-------------
Index: term.h
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/term.h,v
retrieving revision 1.97
retrieving revision 1.98
diff -Lterm.h -Lterm.h -u -p -r1.97 -r1.98
--- term.h
+++ term.h
@@ -1,7 +1,7 @@
/* $Id$ */
/*
* 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_
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 *,
Index: roff.7
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/roff.7,v
retrieving revision 1.49
retrieving revision 1.50
diff -Lroff.7 -Lroff.7 -u -p -r1.49 -r1.50
--- roff.7
+++ roff.7
@@ -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.
Index: mdoc_man.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_man.c,v
retrieving revision 1.59
retrieving revision 1.60
diff -Lmdoc_man.c -Lmdoc_man.c -u -p -r1.59 -r1.60
--- mdoc_man.c
+++ mdoc_man.c
@@ -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_
{ 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 */
};
@@ -1403,6 +1405,14 @@ pre_lk(DECL_ARGS)
print_word(link->string);
font_pop();
return(0);
+}
+
+static int
+pre_ll(DECL_ARGS)
+{
+
+ print_line(".ll", 0);
+ return(1);
}
static int
Index: term_ascii.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/term_ascii.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -Lterm_ascii.c -Lterm_ascii.c -u -p -r1.22 -r1.23
--- term_ascii.c
+++ term_ascii.c
@@ -1,6 +1,7 @@
/* $Id$ */
/*
* 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 *outop
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 *outop
p->advance = ascii_advance;
p->endline = ascii_endline;
p->letter = ascii_letter;
+ p->setwidth = ascii_setwidth;
p->width = ascii_width;
#ifdef USE_WCHAR
@@ -155,6 +158,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 */
Index: term_ps.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/term_ps.c,v
retrieving revision 1.56
retrieving revision 1.57
diff -Lterm_ps.c -Lterm_ps.c -u -p -r1.56 -r1.57
--- term_ps.c
+++ term_ps.c
@@ -1,6 +1,7 @@
/* $Id$ */
/*
* 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
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;
@@ -528,6 +532,17 @@ pspdf_alloc(char *outopts)
p->defrmargin = pagex - (marginx * 2);
return(p);
+}
+
+
+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;
}
Index: mdoc_validate.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_validate.c,v
retrieving revision 1.205
retrieving revision 1.206
diff -Lmdoc_validate.c -Lmdoc_validate.c -u -p -r1.205 -r1.206
--- mdoc_validate.c
+++ mdoc_validate.c
@@ -304,6 +304,7 @@ static const struct valids mdoc_valids[M
{ NULL, posts_sp }, /* sp */
{ NULL, posts_text1 }, /* %U */
{ NULL, NULL }, /* Ta */
+ { NULL, NULL }, /* ll */
};
#define RSORD_MAX 14 /* Number of `Rs' blocks. */
Index: TODO
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/TODO,v
retrieving revision 1.167
retrieving revision 1.168
diff -LTODO -LTODO -u -p -r1.167 -r1.168
--- TODO
+++ TODO
@@ -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
Index: man.h
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man.h,v
retrieving revision 1.63
retrieving revision 1.64
diff -Lman.h -Lman.h -u -p -r1.63 -r1.64
--- man.h
+++ man.h
@@ -57,6 +57,7 @@ enum mant {
MAN_EE,
MAN_UR,
MAN_UE,
+ MAN_ll,
MAN_MAX
};
Index: mdoc.h
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc.h,v
retrieving revision 1.126
retrieving revision 1.127
diff -Lmdoc.h -Lmdoc.h -u -p -r1.126 -r1.127
--- mdoc.h
+++ mdoc.h
@@ -140,6 +140,7 @@ enum mdoct {
MDOC_sp,
MDOC__U,
MDOC_Ta,
+ MDOC_ll,
MDOC_MAX
};
Index: mdoc_argv.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_argv.c,v
retrieving revision 1.90
retrieving revision 1.91
diff -Lmdoc_argv.c -Lmdoc_argv.c -u -p -r1.90 -r1.91
--- mdoc_argv.c
+++ mdoc_argv.c
@@ -267,6 +267,7 @@ static const struct mdocarg mdocargs[MDO
{ ARGSFL_NONE, NULL }, /* sp */
{ ARGSFL_NONE, NULL }, /* %U */
{ ARGSFL_NONE, NULL }, /* Ta */
+ { ARGSFL_NONE, NULL }, /* ll */
};
Index: man_validate.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man_validate.c,v
retrieving revision 1.89
retrieving revision 1.90
diff -Lman_validate.c -Lman_validate.c -u -p -r1.89 -r1.90
--- man_validate.c
+++ man_validate.c
@@ -124,6 +124,7 @@ static const struct man_valid man_valids
{ NULL, posts_fi }, /* EE */
{ NULL, posts_ur }, /* UR */
{ NULL, NULL }, /* UE */
+ { NULL, NULL }, /* ll */
};
Index: man_html.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man_html.c,v
retrieving revision 1.91
retrieving revision 1.92
diff -Lman_html.c -Lman_html.c -u -p -r1.91 -r1.92
--- man_html.c
+++ man_html.c
@@ -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 */
};
/*
Index: mdoc_html.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_html.c,v
retrieving revision 1.186
retrieving revision 1.187
diff -Lmdoc_html.c -Lmdoc_html.c -u -p -r1.186 -r1.187
--- mdoc_html.c
+++ mdoc_html.c
@@ -1,6 +1,7 @@
/* $Id$ */
/*
* 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_
{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 */
Index: man.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man.c,v
retrieving revision 1.127
retrieving revision 1.128
diff -Lman.c -Lman.c -u -p -r1.127 -r1.128
--- man.c
+++ man.c
@@ -45,7 +45,7 @@ const char *const __man_macronames[MAN_M
"fi", "RE", "RS", "DT",
"UC", "PD", "AT", "in",
"ft", "OP", "EX", "EE",
- "UR", "UE"
+ "UR", "UE", "ll"
};
const char * const *man_macronames = __man_macronames;
Index: mdoc.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc.c,v
retrieving revision 1.211
retrieving revision 1.212
diff -Lmdoc.c -Lmdoc.c -u -p -r1.211 -r1.212
--- mdoc.c
+++ mdoc.c
@@ -72,7 +72,7 @@ const char *const __mdoc_macronames[MDOC
/* LINTED */
"Dx", "%Q", "br", "sp",
/* LINTED */
- "%U", "Ta"
+ "%U", "Ta", "ll",
};
const char *const __mdoc_argnames[MDOC_ARG_MAX] = {
Index: man_term.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man_term.c,v
retrieving revision 1.142
retrieving revision 1.143
diff -Lman_term.c -Lman_term.c -u -p -r1.142 -r1.143
--- man_term.c
+++ man_term.c
@@ -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
{ pre_literal, NULL, 0 }, /* EE */
{ pre_UR, post_UR, 0 }, /* UR */
{ NULL, NULL, 0 }, /* UE */
+ { pre_ll, NULL, MAN_NOTEXT }, /* ll */
};
@@ -231,6 +233,16 @@ static int
pre_ign(DECL_ARGS)
{
+ return(0);
+}
+
+
+/* ARGSUSED */
+static int
+pre_ll(DECL_ARGS)
+{
+
+ (*p->setwidth)(p, n->nchild ? a2width(p, n->child->string) : 0);
return(0);
}
Index: mdoc_macro.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_macro.c,v
retrieving revision 1.129
retrieving revision 1.130
diff -Lmdoc_macro.c -Lmdoc_macro.c -u -p -r1.129 -r1.130
--- mdoc_macro.c
+++ mdoc_macro.c
@@ -211,6 +211,7 @@ const struct mdoc_macro __mdoc_macros[MD
{ 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;
Index: mdoc_term.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_term.c,v
retrieving revision 1.259
retrieving revision 1.260
diff -Lmdoc_term.c -Lmdoc_term.c -u -p -r1.259 -r1.260
--- mdoc_term.c
+++ mdoc_term.c
@@ -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[MDO
{ 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;
+ }
}
@@ -610,6 +614,16 @@ print_bvspace(struct termp *p,
}
term_vspace(p);
+}
+
+
+/* ARGSUSED */
+static int
+termp_ll_pre(DECL_ARGS)
+{
+
+ (*p->setwidth)(p, n->nchild ? a2width(p, n->child->string) : 0);
+ return(0);
}
Index: man_macro.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man_macro.c,v
retrieving revision 1.80
retrieving revision 1.81
diff -Lman_macro.c -Lman_macro.c -u -p -r1.80 -r1.81
--- man_macro.c
+++ man_macro.c
@@ -91,6 +91,7 @@ const struct man_macro __man_macros[MAN_
{ 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;
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2014-03-30 19:47 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-30 19:47 mdocml: Implement the roff(7) .ll (line length) request schwarze
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).