]> git.cameronkatri.com Git - mandoc.git/blob - man_macro.c
Linux fixes.
[mandoc.git] / man_macro.c
1 /* $Id: man_macro.c,v 1.2 2009/03/23 14:31:58 kristaps Exp $ */
2 /*
3 * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@openbsd.org>
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the
7 * above copyright notice and this permission notice appear in all
8 * copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17 * PERFORMANCE OF THIS SOFTWARE.
18 */
19 #include <assert.h>
20 #include <ctype.h>
21 #include <stdlib.h>
22 #include <stdio.h>
23 #include <string.h>
24
25 #include "libman.h"
26
27 static int in_line_eoln(MACRO_PROT_ARGS);
28
29 const struct man_macro __man_macros[MAN_MAX] = {
30 { in_line_eoln, 0 }, /* MAN___ */
31 { in_line_eoln, 0 }, /* MAN_TH */
32 { in_line_eoln, 0 }, /* MAN_SH */
33 { in_line_eoln, 0 }, /* MAN_SS */
34 { in_line_eoln, 0 }, /* MAN_TP */
35 { in_line_eoln, 0 }, /* MAN_LP */
36 { in_line_eoln, 0 }, /* MAN_PP */
37 { in_line_eoln, 0 }, /* MAN_P */
38 { in_line_eoln, 0 }, /* MAN_IP */
39 { in_line_eoln, 0 }, /* MAN_HP */
40 { in_line_eoln, 0 }, /* MAN_SM */
41 { in_line_eoln, 0 }, /* MAN_SB */
42 { in_line_eoln, 0 }, /* MAN_BI */
43 { in_line_eoln, 0 }, /* MAN_IB */
44 { in_line_eoln, 0 }, /* MAN_BR */
45 { in_line_eoln, 0 }, /* MAN_RB */
46 { in_line_eoln, 0 }, /* MAN_R */
47 { in_line_eoln, 0 }, /* MAN_B */
48 { in_line_eoln, 0 }, /* MAN_I */
49 };
50
51 const struct man_macro * const man_macros = __man_macros;
52
53
54 /*
55 * In-line macro that spans an entire line. May be callable, but has no
56 * subsequent parsed arguments.
57 */
58 static int
59 in_line_eoln(MACRO_PROT_ARGS)
60 {
61 #if 0
62 int c, w, la;
63 char *p;
64
65 if ( ! man_elem_alloc(man, line, ppos, tok, arg))
66 return(0);
67 man->next = MDOC_NEXT_SIBLING;
68
69 for (;;) {
70 la = *pos;
71 w = man_args(man, line, pos, buf, tok, &p);
72
73 if (ARGS_ERROR == w)
74 return(0);
75 if (ARGS_EOLN == w)
76 break;
77
78 c = ARGS_QWORD == w ? MAN_MAX :
79 lookup(man, line, la, tok, p);
80
81 if (MDOC_MAX != c && -1 != c) {
82 if ( ! rew_elem(mdoc, tok))
83 return(0);
84 return(mdoc_macro(mdoc, c, line, la, pos, buf));
85 } else if (-1 == c)
86 return(0);
87
88 if ( ! mdoc_word_alloc(mdoc, line, la, p))
89 return(0);
90 }
91
92 return(rew_elem(mdoc, tok));
93 #endif
94 return(1);
95 }
96