man_macro.c revision 95c635efb7c3b86efc493e0447eaec7aecca3f0f
2N/A * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> 2N/A * Permission to use, copy, modify, and distribute this software for any 2N/A * purpose with or without fee is hereby granted, provided that the above 2N/A * copyright notice and this permission notice appear in all copies. 2N/A * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 2N/A * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 2N/A * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 2N/A * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 2N/A * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 2N/A * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 2N/A * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 2N/A int *,
char *,
char **);
2N/A * Warn when "n" is an explicit non-roff macro. 2N/A * Rewind scope. If a code "er" != MANDOCERR_MAX has been provided, it 2N/A * will be used if an explicit block scope is being closed out. * Save the parent here, because we may delete the * m->last node in the post-validation phase and reset * it to m->last->parent, causing a step in the closing * There are three scope levels: scoped to the root (all), scoped to the * section (all less sections), and scoped to subsections (all less * sections and subsections). /* We cannot progress beyond the root ever. */ /* Normal nodes shouldn't go to the level of the root. */ /* Already-validated nodes should be closed out. */ /* First: rewind to ourselves. */ * Next follow the implicit scope-smashings as defined by man.7: * section, sub-section, etc. /* Rewind to a section, if a block. */ /* Rewind to a subsection, if a block. */ /* Rewind to a section, if a block. */ /* Rewind to an offsetter, if a block. */ /* Rewind to a subsection, if a block. */ /* Rewind to a section, if a block. */ * Rewinding entails ascending the parse tree until a coherent point, * for example, the `SH' macro will close out any intervening `SS' * scopes. When a scope is closed, it must be validated and actioned. * Whether we should stop immediately (REW_HALT), stop * and rewind until this point (REW_REWIND), or keep * rewinding (REW_NOHALT). * Rewind until the current point. Warn if we're a roff * instruction that's mowing over explicit scopes. * Close out a generic explicit macro. * Close out prior scopes. "Regular" explicit macros cannot be * nested, but we allow roff macros to be placed just about * Parse an implicit-block macro. These contain a MAN_HEAD and a * MAN_BODY contained within a MAN_BLOCK. Rules for closing out other * scopes, such as `SH' closing out an `SS', are defined in the rew /* Close out prior scopes. */ /* Allocate new block & head scope. */ /* Add line arguments. */ /* Close out head and open body (unless MAN_SCOPE). */ /* If we're forcing scope (`TP'), keep it open. */ }
else if (n == m->
last) {
* If no arguments are specified and this is MAN_SCOPED (i.e., * next-line scoped), then set our mode to indicate that we're * waiting for terms to load into our context. /* Set ignorable context, if applicable. */ * Rewind our element scope. Note that when TH is pruned, we'll * be back at the root, so make sure that we don't clobber as * Same here regarding whether we're back at the root.