aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/dummy.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2008-11-25 12:14:02 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2008-11-25 12:14:02 +0000
commit9a10478e2be49a9146c290e65a6a5548490ab33e (patch)
tree1def9ff946331e9110cf3acf69158f83762d13f1 /dummy.c
parent3a3ae57b081ac2a9e8f62c99114b31267dd7ac88 (diff)
downloadmandoc-9a10478e2be49a9146c290e65a6a5548490ab33e.tar.gz
mandoc-9a10478e2be49a9146c290e65a6a5548490ab33e.tar.zst
mandoc-9a10478e2be49a9146c290e65a6a5548490ab33e.zip
Single call-back for filters.
Removed verbose flag. Added more macros and arguments.
Diffstat (limited to 'dummy.c')
-rw-r--r--dummy.c50
1 files changed, 23 insertions, 27 deletions
diff --git a/dummy.c b/dummy.c
index 89b8f46b..54577153 100644
--- a/dummy.c
+++ b/dummy.c
@@ -1,4 +1,4 @@
-/* $Id: dummy.c,v 1.4 2008/11/24 18:32:39 kristaps Exp $ */
+/* $Id: dummy.c,v 1.5 2008/11/25 12:14:02 kristaps Exp $ */
/*
* Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -25,25 +25,25 @@
#include "libmdocml.h"
#include "private.h"
+#ifdef __Linux__
+#define strlcat strncat
+#endif
-static roffin in[ROFF_MAX];
-static roffout out[ROFF_MAX];
-static roffblkin blkin[ROFF_MAX];
-static roffblkout blkout[ROFF_MAX];
+static int md_dummy_blk_in(int);
+static int md_dummy_blk_out(int);
+static int md_dummy_text_in(int, int *, char **);
+static int md_dummy_text_out(int);
-static int md_dummy_blk_in(int);
-static int md_dummy_blk_out(int);
-static int md_dummy_text_in(int, int *, char **);
-static int md_dummy_text_out(int);
+static void dbg_indent(void);
-static void dbg_indent(void);
-
-static int dbg_lvl = 0;
+static int dbg_lvl = 0;
struct md_dummy {
struct rofftree *tree;
};
+static const char *const toknames[ROFF_MAX] = ROFF_NAMES;
+
static void
dbg_indent(void)
@@ -53,8 +53,10 @@ dbg_indent(void)
*buf = 0;
assert(dbg_lvl >= 0);
+
+ /* LINTED */
for (i = 0; i < dbg_lvl; i++)
- (void)strncat(buf, " ", sizeof(buf) - 1);
+ (void)strlcat(buf, " ", sizeof(buf) - 1);
(void)printf("%s", buf);
}
@@ -65,7 +67,7 @@ md_dummy_blk_in(int tok)
{
dbg_indent();
- (void)printf("+++blk\n");
+ (void)printf("%s\n", toknames[tok]);
dbg_lvl++;
return(1);
}
@@ -78,17 +80,18 @@ md_dummy_blk_out(int tok)
assert(dbg_lvl > 0);
dbg_lvl--;
dbg_indent();
- (void)printf("---blk\n");
+ (void)printf("%s\n", toknames[tok]);
return(1);
}
+/* ARGSUSED */
static int
md_dummy_text_in(int tok, int *argcp, char **argvp)
{
dbg_indent();
- (void)printf("in: text\n");
+ (void)printf("%s\n", toknames[tok]);
return(1);
}
@@ -98,7 +101,7 @@ md_dummy_text_out(int tok)
{
dbg_indent();
- (void)printf("out: text\n");
+ (void)printf("%s\n", toknames[tok]);
return(1);
}
@@ -132,22 +135,15 @@ md_init_dummy(const struct md_args *args,
struct md_mbuf *mbuf, const struct md_rbuf *rbuf)
{
struct md_dummy *p;
- int i;
-
- for (i = 0; i < ROFF_MAX; i++) {
- in[i] = md_dummy_text_in;
- out[i] = md_dummy_text_out;
- blkin[i] = md_dummy_blk_in;
- blkout[i] = md_dummy_blk_out;
- }
if (NULL == (p = malloc(sizeof(struct md_dummy)))) {
warn("malloc");
return(NULL);
}
- p->tree = roff_alloc
- (args, mbuf, rbuf, in, out, blkin, blkout);
+ p->tree = roff_alloc(args, mbuf, rbuf,
+ md_dummy_text_in, md_dummy_text_out,
+ md_dummy_blk_in, md_dummy_blk_out);
if (NULL == p->tree) {
free(p);