aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--eqn_term.c34
-rw-r--r--regress/eqn/fromto/basic.out_ascii2
-rw-r--r--regress/eqn/fromto/noarg.out_ascii2
-rw-r--r--regress/eqn/fromto/precedence.out_ascii2
-rw-r--r--regress/eqn/over/noarg.out_ascii2
-rw-r--r--regress/eqn/over/precedence.out_ascii4
-rw-r--r--regress/eqn/subsup/combine.out_ascii2
-rw-r--r--regress/eqn/subsup/noarg.out_ascii2
-rw-r--r--regress/eqn/subsup/precedence.out_ascii2
-rw-r--r--regress/eqn/subsup/sub_group.out_ascii2
10 files changed, 38 insertions, 16 deletions
diff --git a/eqn_term.c b/eqn_term.c
index e11b0485..fde0aca0 100644
--- a/eqn_term.c
+++ b/eqn_term.c
@@ -1,4 +1,4 @@
-/* $Id: eqn_term.c,v 1.11 2017/07/06 00:19:54 schwarze Exp $ */
+/* $Id: eqn_term.c,v 1.12 2017/07/07 19:06:31 schwarze Exp $ */
/*
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014, 2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -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 eqn_box *bp)
}
}
+ /* 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 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)) {
+
+ /* 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)
diff --git a/regress/eqn/fromto/basic.out_ascii b/regress/eqn/fromto/basic.out_ascii
index e4530a15..b67ec47b 100644
--- a/regress/eqn/fromto/basic.out_ascii
+++ b/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
diff --git a/regress/eqn/fromto/noarg.out_ascii b/regress/eqn/fromto/noarg.out_ascii
index c09dcde2..f5f1e8fa 100644
--- a/regress/eqn/fromto/noarg.out_ascii
+++ b/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
diff --git a/regress/eqn/fromto/precedence.out_ascii b/regress/eqn/fromto/precedence.out_ascii
index 1eba1bef..b7da7180 100644
--- a/regress/eqn/fromto/precedence.out_ascii
+++ b/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
diff --git a/regress/eqn/over/noarg.out_ascii b/regress/eqn/over/noarg.out_ascii
index 22ceb49e..c30afa55 100644
--- a/regress/eqn/over/noarg.out_ascii
+++ b/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
diff --git a/regress/eqn/over/precedence.out_ascii b/regress/eqn/over/precedence.out_ascii
index a77aa47f..1059b742 100644
--- a/regress/eqn/over/precedence.out_ascii
+++ b/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
diff --git a/regress/eqn/subsup/combine.out_ascii b/regress/eqn/subsup/combine.out_ascii
index 8812f6f6..468a814c 100644
--- a/regress/eqn/subsup/combine.out_ascii
+++ b/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
diff --git a/regress/eqn/subsup/noarg.out_ascii b/regress/eqn/subsup/noarg.out_ascii
index d5b87b24..eec09f18 100644
--- a/regress/eqn/subsup/noarg.out_ascii
+++ b/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
diff --git a/regress/eqn/subsup/precedence.out_ascii b/regress/eqn/subsup/precedence.out_ascii
index 60619b54..21207dd6 100644
--- a/regress/eqn/subsup/precedence.out_ascii
+++ b/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
diff --git a/regress/eqn/subsup/sub_group.out_ascii b/regress/eqn/subsup/sub_group.out_ascii
index 85e3568a..5628e6d9 100644
--- a/regress/eqn/subsup/sub_group.out_ascii
+++ b/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