From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from localhost (fantadrom.bsd.lv [local]); by fantadrom.bsd.lv (OpenSMTPD) with ESMTPA id 0ff051b7; for ; Thu, 22 Jan 2015 19:42:30 -0500 (EST) Date: Thu, 22 Jan 2015 19:42:30 -0500 (EST) Message-Id: <9662396482244668543.enqueue@fantadrom.bsd.lv> X-Mailinglist: mdocml-source Reply-To: source@mdocml.bsd.lv MIME-Version: 1.0 From: schwarze@mdocml.bsd.lv To: source@mdocml.bsd.lv Subject: mdocml: Wonders of roff(7): Integer numbers in numerical expressions can X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Log Message: ----------- 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@. Modified Files: -------------- mdocml: roff.7 roff.c Revision Data ------------- Index: roff.7 =================================================================== RCS file: /home/cvs/mdocml/mdocml/roff.7,v retrieving revision 1.66 retrieving revision 1.67 diff -Lroff.7 -Lroff.7 -u -p -r1.66 -r1.67 --- roff.7 +++ roff.7 @@ -1715,6 +1715,14 @@ prefixed by an optional sign .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: Index: roff.c =================================================================== RCS file: /home/cvs/mdocml/mdocml/roff.c,v retrieving revision 1.253 retrieving revision 1.254 diff -Lroff.c -Lroff.c -u -p -r1.253 -r1.254 --- roff.c +++ roff.c @@ -1641,8 +1641,46 @@ roff_getnum(const char *v, int *pos, int 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); } /* -- To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv