* mdocml: improve rounding rules for scaling units in horizontal
@ 2017-06-14 17:51 schwarze
0 siblings, 0 replies; only message in thread
From: schwarze @ 2017-06-14 17:51 UTC (permalink / raw)
To: source
Log Message:
-----------
improve rounding rules for scaling units
in horizontal orientation in the terminal formatter
Modified Files:
--------------
mdocml:
man_term.c
mdoc_term.c
roff_term.c
tbl_term.c
term.c
term.h
term_tab.c
mdocml/regress/man/HP:
spacing.in
mdocml/regress/man/IP:
width.in
mdocml/regress/man/RS:
width.in
mdocml/regress/man/TP:
width.in
mdocml/regress/mdoc/Bd:
offset-neg.in
mdocml/regress/mdoc/Bl:
offset.in
offset.out_ascii
offset.out_markdown
tag.in
mdocml/regress/roff/esc:
h.in
h.out_ascii
h.out_lint
mdocml/regress/roff/ta:
basic-man.in
basic-man.out_ascii
mdocml/regress/roff/ti:
basic-man.in
mdocml/regress/tbl/mod:
width.in
Revision Data
-------------
Index: basic-man.in
===================================================================
RCS file: /home/cvs/mdocml/mdocml/regress/roff/ta/basic-man.in,v
retrieving revision 1.1
retrieving revision 1.2
diff -Lregress/roff/ta/basic-man.in -Lregress/roff/ta/basic-man.in -u -p -r1.1 -r1.2
--- regress/roff/ta/basic-man.in
+++ regress/roff/ta/basic-man.in
@@ -17,3 +17,6 @@ none:
default unit:
.ta 3 +4 12
1 2 3 4
+rounding:
+.ta 0.26i T 1c
+1 2 3 4 5 6 7 8 9
Index: basic-man.out_ascii
===================================================================
RCS file: /home/cvs/mdocml/mdocml/regress/roff/ta/basic-man.out_ascii,v
retrieving revision 1.1
retrieving revision 1.2
diff -Lregress/roff/ta/basic-man.out_ascii -Lregress/roff/ta/basic-man.out_ascii -u -p -r1.1 -r1.2
--- regress/roff/ta/basic-man.out_ascii
+++ regress/roff/ta/basic-man.out_ascii
@@ -16,6 +16,8 @@ D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
1 2 3 4 5 6 7 8 9
default unit:
1 2 3 4
+ rounding:
+ 1 2 3 4 5 6 7 8 9
Index: basic-man.in
===================================================================
RCS file: /home/cvs/mdocml/mdocml/regress/roff/ti/basic-man.in,v
retrieving revision 1.1
retrieving revision 1.2
diff -Lregress/roff/ti/basic-man.in -Lregress/roff/ti/basic-man.in -u -p -r1.1 -r1.2
--- regress/roff/ti/basic-man.in
+++ regress/roff/ti/basic-man.in
@@ -3,14 +3,14 @@
ti-basic-man \- temporary indentation in man(7)
.SH DESCRIPTION
initial text
-.ti 10n
+.ti 0.96i
This text is indented.
However, the indent is temporary,
so as soon as the line wraps, it is gone.
.ti +10n
The temporary indent can be relative.
All the same, it will expire in the usual way.
-.ti -3n
+.ti -0.26i
It is also possible to temporarily reduce the indentation,
but that will also last until the next line break only.
.ti -10n
Index: width.in
===================================================================
RCS file: /home/cvs/mdocml/mdocml/regress/man/RS/width.in,v
retrieving revision 1.1
retrieving revision 1.2
diff -Lregress/man/RS/width.in -Lregress/man/RS/width.in -u -p -r1.1 -r1.2
--- regress/man/RS/width.in
+++ regress/man/RS/width.in
@@ -10,13 +10,13 @@ text
.RE
regular
text
-.RS -4n
+.RS -0.36i
indented
text
.RE
regular
text
-.RS 4n
+.RS 0.36i
indented
text
.RE
Index: width.in
===================================================================
RCS file: /home/cvs/mdocml/mdocml/regress/man/TP/width.in,v
retrieving revision 1.1
retrieving revision 1.2
diff -Lregress/man/TP/width.in -Lregress/man/TP/width.in -u -p -r1.1 -r1.2
--- regress/man/TP/width.in
+++ regress/man/TP/width.in
@@ -8,7 +8,7 @@ tag
indented
.br
text
-.TP -4n
+.TP -0.36i
tag
indented
.br
@@ -23,7 +23,7 @@ tag
indented
.br
text
-.TP 2n
+.TP 0.16i
tag
indented
.br
@@ -51,7 +51,7 @@ text
.PP
Literal mode:
.nf
-.TP -10n
+.TP -0.96i
tag
indented
text
@@ -71,7 +71,7 @@ text
tag
indented
text
-.TP 3n
+.TP 0.26i
tag
indented
text
Index: offset-neg.in
===================================================================
RCS file: /home/cvs/mdocml/mdocml/regress/mdoc/Bd/offset-neg.in,v
retrieving revision 1.1
retrieving revision 1.2
diff -Lregress/mdoc/Bd/offset-neg.in -Lregress/mdoc/Bd/offset-neg.in -u -p -r1.1 -r1.2
--- regress/mdoc/Bd/offset-neg.in
+++ regress/mdoc/Bd/offset-neg.in
@@ -6,9 +6,9 @@
.Nd indenting display blocks
.Sh DESCRIPTION
regular text
-.Bd -ragged -offset 8n
+.Bd -ragged -offset 0.76i
outer display
-.Bd -ragged -offset -5n
+.Bd -ragged -offset -0.46i
inner display
.Ed
outer display
Index: offset.out_markdown
===================================================================
RCS file: /home/cvs/mdocml/mdocml/regress/mdoc/Bl/offset.out_markdown,v
retrieving revision 1.1
retrieving revision 1.2
diff -Lregress/mdoc/Bl/offset.out_markdown -Lregress/mdoc/Bl/offset.out_markdown -u -p -r1.1 -r1.2
--- regress/mdoc/Bl/offset.out_markdown
+++ regress/mdoc/Bl/offset.out_markdown
@@ -42,7 +42,7 @@ tag
tag
-> Bl tag width Ds offset 4n
+> Bl tag width Ds offset 0.36i
tag
@@ -58,6 +58,6 @@ tag
tag
-> Bl tag width Ds offset -3n
+> Bl tag width Ds offset -0.26i
OpenBSD - December 25, 2014
Index: offset.in
===================================================================
RCS file: /home/cvs/mdocml/mdocml/regress/mdoc/Bl/offset.in,v
retrieving revision 1.1
retrieving revision 1.2
diff -Lregress/mdoc/Bl/offset.in -Lregress/mdoc/Bl/offset.in -u -p -r1.1 -r1.2
--- regress/mdoc/Bl/offset.in
+++ regress/mdoc/Bl/offset.in
@@ -57,9 +57,9 @@ Bl tag width Ds offset indent
.It tag
Bl tag width Ds offset indent-two
.El
-.Bl -tag -width Ds -offset 4n
+.Bl -tag -width Ds -offset 0.36i
.It tag
-Bl tag width Ds offset 4n
+Bl tag width Ds offset 0.36i
.El
.Bl -tag -width Ds -offset mystring
.It tag
@@ -73,7 +73,7 @@ Bl tag width Ds offset Ds
.It tag
Bl tag width Ds offset 78n
.El
-.Bl -tag -width Ds -offset -3n
+.Bl -tag -width Ds -offset -0.26i
.It tag
-Bl tag width Ds offset -3n
+Bl tag width Ds offset -0.26i
.El
Index: offset.out_ascii
===================================================================
RCS file: /home/cvs/mdocml/mdocml/regress/mdoc/Bl/offset.out_ascii,v
retrieving revision 1.1
retrieving revision 1.2
diff -Lregress/mdoc/Bl/offset.out_ascii -Lregress/mdoc/Bl/offset.out_ascii -u -p -r1.1 -r1.2
--- regress/mdoc/Bl/offset.out_ascii
+++ regress/mdoc/Bl/offset.out_ascii
@@ -33,7 +33,7 @@ D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
tag Bl tag width Ds offset indent-two
- tag Bl tag width Ds offset 4n
+ tag Bl tag width Ds offset 0.36i
tag Bl tag width Ds offset mystring
@@ -46,6 +46,6 @@ D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
offset
78n
- tag Bl tag width Ds offset -3n
+ tag Bl tag width Ds offset -0.26i
OpenBSD December 25, 2014 OpenBSD
Index: tag.in
===================================================================
RCS file: /home/cvs/mdocml/mdocml/regress/mdoc/Bl/tag.in,v
retrieving revision 1.1
retrieving revision 1.2
diff -Lregress/mdoc/Bl/tag.in -Lregress/mdoc/Bl/tag.in -u -p -r1.1 -r1.2
--- regress/mdoc/Bl/tag.in
+++ regress/mdoc/Bl/tag.in
@@ -9,7 +9,7 @@
.It tag
x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
.El
-.Bl -tag -width -3n
+.Bl -tag -width -0.26i
.It tag
x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
.El
@@ -53,7 +53,7 @@ x x x x x x x x x x x x x x x x x x x x
.It quint
x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
.El
-.Bl -tag -width 5n
+.Bl -tag -width 0.46i
.It indent
x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
.El
Index: h.out_ascii
===================================================================
RCS file: /home/cvs/mdocml/mdocml/regress/roff/esc/h.out_ascii,v
retrieving revision 1.1
retrieving revision 1.2
diff -Lregress/roff/esc/h.out_ascii -Lregress/roff/esc/h.out_ascii -u -p -r1.1 -r1.2
--- regress/roff/esc/h.out_ascii
+++ regress/roff/esc/h.out_ascii
@@ -5,6 +5,7 @@ N\bNA\bAM\bME\bE
D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
simple: ><
+ rounding: > <
escape only: ><
escape at the end: ><
escape at the beginning: ><
Index: h.out_lint
===================================================================
RCS file: /home/cvs/mdocml/mdocml/regress/roff/esc/h.out_lint,v
retrieving revision 1.2
retrieving revision 1.3
diff -Lregress/roff/esc/h.out_lint -Lregress/roff/esc/h.out_lint -u -p -r1.2 -r1.3
--- regress/roff/esc/h.out_lint
+++ regress/roff/esc/h.out_lint
@@ -1,2 +1,2 @@
-mandoc: h.in:18:21: WARNING: invalid escape sequence: \h-
+mandoc: h.in:20:21: WARNING: invalid escape sequence: \h-
mandoc: h.in:1:5: STYLE: Mdocdate missing: Dd May
Index: h.in
===================================================================
RCS file: /home/cvs/mdocml/mdocml/regress/roff/esc/h.in,v
retrieving revision 1.2
retrieving revision 1.3
diff -Lregress/roff/esc/h.in -Lregress/roff/esc/h.in -u -p -r1.2 -r1.3
--- regress/roff/esc/h.in
+++ regress/roff/esc/h.in
@@ -7,6 +7,8 @@
.Sh DESCRIPTION
simple: >\h'0'<
.br
+rounding: >\h'0.16i'<
+.br
escape only: >\h'\w'\&'M'<
.br
escape at the end: >\h'0+\w'\&''<
Index: man_term.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/man_term.c,v
retrieving revision 1.204
retrieving revision 1.205
diff -Lman_term.c -Lman_term.c -u -p -r1.204 -r1.205
--- man_term.c
+++ man_term.c
@@ -377,7 +377,7 @@ pre_in(DECL_ARGS)
if (a2roffsu(++cp, &su, SCALE_EN) == NULL)
return 0;
- v = (term_hspan(p, &su) + 11) / 24;
+ v = term_hen(p, &su);
if (less < 0)
p->tcol->offset -= p->tcol->offset > v ? v : p->tcol->offset;
@@ -426,7 +426,7 @@ pre_HP(DECL_ARGS)
if ((nn = n->parent->head->child) != NULL &&
a2roffsu(nn->string, &su, SCALE_EN) != NULL) {
- len = term_hspan(p, &su) / 24;
+ len = term_hen(p, &su);
if (len < 0 && (size_t)(-len) > mt->offset)
len = -mt->offset;
else if (len > SHRT_MAX)
@@ -511,7 +511,7 @@ pre_IP(DECL_ARGS)
if ((nn = n->parent->head->child) != NULL &&
(nn = nn->next) != NULL &&
a2roffsu(nn->string, &su, SCALE_EN) != NULL) {
- len = term_hspan(p, &su) / 24;
+ len = term_hen(p, &su);
if (len < 0 && (size_t)(-len) > mt->offset)
len = -mt->offset;
else if (len > SHRT_MAX)
@@ -593,7 +593,7 @@ pre_TP(DECL_ARGS)
if ((nn = n->parent->head->child) != NULL &&
nn->string != NULL && ! (NODE_LINE & nn->flags) &&
a2roffsu(nn->string, &su, SCALE_EN) != NULL) {
- len = term_hspan(p, &su) / 24;
+ len = term_hen(p, &su);
if (len < 0 && (size_t)(-len) > mt->offset)
len = -mt->offset;
else if (len > SHRT_MAX)
@@ -797,7 +797,7 @@ pre_RS(DECL_ARGS)
if (n->child == NULL)
n->aux = mt->lmargin[mt->lmargincur];
else if (a2roffsu(n->child->string, &su, SCALE_EN) != NULL)
- n->aux = term_hspan(p, &su) / 24;
+ n->aux = term_hen(p, &su);
if (n->aux < 0 && (size_t)(-n->aux) > mt->offset)
n->aux = -mt->offset;
else if (n->aux > SHRT_MAX)
Index: term.h
===================================================================
RCS file: /home/cvs/mdocml/mdocml/term.h,v
retrieving revision 1.127
retrieving revision 1.128
diff -Lterm.h -Lterm.h -u -p -r1.127 -r1.128
--- term.h
+++ term.h
@@ -140,6 +140,7 @@ void term_end(struct termp *);
void term_setwidth(struct termp *, const char *);
int term_hspan(const struct termp *, const struct roffsu *);
+int term_hen(const struct termp *, const struct roffsu *);
int term_vspan(const struct termp *, const struct roffsu *);
size_t term_strlen(const struct termp *, const char *);
size_t term_len(const struct termp *, size_t);
Index: mdoc_term.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mdoc_term.c,v
retrieving revision 1.363
retrieving revision 1.364
diff -Lmdoc_term.c -Lmdoc_term.c -u -p -r1.363 -r1.364
--- mdoc_term.c
+++ mdoc_term.c
@@ -540,7 +540,7 @@ a2width(const struct termp *p, const cha
SCALE_HS_INIT(&su, term_strlen(p, v));
su.scale /= term_strlen(p, "0");
}
- return term_hspan(p, &su) / 24;
+ return term_hen(p, &su);
}
/*
@@ -686,7 +686,7 @@ termp_it_pre(DECL_ARGS)
SCALE_HS_INIT(&su,
term_strlen(p, bl->norm->Bl.cols[i]));
su.scale /= term_strlen(p, "0");
- offset += term_hspan(p, &su) / 24 + dcol;
+ offset += term_hen(p, &su) + dcol;
}
/*
@@ -704,7 +704,7 @@ termp_it_pre(DECL_ARGS)
*/
SCALE_HS_INIT(&su, term_strlen(p, bl->norm->Bl.cols[i]));
su.scale /= term_strlen(p, "0");
- width = term_hspan(p, &su) / 24 + dcol;
+ width = term_hen(p, &su) + dcol;
break;
default:
if (NULL == bl->norm->Bl.width)
Index: term_tab.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/term_tab.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -Lterm_tab.c -Lterm_tab.c -u -p -r1.2 -r1.3
--- term_tab.c
+++ term_tab.c
@@ -52,7 +52,7 @@ term_tab_set(const struct termp *p, cons
recording_period = 0;
if (tabs.d == 0) {
a2roffsu(".8i", &su, SCALE_IN);
- tabs.d = term_hspan(p, &su) / 24;
+ tabs.d = term_hen(p, &su);
}
return;
}
@@ -81,7 +81,7 @@ term_tab_set(const struct termp *p, cons
/* Append the new position. */
- pos = term_hspan(p, &su);
+ pos = term_hen(p, &su);
tl->t[tl->n] = pos;
if (add && tl->n)
tl->t[tl->n] += tl->t[tl->n - 1];
@@ -97,10 +97,6 @@ term_tab_next(size_t prev)
if (i == tabs.a.n) {
if (tabs.p.n == 0)
return prev;
-/*
- return i ? prev :
- (prev / tabs.d + 1) * tabs.d;
- */
tabs.a.n += tabs.p.n;
if (tabs.a.s < tabs.a.n) {
tabs.a.s = tabs.a.n;
@@ -111,7 +107,7 @@ term_tab_next(size_t prev)
tabs.a.t[i + j] = tabs.p.t[j] +
(i ? tabs.a.t[i - 1] : 0);
}
- if (prev < tabs.a.t[i] / 24)
- return tabs.a.t[i] / 24;
+ if (prev < tabs.a.t[i])
+ return tabs.a.t[i];
}
}
Index: term.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/term.c,v
retrieving revision 1.270
retrieving revision 1.271
diff -Lterm.c -Lterm.c -u -p -r1.270 -r1.271
--- term.c
+++ term.c
@@ -528,7 +528,7 @@ term_word(struct termp *p, const char *w
case ESCAPE_HORIZ:
if (a2roffsu(seq, &su, SCALE_EM) == NULL)
continue;
- uc = term_hspan(p, &su) / 24;
+ uc = term_hen(p, &su);
if (uc > 0)
while (uc-- > 0)
bufferc(p, ASCII_NBRSP);
@@ -549,7 +549,7 @@ term_word(struct termp *p, const char *w
case ESCAPE_HLINE:
if ((seq = a2roffsu(seq, &su, SCALE_EM)) == NULL)
continue;
- uc = term_hspan(p, &su) / 24;
+ uc = term_hen(p, &su);
if (uc <= 0) {
if (p->tcol->rmargin <= p->tcol->offset)
continue;
@@ -966,11 +966,25 @@ term_vspan(const struct termp *p, const
}
/*
- * Convert a scaling width to basic units, rounding down.
+ * Convert a scaling width to basic units, rounding towards 0.
*/
int
term_hspan(const struct termp *p, const struct roffsu *su)
{
return (*p->hspan)(p, su);
+}
+
+/*
+ * Convert a scaling width to basic units, rounding to closest.
+ */
+int
+term_hen(const struct termp *p, const struct roffsu *su)
+{
+ int bu;
+
+ if ((bu = (*p->hspan)(p, su)) >= 0)
+ return (bu + 11) / 24;
+ else
+ return -((-bu + 11) / 24);
}
Index: roff_term.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/roff_term.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -Lroff_term.c -Lroff_term.c -u -p -r1.11 -r1.12
--- roff_term.c
+++ roff_term.c
@@ -205,7 +205,7 @@ roff_term_pre_ti(ROFF_TERM_ARGS)
if (a2roffsu(cp, &su, SCALE_EM) == NULL)
return;
- len = term_hspan(p, &su) / 24;
+ len = term_hen(p, &su);
if (sign == 0) {
p->ti = len - p->tcol->offset;
Index: tbl_term.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/tbl_term.c,v
retrieving revision 1.51
retrieving revision 1.52
diff -Ltbl_term.c -Ltbl_term.c -u -p -r1.51 -r1.52
--- tbl_term.c
+++ tbl_term.c
@@ -47,7 +47,7 @@ static void tbl_word(struct termp *, con
static size_t
term_tbl_sulen(const struct roffsu *su, void *arg)
{
- return term_hspan((const struct termp *)arg, su) / 24;
+ return term_hen((const struct termp *)arg, su);
}
static size_t
Index: spacing.in
===================================================================
RCS file: /home/cvs/mdocml/mdocml/regress/man/HP/spacing.in,v
retrieving revision 1.1
retrieving revision 1.2
diff -Lregress/man/HP/spacing.in -Lregress/man/HP/spacing.in -u -p -r1.1 -r1.2
--- regress/man/HP/spacing.in
+++ regress/man/HP/spacing.in
@@ -17,7 +17,7 @@ Each hanged paragraph gets a sufficient
to wrap to the next line.
.br
And a second line.
-.HP -4n
+.HP -0.36i
Each hanged paragraph gets a sufficient amount of text
to wrap to the next line.
.br
@@ -42,7 +42,7 @@ Each hanged paragraph gets a sufficient
to wrap to the next line.
.br
And a second line.
-.HP 8n
+.HP .76i
Each hanged paragraph gets a sufficient amount of text
to wrap to the next line.
.br
Index: width.in
===================================================================
RCS file: /home/cvs/mdocml/mdocml/regress/man/IP/width.in,v
retrieving revision 1.1
retrieving revision 1.2
diff -Lregress/man/IP/width.in -Lregress/man/IP/width.in -u -p -r1.1 -r1.2
--- regress/man/IP/width.in
+++ regress/man/IP/width.in
@@ -7,7 +7,7 @@ Regular mode:
indented
.br
text
-.IP tag -4n
+.IP tag -0.36i
indented
.br
text
@@ -61,7 +61,7 @@ text
.IP tag 2n
indented
text
-.IP tag 3n
+.IP tag 0.26i
indented
text
.IP tag 4n
Index: width.in
===================================================================
RCS file: /home/cvs/mdocml/mdocml/regress/tbl/mod/width.in,v
retrieving revision 1.1
retrieving revision 1.2
diff -Lregress/tbl/mod/width.in -Lregress/tbl/mod/width.in -u -p -r1.1 -r1.2
--- regress/tbl/mod/width.in
+++ regress/tbl/mod/width.in
@@ -5,7 +5,7 @@ tbl-mod-width \- width modifier in table
normal text
.TS
box tab(:);
-lw2 | lw(2n) | lw(0.2i) | lw2 .
+lw2 | lw(2n) | lw(0.16i) | lw2 .
a:abcd:T{
a
T}:T{
--
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:[~2017-06-14 17:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-14 17:51 mdocml: improve rounding rules for scaling units in horizontal 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).