summaryrefslogtreecommitdiffstatshomepage
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
commiteae8f4ff2cd357d92c5e6aa901cf82cc4d344470 (patch)
tree9643abd856c3d831edcab779e5dbf9e0ade9912f /man_macro.c
parentca91d8f3ace59249bb9ba5e96567d230e6a0afde (diff)
downloadmandoc-eae8f4ff2cd357d92c5e6aa901cf82cc4d344470.tar.gz
mandoc-eae8f4ff2cd357d92c5e6aa901cf82cc4d344470.tar.zst
mandoc-eae8f4ff2cd357d92c5e6aa901cf82cc4d344470.zip
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..0c35903a
--- /dev/null
+++ b/man_macro.c
@@ -0,0 +1,96 @@
+/* $Id: man_macro.c,v 1.1 2009/03/23 14:22:11 kristaps Exp $ */
+/*
+ * 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);
+}
+