/* $Id: man_macro.c,v 1.114 2016/01/08 17:48:09 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2012, 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2013 Franco Fichtner <franco@lastsummer.de>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "config.h"
#include <assert.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include "mandoc.h"
#include "roff.h"
#include "man.h"
#include "libmandoc.h"
#include "roff_int.h"
#include "libman.h"
static void blk_close(MACRO_PROT_ARGS);
static void blk_exp(MACRO_PROT_ARGS);
static void blk_imp(MACRO_PROT_ARGS);
static void in_line_eoln(MACRO_PROT_ARGS);
int *, char *, char **);
{ in_line_eoln, 0 }, /* BI */
{ in_line_eoln, 0 }, /* IB */
{ in_line_eoln, 0 }, /* BR */
{ in_line_eoln, 0 }, /* RB */
{ in_line_eoln, 0 }, /* IR */
{ in_line_eoln, 0 }, /* RI */
{ in_line_eoln, 0 }, /* DT */
{ in_line_eoln, 0 }, /* UC */
{ in_line_eoln, 0 }, /* AT */
{ in_line_eoln, 0 }, /* in */
{ in_line_eoln, 0 }, /* ft */
{ in_line_eoln, 0 }, /* OP */
{ in_line_eoln, 0 }, /* ll */
};
void
{
struct roff_node *n;
while (n != to) {
/* Reached the end of the document? */
"EOF breaks %s",
man_macronames[n->tok]);
else {
n = n->parent;
}
n = n->parent;
continue;
}
if (n->type == ROFFT_BLOCK &&
man_macronames[n->tok]);
}
/*
* We might delete the man->last node
* in the post-validation phase.
* Save a pointer to the parent such that
* we know where to continue the iteration.
*/
n = n->parent;
}
/*
* If we ended up at the parent of the node we were
* supposed to rewind to, that means the target node
* got deleted, so add the next node we parse as a child
* of the parent instead of as a sibling of the target.
*/
}
/*
* 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.
*/
static void
{
struct roff_node *n;
/* Preserve empty paragraphs before RS. */
return;
for (;;) {
if (n->type == ROFFT_ROOT)
return;
n = n->parent;
continue;
}
if (n->type != ROFFT_BLOCK) {
man_unscope(man, n);
return;
} else {
n = n->parent;
continue;
}
}
return;
man_unscope(man, n);
}
}
/*
* Close out a generic explicit macro.
*/
void
{
int ntok;
char *p;
nrew = 1;
switch (tok) {
case MAN_RE:
break;
nrew++;
if (*p != '\0')
if (target == 0)
target = 1;
if (nrew < 1) {
return;
}
break;
case MAN_UE:
break;
default:
abort();
}
break;
} else {
/* Move a trailing paragraph behind the block. */
}
}
}
void
{
char *p;
int la;
}
/*
* Parse an implicit-block macro. These contain a ROFFT_HEAD and a
* ROFFT_BODY contained within a ROFFT_BLOCK. Rules for closing out other
* scopes, such as `SH' closing out an `SS', are defined in the rew
* routines.
*/
void
{
int la;
char *p;
struct roff_node *n;
/* Add line arguments. */
for (;;) {
break;
}
/*
* For macros having optional next-line scope,
* keep the head open if there were no arguments.
* For `TP', always keep the head open.
*/
return;
}
/* Close out the head and open the body. */
man_unscope(man, n);
}
void
{
int la;
char *p;
struct roff_node *n;
for (;;) {
break;
}
break;
}
break;
roff_word_append(man, p);
else
}
/*
* Append MAN_EOS in case the last snipped argument
* ends with a dot, e.g. `.IR syslog (3).'
*/
/*
* 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.
*/
return;
}
/* Rewind our element scope. */
break;
}
}
void
{
}
static int
{
char *start;
if ('\0' == *start)
return 0;
return 1;
}