From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from localhost (fantadrom.bsd.lv [local]) by fantadrom.bsd.lv (OpenSMTPD) with ESMTPA id f1ea52ba for ; Fri, 7 Jul 2017 14:07:05 -0500 (EST) Date: Fri, 7 Jul 2017 14:07:05 -0500 (EST) Message-Id: <5785145542013761052.enqueue@fantadrom.bsd.lv> X-Mailinglist: mandoc-source Reply-To: source@mandoc.bsd.lv MIME-Version: 1.0 From: schwarze@mandoc.bsd.lv To: source@mandoc.bsd.lv Subject: mandoc: add parentheses to the output where required for disambiguation X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Log Message: ----------- add parentheses to the output where required for disambiguation Modified Files: -------------- mandoc: eqn_term.c mandoc/regress/eqn/fromto: basic.out_ascii noarg.out_ascii precedence.out_ascii mandoc/regress/eqn/over: noarg.out_ascii precedence.out_ascii mandoc/regress/eqn/subsup: combine.out_ascii noarg.out_ascii precedence.out_ascii sub_group.out_ascii Revision Data ------------- Index: noarg.out_ascii =================================================================== RCS file: /home/cvs/mandoc/mandoc/regress/eqn/fromto/noarg.out_ascii,v retrieving revision 1.3 retrieving revision 1.4 diff -Lregress/eqn/fromto/noarg.out_ascii -Lregress/eqn/fromto/noarg.out_ascii -u -p -r1.3 -r1.4 --- regress/eqn/fromto/noarg.out_ascii +++ regress/eqn/fromto/noarg.out_ascii @@ -4,6 +4,6 @@ NNAAMMEE ffrroommttoo--nnooaarrgg - vertical stacking lacks final argument DDEESSCCRRIIPPTTIIOONN - initial text _x__a^^ final text + initial text _x_(_a^)^ final text OpenBSD July 4, 2017 OpenBSD Index: basic.out_ascii =================================================================== RCS file: /home/cvs/mandoc/mandoc/regress/eqn/fromto/basic.out_ascii,v retrieving revision 1.3 retrieving revision 1.4 diff -Lregress/eqn/fromto/basic.out_ascii -Lregress/eqn/fromto/basic.out_ascii -u -p -r1.3 -r1.4 --- regress/eqn/fromto/basic.out_ascii +++ regress/eqn/fromto/basic.out_ascii @@ -4,6 +4,6 @@ NNAAMMEE ffrroommttoo--bbaassiicc - vertical stacking DDEESSCCRRIIPPTTIIOONN - initial text E_(_i = 1)^oo 1/_i^2 final text + initial text E_(_i = 1)^oo 1/(_i^2) final text OpenBSD July 4, 2017 OpenBSD Index: precedence.out_ascii =================================================================== RCS file: /home/cvs/mandoc/mandoc/regress/eqn/fromto/precedence.out_ascii,v retrieving revision 1.1 retrieving revision 1.2 diff -Lregress/eqn/fromto/precedence.out_ascii -Lregress/eqn/fromto/precedence.out_ascii -u -p -r1.1 -r1.2 --- regress/eqn/fromto/precedence.out_ascii +++ regress/eqn/fromto/precedence.out_ascii @@ -4,6 +4,6 @@ NNAAMMEE ssuubbssuupp--pprreecceeddeennccee - precedence of subscripts and superscripts DDEESSCCRRIIPPTTIIOONN - initial text _X__a_^_c^ ; X_aa^_c ; _X_1^2__a__c^_e^_o__r^_s final text + initial text _X_(_a_)^_c^ ; X_aa^_c ; (_X_1^2)_(_a__c^_e)^(_o__r^_s) final text OpenBSD July 6, 2017 OpenBSD Index: eqn_term.c =================================================================== RCS file: /home/cvs/mandoc/mandoc/eqn_term.c,v retrieving revision 1.11 retrieving revision 1.12 diff -Leqn_term.c -Leqn_term.c -u -p -r1.11 -r1.12 --- eqn_term.c +++ eqn_term.c @@ -51,21 +51,40 @@ static void eqn_box(struct termp *p, const struct eqn_box *bp) { const struct eqn_box *child; + int delim; + + /* Delimiters around this box? */ if ((bp->type == EQN_LIST && bp->expectargs > 1) || (bp->type == EQN_PILE && (bp->prev || bp->next)) || - (bp->parent != NULL && bp->parent->pos == EQNPOS_SQRT)) { + (bp->parent != NULL && (bp->parent->pos == EQNPOS_SQRT || + /* Diacritic followed by ^ or _. */ + ((bp->top != NULL || bp->bottom != NULL) && + bp->parent->type == EQN_SUBEXPR && + bp->parent->pos != EQNPOS_OVER && bp->next != NULL) || + /* Nested over, sub, sup, from, to. */ + (bp->type == EQN_SUBEXPR && bp->pos != EQNPOS_SQRT && + ((bp->parent->type == EQN_LIST && bp->expectargs == 1) || + (bp->parent->type == EQN_SUBEXPR && + bp->pos != EQNPOS_SQRT)))))) { if (bp->parent->type == EQN_SUBEXPR && bp->prev != NULL) p->flags |= TERMP_NOSPACE; term_word(p, bp->left != NULL ? bp->left : "("); p->flags |= TERMP_NOSPACE; - } + delim = 1; + } else + delim = 0; + + /* Handle Fonts and text. */ + if (bp->font != EQNFONT_NONE) term_fontpush(p, fontmap[(int)bp->font]); if (bp->text != NULL) term_word(p, bp->text); + /* Special box types. */ + if (bp->pos == EQNPOS_SQRT) { term_word(p, "sqrt"); if (bp->first != NULL) { @@ -111,6 +130,8 @@ eqn_box(struct termp *p, const struct eq } } + /* Handle Fonts and diacritics. */ + if (bp->font != EQNFONT_NONE) term_fontpop(p); if (bp->top != NULL) { @@ -121,9 +142,10 @@ eqn_box(struct termp *p, const struct eq p->flags |= TERMP_NOSPACE; term_word(p, "_"); } - if ((bp->type == EQN_LIST && bp->expectargs > 1) || - (bp->type == EQN_PILE && (bp->prev || bp->next)) || - (bp->parent != NULL && bp->parent->pos == EQNPOS_SQRT)) { + + /* Right delimiter after this box? */ + + if (delim) { p->flags |= TERMP_NOSPACE; term_word(p, bp->right != NULL ? bp->right : ")"); if (bp->parent->type == EQN_SUBEXPR && bp->next != NULL) Index: noarg.out_ascii =================================================================== RCS file: /home/cvs/mandoc/mandoc/regress/eqn/over/noarg.out_ascii,v retrieving revision 1.2 retrieving revision 1.3 diff -Lregress/eqn/over/noarg.out_ascii -Lregress/eqn/over/noarg.out_ascii -u -p -r1.2 -r1.3 --- regress/eqn/over/noarg.out_ascii +++ regress/eqn/over/noarg.out_ascii @@ -4,6 +4,6 @@ NNAAMMEE oovveerr--nnooaarrgg - fraction operator without arguments DDEESSCCRRIIPPTTIIOONN - initial text // final text + initial text (/)/ final text OpenBSD July 4, 2017 OpenBSD Index: precedence.out_ascii =================================================================== RCS file: /home/cvs/mandoc/mandoc/regress/eqn/over/precedence.out_ascii,v retrieving revision 1.4 retrieving revision 1.5 diff -Lregress/eqn/over/precedence.out_ascii -Lregress/eqn/over/precedence.out_ascii -u -p -r1.4 -r1.5 --- regress/eqn/over/precedence.out_ascii +++ regress/eqn/over/precedence.out_ascii @@ -4,7 +4,7 @@ NNAAMMEE oovveerr--pprreecceeddeennccee - precedence of the fraction operator DDEESSCCRRIIPPTTIIOONN - initial text 1 + _x + _x^2/2 + _x^3/(2 * 3) ; _a^/_c~ ; aa/cc ; sqrt(_a)/sqrt(_c) - final text + initial text 1 + _x + (_x^2)/2 + (_x^3)/(2 * 3) ; _a^/_c~ ; aa/cc ; + sqrt(_a)/sqrt(_c) final text OpenBSD July 6, 2017 OpenBSD Index: precedence.out_ascii =================================================================== RCS file: /home/cvs/mandoc/mandoc/regress/eqn/subsup/precedence.out_ascii,v retrieving revision 1.1 retrieving revision 1.2 diff -Lregress/eqn/subsup/precedence.out_ascii -Lregress/eqn/subsup/precedence.out_ascii -u -p -r1.1 -r1.2 --- regress/eqn/subsup/precedence.out_ascii +++ regress/eqn/subsup/precedence.out_ascii @@ -4,6 +4,6 @@ NNAAMMEE ssuubbssuupp--pprreecceeddeennccee - precedence of subscripts and superscripts DDEESSCCRRIIPPTTIIOONN - initial text _x^_1_^2 + _e~^_x^__s<-> ; I_II^_I + I^II__I final text + initial text (_x^)_(1_)^2 + (_e~)^((_x^)__s<->) ; I_II^_I + I^(II__I) final text OpenBSD July 6, 2017 OpenBSD Index: noarg.out_ascii =================================================================== RCS file: /home/cvs/mandoc/mandoc/regress/eqn/subsup/noarg.out_ascii,v retrieving revision 1.3 retrieving revision 1.4 diff -Lregress/eqn/subsup/noarg.out_ascii -Lregress/eqn/subsup/noarg.out_ascii -u -p -r1.3 -r1.4 --- regress/eqn/subsup/noarg.out_ascii +++ regress/eqn/subsup/noarg.out_ascii @@ -4,6 +4,6 @@ NNAAMMEE ssuubbssuupp--nnooaarrgg - empty subscripts and superscripts DDEESSCCRRIIPPTTIIOONN - initial text _x_1^^ final text + initial text _x_(1^)^ final text OpenBSD July 4, 2017 OpenBSD Index: sub_group.out_ascii =================================================================== RCS file: /home/cvs/mandoc/mandoc/regress/eqn/subsup/sub_group.out_ascii,v retrieving revision 1.3 retrieving revision 1.4 diff -Lregress/eqn/subsup/sub_group.out_ascii -Lregress/eqn/subsup/sub_group.out_ascii -u -p -r1.3 -r1.4 --- regress/eqn/subsup/sub_group.out_ascii +++ regress/eqn/subsup/sub_group.out_ascii @@ -4,6 +4,6 @@ NNAAMMEE ssuubbssuupp--ssuubb__ggrroouupp - grouping of subscripts DDEESSCCRRIIPPTTIIOONN - initial text _x__i + _x__j_1 + (_M__i)__j final text + initial text _x__i + _x_(_j_1) + (_M__i)__j final text OpenBSD July 4, 2017 OpenBSD Index: combine.out_ascii =================================================================== RCS file: /home/cvs/mandoc/mandoc/regress/eqn/subsup/combine.out_ascii,v retrieving revision 1.3 retrieving revision 1.4 diff -Lregress/eqn/subsup/combine.out_ascii -Lregress/eqn/subsup/combine.out_ascii -u -p -r1.3 -r1.4 --- regress/eqn/subsup/combine.out_ascii +++ regress/eqn/subsup/combine.out_ascii @@ -4,6 +4,6 @@ NNAAMMEE ssuubbssuupp--ccoommbbiinnee - combination of subscripts and superscripts DDEESSCCRRIIPPTTIIOONN - initial text _x_1^2 + _e^_x_2 final text + initial text _x_1^2 + _e^(_x_2) final text OpenBSD July 4, 2017 OpenBSD -- To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv