diff options
-rw-r--r-- | eqn.c | 29 | ||||
-rw-r--r-- | eqn_term.c | 17 | ||||
-rw-r--r-- | regress/eqn/fromto/Makefile | 6 | ||||
-rw-r--r-- | regress/eqn/fromto/precedence.in | 15 | ||||
-rw-r--r-- | regress/eqn/fromto/precedence.out_ascii | 9 | ||||
-rw-r--r-- | regress/eqn/fromto/precedence.out_html | 1 | ||||
-rw-r--r-- | regress/eqn/over/precedence.in | 5 | ||||
-rw-r--r-- | regress/eqn/over/precedence.out_ascii | 5 | ||||
-rw-r--r-- | regress/eqn/over/precedence.out_html | 2 | ||||
-rw-r--r-- | regress/eqn/subsup/Makefile | 6 | ||||
-rw-r--r-- | regress/eqn/subsup/precedence.in | 14 | ||||
-rw-r--r-- | regress/eqn/subsup/precedence.out_ascii | 9 | ||||
-rw-r--r-- | regress/eqn/subsup/precedence.out_html | 1 | ||||
-rw-r--r-- | regress/eqn/unary/bold.in | 4 | ||||
-rw-r--r-- | regress/eqn/unary/bold.out_ascii | 4 | ||||
-rw-r--r-- | regress/eqn/unary/bold.out_html | 2 | ||||
-rw-r--r-- | regress/eqn/unary/diacrit.in | 3 | ||||
-rw-r--r-- | regress/eqn/unary/diacrit.out_ascii | 4 | ||||
-rw-r--r-- | regress/eqn/unary/diacrit.out_html | 2 | ||||
-rw-r--r-- | regress/eqn/unary/sqrt.in | 4 | ||||
-rw-r--r-- | regress/eqn/unary/sqrt.out_ascii | 5 | ||||
-rw-r--r-- | regress/eqn/unary/sqrt.out_html | 2 |
22 files changed, 105 insertions, 44 deletions
@@ -819,6 +819,8 @@ next_tok: ep->gsize = size; break; } + while (parent->args == parent->expectargs) + parent = parent->parent; parent = eqn_box_alloc(ep, parent); parent->type = EQN_LIST; parent->expectargs = 1; @@ -840,13 +842,25 @@ next_tok: cur->type = EQN_TEXT; cur->text = mandoc_strdup(""); } - /* Handle the "subsup" and "fromto" positions. */ - if (EQN_TOK_SUP == tok && parent->pos == EQNPOS_SUB) { + while (parent->expectargs == 1 && parent->args == 1) + parent = parent->parent; + if (tok == EQN_TOK_FROM || tok == EQN_TOK_TO) { + for (cur = parent; cur != NULL; cur = cur->parent) + if (cur->pos == EQNPOS_SUB || + cur->pos == EQNPOS_SUP || + cur->pos == EQNPOS_SUBSUP || + cur->pos == EQNPOS_SQRT || + cur->pos == EQNPOS_OVER) + break; + if (cur != NULL) + parent = cur->parent; + } + if (tok == EQN_TOK_SUP && parent->pos == EQNPOS_SUB) { parent->expectargs = 3; parent->pos = EQNPOS_SUBSUP; break; } - if (EQN_TOK_TO == tok && parent->pos == EQNPOS_FROM) { + if (tok == EQN_TOK_TO && parent->pos == EQNPOS_FROM) { parent->expectargs = 3; parent->pos = EQNPOS_FROMTO; break; @@ -895,6 +909,8 @@ next_tok: cur->type = EQN_TEXT; cur->text = mandoc_strdup(""); } + while (parent->args == parent->expectargs) + parent = parent->parent; while (EQN_SUBEXPR == parent->type) parent = parent->parent; parent = eqn_box_makebinary(ep, EQNPOS_OVER, parent); @@ -1099,13 +1115,6 @@ next_tok: parent = split->parent; break; } - /* - * Post-process list status. - */ - while (parent->type == EQN_LIST && - parent->expectargs == 1 && - parent->args == 1) - parent = parent->parent; break; default: abort(); @@ -113,15 +113,6 @@ eqn_box(struct termp *p, const struct eqn_box *bp) if (bp->font != EQNFONT_NONE) term_fontpop(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)) { - p->flags |= TERMP_NOSPACE; - term_word(p, bp->right != NULL ? bp->right : ")"); - if (bp->parent->type == EQN_SUBEXPR && bp->next != NULL) - p->flags |= TERMP_NOSPACE; - } - if (bp->top != NULL) { p->flags |= TERMP_NOSPACE; term_word(p, bp->top); @@ -130,4 +121,12 @@ eqn_box(struct termp *p, const struct eqn_box *bp) 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)) { + p->flags |= TERMP_NOSPACE; + term_word(p, bp->right != NULL ? bp->right : ")"); + if (bp->parent->type == EQN_SUBEXPR && bp->next != NULL) + p->flags |= TERMP_NOSPACE; + } } diff --git a/regress/eqn/fromto/Makefile b/regress/eqn/fromto/Makefile index a2012e8f..1384c543 100644 --- a/regress/eqn/fromto/Makefile +++ b/regress/eqn/fromto/Makefile @@ -1,6 +1,6 @@ -# $OpenBSD: Makefile,v 1.2 2015/01/01 15:34:43 schwarze Exp $ +# $OpenBSD: Makefile,v 1.3 2017/07/06 00:08:52 schwarze Exp $ -REGRESS_TARGETS = basic noarg -HTML_TARGETS = basic noarg +REGRESS_TARGETS = basic noarg precedence +HTML_TARGETS = basic noarg precedence .include <bsd.regress.mk> diff --git a/regress/eqn/fromto/precedence.in b/regress/eqn/fromto/precedence.in new file mode 100644 index 00000000..cbb85e36 --- /dev/null +++ b/regress/eqn/fromto/precedence.in @@ -0,0 +1,15 @@ +.\" $OpenBSD: precedence.in,v 1.1 2017/07/06 00:08:52 schwarze Exp $ +.Dd $Mdocdate$ +.Dt SUBSUP-PRECEDENCE 1 +.Os +.Sh NAME +.Nm subsup-precedence +.Nd precedence of subscripts and superscripts +.Sh DESCRIPTION +.ps 36 +initial text +.EQ +X from a under to c hat ; roman X from bold a to italic c ; +X sub 1 sup 2 from a sub c sup e to o sub r sup s +.EN +final text diff --git a/regress/eqn/fromto/precedence.out_ascii b/regress/eqn/fromto/precedence.out_ascii new file mode 100644 index 00000000..1eba1bef --- /dev/null +++ b/regress/eqn/fromto/precedence.out_ascii @@ -0,0 +1,9 @@ +SUBSUP-PRECEDENCE(1) General Commands Manual SUBSUP-PRECEDENCE(1) + +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 + +OpenBSD July 6, 2017 OpenBSD diff --git a/regress/eqn/fromto/precedence.out_html b/regress/eqn/fromto/precedence.out_html new file mode 100644 index 00000000..bb9074e6 --- /dev/null +++ b/regress/eqn/fromto/precedence.out_html @@ -0,0 +1 @@ +<mrow><munderover><mi>X</mi><munder><mi>a</mi><mo>_</mo></munder><mover><mi>c</mi><mo>^</mo></mover></munderover><mo>;</mo><munderover><mrow><mi fontstyle="normal">X</mi></mrow><mrow><mi fontweight="bold">a</mi></mrow><mrow><mi>c</mi></mrow></munderover><mo>;</mo><munderover><msubsup><mi>X</mi><mn>1</mn><mn>2</mn></msubsup><msubsup><mi>a</mi><mi>c</mi><mi>e</mi></msubsup><msubsup><mi>o</mi><mi>r</mi><mi>s</mi></msubsup></munderover></mrow> diff --git a/regress/eqn/over/precedence.in b/regress/eqn/over/precedence.in index 9e1bb7d7..0fb509a9 100644 --- a/regress/eqn/over/precedence.in +++ b/regress/eqn/over/precedence.in @@ -1,4 +1,4 @@ -.\" $OpenBSD: precedence.in,v 1.2 2017/07/04 14:53:23 schwarze Exp $ +.\" $OpenBSD: precedence.in,v 1.3 2017/07/06 00:08:52 schwarze Exp $ .Dd $Mdocdate$ .Dt OVER-PRECEDENCE 1 .Os @@ -8,6 +8,7 @@ .Sh DESCRIPTION initial text .EQ -1 + x + x sup 2 over 2 + x sup 3 over { 2 * 3 } +1 + x + x sup 2 over 2 + x sup 3 over { 2 * 3 } ; +a hat over c tilde ; bold a over bold c ; sqrt a over sqrt c .EN final text diff --git a/regress/eqn/over/precedence.out_ascii b/regress/eqn/over/precedence.out_ascii index 92529bb4..a77aa47f 100644 --- a/regress/eqn/over/precedence.out_ascii +++ b/regress/eqn/over/precedence.out_ascii @@ -4,6 +4,7 @@ NNAAMMEE oovveerr--pprreecceeddeennccee - precedence of the fraction operator DDEESSCCRRIIPPTTIIOONN - initial text 1 + _x + _x^2/2 + _x^3/(2 * 3) 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 4, 2017 OpenBSD +OpenBSD July 6, 2017 OpenBSD diff --git a/regress/eqn/over/precedence.out_html b/regress/eqn/over/precedence.out_html index b7c4f36d..52e45eb5 100644 --- a/regress/eqn/over/precedence.out_html +++ b/regress/eqn/over/precedence.out_html @@ -1 +1 @@ -<mrow><mn>1</mn><mo>+</mo><mi>x</mi><mo>+</mo><mfrac><msup><mi>x</mi><mn>2</mn></msup><mn>2</mn></mfrac><mo>+</mo><mfrac><msup><mi>x</mi><mn>3</mn></msup><mrow><mn>2</mn><mo>*</mo><mn>3</mn></mrow></mfrac></mrow> +<mrow><mn>1</mn><mo>+</mo><mi>x</mi><mo>+</mo><mfrac><msup><mi>x</mi><mn>2</mn></msup><mn>2</mn></mfrac><mo>+</mo><mfrac><msup><mi>x</mi><mn>3</mn></msup><mrow><mn>2</mn><mo>*</mo><mn>3</mn></mrow></mfrac><mo>;</mo><mfrac><mover><mi>a</mi><mo>^</mo></mover><mover><mi>c</mi><mo>~</mo></mover></mfrac><mo>;</mo><mfrac><mrow><mi fontweight="bold">a</mi></mrow><mrow><mi fontweight="bold">c</mi></mrow></mfrac><mo>;</mo><mfrac><msqrt><mi>a</mi></msqrt><msqrt><mi>c</mi></msqrt></mfrac></mrow> diff --git a/regress/eqn/subsup/Makefile b/regress/eqn/subsup/Makefile index 4e11b33d..a7801046 100644 --- a/regress/eqn/subsup/Makefile +++ b/regress/eqn/subsup/Makefile @@ -1,6 +1,6 @@ -# $OpenBSD: Makefile,v 1.2 2015/01/01 15:34:43 schwarze Exp $ +# $OpenBSD: Makefile,v 1.3 2017/07/06 00:08:52 schwarze Exp $ -REGRESS_TARGETS = combine noarg sub_group -HTML_TARGETS = combine noarg sub_group +REGRESS_TARGETS = combine noarg precedence sub_group +HTML_TARGETS = combine noarg precedence sub_group .include <bsd.regress.mk> diff --git a/regress/eqn/subsup/precedence.in b/regress/eqn/subsup/precedence.in new file mode 100644 index 00000000..3972de65 --- /dev/null +++ b/regress/eqn/subsup/precedence.in @@ -0,0 +1,14 @@ +.\" $OpenBSD: precedence.in,v 1.1 2017/07/06 00:08:52 schwarze Exp $ +.Dd $Mdocdate$ +.Dt SUBSUP-PRECEDENCE 1 +.Os +.Sh NAME +.Nm subsup-precedence +.Nd precedence of subscripts and superscripts +.Sh DESCRIPTION +initial text +.EQ +x hat sub 1 under sup 2 bar + e tilde sup x hat sub s dyad ; +roman I sub bold I sup italic I + roman I sup bold I sub italic I +.EN +final text diff --git a/regress/eqn/subsup/precedence.out_ascii b/regress/eqn/subsup/precedence.out_ascii new file mode 100644 index 00000000..60619b54 --- /dev/null +++ b/regress/eqn/subsup/precedence.out_ascii @@ -0,0 +1,9 @@ +SUBSUP-PRECEDENCE(1) General Commands Manual SUBSUP-PRECEDENCE(1) + +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 + +OpenBSD July 6, 2017 OpenBSD diff --git a/regress/eqn/subsup/precedence.out_html b/regress/eqn/subsup/precedence.out_html new file mode 100644 index 00000000..1cad9ce2 --- /dev/null +++ b/regress/eqn/subsup/precedence.out_html @@ -0,0 +1 @@ +<mrow><msubsup><mover><mi>x</mi><mo>^</mo></mover><munder><mn>1</mn><mo>_</mo></munder><mover><mn>2</mn><mo></mo></mover></msubsup><mo>+</mo><msup><mover><mi>e</mi><mo>~</mo></mover><msub><mover><mi>x</mi><mo>^</mo></mover><mover><mi>s</mi><mo>↔</mo></mover></msub></msup><mo>;</mo><msubsup><mrow><mi fontstyle="normal">I</mi></mrow><mrow><mi fontweight="bold">I</mi></mrow><mrow><mi>I</mi></mrow></msubsup><mo>+</mo><msup><mrow><mi fontstyle="normal">I</mi></mrow><msub><mrow><mi fontweight="bold">I</mi></mrow><mrow><mi>I</mi></mrow></msub></msup></mrow> diff --git a/regress/eqn/unary/bold.in b/regress/eqn/unary/bold.in index 4854106a..fae4daa2 100644 --- a/regress/eqn/unary/bold.in +++ b/regress/eqn/unary/bold.in @@ -1,4 +1,4 @@ -.\" $OpenBSD: bold.in,v 1.2 2017/07/04 14:53:23 schwarze Exp $ +.\" $OpenBSD: bold.in,v 1.3 2017/07/06 00:08:52 schwarze Exp $ .Dd $Mdocdate$ .Dt UNARY-BOLD 1 .Os @@ -8,6 +8,6 @@ .Sh DESCRIPTION initial text .EQ -bold { sin "sin" } +bold { sin "sin" } "text" bold x hat .EN final text diff --git a/regress/eqn/unary/bold.out_ascii b/regress/eqn/unary/bold.out_ascii index c20dc638..7356ede0 100644 --- a/regress/eqn/unary/bold.out_ascii +++ b/regress/eqn/unary/bold.out_ascii @@ -4,6 +4,6 @@ NNAAMMEE uunnaarryy--bboolldd - font handling in bold boxes DDEESSCCRRIIPPTTIIOONN - initial text ((sin ssiinn)) final text + initial text ((sin ssiinn)) _t_e_x_t xx^^ final text -OpenBSD July 4, 2017 OpenBSD +OpenBSD July 6, 2017 OpenBSD diff --git a/regress/eqn/unary/bold.out_html b/regress/eqn/unary/bold.out_html index 56d6762f..e1263a4f 100644 --- a/regress/eqn/unary/bold.out_html +++ b/regress/eqn/unary/bold.out_html @@ -1 +1 @@ -<mrow><mrow><mrow><mi>sin</mi><mi fontweight="bold">sin</mi></mrow></mrow></mrow> +<mrow><mrow><mrow><mi>sin</mi><mi fontweight="bold">sin</mi></mrow></mrow><mi fontstyle="italic">text</mi><mrow><mover><mi fontweight="bold">x</mi><mo>^</mo></mover></mrow></mrow> diff --git a/regress/eqn/unary/diacrit.in b/regress/eqn/unary/diacrit.in index 00e83cbb..e039b4ce 100644 --- a/regress/eqn/unary/diacrit.in +++ b/regress/eqn/unary/diacrit.in @@ -1,4 +1,4 @@ -.\" $OpenBSD: diacrit.in,v 1.2 2017/07/04 14:53:23 schwarze Exp $ +.\" $OpenBSD: diacrit.in,v 1.3 2017/07/06 00:08:52 schwarze Exp $ .Dd $Mdocdate$ .Dt UNARY-DIACRIT 1 .Os @@ -10,5 +10,6 @@ initial text .EQ x dot x dotdot x hat x tilde x vec x dyad { x + y } bar { x + y } under +x tilde hat .EN final text diff --git a/regress/eqn/unary/diacrit.out_ascii b/regress/eqn/unary/diacrit.out_ascii index f2c5b0bb..62ac035f 100644 --- a/regress/eqn/unary/diacrit.out_ascii +++ b/regress/eqn/unary/diacrit.out_ascii @@ -4,6 +4,6 @@ NNAAMMEE uunnaarryy--ddiiaaccrriitt - diacritical marks in equations DDEESSCCRRIIPPTTIIOONN - initial text _x. _x" _x^ _x~ _x-> _x<-> (_x + _y) (_x + _y)_ final text + initial text _x. _x" _x^ _x~ _x-> _x<-> (_x + _y) (_x + _y)_ _x~^ final text -OpenBSD July 4, 2017 OpenBSD +OpenBSD July 6, 2017 OpenBSD diff --git a/regress/eqn/unary/diacrit.out_html b/regress/eqn/unary/diacrit.out_html index 02dcc2f4..d3d4d361 100644 --- a/regress/eqn/unary/diacrit.out_html +++ b/regress/eqn/unary/diacrit.out_html @@ -1 +1 @@ -<mrow><mover><mi>x</mi><mo>˙</mo></mover><mover><mi>x</mi><mo>¨</mo></mover><mover><mi>x</mi><mo>^</mo></mover><mover><mi>x</mi><mo>~</mo></mover><mover><mi>x</mi><mo>→</mo></mover><mover><mi>x</mi><mo>↔</mo></mover><mover><mrow><mi>x</mi><mo>+</mo><mi>y</mi></mrow><mo></mo></mover><munder><mrow><mi>x</mi><mo>+</mo><mi>y</mi></mrow><mo>_</mo></munder></mrow> +<mrow><mover><mi>x</mi><mo>˙</mo></mover><mover><mi>x</mi><mo>¨</mo></mover><mover><mi>x</mi><mo>^</mo></mover><mover><mi>x</mi><mo>~</mo></mover><mover><mi>x</mi><mo>→</mo></mover><mover><mi>x</mi><mo>↔</mo></mover><mover><mrow><mi>x</mi><mo>+</mo><mi>y</mi></mrow><mo></mo></mover><munder><mrow><mi>x</mi><mo>+</mo><mi>y</mi></mrow><mo>_</mo></munder><mover><mover><mi>x</mi><mo>~</mo></mover><mo>^</mo></mover></mrow> diff --git a/regress/eqn/unary/sqrt.in b/regress/eqn/unary/sqrt.in index 41086285..3bf9da4c 100644 --- a/regress/eqn/unary/sqrt.in +++ b/regress/eqn/unary/sqrt.in @@ -1,4 +1,4 @@ -.\" $OpenBSD: sqrt.in,v 1.4 2017/07/04 14:53:23 schwarze Exp $ +.\" $OpenBSD: sqrt.in,v 1.5 2017/07/06 00:08:52 schwarze Exp $ .Dd $Mdocdate$ .Dt UNARY-SQRT 1 .Os @@ -8,6 +8,6 @@ .Sh DESCRIPTION initial text .EQ -r = sqrt { x sup 2 + y sup 2 } + sqrt a+b + sqrt { } + sqrt +r = sqrt { x sup 2 + y sup 2 } + sqrt a+b + sqrt x hat + sqrt { } + sqrt .EN final text diff --git a/regress/eqn/unary/sqrt.out_ascii b/regress/eqn/unary/sqrt.out_ascii index 607a6013..72b7047d 100644 --- a/regress/eqn/unary/sqrt.out_ascii +++ b/regress/eqn/unary/sqrt.out_ascii @@ -4,6 +4,7 @@ NNAAMMEE uunnaarryy--ssqqrrtt - square root DDEESSCCRRIIPPTTIIOONN - initial text _r = sqrt(_x^2 + _y^2) + sqrt(_a + _b) + sqrt() + sqrt final text + initial text _r = sqrt(_x^2 + _y^2) + sqrt(_a + _b) + sqrt(_x^) + sqrt() + sqrt + final text -OpenBSD July 4, 2017 OpenBSD +OpenBSD July 6, 2017 OpenBSD diff --git a/regress/eqn/unary/sqrt.out_html b/regress/eqn/unary/sqrt.out_html index ca2de199..0b5fe37e 100644 --- a/regress/eqn/unary/sqrt.out_html +++ b/regress/eqn/unary/sqrt.out_html @@ -1 +1 @@ -<mrow><mi>r</mi><mo>=</mo><msqrt><mrow><msup><mi>x</mi><mn>2</mn></msup><mo>+</mo><msup><mi>y</mi><mn>2</mn></msup></mrow></msqrt><mo>+</mo><msqrt><mrow><mi>a</mi><mo>+</mo><mi>b</mi></mrow></msqrt><mo>+</mo><msqrt><mrow></mrow></msqrt><mo>+</mo><msqrt></msqrt></mrow> +<mrow><mi>r</mi><mo>=</mo><msqrt><mrow><msup><mi>x</mi><mn>2</mn></msup><mo>+</mo><msup><mi>y</mi><mn>2</mn></msup></mrow></msqrt><mo>+</mo><msqrt><mrow><mi>a</mi><mo>+</mo><mi>b</mi></mrow></msqrt><mo>+</mo><msqrt><mover><mi>x</mi><mo>^</mo></mover></msqrt><mo>+</mo><msqrt><mrow></mrow></msqrt><mo>+</mo><msqrt></msqrt></mrow> |