version 1.5, 2008/11/25 12:14:02 |
version 1.6, 2008/11/25 16:49:57 |
|
|
#include "libmdocml.h" |
#include "libmdocml.h" |
#include "private.h" |
#include "private.h" |
|
|
#ifdef __Linux__ |
#ifdef __linux__ |
#define strlcat strncat |
#define strlcat strncat |
#endif |
#endif |
|
|
Line 34 static int md_dummy_blk_out(int); |
|
Line 34 static int md_dummy_blk_out(int); |
|
static int md_dummy_text_in(int, int *, char **); |
static int md_dummy_text_in(int, int *, char **); |
static int md_dummy_text_out(int); |
static int md_dummy_text_out(int); |
|
|
static void dbg_indent(void); |
static void dbg_prologue(const char *); |
|
static void dbg_epilogue(void); |
|
|
static int dbg_lvl = 0; |
static int dbg_lvl = 0; |
|
static char dbg_line[72]; |
|
|
struct md_dummy { |
struct md_dummy { |
struct rofftree *tree; |
struct rofftree *tree; |
}; |
}; |
|
|
static const char *const toknames[ROFF_MAX] = ROFF_NAMES; |
|
|
|
|
|
static void |
static void |
dbg_indent(void) |
dbg_prologue(const char *p) |
{ |
{ |
char buf[128]; |
int i; |
int i; |
|
|
|
*buf = 0; |
(void)snprintf(dbg_line, sizeof(dbg_line) - 1, "%6s", p); |
assert(dbg_lvl >= 0); |
(void)strlcat(dbg_line, ": ", sizeof(dbg_line) - 1); |
|
|
/* LINTED */ |
/* LINTED */ |
for (i = 0; i < dbg_lvl; i++) |
for (i = 0; i < dbg_lvl; i++) |
(void)strlcat(buf, " ", sizeof(buf) - 1); |
(void)strlcat(dbg_line, " ", sizeof(dbg_line) - 1); |
|
} |
|
|
(void)printf("%s", buf); |
|
|
static void |
|
dbg_epilogue(void) |
|
{ |
|
|
|
assert(0 != dbg_line[0]); |
|
(void)printf("%s\n", dbg_line); |
} |
} |
|
|
|
|
|
|
md_dummy_blk_in(int tok) |
md_dummy_blk_in(int tok) |
{ |
{ |
|
|
dbg_indent(); |
dbg_prologue("blk"); |
(void)printf("%s\n", toknames[tok]); |
(void)strlcat(dbg_line, toknames[tok], sizeof(dbg_line) - 1); |
|
dbg_epilogue(); |
|
|
dbg_lvl++; |
dbg_lvl++; |
return(1); |
return(1); |
} |
} |
|
|
md_dummy_blk_out(int tok) |
md_dummy_blk_out(int tok) |
{ |
{ |
|
|
assert(dbg_lvl > 0); |
|
dbg_lvl--; |
dbg_lvl--; |
dbg_indent(); |
|
(void)printf("%s\n", toknames[tok]); |
|
return(1); |
return(1); |
} |
} |
|
|
|
|
md_dummy_text_in(int tok, int *argcp, char **argvp) |
md_dummy_text_in(int tok, int *argcp, char **argvp) |
{ |
{ |
|
|
dbg_indent(); |
dbg_prologue("text"); |
(void)printf("%s\n", toknames[tok]); |
(void)strlcat(dbg_line, toknames[tok], sizeof(dbg_line) - 1); |
|
(void)strlcat(dbg_line, " ", sizeof(dbg_line) - 1); |
|
while (ROFF_ARGMAX != *argcp) { |
|
(void)strlcat(dbg_line, "[", sizeof(dbg_line) - 1); |
|
(void)strlcat(dbg_line, tokargnames[*argcp], |
|
sizeof(dbg_line) - 1); |
|
if (*argvp) { |
|
(void)strlcat(dbg_line, " [", |
|
sizeof(dbg_line) - 1); |
|
(void)strlcat(dbg_line, *argvp, |
|
sizeof(dbg_line) - 1); |
|
(void)strlcat(dbg_line, "]", |
|
sizeof(dbg_line) - 1); |
|
} |
|
(void)strlcat(dbg_line, "]", sizeof(dbg_line) - 1); |
|
argcp++; |
|
argvp++; |
|
} |
|
dbg_epilogue(); |
return(1); |
return(1); |
} |
} |
|
|
|
|
md_dummy_text_out(int tok) |
md_dummy_text_out(int tok) |
{ |
{ |
|
|
dbg_indent(); |
|
(void)printf("%s\n", toknames[tok]); |
|
return(1); |
return(1); |
} |
} |
|
|