Fix vertical scaling. Obviously, nobody ever had a serious look at this.
authorschwarze <schwarze@openbsd.org>
Tue, 23 Dec 2014 06:16:21 +0000 (06:16 +0000)
committerschwarze <schwarze@openbsd.org>
Tue, 23 Dec 2014 06:16:21 +0000 (06:16 +0000)
Basic units, centimeters, points, ens, ems, and the rounding algorithm
were all wrong, only inches, pica, and the default vertical span worked.

regress/usr.bin/mandoc/roff/sp/Makefile
regress/usr.bin/mandoc/roff/sp/scaling-man.in [new file with mode: 0644]
regress/usr.bin/mandoc/roff/sp/scaling-man.out_ascii [new file with mode: 0644]
regress/usr.bin/mandoc/roff/sp/scaling-mdoc.in [new file with mode: 0644]
regress/usr.bin/mandoc/roff/sp/scaling-mdoc.out_ascii [new file with mode: 0644]
usr.bin/mandoc/term.c

index 62e2b34..9e853e0 100644 (file)
@@ -1,5 +1,5 @@
-# $OpenBSD: Makefile,v 1.3 2012/07/13 14:15:50 schwarze Exp $
+# $OpenBSD: Makefile,v 1.4 2014/12/23 06:16:21 schwarze Exp $
 
-REGRESS_TARGETS = badargs-mdoc badargs-man negative
+REGRESS_TARGETS        = badargs-man badargs-mdoc negative scaling-man scaling-mdoc
 
 .include <bsd.regress.mk>
diff --git a/regress/usr.bin/mandoc/roff/sp/scaling-man.in b/regress/usr.bin/mandoc/roff/sp/scaling-man.in
new file mode 100644 (file)
index 0000000..69318ec
--- /dev/null
@@ -0,0 +1,27 @@
+.TH SP-SCALING-MAN 1 "December 23, 2014" OpenBSD
+.SH NAME
+sp-scaling-man \- scaled arguments to .sp requests in man(7)
+.SH DESCRIPTION
+20 basic units:
+.sp 20u
+21 basic units:
+.sp 21u
+one centimeter:
+.sp 1c
+quarter of an inch:
+.sp 0.25i
+half a pica:
+.sp 0.5P
+one pica:
+.sp 1P
+6 points:
+.sp 6p
+7 points:
+.sp 7p
+one en:
+.sp 1n
+three en:
+.sp 3n
+two em:
+.sp 2m
+end of test document
diff --git a/regress/usr.bin/mandoc/roff/sp/scaling-man.out_ascii b/regress/usr.bin/mandoc/roff/sp/scaling-man.out_ascii
new file mode 100644 (file)
index 0000000..72a0b53
--- /dev/null
@@ -0,0 +1,34 @@
+SP-SCALING-MAN(1)           General Commands Manual          SP-SCALING-MAN(1)
+
+
+
+N\bNA\bAM\bME\bE
+       sp-scaling-man - scaled arguments to .sp requests in man(7)
+
+D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+       20 basic units:
+       21 basic units:
+
+       one centimeter:
+
+
+       quarter of an inch:
+
+       half a pica:
+       one pica:
+
+       6 points:
+       7 points:
+
+       one en:
+
+       three en:
+
+
+       two em:
+
+       end of test document
+
+
+
+OpenBSD                        December 23, 2014             SP-SCALING-MAN(1)
diff --git a/regress/usr.bin/mandoc/roff/sp/scaling-mdoc.in b/regress/usr.bin/mandoc/roff/sp/scaling-mdoc.in
new file mode 100644 (file)
index 0000000..ff4d45c
--- /dev/null
@@ -0,0 +1,30 @@
+.Dd December 23, 2014
+.Dt SP-SCALING-MDOC 1
+.Os OpenBSD
+.Sh NAME
+.Nm sp-scaling-mdoc
+.Nd scaled arguments to .sp requests in mdoc(7)
+.Sh DESCRIPTION
+20 basic units:
+.sp 20u
+21 basic units:
+.sp 21u
+one centimeter:
+.sp 1c
+quarter of an inch:
+.sp 0.25i
+half a pica:
+.sp 0.5P
+one pica:
+.sp 1P
+6 points:
+.sp 6p
+7 points:
+.sp 7p
+one en:
+.sp 1n
+three en:
+.sp 3n
+two em:
+.sp 2m
+end of test document
diff --git a/regress/usr.bin/mandoc/roff/sp/scaling-mdoc.out_ascii b/regress/usr.bin/mandoc/roff/sp/scaling-mdoc.out_ascii
new file mode 100644 (file)
index 0000000..625ba7c
--- /dev/null
@@ -0,0 +1,30 @@
+SP-SCALING-MDOC(1)          General Commands Manual         SP-SCALING-MDOC(1)
+
+N\bNA\bAM\bME\bE
+     s\bsp\bp-\b-s\bsc\bca\bal\bli\bin\bng\bg-\b-m\bmd\bdo\boc\bc - scaled arguments to .sp requests in mdoc(7)
+
+D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+     20 basic units:
+     21 basic units:
+
+     one centimeter:
+
+
+     quarter of an inch:
+
+     half a pica:
+     one pica:
+
+     6 points:
+     7 points:
+
+     one en:
+
+     three en:
+
+
+     two em:
+
+     end of test document
+
+OpenBSD                        December 23, 2014                       OpenBSD
index 79f0239..1c69ca2 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: term.c,v 1.98 2014/12/19 17:10:42 schwarze Exp $ */
+/*     $OpenBSD: term.c,v 1.99 2014/12/23 06:16:21 schwarze Exp $ */
 /*
  * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
  * Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -774,32 +774,43 @@ term_vspan(const struct termp *p, const struct roffsu *su)
        double           r;
 
        switch (su->unit) {
+       case SCALE_BU:
+               r = su->scale / 40.0;
+               break;
        case SCALE_CM:
-               r = su->scale * 2.0;
+               r = su->scale * 6.0 / 2.54;
+               break;
+       case SCALE_FS:
+               r = su->scale * 65536.0 / 40.0;
                break;
        case SCALE_IN:
                r = su->scale * 6.0;
                break;
+       case SCALE_MM:
+               r = su->scale * 0.006;
+               break;
        case SCALE_PC:
                r = su->scale;
                break;
        case SCALE_PT:
-               r = su->scale / 8.0;
+               r = su->scale / 12.0;
                break;
-       case SCALE_MM:
-               r = su->scale / 1000.0;
+       case SCALE_EN:
+               /* FALLTHROUGH */
+       case SCALE_EM:
+               r = su->scale * 0.6;
                break;
        case SCALE_VS:
                r = su->scale;
                break;
        default:
-               r = su->scale - 1.0;
-               break;
+               abort();
+               /* NOTREACHED */
        }
 
        if (r < 0.0)
                r = 0.0;
-       return((size_t)(r + 0.0005));
+       return((size_t)(r + 0.4995));
 }
 
 size_t