From: schwarze@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: Wonders of roff(7): Integer numbers in numerical expressions can
Date: Thu, 22 Jan 2015 19:42:30 -0500 (EST) [thread overview]
Message-ID: <9662396482244668543.enqueue@fantadrom.bsd.lv> (raw)
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
reply other threads:[~2015-01-23 0:42 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9662396482244668543.enqueue@fantadrom.bsd.lv \
--to=schwarze@mdocml.bsd.lv \
--cc=source@mdocml.bsd.lv \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).