tools/llvm: Do not build with symbols
[minix3.git] / external / bsd / mdocml / dist / eqn_term.c
blobc214d7d6971a71eb3462b2ca3a8d43066ee095fa
1 /* $Vendor-Id: eqn_term.c,v 1.4 2011/07/24 10:09:03 kristaps Exp $ */
2 /*
3 * Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 #ifdef HAVE_CONFIG_H
18 #include "config.h"
19 #endif
21 #include <assert.h>
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <string.h>
26 #include "mandoc.h"
27 #include "out.h"
28 #include "term.h"
30 static const enum termfont fontmap[EQNFONT__MAX] = {
31 TERMFONT_NONE, /* EQNFONT_NONE */
32 TERMFONT_NONE, /* EQNFONT_ROMAN */
33 TERMFONT_BOLD, /* EQNFONT_BOLD */
34 TERMFONT_BOLD, /* EQNFONT_FAT */
35 TERMFONT_UNDER /* EQNFONT_ITALIC */
38 static void eqn_box(struct termp *, const struct eqn_box *);
40 void
41 term_eqn(struct termp *p, const struct eqn *ep)
44 p->flags |= TERMP_NONOSPACE;
45 eqn_box(p, ep->root);
46 term_word(p, " ");
47 p->flags &= ~TERMP_NONOSPACE;
50 static void
51 eqn_box(struct termp *p, const struct eqn_box *bp)
54 if (EQNFONT_NONE != bp->font)
55 term_fontpush(p, fontmap[(int)bp->font]);
56 if (bp->left)
57 term_word(p, bp->left);
58 if (EQN_SUBEXPR == bp->type)
59 term_word(p, "(");
61 if (bp->text)
62 term_word(p, bp->text);
64 if (bp->first)
65 eqn_box(p, bp->first);
67 if (EQN_SUBEXPR == bp->type)
68 term_word(p, ")");
69 if (bp->right)
70 term_word(p, bp->right);
71 if (EQNFONT_NONE != bp->font)
72 term_fontpop(p);
74 if (bp->next)
75 eqn_box(p, bp->next);