summaryrefslogtreecommitdiffstatshomepage
path: root/man.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-03-25 21:03:13 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-03-25 21:03:13 +0000
commit5fa47110bac19f7e6acb9a32e76e800657e98799 (patch)
tree2bd4eb2226886e1111eae629e521300216c8ae1b /man.c
parent55683ede1843a9c3cea8cdfa0349f7364140d61e (diff)
downloadmandoc-5fa47110bac19f7e6acb9a32e76e800657e98799.tar.gz
mandoc-5fa47110bac19f7e6acb9a32e76e800657e98799.tar.zst
mandoc-5fa47110bac19f7e6acb9a32e76e800657e98799.zip
Added pflags to man_alloc.
Abstract fflags -> pflags in main.c.
Diffstat (limited to 'man.c')
-rw-r--r--man.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/man.c b/man.c
index 4b20b728..21c15e71 100644
--- a/man.c
+++ b/man.c
@@ -1,4 +1,4 @@
-/* $Id: man.c,v 1.6 2009/03/25 16:07:36 kristaps Exp $ */
+/* $Id: man.c,v 1.7 2009/03/25 21:03:13 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@openbsd.org>
*
@@ -18,7 +18,6 @@
*/
#include <assert.h>
#include <ctype.h>
-#include <err.h>
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
@@ -83,7 +82,7 @@ man_free(struct man *man)
struct man *
-man_alloc(void *data, const struct man_cb *cb)
+man_alloc(void *data, int pflags, const struct man_cb *cb)
{
struct man *p;
@@ -98,6 +97,8 @@ man_alloc(void *data, const struct man_cb *cb)
p->htab = man_hash_alloc();
p->data = data;
+ p->pflags = pflags;
+
return(p);
}
@@ -287,8 +288,7 @@ man_pmacro(struct man *m, int ln, char *buf)
i++;
if (0 == buf[i])
return(1);
- warnx("invalid syntax");
- return(0);
+ return(man_vwarn(m, ln, 0, "invalid syntax"));
}
if (buf[1] && '\\' == buf[1])
@@ -307,13 +307,25 @@ man_pmacro(struct man *m, int ln, char *buf)
mac[i - 1] = 0;
if (i == 5 || i <= 1) {
- warnx("unknown macro: %s", mac);
- goto err;
- }
+ if ( ! (MAN_IGN_MACRO & m->pflags)) {
+ (void)man_verr(m, ln, 1,
+ "ill-formed macro: %s", mac);
+ goto err;
+ }
+ if ( ! man_vwarn(m, ln, 1, "ill-formed macro: %s", mac))
+ goto err;
+ return(1);
+ }
if (MAN_MAX == (c = man_hash_find(m->htab, mac))) {
- warnx("unknown macro: %s", mac);
- goto err;
+ if ( ! (MAN_IGN_MACRO & m->pflags)) {
+ (void)man_verr(m, ln, 1,
+ "unknown macro: %s", mac);
+ goto err;
+ }
+ if ( ! man_vwarn(m, ln, 1, "unknown macro: %s", mac))
+ goto err;
+ return(1);
}
/* The macro is sane. Jump to the next word. */