version 1.162, 2010/08/08 14:51:32 |
version 1.164, 2010/08/29 11:29:51 |
Line 98 static int node_append(struct mdoc *, |
|
Line 98 static int node_append(struct mdoc *, |
|
struct mdoc_node *); |
struct mdoc_node *); |
static int mdoc_ptext(struct mdoc *, int, char *, int); |
static int mdoc_ptext(struct mdoc *, int, char *, int); |
static int mdoc_pmacro(struct mdoc *, int, char *, int); |
static int mdoc_pmacro(struct mdoc *, int, char *, int); |
static int macrowarn(struct mdoc *, int, |
|
const char *, int); |
|
|
|
|
|
const struct mdoc_node * |
const struct mdoc_node * |
Line 191 mdoc_free(struct mdoc *mdoc) |
|
Line 189 mdoc_free(struct mdoc *mdoc) |
|
* Allocate volatile and non-volatile parse resources. |
* Allocate volatile and non-volatile parse resources. |
*/ |
*/ |
struct mdoc * |
struct mdoc * |
mdoc_alloc(struct regset *regs, void *data, |
mdoc_alloc(struct regset *regs, void *data, mandocmsg msg) |
int pflags, mandocmsg msg) |
|
{ |
{ |
struct mdoc *p; |
struct mdoc *p; |
|
|
Line 200 mdoc_alloc(struct regset *regs, void *data, |
|
Line 197 mdoc_alloc(struct regset *regs, void *data, |
|
|
|
p->msg = msg; |
p->msg = msg; |
p->data = data; |
p->data = data; |
p->pflags = pflags; |
|
p->regs = regs; |
p->regs = regs; |
|
|
mdoc_hash_init(); |
mdoc_hash_init(); |
Line 727 mdoc_ptext(struct mdoc *m, int line, char *buf, int of |
|
Line 723 mdoc_ptext(struct mdoc *m, int line, char *buf, int of |
|
} |
} |
|
|
|
|
static int |
|
macrowarn(struct mdoc *m, int ln, const char *buf, int offs) |
|
{ |
|
int rc; |
|
|
|
rc = mdoc_vmsg(m, MANDOCERR_MACRO, ln, offs, |
|
"unknown macro: %s%s", |
|
buf, strlen(buf) > 3 ? "..." : ""); |
|
|
|
/* FIXME: logic should be in driver. */ |
|
/* FIXME: broken, will error out and not omit a message. */ |
|
return(MDOC_IGN_MACRO & m->pflags ? rc : 0); |
|
} |
|
|
|
|
|
/* |
/* |
* 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 777 mdoc_pmacro(struct mdoc *m, int ln, char *buf, int off |
|
Line 758 mdoc_pmacro(struct mdoc *m, int ln, char *buf, int off |
|
|
|
/* |
/* |
* Copy the first word into a nil-terminated buffer. |
* Copy the first word into a nil-terminated buffer. |
* Stop copying when a tab, space, or eoln is encountered. |
* Stop copying when a tab, space, backslash, or eoln is encountered. |
*/ |
*/ |
|
|
j = 0; |
j = 0; |
while (j < 4 && '\0' != buf[i] && ' ' != buf[i] && '\t' != buf[i]) |
while (j < 4 && '\0' != buf[i] && |
|
' ' != buf[i] && |
|
'\t' != buf[i] && |
|
'\\' != buf[i]) |
mac[j++] = buf[i++]; |
mac[j++] = buf[i++]; |
mac[j] = '\0'; |
mac[j] = '\0'; |
|
|
if (j == 4 || j < 2) { |
tok = (j > 1 || j < 4) ? mdoc_hash_find(mac) : MDOC_MAX; |
if ( ! macrowarn(m, ln, mac, sv)) |
if (MDOC_MAX == tok) { |
goto err; |
mdoc_vmsg(m, MANDOCERR_MACRO, ln, sv, |
return(1); |
"unknown macro: %s%s", |
} |
buf, strlen(buf) > 3 ? "..." : ""); |
|
|
if (MDOC_MAX == (tok = mdoc_hash_find(mac))) { |
|
if ( ! macrowarn(m, ln, mac, sv)) |
|
goto err; |
|
return(1); |
return(1); |
} |
} |
|
|