summaryrefslogtreecommitdiffstatshomepage
path: root/man_macro.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-03-26 14:38:11 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-03-26 14:38:11 +0000
commit080c584ff1e9cef269b4c220a099f4fb842e538c (patch)
tree3b391a36b2f109f2e19383efa85879f863c45b12 /man_macro.c
parentfd67adbb53e1be77e0cebd2f9e4c50c1c643cb72 (diff)
downloadmandoc-080c584ff1e9cef269b4c220a099f4fb842e538c.tar.gz
mandoc-080c584ff1e9cef269b4c220a099f4fb842e538c.tar.zst
mandoc-080c584ff1e9cef269b4c220a099f4fb842e538c.zip
Initial front-end formatting for -man pages.
Diffstat (limited to 'man_macro.c')
-rw-r--r--man_macro.c44
1 files changed, 43 insertions, 1 deletions
diff --git a/man_macro.c b/man_macro.c
index 70b3a912..9af77c6b 100644
--- a/man_macro.c
+++ b/man_macro.c
@@ -1,4 +1,4 @@
-/* $Id: man_macro.c,v 1.8 2009/03/26 11:16:21 kristaps Exp $ */
+/* $Id: man_macro.c,v 1.9 2009/03/26 14:38:11 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@openbsd.org>
*
@@ -24,9 +24,35 @@
#include "libman.h"
+#define FL_NLINE (1 << 0)
+#define FL_TLINE (1 << 1)
+
static int man_args(struct man *, int,
int *, char *, char **);
+static int man_flags[MAN_MAX] = {
+ 0, /* __ */
+ 0, /* TH */
+ 0, /* SH */
+ 0, /* SS */
+ FL_TLINE, /* TP */
+ 0, /* LP */
+ 0, /* PP */
+ 0, /* P */
+ 0, /* IP */
+ 0, /* HP */
+ FL_NLINE, /* SM */
+ FL_NLINE, /* SB */
+ FL_NLINE, /* BI */
+ FL_NLINE, /* IB */
+ FL_NLINE, /* BR */
+ FL_NLINE, /* RB */
+ FL_NLINE, /* R */
+ FL_NLINE, /* B */
+ FL_NLINE, /* I */
+ FL_NLINE, /* IR */
+ FL_NLINE, /* RI */
+};
int
man_macro(struct man *man, int tok, int line,
@@ -55,6 +81,22 @@ man_macro(struct man *man, int tok, int line,
man->next = MAN_NEXT_SIBLING;
}
+ if (n == man->last && (FL_NLINE & man_flags[tok])) {
+ if (MAN_NLINE & man->flags)
+ return(man_verr(man, line, ppos,
+ "next-line scope already open"));
+ man->flags |= MAN_NLINE;
+ return(1);
+ }
+
+ if (FL_TLINE & man_flags[tok]) {
+ if (MAN_NLINE & man->flags)
+ return(man_verr(man, line, ppos,
+ "next-line scope already open"));
+ man->flags |= MAN_NLINE;
+ return(1);
+ }
+
/*
* Note that when TH is pruned, we'll be back at the root, so
* make sure that we don't clobber as its sibling.