version 1.378, 2020/02/27 01:43:52 |
version 1.379, 2020/02/27 21:43:44 |
Line 1094 post_st(POST_ARGS) |
|
Line 1094 post_st(POST_ARGS) |
|
static void |
static void |
post_tg(POST_ARGS) |
post_tg(POST_ARGS) |
{ |
{ |
struct roff_node *n, *nch; |
struct roff_node *n, *nch, *nn; |
size_t len; |
size_t len; |
|
|
|
/* Find the next node. */ |
n = mdoc->last; |
n = mdoc->last; |
|
for (nn = n; nn != NULL; nn = nn->parent) { |
|
if (nn->next != NULL) { |
|
nn = nn->next; |
|
break; |
|
} |
|
} |
|
|
|
/* Add the default argument, if needed. */ |
nch = n->child; |
nch = n->child; |
if (nch == NULL && n->next != NULL && |
if (nch == NULL && nn != NULL && nn->child->type == ROFFT_TEXT) { |
n->next->child->type == ROFFT_TEXT) { |
|
mdoc->next = ROFF_NEXT_CHILD; |
mdoc->next = ROFF_NEXT_CHILD; |
roff_word_alloc(mdoc, n->line, n->pos, n->next->child->string); |
roff_word_alloc(mdoc, n->line, n->pos, n->next->child->string); |
nch = mdoc->last; |
nch = mdoc->last; |
nch->flags |= NODE_NOSRC; |
nch->flags |= NODE_NOSRC; |
mdoc->last = n; |
mdoc->last = n; |
} |
} |
if (nch == NULL || *nch->string == '\0') { |
|
|
/* Validate the first argument. */ |
|
if (nch == NULL || *nch->string == '\0') |
mandoc_msg(MANDOCERR_MACRO_EMPTY, n->line, n->pos, "Tg"); |
mandoc_msg(MANDOCERR_MACRO_EMPTY, n->line, n->pos, "Tg"); |
|
if (nch == NULL) { |
roff_node_delete(mdoc, n); |
roff_node_delete(mdoc, n); |
return; |
return; |
} |
} |
Line 1116 post_tg(POST_ARGS) |
|
Line 1127 post_tg(POST_ARGS) |
|
if (nch->string[len] != '\0') |
if (nch->string[len] != '\0') |
mandoc_msg(MANDOCERR_TG_SPC, nch->line, nch->pos + len + 1, |
mandoc_msg(MANDOCERR_TG_SPC, nch->line, nch->pos + len + 1, |
"Tg %s", nch->string); |
"Tg %s", nch->string); |
|
|
|
/* Keep only the first argument. */ |
if (nch->next != NULL) { |
if (nch->next != NULL) { |
mandoc_msg(MANDOCERR_ARG_EXCESS, nch->next->line, |
mandoc_msg(MANDOCERR_ARG_EXCESS, nch->next->line, |
nch->next->pos, "Tg ... %s", nch->next->string); |
nch->next->pos, "Tg ... %s", nch->next->string); |
while (nch->next != NULL) |
while (nch->next != NULL) |
roff_node_delete(mdoc, nch->next); |
roff_node_delete(mdoc, nch->next); |
} |
} |
if (nch->string[len] != '\0') |
|
|
/* Drop the macro if the first argument is invalid. */ |
|
if (len == 0 || nch->string[len] != '\0') { |
roff_node_delete(mdoc, n); |
roff_node_delete(mdoc, n); |
|
return; |
|
} |
|
|
|
/* By default, write a <mark> element. */ |
|
n->flags |= NODE_ID; |
|
if (nn == NULL) |
|
return; |
|
|
|
/* Explicit tagging of specific macros. */ |
|
switch (nn->tok) { |
|
case MDOC_Sh: |
|
case MDOC_Ss: |
|
if (nn->head->flags & NODE_ID || nn->head->child == NULL) |
|
break; |
|
n->flags |= NODE_NOPRT; |
|
nn->head->flags |= NODE_ID | NODE_HREF; |
|
assert(nn->head->string == NULL); |
|
nn->head->string = mandoc_strdup(nch->string); |
|
break; |
|
default: |
|
break; |
|
} |
|
if (n->flags & NODE_NOPRT) |
|
n->flags &= ~NODE_ID; |
} |
} |
|
|
static void |
static void |