version 1.54, 2009/03/08 12:40:27 |
version 1.60, 2009/03/09 14:19:59 |
Line 38 static int mdoc_node_append(struct mdoc *, |
|
Line 38 static int mdoc_node_append(struct mdoc *, |
|
|
|
static int parsetext(struct mdoc *, int, char *); |
static int parsetext(struct mdoc *, int, char *); |
static int parsemacro(struct mdoc *, int, char *); |
static int parsemacro(struct mdoc *, int, char *); |
|
static int macrowarn(struct mdoc *, int, const char *); |
|
|
|
|
const char *const __mdoc_macronames[MDOC_MAX] = { |
const char *const __mdoc_macronames[MDOC_MAX] = { |
Line 70 const char *const __mdoc_macronames[MDOC_MAX] = { |
|
Line 71 const char *const __mdoc_macronames[MDOC_MAX] = { |
|
"Tn", "Ux", "Xc", "Xo", |
"Tn", "Ux", "Xc", "Xo", |
"Fo", "Fc", "Oo", "Oc", |
"Fo", "Fc", "Oo", "Oc", |
"Bk", "Ek", "Bt", "Hf", |
"Bk", "Ek", "Bt", "Hf", |
"Fr", "Ud", "Lb", |
"Fr", "Ud", "Lb", "Ap", |
|
"Lp", "Lk", "Mt" |
}; |
}; |
|
|
const char *const __mdoc_argnames[MDOC_ARG_MAX] = { |
const char *const __mdoc_argnames[MDOC_ARG_MAX] = { |
Line 129 mdoc_free(struct mdoc *mdoc) |
|
Line 131 mdoc_free(struct mdoc *mdoc) |
|
|
|
|
|
struct mdoc * |
struct mdoc * |
mdoc_alloc(void *data, const struct mdoc_cb *cb) |
mdoc_alloc(void *data, int pflags, const struct mdoc_cb *cb) |
{ |
{ |
struct mdoc *p; |
struct mdoc *p; |
|
|
Line 142 mdoc_alloc(void *data, const struct mdoc_cb *cb) |
|
Line 144 mdoc_alloc(void *data, const struct mdoc_cb *cb) |
|
p->last = xcalloc(1, sizeof(struct mdoc_node)); |
p->last = xcalloc(1, sizeof(struct mdoc_node)); |
p->last->type = MDOC_ROOT; |
p->last->type = MDOC_ROOT; |
p->first = p->last; |
p->first = p->last; |
|
p->pflags = pflags; |
p->next = MDOC_NEXT_CHILD; |
p->next = MDOC_NEXT_CHILD; |
p->htab = mdoc_tokhash_alloc(); |
p->htab = mdoc_tokhash_alloc(); |
|
|
Line 494 parsetext(struct mdoc *mdoc, int line, char *buf) |
|
Line 496 parsetext(struct mdoc *mdoc, int line, char *buf) |
|
} |
} |
|
|
|
|
|
static int |
|
macrowarn(struct mdoc *m, int ln, const char *buf) |
|
{ |
|
if ( ! (MDOC_IGN_MACRO & m->pflags)) |
|
return(mdoc_perr(m, ln, 1, "unknown macro: %s%s", |
|
buf, strlen(buf) > 3 ? "..." : "")); |
|
return(mdoc_pwarn(m, ln, 1, WARN_SYNTAX, |
|
"unknown macro: %s%s", |
|
buf, strlen(buf) > 3 ? "..." : "")); |
|
} |
|
|
|
|
|
|
/* |
/* |
* Parse a macro line, that is, a line beginning with the control |
* Parse a macro line, that is, a line beginning with the control |
* character. |
* character. |
Line 524 parsemacro(struct mdoc *m, int ln, char *buf) |
|
Line 539 parsemacro(struct mdoc *m, int ln, char *buf) |
|
mac[i - 1] = 0; |
mac[i - 1] = 0; |
|
|
if (i == 5 || i <= 2) { |
if (i == 5 || i <= 2) { |
(void)mdoc_perr(m, ln, 1, "unknown macro: %s%s", |
if ( ! macrowarn(m, ln, mac)) |
mac, i == 5 ? "..." : ""); |
goto err; |
goto err; |
return(1); |
} |
} |
|
|
if (MDOC_MAX == (c = mdoc_tokhash_find(m->htab, mac))) { |
if (MDOC_MAX == (c = mdoc_tokhash_find(m->htab, mac))) { |
(void)mdoc_perr(m, ln, 1, "unknown macro: %s", mac); |
if ( ! macrowarn(m, ln, mac)) |
goto err; |
goto err; |
|
return(1); |
} |
} |
|
|
/* The macro is sane. Jump to the next word. */ |
/* The macro is sane. Jump to the next word. */ |