source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: schwarze@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: Handle some predefined read-only number registers, e.g.
Date: Fri, 14 Feb 2014 17:27:41 -0500 (EST)	[thread overview]
Message-ID: <201402142227.s1EMRfdx026359@krisdoz.my.domain> (raw)

Log Message:
-----------
Handle some predefined read-only number registers, e.g. .H and .V.
In particular, this improves handling of the pod2man(1) preamble;
for examples of the effect, see some author names in perlthrtut(1).

Missing feature reported by Andreas Voegele <mail at andreasvoegele dot com>
more than two years ago.  Written at Christchurch International Airport.

Modified Files:
--------------
    mdocml:
        TODO
        roff.c

Revision Data
-------------
Index: TODO
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/TODO,v
retrieving revision 1.162
retrieving revision 1.163
diff -LTODO -LTODO -u -p -r1.162 -r1.163
--- TODO
+++ TODO
@@ -15,11 +15,6 @@ None known.
 
 --- missing roff features ----------------------------------------------
 
-- roff.c should treat \n(.H>23 and \n(.V>19 in the pod2man(1)
-  preamble as true, see for example AUTHORS in MooseX::Getopt.3p
-  reported by Andreas Voegele <mail at andreasvoegele dot com>
-  Tue, 22 Nov 2011 15:34:47 +0100 on ports@
-
 - .ad (adjust margins)
   .ad l -- adjust left margin only (flush left)
   .ad r -- adjust right margin only (flush right)
Index: roff.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/roff.c,v
retrieving revision 1.191
retrieving revision 1.192
diff -Lroff.c -Lroff.c -u -p -r1.191 -r1.192
--- roff.c
+++ roff.c
@@ -192,6 +192,7 @@ static	int		 roff_getnum(const char *, i
 static	int		 roff_getop(const char *, int *, char *);
 static	int		 roff_getregn(const struct roff *,
 				const char *, size_t);
+static	int		 roff_getregro(const char *name);
 static	const char	*roff_getstrn(const struct roff *, 
 				const char *, size_t);
 static	enum rofferr	 roff_it(ROFF_ARGS);
@@ -1380,10 +1381,45 @@ roff_setreg(struct roff *r, const char *
 		reg->val = val;
 }
 
+/*
+ * Handle some predefined read-only number registers.
+ * For now, return -1 if the requested register is not predefined;
+ * in case a predefined read-only register having the value -1
+ * were to turn up, another special value would have to be chosen.
+ */
+static int
+roff_getregro(const char *name)
+{
+
+	switch (*name) {
+	case ('A'):  /* ASCII approximation mode is always off. */
+		return(0);
+	case ('g'):  /* Groff compatibility mode is always on. */
+		return(1);
+	case ('H'):  /* Fixed horizontal resolution. */
+		return (24);
+	case ('j'):  /* Always adjust left margin only. */
+		return(0);
+	case ('T'):  /* Some output device is always defined. */
+		return(1);
+	case ('V'):  /* Fixed vertical resolution. */
+		return (40);
+	default:
+		return (-1);
+	}
+}
+
 int
 roff_getreg(const struct roff *r, const char *name)
 {
 	struct roffreg	*reg;
+	int		 val;
+
+	if ('.' == name[0] && '\0' != name[1] && '\0' == name[2]) {
+		val = roff_getregro(name + 1);
+		if (-1 != val)
+			return (val);
+	}
 
 	for (reg = r->regtab; reg; reg = reg->next)
 		if (0 == strcmp(name, reg->key.p))
@@ -1396,6 +1432,13 @@ static int
 roff_getregn(const struct roff *r, const char *name, size_t len)
 {
 	struct roffreg	*reg;
+	int		 val;
+
+	if ('.' == name[0] && 2 == len) {
+		val = roff_getregro(name + 1);
+		if (-1 != val)
+			return (val);
+	}
 
 	for (reg = r->regtab; reg; reg = reg->next)
 		if (len == reg->key.sz &&
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

                 reply	other threads:[~2014-02-14 22:27 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=201402142227.s1EMRfdx026359@krisdoz.my.domain \
    --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).