Deleted Added
full compact
1c1
< /* $Id: eqn_term.c,v 1.8 2015/01/01 15:36:08 schwarze Exp $ */
---
> /* $Id: eqn_term.c,v 1.13 2017/07/08 14:51:04 schwarze Exp $ */
4c4
< * Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
---
> * Copyright (c) 2014, 2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
43c43
< term_eqn(struct termp *p, const struct eqn *ep)
---
> term_eqn(struct termp *p, const struct eqn_box *bp)
46c46
< eqn_box(p, ep->root);
---
> eqn_box(p, bp);
53a54
> int delim;
55c56,58
< if (bp->type == EQN_LIST ||
---
> /* Delimiters around this box? */
>
> if ((bp->type == EQN_LIST && bp->expectargs > 1) ||
57c60,69
< (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)))))) {
62c74,79
< }
---
> delim = 1;
> } else
> delim = 0;
>
> /* Handle Fonts and text. */
>
68a86,87
> /* Special box types. */
>
71,72c90,93
< p->flags |= TERMP_NOSPACE;
< eqn_box(p, bp->first);
---
> if (bp->first != NULL) {
> p->flags |= TERMP_NOSPACE;
> eqn_box(p, bp->first);
> }
96c117,120
< if (bp->type == EQN_MATRIX && child->type == EQN_LIST)
---
> if (bp->type == EQN_MATRIX &&
> child != NULL &&
> child->type == EQN_LIST &&
> child->expectargs > 1)
101a126
> child->expectargs > 1 &&
107a133,134
> /* Handle Fonts and diacritics. */
>
110,118d136
< if (bp->type == EQN_LIST ||
< (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;
< }
<
126a145,153
>
> /* 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)
> p->flags |= TERMP_NOSPACE;
> }