371584c2eae4cf827fd406ba26c14f021adaaa70Yuri Pankov/* $Id: mdoc_state.c,v 1.3 2015/10/30 18:53:54 schwarze Exp $ */
371584c2eae4cf827fd406ba26c14f021adaaa70Yuri Pankov * Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
371584c2eae4cf827fd406ba26c14f021adaaa70Yuri Pankov * Permission to use, copy, modify, and distribute this software for any
371584c2eae4cf827fd406ba26c14f021adaaa70Yuri Pankov * purpose with or without fee is hereby granted, provided that the above
371584c2eae4cf827fd406ba26c14f021adaaa70Yuri Pankov * copyright notice and this permission notice appear in all copies.
371584c2eae4cf827fd406ba26c14f021adaaa70Yuri Pankov * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
371584c2eae4cf827fd406ba26c14f021adaaa70Yuri Pankov * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
371584c2eae4cf827fd406ba26c14f021adaaa70Yuri Pankov * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
371584c2eae4cf827fd406ba26c14f021adaaa70Yuri Pankov * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
371584c2eae4cf827fd406ba26c14f021adaaa70Yuri Pankov * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
371584c2eae4cf827fd406ba26c14f021adaaa70Yuri Pankov * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
371584c2eae4cf827fd406ba26c14f021adaaa70Yuri Pankov * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
371584c2eae4cf827fd406ba26c14f021adaaa70Yuri Pankov#define STATE_ARGS struct roff_man *mdoc, struct roff_node *n
371584c2eae4cf827fd406ba26c14f021adaaa70Yuri Pankovstatic const state_handler state_handlers[MDOC_MAX] = {
371584c2eae4cf827fd406ba26c14f021adaaa70Yuri Pankovmdoc_state(struct roff_man *mdoc, struct roff_node *n)
371584c2eae4cf827fd406ba26c14f021adaaa70Yuri Pankov if ( ! (mdoc_macros[n->tok].flags & MDOC_PROLOGUE))
371584c2eae4cf827fd406ba26c14f021adaaa70Yuri Pankov (n->type != ROFFT_BODY || n->end != ENDBODY_NOT))
371584c2eae4cf827fd406ba26c14f021adaaa70Yuri Pankov if (arg != MDOC_Literal && arg != MDOC_Unfilled)
371584c2eae4cf827fd406ba26c14f021adaaa70Yuri Pankov if (n->type != ROFFT_HEAD || n->parent->args == NULL)
371584c2eae4cf827fd406ba26c14f021adaaa70Yuri Pankov switch (n->type) {
371584c2eae4cf827fd406ba26c14f021adaaa70Yuri Pankov * Set the section attribute for the BLOCK, HEAD,
371584c2eae4cf827fd406ba26c14f021adaaa70Yuri Pankov * and HEAD children; the latter can only be TEXT
371584c2eae4cf827fd406ba26c14f021adaaa70Yuri Pankov * nodes, so no recursion is needed. For other
371584c2eae4cf827fd406ba26c14f021adaaa70Yuri Pankov * nodes, including the .Sh BODY, this is done
371584c2eae4cf827fd406ba26c14f021adaaa70Yuri Pankov * when allocating the node data structures, but
371584c2eae4cf827fd406ba26c14f021adaaa70Yuri Pankov * for .Sh BLOCK and HEAD, the section is still
371584c2eae4cf827fd406ba26c14f021adaaa70Yuri Pankov * unknown at that time.
371584c2eae4cf827fd406ba26c14f021adaaa70Yuri Pankov for (nch = n->child; nch != NULL; nch = nch->next)