diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2015-01-23 00:42:00 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2015-01-23 00:42:00 +0000 |
commit | 1c07d0670659745601b58f021984f85c38c41f44 (patch) | |
tree | 1659ee382e2cc118df5cf22df6423e8ac1e2b902 /roff.c | |
parent | 8a2f1706fd6632a3035d5145d1d04c67148824c6 (diff) | |
download | mandoc-1c07d0670659745601b58f021984f85c38c41f44.tar.gz |
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 'roff.c')
-rw-r--r-- | roff.c | 42 |
1 files changed, 40 insertions, 2 deletions
@@ -1641,8 +1641,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); } /* |