summaryrefslogtreecommitdiffstats
path: root/man_macro.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-03-23 14:22:11 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-03-23 14:22:11 +0000
commitdc4e5ca1c9fd9bd34e243dcdb884af02102c9389 (patch)
tree78f2d3ac00100e778e6832933da1ace2dab9e080 /man_macro.c
parentd4dba4479e3ed55fdc52b75eab00afe7ad78d5f0 (diff)
downloadmandoc-dc4e5ca1c9fd9bd34e243dcdb884af02102c9389.tar.gz
First addition of -man macro support.
Abstraction of mdoc.
Diffstat (limited to 'man_macro.c')
-rw-r--r--man_macro.c96
1 files changed, 96 insertions, 0 deletions
diff --git a/man_macro.c b/man_macro.c
new file mode 100644
index 00000000..915c29e6
--- /dev/null
+++ b/man_macro.c
@@ -0,0 +1,96 @@
+/* $Id$ */
+/*
+ * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the
+ * above copyright notice and this permission notice appear in all
+ * copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
+ * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+#include <assert.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "libman.h"
+
+static int in_line_eoln(MACRO_PROT_ARGS);
+
+const struct man_macro __man_macros[MAN_MAX] = {
+ { in_line_eoln, NULL }, /* MAN___ */
+ { in_line_eoln, NULL }, /* MAN_TH */
+ { in_line_eoln, NULL }, /* MAN_SH */
+ { in_line_eoln, NULL }, /* MAN_SS */
+ { in_line_eoln, NULL }, /* MAN_TP */
+ { in_line_eoln, NULL }, /* MAN_LP */
+ { in_line_eoln, NULL }, /* MAN_PP */
+ { in_line_eoln, NULL }, /* MAN_P */
+ { in_line_eoln, NULL }, /* MAN_IP */
+ { in_line_eoln, NULL }, /* MAN_HP */
+ { in_line_eoln, NULL }, /* MAN_SM */
+ { in_line_eoln, NULL }, /* MAN_SB */
+ { in_line_eoln, NULL }, /* MAN_BI */
+ { in_line_eoln, NULL }, /* MAN_IB */
+ { in_line_eoln, NULL }, /* MAN_BR */
+ { in_line_eoln, NULL }, /* MAN_RB */
+ { in_line_eoln, NULL }, /* MAN_R */
+ { in_line_eoln, NULL }, /* MAN_B */
+ { in_line_eoln, NULL }, /* MAN_I */
+};
+
+const struct man_macro * const man_macros = __man_macros;
+
+
+/*
+ * In-line macro that spans an entire line. May be callable, but has no
+ * subsequent parsed arguments.
+ */
+static int
+in_line_eoln(MACRO_PROT_ARGS)
+{
+#if 0
+ int c, w, la;
+ char *p;
+
+ if ( ! man_elem_alloc(man, line, ppos, tok, arg))
+ return(0);
+ man->next = MDOC_NEXT_SIBLING;
+
+ for (;;) {
+ la = *pos;
+ w = man_args(man, line, pos, buf, tok, &p);
+
+ if (ARGS_ERROR == w)
+ return(0);
+ if (ARGS_EOLN == w)
+ break;
+
+ c = ARGS_QWORD == w ? MAN_MAX :
+ lookup(man, line, la, tok, p);
+
+ if (MDOC_MAX != c && -1 != c) {
+ if ( ! rew_elem(mdoc, tok))
+ return(0);
+ return(mdoc_macro(mdoc, c, line, la, pos, buf));
+ } else if (-1 == c)
+ return(0);
+
+ if ( ! mdoc_word_alloc(mdoc, line, la, p))
+ return(0);
+ }
+
+ return(rew_elem(mdoc, tok));
+#endif
+ return(1);
+}
+