-# $OpenBSD: Makefile,v 1.8 2014/11/10 20:59:41 schwarze Exp $
+# $OpenBSD: Makefile,v 1.9 2015/01/23 00:38:43 schwarze Exp $
-REGRESS_TARGETS = argc divzero eval escname int predef rr
+REGRESS_TARGETS = argc divzero eval escname int predef rr scale
LINT_TARGETS = divzero escname
.include <bsd.regress.mk>
--- /dev/null
+.TH NR-INT 1 "January 23, 2015" OpenBSD
+.SH NAME
+nr-scale \- scaling units in numeric expressions
+.SH DESCRIPTION
+.nr Y 1f+1
+\nY
+.nr Y 1i+1
+\nY
+.nr Y 10c+1
+\nY
+.nr Y 1v+1
+\nY
+.nr Y 1P+1
+\nY
+.nr Y 1m+1
+\nY
+.nr Y 1n+1
+\nY
+.nr Y 10p+1
+\nY
+.nr Y 1u+1
+\nY
+.nr Y 100M+1
+\nY
+.nr Y 1X+2
+\nY
--- /dev/null
+NR-INT(1) General Commands Manual NR-INT(1)
+
+
+
+N\bNA\bAM\bME\bE
+ nr-scale - scaling units in numeric expressions
+
+D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+ 65537 241 945 41 41 25 25 34 2 25 1
+
+
+
+OpenBSD January 23, 2015 NR-INT(1)
-.\" $OpenBSD: roff.7,v 1.45 2015/01/21 23:48:05 jmc Exp $
+.\" $OpenBSD: roff.7,v 1.46 2015/01/23 00:38:42 schwarze Exp $
.\"
.\" Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
.\" Copyright (c) 2010, 2011, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: January 21 2015 $
+.Dd $Mdocdate: January 23 2015 $
.Dt ROFF 7
.Os
.Sh NAME
.Sq +
or
.Sq - .
+Each number may be followed by one optional scaling unit described below
+.Sx Scaling Widths .
+The following equations hold:
+.Bd -literal -offset indent
+1i = 6v = 6P = 10m = 10n = 72p = 1000M = 240u = 240
+254c = 100i = 24000u = 24000
+1f = 65536u = 65536
+.Ed
.Pp
The following binary operators are implemented.
Unless otherwise stated, they behave as in the C language:
-/* $OpenBSD: roff.c,v 1.125 2015/01/22 22:50:31 schwarze Exp $ */
+/* $OpenBSD: roff.c,v 1.126 2015/01/23 00:38:42 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011, 2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org>
if (n)
*res = -*res;
- *pos = p;
- return 1;
+ /* Each number may be followed by one optional scaling unit. */
+
+ switch (v[p]) {
+ case 'f':
+ *res *= 65536;
+ break;
+ case 'i':
+ *res *= 240;
+ break;
+ case 'c':
+ *res *= 240;
+ *res /= 2.54;
+ break;
+ case 'v':
+ /* FALLTROUGH */
+ case 'P':
+ *res *= 40;
+ break;
+ case 'm':
+ /* FALLTROUGH */
+ case 'n':
+ *res *= 24;
+ break;
+ case 'p':
+ *res *= 10;
+ *res /= 3;
+ break;
+ case 'u':
+ break;
+ case 'M':
+ *res *= 6;
+ *res /= 25;
+ break;
+ default:
+ p--;
+ break;
+ }
+
+ *pos = p + 1;
+ return(1);
}
/*