diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2008-11-25 16:49:57 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2008-11-25 16:49:57 +0000 |
commit | 984f70eeb4b5c4ef5ae5b30cf3ebda2c8e350d10 (patch) | |
tree | da989e2f1be307cc0987a0446e99279daf34b6fc /dummy.c | |
parent | cd382100edfa7077b2c4d42bae7af355e112d95b (diff) | |
download | mandoc-984f70eeb4b5c4ef5ae5b30cf3ebda2c8e350d10.tar.gz |
Imported all macros from mdoc(7).
Put all names into roff.c with extern access from private.h.
Annotated list of changes that must occur for end-game (scope, nests, etc.).
Diffstat (limited to 'dummy.c')
-rw-r--r-- | dummy.c | 63 |
1 files changed, 41 insertions, 22 deletions
@@ -25,7 +25,7 @@ #include "libmdocml.h" #include "private.h" -#ifdef __Linux__ +#ifdef __linux__ #define strlcat strncat #endif @@ -34,31 +34,35 @@ 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_prologue(const char *); +static void dbg_epilogue(void); static int dbg_lvl = 0; +static char dbg_line[72]; struct md_dummy { struct rofftree *tree; }; -static const char *const toknames[ROFF_MAX] = ROFF_NAMES; - - static void -dbg_indent(void) +dbg_prologue(const char *p) { - char buf[128]; - int i; - - *buf = 0; - assert(dbg_lvl >= 0); + int i; + (void)snprintf(dbg_line, sizeof(dbg_line) - 1, "%6s", p); + (void)strlcat(dbg_line, ": ", sizeof(dbg_line) - 1); /* LINTED */ 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); } @@ -66,8 +70,10 @@ static int md_dummy_blk_in(int tok) { - dbg_indent(); - (void)printf("%s\n", toknames[tok]); + dbg_prologue("blk"); + (void)strlcat(dbg_line, toknames[tok], sizeof(dbg_line) - 1); + dbg_epilogue(); + dbg_lvl++; return(1); } @@ -77,10 +83,7 @@ static int md_dummy_blk_out(int tok) { - assert(dbg_lvl > 0); dbg_lvl--; - dbg_indent(); - (void)printf("%s\n", toknames[tok]); return(1); } @@ -90,8 +93,26 @@ static int md_dummy_text_in(int tok, int *argcp, char **argvp) { - dbg_indent(); - (void)printf("%s\n", toknames[tok]); + dbg_prologue("text"); + (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); } @@ -100,8 +121,6 @@ static int md_dummy_text_out(int tok) { - dbg_indent(); - (void)printf("%s\n", toknames[tok]); return(1); } |