version 1.61, 2015/02/03 18:37:59 |
version 1.63, 2015/04/02 21:36:51 |
|
|
* purpose with or without fee is hereby granted, provided that the above |
* purpose with or without fee is hereby granted, provided that the above |
* copyright notice and this permission notice appear in all copies. |
* copyright notice and this permission notice appear in all copies. |
* |
* |
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES |
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR |
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
|
|
#include <time.h> |
#include <time.h> |
|
|
#include "mandoc.h" |
#include "mandoc.h" |
|
#include "roff.h" |
#include "mdoc.h" |
#include "mdoc.h" |
#include "man.h" |
#include "man.h" |
#include "main.h" |
#include "main.h" |
Line 66 print_mdoc(const struct mdoc_node *n, int indent) |
|
Line 67 print_mdoc(const struct mdoc_node *n, int indent) |
|
t = p = NULL; |
t = p = NULL; |
|
|
switch (n->type) { |
switch (n->type) { |
case MDOC_ROOT: |
case ROFFT_ROOT: |
t = "root"; |
t = "root"; |
break; |
break; |
case MDOC_BLOCK: |
case ROFFT_BLOCK: |
t = "block"; |
t = "block"; |
break; |
break; |
case MDOC_HEAD: |
case ROFFT_HEAD: |
t = "block-head"; |
t = "block-head"; |
break; |
break; |
case MDOC_BODY: |
case ROFFT_BODY: |
if (n->end) |
if (n->end) |
t = "body-end"; |
t = "body-end"; |
else |
else |
t = "block-body"; |
t = "block-body"; |
break; |
break; |
case MDOC_TAIL: |
case ROFFT_TAIL: |
t = "block-tail"; |
t = "block-tail"; |
break; |
break; |
case MDOC_ELEM: |
case ROFFT_ELEM: |
t = "elem"; |
t = "elem"; |
break; |
break; |
case MDOC_TEXT: |
case ROFFT_TEXT: |
t = "text"; |
t = "text"; |
break; |
break; |
case MDOC_TBL: |
case ROFFT_TBL: |
break; |
break; |
case MDOC_EQN: |
case ROFFT_EQN: |
t = "eqn"; |
t = "eqn"; |
break; |
break; |
default: |
default: |
Line 101 print_mdoc(const struct mdoc_node *n, int indent) |
|
Line 102 print_mdoc(const struct mdoc_node *n, int indent) |
|
} |
} |
|
|
switch (n->type) { |
switch (n->type) { |
case MDOC_TEXT: |
case ROFFT_TEXT: |
p = n->string; |
p = n->string; |
break; |
break; |
case MDOC_BODY: |
case ROFFT_BODY: |
p = mdoc_macronames[n->tok]; |
p = mdoc_macronames[n->tok]; |
break; |
break; |
case MDOC_HEAD: |
case ROFFT_HEAD: |
p = mdoc_macronames[n->tok]; |
p = mdoc_macronames[n->tok]; |
break; |
break; |
case MDOC_TAIL: |
case ROFFT_TAIL: |
p = mdoc_macronames[n->tok]; |
p = mdoc_macronames[n->tok]; |
break; |
break; |
case MDOC_ELEM: |
case ROFFT_ELEM: |
p = mdoc_macronames[n->tok]; |
p = mdoc_macronames[n->tok]; |
if (n->args) { |
if (n->args) { |
argv = n->args->argv; |
argv = n->args->argv; |
argc = n->args->argc; |
argc = n->args->argc; |
} |
} |
break; |
break; |
case MDOC_BLOCK: |
case ROFFT_BLOCK: |
p = mdoc_macronames[n->tok]; |
p = mdoc_macronames[n->tok]; |
if (n->args) { |
if (n->args) { |
argv = n->args->argv; |
argv = n->args->argv; |
argc = n->args->argc; |
argc = n->args->argc; |
} |
} |
break; |
break; |
case MDOC_TBL: |
case ROFFT_TBL: |
break; |
break; |
case MDOC_EQN: |
case ROFFT_EQN: |
p = "EQ"; |
p = "EQ"; |
break; |
break; |
case MDOC_ROOT: |
case ROFFT_ROOT: |
p = "root"; |
p = "root"; |
break; |
break; |
default: |
default: |
Line 162 print_mdoc(const struct mdoc_node *n, int indent) |
|
Line 163 print_mdoc(const struct mdoc_node *n, int indent) |
|
putchar(' '); |
putchar(' '); |
if (MDOC_LINE & n->flags) |
if (MDOC_LINE & n->flags) |
putchar('*'); |
putchar('*'); |
printf("%d:%d", n->line, n->pos + 1); |
printf("%d:%d\n", n->line, n->pos + 1); |
if (n->lastline != n->line) |
|
printf("-%d", n->lastline); |
|
putchar('\n'); |
|
} |
} |
|
|
if (n->eqn) |
if (n->eqn) |
print_box(n->eqn->root->first, indent + 4); |
print_box(n->eqn->root->first, indent + 4); |
if (n->child) |
if (n->child) |
print_mdoc(n->child, indent + |
print_mdoc(n->child, indent + |
(n->type == MDOC_BLOCK ? 2 : 4)); |
(n->type == ROFFT_BLOCK ? 2 : 4)); |
if (n->next) |
if (n->next) |
print_mdoc(n->next, indent); |
print_mdoc(n->next, indent); |
} |
} |
Line 189 print_man(const struct man_node *n, int indent) |
|
Line 187 print_man(const struct man_node *n, int indent) |
|
t = p = NULL; |
t = p = NULL; |
|
|
switch (n->type) { |
switch (n->type) { |
case MAN_ROOT: |
case ROFFT_ROOT: |
t = "root"; |
t = "root"; |
break; |
break; |
case MAN_ELEM: |
case ROFFT_ELEM: |
t = "elem"; |
t = "elem"; |
break; |
break; |
case MAN_TEXT: |
case ROFFT_TEXT: |
t = "text"; |
t = "text"; |
break; |
break; |
case MAN_BLOCK: |
case ROFFT_BLOCK: |
t = "block"; |
t = "block"; |
break; |
break; |
case MAN_HEAD: |
case ROFFT_HEAD: |
t = "block-head"; |
t = "block-head"; |
break; |
break; |
case MAN_BODY: |
case ROFFT_BODY: |
t = "block-body"; |
t = "block-body"; |
break; |
break; |
case MAN_TBL: |
case ROFFT_TBL: |
break; |
break; |
case MAN_EQN: |
case ROFFT_EQN: |
t = "eqn"; |
t = "eqn"; |
break; |
break; |
default: |
default: |
Line 218 print_man(const struct man_node *n, int indent) |
|
Line 216 print_man(const struct man_node *n, int indent) |
|
} |
} |
|
|
switch (n->type) { |
switch (n->type) { |
case MAN_TEXT: |
case ROFFT_TEXT: |
p = n->string; |
p = n->string; |
break; |
break; |
case MAN_ELEM: |
case ROFFT_ELEM: |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case MAN_BLOCK: |
case ROFFT_BLOCK: |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case MAN_HEAD: |
case ROFFT_HEAD: |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case MAN_BODY: |
case ROFFT_BODY: |
p = man_macronames[n->tok]; |
p = man_macronames[n->tok]; |
break; |
break; |
case MAN_ROOT: |
case ROFFT_ROOT: |
p = "root"; |
p = "root"; |
break; |
break; |
case MAN_TBL: |
case ROFFT_TBL: |
break; |
break; |
case MAN_EQN: |
case ROFFT_EQN: |
p = "EQ"; |
p = "EQ"; |
break; |
break; |
default: |
default: |
Line 259 print_man(const struct man_node *n, int indent) |
|
Line 257 print_man(const struct man_node *n, int indent) |
|
print_box(n->eqn->root->first, indent + 4); |
print_box(n->eqn->root->first, indent + 4); |
if (n->child) |
if (n->child) |
print_man(n->child, indent + |
print_man(n->child, indent + |
(n->type == MAN_BLOCK ? 2 : 4)); |
(n->type == ROFFT_BLOCK ? 2 : 4)); |
if (n->next) |
if (n->next) |
print_man(n->next, indent); |
print_man(n->next, indent); |
} |
} |