discuss@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: Kristaps Dzonsons <kristaps@bsd.lv>
To: discuss@mdocml.bsd.lv
Subject: Re: Render \*(Pi as pi, not n
Date: Thu, 02 Jun 2011 16:13:10 +0300	[thread overview]
Message-ID: <4DE78C66.8060604@bsd.lv> (raw)
In-Reply-To: <20110602115758.GA2260@iris.usta.de>

[-- Attachment #1: Type: text/plain, Size: 2629 bytes --]

On 02/06/2011 14:57, Ingo Schwarze wrote:
> Hi Ulrich,
>
> Ulrich Spörlein wrote on Thu, Jun 02, 2011 at 01:15:47PM +0200:
>> On Thu, 02.06.2011 at 12:54:56 +0300, Kristaps Dzonsons wrote:
>>> On 02/06/2011 12:28, Ulrich Spörlein wrote:
>
>>>> Hello,
>>>>
>>>> please consider doing the same as groff here, fixing ambiguities
>>>>
>>>> Before:
>>>>
>>>>        The atan2(), atan2f(), and atan2l() functions, if successful,
>>>>        return the arc tangent of y/x in the range [-n, +n] radians.
>>>>
>>>> After:
>>>>
>>>>        The atan2(), atan2f(), and atan2l() functions, if successful,
>>>>        return the arc tangent of y/x in the range [-pi, +pi] radians.
>>>>
>>>> Although 'n' might look a little like '??' we shouldn't replace random
>>>> letters for greek symbols that have different meaning.
>
>>> This is not something that groff agrees upon.  The stock groff on
>>> GNU/Linux returns `n' instead of `pi'.  Version: GNU troff (groff)
>>> version 1.21.  We've discussed this before, I think... the quick
>>> solution is to patch it downstream (chars.in).  I personally don't like
>>> the attenuation of /any/ Greek characters, as my own formulas end up
>>> confusing (those with both pi and n, for example).
>
>> I disagree on groff disagreeing
>>
>> FreeBSD base groff version 1.19.2: \*(Pi ->  pi
>> FreeBSD port groff version 1.21:   \*(Pi ->  pi
>> Ubuntu groff version 1.20.1:       \*(Pi ->  pi
>
> Oh that one, indeed.
>
> I fixed this here and just need to merge it to bsd.lv:
>
> http://www.openbsd.org/cgi-bin/cvsweb/src/usr.bin/mandoc/predefs.in
> Revision 1.2
>
> Ulrich is talking about \*(Pi in -Tascii,
> Kristaps is talking about \(*p in -Tascii.
>
> What groff does with \*(Pi is
>   - "pi" in nroff mode (-Tascii)
>   - real pi glyph in troff mode (-Tps)
>
> Mandoc could do the same as long as it was handling predefined strings
> in the same way as character escape sequences.  Now that it handles
> predefined strings in the preprocessor, it cannot achieve this any
> longer.
>
> Hum.  I only realize now how serious that regression is from a
> theoretical point of view...
> Not sure what to do about this in general.

Ingo,

I don't think this is serious.  It's trivial to add bits that pass 
libroff the notion of whether it's troff (-Tascii) or nroff 
(-Teverythinglese).  In fact, we should be doing this anyway, which will 
allow us to respond to `.if n' in the Right Way.  Doubly in fact, 
enclosed is a patch for it.  Thoughts?  From here it's just a matter of 
mechanical bits to let this go to predef.in in some way, whether by 
having predef.in have `.if' clauses or whatever.

K.

[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 5613 bytes --]

Index: libmandoc.h
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/libmandoc.h,v
retrieving revision 1.21
diff -u -r1.21 libmandoc.h
--- libmandoc.h	14 May 2011 16:06:09 -0000	1.21
+++ libmandoc.h	2 Jun 2011 13:11:52 -0000
@@ -98,7 +98,7 @@
 int		 man_addeqn(struct man *, const struct eqn *);
 
 void	 	 roff_free(struct roff *);
-struct roff	*roff_alloc(struct regset *, struct mparse *);
+struct roff	*roff_alloc(enum mrofft, struct regset *, struct mparse *);
 void		 roff_reset(struct roff *);
 enum rofferr	 roff_parseln(struct roff *, int, 
 			char **, size_t *, int, int *);
Index: main.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/main.c,v
retrieving revision 1.163
diff -u -r1.163 main.c
--- main.c	20 May 2011 15:51:18 -0000	1.163
+++ main.c	2 Jun 2011 13:11:53 -0000
@@ -124,7 +124,9 @@
 			/* NOTREACHED */
 		}
 
-	curp.mp = mparse_alloc(type, curp.wlevel, mmsg, &curp);
+	curp.mp = mparse_alloc
+		(OUTT_ASCII == curp.outtype ? MROFF_NROFF : MROFF_TROFF,
+		 type, curp.wlevel, mmsg, &curp);
 
 	argc -= optind;
 	argv += optind;
Index: makewhatis.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/makewhatis.c,v
retrieving revision 1.2
diff -u -r1.2 makewhatis.c
--- makewhatis.c	15 May 2011 02:47:17 -0000	1.2
+++ makewhatis.c	2 Jun 2011 13:11:53 -0000
@@ -330,7 +330,8 @@
 	 * Use the auto-parser and don't report any errors.
 	 */
 
-	mp = mparse_alloc(MPARSE_AUTO, MANDOCLEVEL_FATAL, NULL, NULL);
+	mp = mparse_alloc(MROFF_NROFF, MPARSE_AUTO, 
+			MANDOCLEVEL_FATAL, NULL, NULL);
 
 	memset(&key, 0, sizeof(DBT));
 	memset(&val, 0, sizeof(DBT));
Index: mandoc.h
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mandoc.h,v
retrieving revision 1.77
diff -u -r1.77 mandoc.h
--- mandoc.h	24 May 2011 21:31:23 -0000	1.77
+++ mandoc.h	2 Jun 2011 13:11:53 -0000
@@ -288,6 +288,11 @@
 	MPARSE_MAN /* assume -man */
 };
 
+enum	mrofft {
+	MROFF_NROFF, /* use nroff output mode */
+	MROFF_TROFF /* use troff output mode */
+};
+
 enum	mandoc_esc {
 	ESCAPE_ERROR = 0, /* bail! unparsable escape */
 	ESCAPE_IGNORE, /* escape to be ignored */
@@ -314,7 +319,7 @@
 
 void		  mparse_free(struct mparse *);
 void		  mparse_reset(struct mparse *);
-struct mparse	 *mparse_alloc(enum mparset, 
+struct mparse	 *mparse_alloc(enum mrofft, enum mparset, 
 			enum mandoclevel, mandocmsg, void *);
 enum mandoclevel  mparse_readfd(struct mparse *, int, const char *);
 void		  mparse_result(struct mparse *, struct mdoc **, struct man **);
Index: read.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/read.c,v
retrieving revision 1.15
diff -u -r1.15 read.c
--- read.c	26 May 2011 20:36:21 -0000	1.15
+++ read.c	2 Jun 2011 13:11:53 -0000
@@ -668,7 +668,8 @@
 }
 
 struct mparse *
-mparse_alloc(enum mparset inttype, enum mandoclevel wlevel, mandocmsg mmsg, void *arg)
+mparse_alloc(enum mrofft rofft, enum mparset inttype, 
+		enum mandoclevel wlevel, mandocmsg mmsg, void *arg)
 {
 	struct mparse	*curp;
 
@@ -681,7 +682,7 @@
 	curp->arg = arg;
 	curp->inttype = inttype;
 
-	curp->roff = roff_alloc(&curp->regs, curp);
+	curp->roff = roff_alloc(rofft, &curp->regs, curp);
 	return(curp);
 }
 
Index: roff.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/roff.c,v
retrieving revision 1.142
diff -u -r1.142 roff.c
--- roff.c	26 May 2011 11:58:25 -0000	1.142
+++ roff.c	2 Jun 2011 13:11:53 -0000
@@ -81,6 +81,7 @@
 	struct mparse	*parse; /* parse point */
 	struct roffnode	*last; /* leaf of stack */
 	enum roffrule	 rstack[RSTACK_MAX]; /* stack of !`ie' rules */
+	enum mrofft	 mode;
 	int		 rstackpos; /* position in rstack */
 	struct regset	*regs; /* read/writable registers */
 	struct roffstr	*first_string; /* user-defined strings & macros */
@@ -142,7 +143,7 @@
 static	enum rofferr	 roff_cond_text(ROFF_ARGS);
 static	enum rofferr	 roff_cond_sub(ROFF_ARGS);
 static	enum rofferr	 roff_ds(ROFF_ARGS);
-static	enum roffrule	 roff_evalcond(const char *, int *);
+static	enum roffrule	 roff_evalcond(enum mrofft, const char *, int *);
 static	void		 roff_freestr(struct roff *);
 static	char		*roff_getname(struct roff *, char **, int, int);
 static	const char	*roff_getstrn(const struct roff *, 
@@ -362,12 +363,13 @@
 
 
 struct roff *
-roff_alloc(struct regset *regs, struct mparse *parse)
+roff_alloc(enum mrofft mode, struct regset *regs, struct mparse *parse)
 {
 	struct roff	*r;
 	int		 i;
 
 	r = mandoc_calloc(1, sizeof(struct roff));
+	r->mode = mode;
 	r->regs = regs;
 	r->parse = parse;
 	r->rstackpos = -1;
@@ -925,20 +927,23 @@
 }
 
 static enum roffrule
-roff_evalcond(const char *v, int *pos)
+roff_evalcond(enum mrofft mode, const char *v, int *pos)
 {
 
 	switch (v[*pos]) {
 	case ('n'):
 		(*pos)++;
-		return(ROFFRULE_ALLOW);
+		return(MROFF_NROFF == mode ? 
+				ROFFRULE_ALLOW : ROFFRULE_DENY);
 	case ('e'):
 		/* FALLTHROUGH */
 	case ('o'):
-		/* FALLTHROUGH */
-	case ('t'):
 		(*pos)++;
 		return(ROFFRULE_DENY);
+	case ('t'):
+		(*pos)++;
+		return(MROFF_TROFF == mode ? 
+				ROFFRULE_ALLOW : ROFFRULE_DENY);
 	default:
 		break;
 	}
@@ -977,7 +982,7 @@
 	rule = ROFF_el == tok ?
 		(r->rstackpos < 0 ? 
 		 ROFFRULE_DENY : r->rstack[r->rstackpos--]) :
-		roff_evalcond(*bufp, &pos);
+		roff_evalcond(r->mode, *bufp, &pos);
 
 	sv = pos;
 	while (' ' == (*bufp)[pos])

  reply	other threads:[~2011-06-02 13:13 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-02  9:28 Ulrich Spörlein
2011-06-02  9:54 ` Kristaps Dzonsons
2011-06-02 11:15   ` Ulrich Spörlein
2011-06-02 11:57     ` Ingo Schwarze
2011-06-02 13:13       ` Kristaps Dzonsons [this message]
2011-06-02 13:22         ` Kristaps Dzonsons
2011-06-02 16:09         ` Ingo Schwarze

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=4DE78C66.8060604@bsd.lv \
    --to=kristaps@bsd.lv \
    --cc=discuss@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).