-/* $Id: man_term.c,v 1.82 2010/07/22 13:47:50 kristaps Exp $ */
+/* $Id: man_term.c,v 1.85 2010/09/15 14:36:16 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
static int pre_SH(DECL_ARGS);
static int pre_SS(DECL_ARGS);
static int pre_TP(DECL_ARGS);
-static int pre_fi(DECL_ARGS);
static int pre_ign(DECL_ARGS);
-static int pre_nf(DECL_ARGS);
+static int pre_in(DECL_ARGS);
+static int pre_literal(DECL_ARGS);
static int pre_sp(DECL_ARGS);
static void post_IP(DECL_ARGS);
{ NULL, NULL, MAN_NOTEXT }, /* na */
{ pre_I, NULL, 0 }, /* i */
{ pre_sp, NULL, MAN_NOTEXT }, /* sp */
- { pre_nf, NULL, 0 }, /* nf */
- { pre_fi, NULL, 0 }, /* fi */
+ { pre_literal, NULL, 0 }, /* nf */
+ { pre_literal, NULL, 0 }, /* fi */
{ NULL, NULL, 0 }, /* r */
{ NULL, NULL, 0 }, /* RE */
{ pre_RS, post_RS, 0 }, /* RS */
{ pre_ign, NULL, 0 }, /* UC */
{ pre_ign, NULL, 0 }, /* PD */
{ pre_sp, NULL, MAN_NOTEXT }, /* Sp */
- { pre_nf, NULL, 0 }, /* Vb */
- { pre_fi, NULL, 0 }, /* Ve */
+ { pre_literal, NULL, 0 }, /* Vb */
+ { pre_literal, NULL, 0 }, /* Ve */
{ pre_ign, NULL, 0 }, /* AT */
+ { pre_in, NULL, MAN_NOTEXT }, /* in */
};
/* ARGSUSED */
static int
-pre_fi(DECL_ARGS)
+pre_literal(DECL_ARGS)
{
term_newln(p);
- mt->fl &= ~MANT_LITERAL;
+ switch (n->tok) {
+ case (MAN_Vb):
+ /* FALLTHROUGH */
+ case (MAN_nf):
+ mt->fl |= MANT_LITERAL;
+ return(MAN_Vb != n->tok);
+ default:
+ mt->fl &= ~MANT_LITERAL;
+ break;
+ }
+
return(1);
}
-/* ARGSUSED */
-static int
-pre_nf(DECL_ARGS)
-{
-
- term_newln(p);
- mt->fl |= MANT_LITERAL;
- return(MAN_Vb != n->tok);
-}
-
/* ARGSUSED */
static int
}
+/* ARGSUSED */
+static int
+pre_in(DECL_ARGS)
+{
+ int len, less;
+ size_t v;
+ const char *cp;
+
+ term_newln(p);
+
+ if (NULL == n->child) {
+ p->offset = mt->offset;
+ return(0);
+ }
+
+ cp = n->child->string;
+ less = 0;
+
+ if ('-' == *cp)
+ less = -1;
+ else if ('+' == *cp)
+ less = 1;
+ else
+ cp--;
+
+ if ((len = a2width(p, ++cp)) < 0)
+ return(0);
+
+ v = (size_t)len;
+
+ if (less < 0)
+ p->offset -= p->offset > v ? v : p->offset;
+ else if (less > 0)
+ p->offset += v;
+ else
+ p->offset = v;
+
+ return(0);
+}
+
+
/* ARGSUSED */
static int
pre_sp(DECL_ARGS)
p->rmargin = p->maxrmargin - term_strlen(p, buf);
p->offset = 0;
+ /* term_strlen() can return zero. */
+ if (p->rmargin == p->maxrmargin)
+ p->rmargin--;
+
if (meta->source)
term_word(p, meta->source);
if (meta->source)