version 1.249, 2015/04/19 14:25:41 |
version 1.252, 2015/04/23 16:17:44 |
Line 89 static int mdoc_ptext(struct roff_man *, int, char |
|
Line 89 static int mdoc_ptext(struct roff_man *, int, char |
|
static int mdoc_pmacro(struct roff_man *, int, char *, int); |
static int mdoc_pmacro(struct roff_man *, int, char *, int); |
|
|
|
|
void |
|
mdoc_endparse(struct roff_man *mdoc) |
|
{ |
|
|
|
mdoc_macroend(mdoc); |
|
} |
|
|
|
/* |
/* |
* Main parse routine. Parses a single line -- really just hands off to |
* Main parse routine. Parses a single line -- really just hands off to |
* the macro (mdoc_pmacro()) or text parser (mdoc_ptext()). |
* the macro (mdoc_pmacro()) or text parser (mdoc_ptext()). |
Line 329 mdoc_ptext(struct roff_man *mdoc, int line, char *buf, |
|
Line 322 mdoc_ptext(struct roff_man *mdoc, int line, char *buf, |
|
* blank lines aren't allowed, but enough manuals assume this |
* blank lines aren't allowed, but enough manuals assume this |
* behaviour that we want to work around it. |
* behaviour that we want to work around it. |
*/ |
*/ |
mdoc_elem_alloc(mdoc, line, offs, MDOC_sp, NULL); |
roff_elem_alloc(mdoc, line, offs, MDOC_sp); |
mdoc->next = ROFF_NEXT_SIBLING; |
mdoc->next = ROFF_NEXT_SIBLING; |
mdoc_valid_post(mdoc); |
mdoc_valid_post(mdoc); |
return(1); |
return(1); |
Line 513 mdoc_isdelim(const char *p) |
|
Line 506 mdoc_isdelim(const char *p) |
|
return(DELIM_MIDDLE); |
return(DELIM_MIDDLE); |
|
|
return(DELIM_NONE); |
return(DELIM_NONE); |
} |
|
|
|
void |
|
mdoc_deroff(char **dest, const struct roff_node *n) |
|
{ |
|
char *cp; |
|
size_t sz; |
|
|
|
if (n->type != ROFFT_TEXT) { |
|
for (n = n->child; n; n = n->next) |
|
mdoc_deroff(dest, n); |
|
return; |
|
} |
|
|
|
/* Skip leading whitespace. */ |
|
|
|
for (cp = n->string; '\0' != *cp; cp++) |
|
if (0 == isspace((unsigned char)*cp)) |
|
break; |
|
|
|
/* Skip trailing whitespace. */ |
|
|
|
for (sz = strlen(cp); sz; sz--) |
|
if (0 == isspace((unsigned char)cp[sz-1])) |
|
break; |
|
|
|
/* Skip empty strings. */ |
|
|
|
if (0 == sz) |
|
return; |
|
|
|
if (NULL == *dest) { |
|
*dest = mandoc_strndup(cp, sz); |
|
return; |
|
} |
|
|
|
mandoc_asprintf(&cp, "%s %*s", *dest, (int)sz, cp); |
|
free(*dest); |
|
*dest = cp; |
|
} |
} |