summaryrefslogtreecommitdiffstats
path: root/eqn_term.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2017-07-06 00:19:54 +0000
committerIngo Schwarze <schwarze@openbsd.org>2017-07-06 00:19:54 +0000
commit8bfd46f38d1b15589e5ffa8b44915557a3030385 (patch)
tree02789eb4144757c270da344ddd007d37cb15d92a /eqn_term.c
parente0015d9facf740a96124938363ba25c3b6c09af8 (diff)
downloadmandoc-8bfd46f38d1b15589e5ffa8b44915557a3030385.tar.gz
Fix operator precedence according to Brian W. Kernighan and Lorinda
L. Cherry, "Typesetting Mathematics - User's Guide (Second Edition)", August 15, 1978, paragraph 23; swarm of bugs pointed out by bentley@.
Diffstat (limited to 'eqn_term.c')
-rw-r--r--eqn_term.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/eqn_term.c b/eqn_term.c
index 35541afd..97c6a7af 100644
--- a/eqn_term.c
+++ b/eqn_term.c
@@ -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;
+ }
}