version 1.139, 2014/09/06 23:24:32 |
version 1.143, 2014/11/19 03:08:17 |
|
|
man_parseln(struct man *man, int ln, char *buf, int offs) |
man_parseln(struct man *man, int ln, char *buf, int offs) |
{ |
{ |
|
|
man->flags |= MAN_NEWLINE; |
if (man->last->type != MAN_EQN || ln > man->last->line) |
|
man->flags |= MAN_NEWLINE; |
|
|
return (roff_getcontrol(man->roff, buf, &offs) ? |
return (roff_getcontrol(man->roff, buf, &offs) ? |
man_pmacro(man, ln, buf, offs) : |
man_pmacro(man, ln, buf, offs) : |
Line 314 man_word_alloc(struct man *man, int line, int pos, con |
|
Line 315 man_word_alloc(struct man *man, int line, int pos, con |
|
return(1); |
return(1); |
} |
} |
|
|
|
void |
|
man_word_append(struct man *man, const char *word) |
|
{ |
|
struct man_node *n; |
|
char *addstr, *newstr; |
|
|
|
n = man->last; |
|
addstr = roff_strdup(man->roff, word); |
|
mandoc_asprintf(&newstr, "%s %s", n->string, addstr); |
|
free(addstr); |
|
free(n->string); |
|
n->string = newstr; |
|
man->next = MAN_NEXT_SIBLING; |
|
} |
|
|
/* |
/* |
* Free all of the resources held by a node. This does NOT unlink a |
* Free all of the resources held by a node. This does NOT unlink a |
* node from its context; for that, see man_node_unlink(). |
* node from its context; for that, see man_node_unlink(). |
Line 345 man_addeqn(struct man *man, const struct eqn *ep) |
|
Line 361 man_addeqn(struct man *man, const struct eqn *ep) |
|
|
|
n = man_node_alloc(man, ep->ln, ep->pos, MAN_EQN, MAN_MAX); |
n = man_node_alloc(man, ep->ln, ep->pos, MAN_EQN, MAN_MAX); |
n->eqn = ep; |
n->eqn = ep; |
|
if (ep->ln > man->last->line) |
|
n->flags |= MAN_LINE; |
|
|
if ( ! man_node_append(man, n)) |
if ( ! man_node_append(man, n)) |
return(0); |
return(0); |
Line 465 man_ptext(struct man *man, int line, char *buf, int of |
|
Line 483 man_ptext(struct man *man, int line, char *buf, int of |
|
static int |
static int |
man_pmacro(struct man *man, int ln, char *buf, int offs) |
man_pmacro(struct man *man, int ln, char *buf, int offs) |
{ |
{ |
char mac[5]; |
|
struct man_node *n; |
struct man_node *n; |
|
const char *cp; |
enum mant tok; |
enum mant tok; |
int i, ppos; |
int i, ppos; |
int bline; |
int bline; |
|
char mac[5]; |
|
|
ppos = offs; |
ppos = offs; |
|
|
/* |
/* |
* 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 when a space, tab, escape, or eoln is encountered. |
*/ |
*/ |
|
|
i = 0; |
i = 0; |
while (i < 4 && '\0' != buf[offs] && ' ' != buf[offs] && |
while (i < 4 && strchr(" \t\\", buf[offs]) == NULL) |
'\t' != buf[offs]) |
|
mac[i++] = buf[offs++]; |
mac[i++] = buf[offs++]; |
|
|
mac[i] = '\0'; |
mac[i] = '\0'; |
|
|
tok = (i > 0 && i < 4) ? man_hash_find(mac) : MAN_MAX; |
tok = (i > 0 && i < 4) ? man_hash_find(mac) : MAN_MAX; |
|
|
if (MAN_MAX == tok) { |
if (tok == MAN_MAX) { |
mandoc_msg(MANDOCERR_MACRO, man->parse, |
mandoc_msg(MANDOCERR_MACRO, man->parse, |
ln, ppos, buf + ppos - 1); |
ln, ppos, buf + ppos - 1); |
return(1); |
return(1); |
} |
} |
|
|
/* The macro is sane. Jump to the next word. */ |
/* Skip a leading escape sequence or tab. */ |
|
|
|
switch (buf[offs]) { |
|
case '\\': |
|
cp = buf + offs + 1; |
|
mandoc_escape(&cp, NULL, NULL); |
|
offs = cp - buf; |
|
break; |
|
case '\t': |
|
offs++; |
|
break; |
|
default: |
|
break; |
|
} |
|
|
|
/* Jump to the next non-whitespace word. */ |
|
|
while (buf[offs] && ' ' == buf[offs]) |
while (buf[offs] && ' ' == buf[offs]) |
offs++; |
offs++; |