From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp-1.sys.kth.se (smtp-1.sys.kth.se [130.237.32.175]) by krisdoz.my.domain (8.14.3/8.14.3) with ESMTP id p52DDLF5007705 for ; Thu, 2 Jun 2011 09:13:21 -0400 (EDT) Received: from mailscan-1.sys.kth.se (mailscan-1.sys.kth.se [130.237.32.91]) by smtp-1.sys.kth.se (Postfix) with ESMTP id 328D4156B34 for ; Thu, 2 Jun 2011 15:13:15 +0200 (CEST) X-Virus-Scanned: by amavisd-new at kth.se Received: from smtp-1.sys.kth.se ([130.237.32.175]) by mailscan-1.sys.kth.se (mailscan-1.sys.kth.se [130.237.32.91]) (amavisd-new, port 10024) with LMTP id TjfM9taN+m+5 for ; Thu, 2 Jun 2011 15:13:12 +0200 (CEST) X-KTH-Auth: kristaps [81.198.4.39] X-KTH-mail-from: kristaps@bsd.lv X-KTH-rcpt-to: discuss@mdocml.bsd.lv Received: from macky.local (unknown [81.198.4.39]) by smtp-1.sys.kth.se (Postfix) with ESMTP id 4F621156B3B for ; Thu, 2 Jun 2011 15:13:10 +0200 (CEST) Message-ID: <4DE78C66.8060604@bsd.lv> Date: Thu, 02 Jun 2011 16:13:10 +0300 From: Kristaps Dzonsons User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.17) Gecko/20110414 Thunderbird/3.1.10 X-Mailinglist: mdocml-discuss Reply-To: discuss@mdocml.bsd.lv MIME-Version: 1.0 To: discuss@mdocml.bsd.lv Subject: Re: Render \*(Pi as pi, not n References: <20110602092814.GO1002@acme.spoerlein.net> <4DE75DF0.4010600@bsd.lv> <20110602111547.GT1002@acme.spoerlein.net> <20110602115758.GA2260@iris.usta.de> In-Reply-To: <20110602115758.GA2260@iris.usta.de> Content-Type: multipart/mixed; boundary="------------010105070302080403010901" This is a multi-part message in MIME format. --------------010105070302080403010901 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit 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. --------------010105070302080403010901 Content-Type: text/plain; name="patch.txt" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="patch.txt" 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]) --------------010105070302080403010901-- -- To unsubscribe send an email to discuss+unsubscribe@mdocml.bsd.lv