* Render \*(Pi as pi, not n @ 2011-06-02 9:28 Ulrich Spörlein 2011-06-02 9:54 ` Kristaps Dzonsons 0 siblings, 1 reply; 7+ messages in thread From: Ulrich Spörlein @ 2011-06-02 9:28 UTC (permalink / raw) To: discuss [-- Attachment #1: Type: text/plain, Size: 501 bytes --] 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. Cheers, Uli [-- Attachment #2: pi.diff --] [-- Type: text/x-diff, Size: 523 bytes --] Index: chars.in =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/chars.in,v retrieving revision 1.39 diff -u -p -r1.39 chars.in --- chars.in 24 May 2011 21:40:14 -0000 1.39 +++ chars.in 2 Jun 2011 09:20:39 -0000 @@ -152,7 +152,7 @@ CHAR("*m", "u", 956) CHAR("*n", "v", 957) CHAR("*c", "E", 958) CHAR("*o", "o", 959) -CHAR("*p", "n", 960) +CHAR("*p", "pi", 960) CHAR("*r", "p", 961) CHAR("*s", "o", 963) CHAR("*t", "t", 964) ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Render \*(Pi as pi, not n 2011-06-02 9:28 Render \*(Pi as pi, not n Ulrich Spörlein @ 2011-06-02 9:54 ` Kristaps Dzonsons 2011-06-02 11:15 ` Ulrich Spörlein 0 siblings, 1 reply; 7+ messages in thread From: Kristaps Dzonsons @ 2011-06-02 9:54 UTC (permalink / raw) To: discuss 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. > > Cheers, > Uli Ulrich, 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). Kristaps -- To unsubscribe send an email to discuss+unsubscribe@mdocml.bsd.lv ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Render \*(Pi as pi, not n 2011-06-02 9:54 ` Kristaps Dzonsons @ 2011-06-02 11:15 ` Ulrich Spörlein 2011-06-02 11:57 ` Ingo Schwarze 0 siblings, 1 reply; 7+ messages in thread From: Ulrich Spörlein @ 2011-06-02 11:15 UTC (permalink / raw) To: discuss 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. > > > > Cheers, > > Uli > > Ulrich, > > 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 Which distribution where you checking? Uli -- To unsubscribe send an email to discuss+unsubscribe@mdocml.bsd.lv ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Render \*(Pi as pi, not n 2011-06-02 11:15 ` Ulrich Spörlein @ 2011-06-02 11:57 ` Ingo Schwarze 2011-06-02 13:13 ` Kristaps Dzonsons 0 siblings, 1 reply; 7+ messages in thread From: Ingo Schwarze @ 2011-06-02 11:57 UTC (permalink / raw) To: discuss 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. Yours, Ingo -- To unsubscribe send an email to discuss+unsubscribe@mdocml.bsd.lv ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Render \*(Pi as pi, not n 2011-06-02 11:57 ` Ingo Schwarze @ 2011-06-02 13:13 ` Kristaps Dzonsons 2011-06-02 13:22 ` Kristaps Dzonsons 2011-06-02 16:09 ` Ingo Schwarze 0 siblings, 2 replies; 7+ messages in thread From: Kristaps Dzonsons @ 2011-06-02 13:13 UTC (permalink / raw) To: discuss [-- 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]) ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Render \*(Pi as pi, not n 2011-06-02 13:13 ` Kristaps Dzonsons @ 2011-06-02 13:22 ` Kristaps Dzonsons 2011-06-02 16:09 ` Ingo Schwarze 1 sibling, 0 replies; 7+ messages in thread From: Kristaps Dzonsons @ 2011-06-02 13:22 UTC (permalink / raw) To: discuss > 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). Fui, other way round... you get the point. -- To unsubscribe send an email to discuss+unsubscribe@mdocml.bsd.lv ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Render \*(Pi as pi, not n 2011-06-02 13:13 ` Kristaps Dzonsons 2011-06-02 13:22 ` Kristaps Dzonsons @ 2011-06-02 16:09 ` Ingo Schwarze 1 sibling, 0 replies; 7+ messages in thread From: Ingo Schwarze @ 2011-06-02 16:09 UTC (permalink / raw) To: discuss Hi Kristaps, > I don't think this is serious. Maybe you are right. However: > It's trivial to add bits that pass libroff the notion of > whether it's nroff (-Tascii) or troff (-Teverythinglese). That's a slippery slope. As i said in my BSDCan talk http://www.openbsd.org/papers/bsdcan11-mandoc-openbsd.html on page 13: * roff expands high-level macros into low-level requests, then renders the resulting stream of low-level requests * mandoc preprocesses low-level requests, then compiles the remaining high level macros into a syntax tree, then renders that syntax tree In roff, the intermediate representation (request stream) depends on the output mode. But in mandoc, so far, the intermediate representation (syntax tree) does *not* depend on the output mode, only on the input file. Consequently, in roff, a normalizing parser is impossible. You cannot implement a -Tmdoc output mode in roff. In mandoc, so far, a normalizing parser is possible. The command mandoc -mdoc -Tmdoc foo.1 > foo-norm.1 could be implemented to parse and normalize the mdoc code in foo.1, guaranteeing that processing foo.1 and foo-norm.1 will produce the same syntax tree and hence the same output for all output modes, for all possible input files. If we go down the route you propose, that is no longer possible. mandoc atan2.3 # will produce [-pi, +pi] mandoc -Tmdoc atan2.3 | mandoc # will produce [-n, +n] Moving expansion of the predefined strings into roff.c already gave up the chance to preserve them during normalization. The file atan2-norm.3 will already turn .Bq "\-\*(Pi, +\*(Pi" into .Bq "\-pi, +pi" even without this patch. With this patch, it will produce .Bq "\-n, +n" > In fact, we should be doing this anyway, which > will allow us to respond to `.if n' in the Right Way. For now, i think this is an improvement. In the long run, i feel more stuff must be moved into the syntax tree, for example escape sequences, which are just elements, in a sense very similar to in-line macros. Maybe even string expansions and definitions. However, this requires unifying the mdoc(7) and man(7) syntax trees, such that both can use a number of common elements. Which is a huge project and not yet well thought out. Yours, Ingo -- To unsubscribe send an email to discuss+unsubscribe@mdocml.bsd.lv ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2011-06-02 16:09 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2011-06-02 9:28 Render \*(Pi as pi, not n 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 2011-06-02 13:22 ` Kristaps Dzonsons 2011-06-02 16:09 ` Ingo Schwarze
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).