version 1.186, 2018/12/31 10:04:39 |
version 1.189, 2022/08/16 23:01:09 |
|
|
/* $Id$ */ |
/* $Id$ */ |
/* |
/* |
|
* Copyright (c) 2013-2015,2017-2019,2022 Ingo Schwarze <schwarze@openbsd.org> |
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> |
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> |
* Copyright (c) 2013,2014,2015,2017,2018 Ingo Schwarze <schwarze@openbsd.org> |
|
* Copyright (c) 2011 Joerg Sonnenberger <joerg@netbsd.org> |
* Copyright (c) 2011 Joerg Sonnenberger <joerg@netbsd.org> |
* |
* |
* Permission to use, copy, modify, and distribute this software for any |
* Permission to use, copy, modify, and distribute this software for any |
Line 70 man_hasc(char *start) |
|
Line 70 man_hasc(char *start) |
|
return (ep - cp) % 2 ? NULL : ep; |
return (ep - cp) % 2 ? NULL : ep; |
} |
} |
|
|
|
/* |
|
* Rewind all open next-line scopes. |
|
*/ |
void |
void |
man_descope(struct roff_man *man, int line, int offs, char *start) |
man_descope(struct roff_man *man, int line, int offs, char *start) |
{ |
{ |
/* Trailing \c keeps next-line scope open. */ |
/* First close out all next-line element scopes, if any. */ |
|
|
if (start != NULL && man_hasc(start) != NULL) |
|
return; |
|
|
|
/* |
|
* Co-ordinate what happens with having a next-line scope open: |
|
* first close out the element scopes (if applicable), |
|
* then close out the block scope (also if applicable). |
|
*/ |
|
|
|
if (man->flags & MAN_ELINE) { |
if (man->flags & MAN_ELINE) { |
while (man->last->parent->type != ROFFT_ROOT && |
while (man->last->parent->type != ROFFT_ROOT && |
man_macro(man->last->parent->tok)->flags & MAN_ESCOPED) |
man_macro(man->last->parent->tok)->flags & MAN_ESCOPED) |
man_unscope(man, man->last->parent); |
man_unscope(man, man->last->parent); |
man->flags &= ~MAN_ELINE; |
man->flags &= ~MAN_ELINE; |
} |
} |
|
|
|
/* Trailing \c keeps next-line block scope open. */ |
|
|
|
if (start != NULL && man_hasc(start) != NULL) |
|
return; |
|
|
|
/* Close out the next-line block scope, if there is one. */ |
|
|
if ( ! (man->flags & MAN_BLINE)) |
if ( ! (man->flags & MAN_BLINE)) |
return; |
return; |
man->flags &= ~MAN_BLINE; |
|
man_unscope(man, man->last->parent); |
man_unscope(man, man->last->parent); |
roff_body_alloc(man, line, offs, man->last->tok); |
roff_body_alloc(man, line, offs, man->last->tok); |
|
man->flags &= ~(MAN_BLINE | ROFF_NONOFILL); |
} |
} |
|
|
static int |
static int |
Line 268 man_pmacro(struct roff_man *man, int ln, char *buf, in |
|
Line 270 man_pmacro(struct roff_man *man, int ln, char *buf, in |
|
man_macro(tok)->flags & MAN_NSCOPED) |
man_macro(tok)->flags & MAN_NSCOPED) |
return 1; |
return 1; |
|
|
man->flags &= ~MAN_BLINE; |
|
man_unscope(man, man->last->parent); |
man_unscope(man, man->last->parent); |
roff_body_alloc(man, ln, ppos, man->last->tok); |
roff_body_alloc(man, ln, ppos, man->last->tok); |
|
man->flags &= ~(MAN_BLINE | ROFF_NONOFILL); |
return 1; |
return 1; |
} |
} |
|
|
|
/* |
|
* Rewind open next-line scopes |
|
* unless the tok request or macro is allowed inside them. |
|
*/ |
void |
void |
man_breakscope(struct roff_man *man, int tok) |
man_breakscope(struct roff_man *man, int tok) |
{ |
{ |
Line 294 man_breakscope(struct roff_man *man, int tok) |
|
Line 300 man_breakscope(struct roff_man *man, int tok) |
|
(man_macro(n->tok)->flags & (MAN_NSCOPED | MAN_ESCOPED)) |
(man_macro(n->tok)->flags & (MAN_NSCOPED | MAN_ESCOPED)) |
== MAN_NSCOPED) |
== MAN_NSCOPED) |
n = n->parent; |
n = n->parent; |
|
for (;;) { |
mandoc_msg(MANDOCERR_BLK_LINE, n->line, n->pos, |
mandoc_msg(MANDOCERR_BLK_LINE, n->line, n->pos, |
"%s breaks %s", roff_name[tok], roff_name[n->tok]); |
"%s breaks %s", roff_name[tok], roff_name[n->tok]); |
|
if (n->parent->type != ROFFT_ELEM || |
|
(man_macro(n->parent->tok)->flags & |
|
MAN_ESCOPED) == 0) |
|
break; |
|
n = n->parent; |
|
} |
roff_node_delete(man, n); |
roff_node_delete(man, n); |
man->flags &= ~MAN_ELINE; |
man->flags &= ~MAN_ELINE; |
} |
} |
Line 313 man_breakscope(struct roff_man *man, int tok) |
|
Line 324 man_breakscope(struct roff_man *man, int tok) |
|
n = man->last; |
n = man->last; |
man_unscope(man, n); |
man_unscope(man, n); |
roff_body_alloc(man, n->line, n->pos, n->tok); |
roff_body_alloc(man, n->line, n->pos, n->tok); |
man->flags &= ~MAN_BLINE; |
man->flags &= ~(MAN_BLINE | ROFF_NONOFILL); |
} |
} |
|
|
/* |
/* |
Line 340 man_breakscope(struct roff_man *man, int tok) |
|
Line 351 man_breakscope(struct roff_man *man, int tok) |
|
"%s breaks %s", roff_name[tok], roff_name[n->tok]); |
"%s breaks %s", roff_name[tok], roff_name[n->tok]); |
|
|
roff_node_delete(man, n); |
roff_node_delete(man, n); |
man->flags &= ~MAN_BLINE; |
man->flags &= ~(MAN_BLINE | ROFF_NONOFILL); |
} |
} |
} |
} |