summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2015-01-23 00:38:44 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2015-01-23 00:38:44 +0000
commit9d56a54c53e758000592659ceca2a9a5ee012619 (patch)
treed21eacf8317df89a83be68807be44134bf0be742 /usr.bin
parentdc19c117010d5d4662c8bfc46e13f2ba350efa92 (diff)
Wonders of roff(7): Integer numbers in numerical expressions can carry
scaling units, and some manuals (e.g. in devel/grcs) actually use that, so let's support it. Missing feature reported by naddy@.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/mandoc/roff.c44
1 files changed, 41 insertions, 3 deletions
diff --git a/usr.bin/mandoc/roff.c b/usr.bin/mandoc/roff.c
index 6e38f63443c..223cc407ff1 100644
--- a/usr.bin/mandoc/roff.c
+++ b/usr.bin/mandoc/roff.c
@@ -1,4 +1,4 @@
-/* $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>
@@ -1639,8 +1639,46 @@ roff_getnum(const char *v, int *pos, int *res)
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);
}
/*