version 1.327, 2018/04/10 00:52:30 |
version 1.329, 2018/08/01 15:40:17 |
Line 762 roff_alloc(struct mparse *parse, int options) |
|
Line 762 roff_alloc(struct mparse *parse, int options) |
|
|
|
r = mandoc_calloc(1, sizeof(struct roff)); |
r = mandoc_calloc(1, sizeof(struct roff)); |
r->parse = parse; |
r->parse = parse; |
r->reqtab = roffhash_alloc(0, ROFF_USERDEF); |
r->reqtab = roffhash_alloc(0, ROFF_RENAMED); |
r->options = options; |
r->options = options; |
r->format = options & (MPARSE_MDOC | MPARSE_MAN); |
r->format = options & (MPARSE_MDOC | MPARSE_MAN); |
r->rstackpos = -1; |
r->rstackpos = -1; |
Line 1122 static enum rofferr |
|
Line 1122 static enum rofferr |
|
roff_res(struct roff *r, struct buf *buf, int ln, int pos) |
roff_res(struct roff *r, struct buf *buf, int ln, int pos) |
{ |
{ |
char ubuf[24]; /* buffer to print the number */ |
char ubuf[24]; /* buffer to print the number */ |
|
struct roff_node *n; /* used for header comments */ |
const char *start; /* start of the string to process */ |
const char *start; /* start of the string to process */ |
char *stesc; /* start of an escape sequence ('\\') */ |
char *stesc; /* start of an escape sequence ('\\') */ |
|
char *ep; /* end of comment string */ |
const char *stnam; /* start of the name, after "[(*" */ |
const char *stnam; /* start of the name, after "[(*" */ |
const char *cp; /* end of the name, e.g. before ']' */ |
const char *cp; /* end of the name, e.g. before ']' */ |
const char *res; /* the string to be substituted */ |
const char *res; /* the string to be substituted */ |
Line 1173 roff_res(struct roff *r, struct buf *buf, int ln, int |
|
Line 1175 roff_res(struct roff *r, struct buf *buf, int ln, int |
|
|
|
/* Handle trailing whitespace. */ |
/* Handle trailing whitespace. */ |
|
|
cp = strchr(stesc--, '\0') - 1; |
ep = strchr(stesc--, '\0') - 1; |
if (*cp == '\n') { |
if (*ep == '\n') { |
done = 1; |
done = 1; |
cp--; |
ep--; |
} |
} |
if (*cp == ' ' || *cp == '\t') |
if (*ep == ' ' || *ep == '\t') |
mandoc_msg(MANDOCERR_SPACE_EOL, r->parse, |
mandoc_msg(MANDOCERR_SPACE_EOL, r->parse, |
ln, cp - buf->buf, NULL); |
ln, ep - buf->buf, NULL); |
|
|
|
/* |
|
* Save comments preceding the title macro |
|
* in the syntax tree. |
|
*/ |
|
|
|
if (r->format == 0) { |
|
while (*ep == ' ' || *ep == '\t') |
|
ep--; |
|
ep[1] = '\0'; |
|
n = roff_node_alloc(r->man, |
|
ln, stesc + 1 - buf->buf, |
|
ROFFT_COMMENT, TOKEN_NONE); |
|
n->string = mandoc_strdup(stesc + 2); |
|
roff_node_append(r->man, n); |
|
n->flags |= NODE_VALID | NODE_ENDED; |
|
r->man->next = ROFF_NEXT_SIBLING; |
|
} |
|
|
|
/* Discard comments. */ |
|
|
while (stesc > start && stesc[-1] == ' ') |
while (stesc > start && stesc[-1] == ' ') |
stesc--; |
stesc--; |
*stesc = '\0'; |
*stesc = '\0'; |
Line 2822 roff_TE(ROFF_ARGS) |
|
Line 2845 roff_TE(ROFF_ARGS) |
|
free(buf->buf); |
free(buf->buf); |
buf->buf = mandoc_strdup(".sp"); |
buf->buf = mandoc_strdup(".sp"); |
buf->sz = 4; |
buf->sz = 4; |
|
*offs = 0; |
return ROFF_REPARSE; |
return ROFF_REPARSE; |
} |
} |
r->tbl = NULL; |
r->tbl = NULL; |
Line 3341 roff_userdef(ROFF_ARGS) |
|
Line 3365 roff_userdef(ROFF_ARGS) |
|
ln, (int)(cp - n1), NULL); |
ln, (int)(cp - n1), NULL); |
free(buf->buf); |
free(buf->buf); |
buf->buf = n1; |
buf->buf = n1; |
|
*offs = 0; |
return ROFF_IGN; |
return ROFF_IGN; |
} |
} |
|
|
Line 3435 roff_renamed(ROFF_ARGS) |
|
Line 3460 roff_renamed(ROFF_ARGS) |
|
buf->buf[pos] == '\0' ? "" : " ", buf->buf + pos) + 1; |
buf->buf[pos] == '\0' ? "" : " ", buf->buf + pos) + 1; |
free(buf->buf); |
free(buf->buf); |
buf->buf = nbuf; |
buf->buf = nbuf; |
|
*offs = 0; |
return ROFF_CONT; |
return ROFF_CONT; |
} |
} |
|
|