-/* $Id: apropos.c,v 1.21 2014/04/11 15:45:39 schwarze Exp $ */
+/* $Id: apropos.c,v 1.22 2014/04/20 16:44:44 schwarze Exp $ */
/*
* Copyright (c) 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013 Ingo Schwarze <schwarze@openbsd.org>
#include "manpath.h"
#include "mansearch.h"
+
int
apropos(int argc, char *argv[])
{
while (-1 != (ch = getopt(argc, argv, "C:M:m:O:S:s:")))
switch (ch) {
- case ('C'):
+ case 'C':
conf_file = optarg;
break;
- case ('M'):
+ case 'M':
defpaths = optarg;
break;
- case ('m'):
+ case 'm':
auxpaths = optarg;
break;
- case ('O'):
+ case 'O':
outkey = optarg;
break;
- case ('S'):
+ case 'S':
search.arch = optarg;
break;
- case ('s'):
+ case 's':
search.sec = optarg;
break;
default:
-/* $Id: arch.c,v 1.7 2014/03/21 22:17:01 schwarze Exp $ */
+/* $Id: arch.c,v 1.8 2014/04/20 16:44:44 schwarze Exp $ */
/*
* Copyright (c) 2009 Kristaps Dzonsons <kristaps@bsd.lv>
*
#define LINE(x, y) \
if (0 == strcmp(p, x)) return(y);
+
const char *
mdoc_a2arch(const char *p)
{
-#include "arch.in"
+#include "arch.in"
return(NULL);
}
-/* $Id: att.c,v 1.7 2014/03/21 22:17:01 schwarze Exp $ */
+/* $Id: att.c,v 1.8 2014/04/20 16:44:44 schwarze Exp $ */
/*
* Copyright (c) 2009 Kristaps Dzonsons <kristaps@bsd.lv>
*
#define LINE(x, y) \
if (0 == strcmp(p, x)) return(y);
+
const char *
mdoc_a2att(const char *p)
{
-#include "att.in"
+#include "att.in"
return(NULL);
}
-/* $Id: chars.c,v 1.27 2014/03/21 22:17:01 schwarze Exp $ */
+/* $Id: chars.c,v 1.28 2014/04/20 16:44:44 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org>
struct ln **htab;
};
-static const struct ln *find(const struct mchars *,
+static const struct ln *find(const struct mchars *,
const char *, size_t);
+
void
mchars_free(struct mchars *arg)
{
char
mchars_num2char(const char *p, size_t sz)
{
- int i;
+ int i;
if ((i = mandoc_strntoi(p, sz, 10)) < 0)
return('\0');
- return(i > 0 && i < 256 && isprint(i) ?
- /* LINTED */ i : '\0');
+
+ return(i > 0 && i < 256 && isprint(i) ? i : '\0');
}
int
mchars_num2uc(const char *p, size_t sz)
{
- int i;
+ int i;
if ((i = mandoc_strntoi(p, sz, 16)) < 0)
return('\0');
}
const char *
-mchars_spec2str(const struct mchars *arg,
+mchars_spec2str(const struct mchars *arg,
const char *p, size_t sz, size_t *rsz)
{
const struct ln *ln;
hash = (int)p[0] - PRINT_LO;
for (pp = tab->htab[hash]; pp; pp = pp->next)
- if (0 == strncmp(pp->code, p, sz) &&
- '\0' == pp->code[(int)sz])
+ if (0 == strncmp(pp->code, p, sz) &&
+ '\0' == pp->code[(int)sz])
return(pp);
return(NULL);
-/* $Id: chars.in,v 1.21 2014/03/05 23:14:37 schwarze Exp $ */
+/* $Id: chars.in,v 1.22 2014/04/20 16:44:44 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org>
*/
/*
- * The ASCII translation tables.
+ * The ASCII translation tables.
*
* The left-hand side corresponds to the input sequence (\x, \(xx, \*(xx
* and so on) whose length is listed second element. The right-hand
-/* $Id: eqn.c,v 1.6 2014/03/21 22:17:01 schwarze Exp $ */
+/* $Id: eqn.c,v 1.7 2014/04/20 16:44:44 schwarze Exp $ */
/*
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
const char *sym;
};
-
static enum eqn_rest eqn_box(struct eqn_node *, struct eqn_box *);
-static struct eqn_box *eqn_box_alloc(struct eqn_node *,
+static struct eqn_box *eqn_box_alloc(struct eqn_node *,
struct eqn_box *);
static void eqn_box_free(struct eqn_box *);
-static struct eqn_def *eqn_def_find(struct eqn_node *,
+static struct eqn_def *eqn_def_find(struct eqn_node *,
const char *, size_t);
static int eqn_do_gfont(struct eqn_node *);
static int eqn_do_gsize(struct eqn_node *);
static enum eqn_rest eqn_matrix(struct eqn_node *, struct eqn_box *);
static const char *eqn_nexttok(struct eqn_node *, size_t *);
static const char *eqn_nextrawtok(struct eqn_node *, size_t *);
-static const char *eqn_next(struct eqn_node *,
+static const char *eqn_next(struct eqn_node *,
char, size_t *, int);
static void eqn_rewind(struct eqn_node *);
{ { ">=", 2 }, ">=" }, /* EQNSYM_moreequal */
};
-/* ARGSUSED */
+
enum rofferr
-eqn_read(struct eqn_node **epp, int ln,
+eqn_read(struct eqn_node **epp, int ln,
const char *p, int pos, int *offs)
{
size_t sz;
p += 3;
while (' ' == *p || '\t' == *p)
p++;
- if ('\0' == *p)
+ if ('\0' == *p)
return(er);
mandoc_msg(MANDOCERR_ARGSLOST, ep->parse, ln, pos, NULL);
return(er);
while (EQN_OK == (c = eqn_box(ep, bp)))
switch (bp->last->pile) {
- case (EQNPILE_LCOL):
+ case EQNPILE_LCOL:
/* FALLTHROUGH */
- case (EQNPILE_CCOL):
+ case EQNPILE_CCOL:
/* FALLTHROUGH */
- case (EQNPILE_RCOL):
+ case EQNPILE_RCOL:
continue;
default:
EQN_MSG(MANDOCERR_EQNSYNT, ep);
for (i = 0; i < (int)EQN__MAX; i++) {
if ( ! EQNSTREQ(&eqnparts[i].str, start, sz))
continue;
- return((*eqnparts[i].fp)(ep) ?
- EQN_OK : EQN_ERR);
- }
+ return((*eqnparts[i].fp)(ep) ? EQN_OK : EQN_ERR);
+ }
if (STRNEQ(start, sz, "{", 1)) {
if (EQN_DESCOPE != (c = eqn_eqn(ep, last))) {
return(EQN_OK);
EQN_MSG(MANDOCERR_EQNBADSCOPE, ep);
return(EQN_ERR);
- }
+ }
for (i = 0; i < (int)EQNPILE__MAX; i++) {
if ( ! EQNSTREQ(&eqnpiles[i], start, sz))
if (NULL == last->last) {
EQN_MSG(MANDOCERR_EQNSYNT, ep);
return(EQN_ERR);
- }
+ }
last->last->pos = (enum eqn_post)i;
if (EQN_EOF == (c = eqn_box(ep, last))) {
EQN_MSG(MANDOCERR_EQNEOF, ep);
if (NULL == last->last) {
EQN_MSG(MANDOCERR_EQNSYNT, ep);
return(EQN_ERR);
- }
+ }
last->last->mark = (enum eqn_markt)i;
if (EQN_EOF == (c = eqn_box(ep, last))) {
EQN_MSG(MANDOCERR_EQNEOF, ep);
if (q)
ep->cur++;
while (' ' == ep->data[(int)ep->cur] ||
- '\t' == ep->data[(int)ep->cur] ||
- '^' == ep->data[(int)ep->cur] ||
- '~' == ep->data[(int)ep->cur])
+ '\t' == ep->data[(int)ep->cur] ||
+ '^' == ep->data[(int)ep->cur] ||
+ '~' == ep->data[(int)ep->cur])
ep->cur++;
} else {
if (q)
}
diff = def->valsz - *sz;
- memmove(start + *sz + diff, start + *sz,
- (strlen(start) - *sz) + 1);
+ memmove(start + *sz + diff, start + *sz,
+ (strlen(start) - *sz) + 1);
memcpy(start, def->val, def->valsz);
goto again;
}
return(0);
}
- /*
- * Search for a key that already exists.
+ /*
+ * Search for a key that already exists.
* Create a new key if none is found.
*/
if (i == (int)ep->defsz) {
ep->defsz++;
- ep->defs = mandoc_realloc
- (ep->defs, ep->defsz *
- sizeof(struct eqn_def));
+ ep->defs = mandoc_realloc(ep->defs,
+ ep->defsz * sizeof(struct eqn_def));
ep->defs[i].key = ep->defs[i].val = NULL;
}
ep->defs[i].keysz = sz;
- ep->defs[i].key = mandoc_realloc
- (ep->defs[i].key, sz + 1);
+ ep->defs[i].key = mandoc_realloc(
+ ep->defs[i].key, sz + 1);
memcpy(ep->defs[i].key, start, sz);
ep->defs[i].key[(int)sz] = '\0';
if (NULL == eqn_nextrawtok(ep, NULL)) {
EQN_MSG(MANDOCERR_EQNEOF, ep);
return(0);
- }
+ }
return(1);
}
if (NULL == (start = eqn_nextrawtok(ep, &sz))) {
EQN_MSG(MANDOCERR_EQNEOF, ep);
return(0);
- }
+ }
ep->gsize = mandoc_strntoi(start, sz, 10);
return(1);
}
{
int i;
- for (i = 0; i < (int)ep->defsz; i++)
- if (ep->defs[i].keysz && STRNEQ(ep->defs[i].key,
- ep->defs[i].keysz, key, sz))
+ for (i = 0; i < (int)ep->defsz; i++)
+ if (ep->defs[i].keysz && STRNEQ(ep->defs[i].key,
+ ep->defs[i].keysz, key, sz))
return(&ep->defs[i]);
return(NULL);
-/* $Id: eqn_html.c,v 1.1 2011/09/18 10:25:28 schwarze Exp $ */
+/* $Id: eqn_html.c,v 1.2 2014/04/20 16:44:44 schwarze Exp $ */
/*
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
TAG_I /* EQNFONT_ITALIC */
};
-
static void eqn_box(struct html *, const struct eqn_box *);
+
void
print_eqn(struct html *p, const struct eqn *ep)
{
{
struct tag *t;
- t = EQNFONT_NONE == bp->font ? NULL :
- print_otag(p, fontmap[(int)bp->font], 0, NULL);
+ t = EQNFONT_NONE == bp->font ? NULL :
+ print_otag(p, fontmap[(int)bp->font], 0, NULL);
if (bp->left)
print_text(p, bp->left);
-
+
if (bp->text)
print_text(p, bp->text);
-/* $Id: eqn_term.c,v 1.1 2011/09/18 10:25:28 schwarze Exp $ */
+/* $Id: eqn_term.c,v 1.2 2014/04/20 16:44:44 schwarze Exp $ */
/*
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
static void eqn_box(struct termp *, const struct eqn_box *);
+
void
term_eqn(struct termp *p, const struct eqn *ep)
{
term_word(p, ")");
if (bp->right)
term_word(p, bp->right);
- if (EQNFONT_NONE != bp->font)
+ if (EQNFONT_NONE != bp->font)
term_fontpop(p);
if (bp->next)
-/* $Id: html.c,v 1.34 2014/03/21 22:17:01 schwarze Exp $ */
+/* $Id: html.c,v 1.35 2014/04/20 16:44:44 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
static void print_attr(struct html *, const char *, const char *);
static void *ml_alloc(char *, enum htmltype);
+
static void *
ml_alloc(char *outopts, enum htmltype type)
{
while (outopts && *outopts)
switch (getsubopt(&outopts, UNCONST(toks), &v)) {
- case (0):
+ case 0:
h->style = v;
break;
- case (1):
+ case 1:
h->base_man = v;
break;
- case (2):
+ case 2:
h->base_includes = v;
break;
- case (3):
+ case 3:
h->oflags |= HTML_FRAGMENT;
break;
default:
return(ml_alloc(outopts, HTML_HTML_4_01_STRICT));
}
-
void *
xhtml_alloc(char *outopts)
{
return(ml_alloc(outopts, HTML_XHTML_1_0_STRICT));
}
-
void
html_free(void *p)
{
h = (struct html *)p;
while ((tag = h->tags.head) != NULL) {
- h->tags.head = tag->next;
+ h->tags.head = tag->next;
free(tag);
}
-
+
if (h->symtab)
mchars_free(h->symtab);
free(h);
}
-
void
print_gen_head(struct html *h)
{
enum htmlfont font;
switch (deco) {
- case (ESCAPE_FONTPREV):
+ case ESCAPE_FONTPREV:
font = h->metal;
break;
- case (ESCAPE_FONTITALIC):
+ case ESCAPE_FONTITALIC:
font = HTMLFONT_ITALIC;
break;
- case (ESCAPE_FONTBOLD):
+ case ESCAPE_FONTBOLD:
font = HTMLFONT_BOLD;
break;
- case (ESCAPE_FONTBI):
+ case ESCAPE_FONTBI:
font = HTMLFONT_BI;
break;
- case (ESCAPE_FONT):
+ case ESCAPE_FONT:
/* FALLTHROUGH */
- case (ESCAPE_FONTROMAN):
+ case ESCAPE_FONTROMAN:
font = HTMLFONT_NONE;
break;
default:
h->metac = font;
switch (font) {
- case (HTMLFONT_ITALIC):
+ case HTMLFONT_ITALIC:
h->metaf = print_otag(h, TAG_I, 0, NULL);
break;
- case (HTMLFONT_BOLD):
+ case HTMLFONT_BOLD:
h->metaf = print_otag(h, TAG_B, 0, NULL);
break;
- case (HTMLFONT_BI):
+ case HTMLFONT_BI:
h->metaf = print_otag(h, TAG_B, 0, NULL);
print_otag(h, TAG_I, 0, NULL);
break;
break;
cp++;
switch (mandoc_escape(&cp, NULL, NULL)) {
- case (ESCAPE_ERROR):
+ case ESCAPE_ERROR:
return(sz);
- case (ESCAPE_UNICODE):
+ case ESCAPE_UNICODE:
/* FALLTHROUGH */
- case (ESCAPE_NUMBERED):
+ case ESCAPE_NUMBERED:
/* FALLTHROUGH */
- case (ESCAPE_SPECIAL):
+ case ESCAPE_SPECIAL:
if (skip)
skip = 0;
else
sz++;
break;
- case (ESCAPE_SKIPCHAR):
+ case ESCAPE_SKIPCHAR:
skip = 1;
break;
default:
break;
switch (*p++) {
- case ('<'):
+ case '<':
printf("<");
continue;
- case ('>'):
+ case '>':
printf(">");
continue;
- case ('&'):
+ case '&':
printf("&");
continue;
- case (ASCII_NBRSP):
+ case ASCII_NBRSP:
putchar('-');
continue;
- case (ASCII_HYPH):
+ case ASCII_HYPH:
putchar('-');
/* FALLTHROUGH */
- case (ASCII_BREAK):
+ case ASCII_BREAK:
continue;
default:
break;
break;
switch (esc) {
- case (ESCAPE_FONT):
+ case ESCAPE_FONT:
/* FALLTHROUGH */
- case (ESCAPE_FONTPREV):
+ case ESCAPE_FONTPREV:
/* FALLTHROUGH */
- case (ESCAPE_FONTBOLD):
+ case ESCAPE_FONTBOLD:
/* FALLTHROUGH */
- case (ESCAPE_FONTITALIC):
+ case ESCAPE_FONTITALIC:
/* FALLTHROUGH */
- case (ESCAPE_FONTBI):
+ case ESCAPE_FONTBI:
/* FALLTHROUGH */
- case (ESCAPE_FONTROMAN):
+ case ESCAPE_FONTROMAN:
if (0 == norecurse)
print_metaf(h, esc);
continue;
- case (ESCAPE_SKIPCHAR):
+ case ESCAPE_SKIPCHAR:
h->flags |= HTML_SKIPCHAR;
continue;
default:
}
switch (esc) {
- case (ESCAPE_UNICODE):
+ case ESCAPE_UNICODE:
/* Skip passed "u" header. */
c = mchars_num2uc(seq + 1, len - 1);
if ('\0' != c)
printf("&#x%x;", c);
break;
- case (ESCAPE_NUMBERED):
+ case ESCAPE_NUMBERED:
c = mchars_num2char(seq, len);
if ('\0' != c)
putchar(c);
break;
- case (ESCAPE_SPECIAL):
+ case ESCAPE_SPECIAL:
c = mchars_spec2cp(h->symtab, seq, len);
if (c > 0)
printf("&#%d;", c);
else if (-1 == c && 1 == len)
putchar((int)*seq);
break;
- case (ESCAPE_NOSPACE):
+ case ESCAPE_NOSPACE:
if ('\0' == *p)
nospace = 1;
break;
return(nospace);
}
-
static void
print_attr(struct html *h, const char *key, const char *val)
{
putchar('\"');
}
-
struct tag *
-print_otag(struct html *h, enum htmltag tag,
+print_otag(struct html *h, enum htmltag tag,
int sz, const struct htmlpair *p)
{
int i;
if (HTML_AUTOCLOSE & htmltags[tag].flags)
switch (h->type) {
- case (HTML_XHTML_1_0_STRICT):
+ case HTML_XHTML_1_0_STRICT:
putchar('/');
break;
default:
return(t);
}
-
static void
print_ctag(struct html *h, enum htmltag tag)
{
-
+
printf("</%s>", htmltags[tag].name);
if (HTML_CLRLINE & htmltags[tag].flags) {
h->flags |= HTML_NOSPACE;
putchar('\n');
- }
+ }
}
void
const char *name;
switch (h->type) {
- case (HTML_HTML_4_01_STRICT):
+ case HTML_HTML_4_01_STRICT:
name = "HTML";
doctype = "-//W3C//DTD HTML 4.01//EN";
dtd = "http://www.w3.org/TR/html4/strict.dtd";
break;
}
- printf("<!DOCTYPE %s PUBLIC \"%s\" \"%s\">\n",
- name, doctype, dtd);
+ printf("<!DOCTYPE %s PUBLIC \"%s\" \"%s\">\n",
+ name, doctype, dtd);
}
void
assert(NULL == h->metaf);
switch (h->metac) {
- case (HTMLFONT_ITALIC):
+ case HTMLFONT_ITALIC:
h->metaf = print_otag(h, TAG_I, 0, NULL);
break;
- case (HTMLFONT_BOLD):
+ case HTMLFONT_BOLD:
h->metaf = print_otag(h, TAG_B, 0, NULL);
break;
- case (HTMLFONT_BI):
+ case HTMLFONT_BI:
h->metaf = print_otag(h, TAG_B, 0, NULL);
print_otag(h, TAG_I, 0, NULL);
break;
h->flags &= ~HTML_IGNDELIM;
}
-
void
print_tagq(struct html *h, const struct tag *until)
{
struct tag *tag;
while ((tag = h->tags.head) != NULL) {
- /*
+ /*
* Remember to close out and nullify the current
* meta-font and table, if applicable.
*/
}
}
-
void
print_stagq(struct html *h, const struct tag *suntil)
{
while ((tag = h->tags.head) != NULL) {
if (suntil && tag == suntil)
return;
- /*
+ /*
* Remember to close out and nullify the current
* meta-font and table, if applicable.
*/
va_list ap;
va_start(ap, fmt);
- (void)vsnprintf(h->buf + (int)h->buflen,
- BUFSIZ - h->buflen - 1, fmt, ap);
+ (void)vsnprintf(h->buf + (int)h->buflen,
+ BUFSIZ - h->buflen - 1, fmt, ap);
va_end(ap);
h->buflen = strlen(h->buf);
}
const char *p, *pp;
pp = h->base_includes;
-
+
bufinit(h);
while (NULL != (p = strchr(pp, '%'))) {
bufncat(h, pp, (size_t)(p - pp));
switch (*(p + 1)) {
- case('I'):
+ case'I':
bufcat(h, name);
break;
default:
}
void
-buffmt_man(struct html *h,
- const char *name, const char *sec)
+buffmt_man(struct html *h, const char *name, const char *sec)
{
const char *p, *pp;
pp = h->base_man;
-
+
bufinit(h);
while (NULL != (p = strchr(pp, '%'))) {
bufncat(h, pp, (size_t)(p - pp));
switch (*(p + 1)) {
- case('S'):
+ case 'S':
bufcat(h, sec ? sec : "1");
break;
- case('N'):
+ case 'N':
bufcat_fmt(h, "%s", name);
break;
default:
-/* $Id: html.h,v 1.20 2013/08/08 20:07:24 schwarze Exp $ */
+/* $Id: html.h,v 1.21 2014/04/20 16:44:44 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
#define PAIR_STYLE_INIT(p, h) PAIR_INIT(p, ATTR_STYLE, (h)->buf)
#define PAIR_SUMMARY_INIT(p, v) PAIR_INIT(p, ATTR_SUMMARY, v)
-enum htmltype {
+enum htmltype {
HTML_HTML_4_01_STRICT,
HTML_XHTML_1_0_STRICT
};
char *base_includes; /* base for include href */
char *style; /* style-sheet URI */
char buf[BUFSIZ]; /* see bufcat and friends */
- size_t buflen;
+ size_t buflen;
struct tag *metaf; /* current open font scope */
enum htmlfont metal; /* last used font */
enum htmlfont metac; /* current font mode */
void print_gen_decls(struct html *);
void print_gen_head(struct html *);
-struct tag *print_otag(struct html *, enum htmltag,
+struct tag *print_otag(struct html *, enum htmltag,
int, const struct htmlpair *);
void print_tagq(struct html *, const struct tag *);
void print_stagq(struct html *, const struct tag *);
void bufcat_fmt(struct html *, const char *, ...);
void bufcat(struct html *, const char *);
void bufcat_id(struct html *, const char *);
-void bufcat_style(struct html *,
+void bufcat_style(struct html *,
const char *, const char *);
-void bufcat_su(struct html *, const char *,
+void bufcat_su(struct html *, const char *,
const struct roffsu *);
void bufinit(struct html *);
-void buffmt_man(struct html *,
+void buffmt_man(struct html *,
const char *, const char *);
void buffmt_includes(struct html *, const char *);
-/* $Id: libman.h,v 1.33 2014/01/05 20:26:27 schwarze Exp $ */
+/* $Id: libman.h,v 1.34 2014/04/20 16:44:44 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
int man_macroend(struct man *);
int man_valid_post(struct man *);
int man_valid_pre(struct man *, struct man_node *);
-int man_unscope(struct man *,
- const struct man_node *, enum mandocerr);
+int man_unscope(struct man *, const struct man_node *,
+ enum mandocerr);
__END_DECLS
-/* $Id: libmandoc.h,v 1.26 2014/03/19 21:50:59 schwarze Exp $ */
+/* $Id: libmandoc.h,v 1.27 2014/04/20 16:44:44 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
struct mdoc;
struct man;
-void mandoc_msg(enum mandocerr, struct mparse *,
+void mandoc_msg(enum mandocerr, struct mparse *,
int, int, const char *);
-void mandoc_vmsg(enum mandocerr, struct mparse *,
+void mandoc_vmsg(enum mandocerr, struct mparse *,
int, int, const char *, ...);
char *mandoc_getarg(struct mparse *, char **, int, int *);
char *mandoc_normdate(struct mparse *, char *, int, int);
int mandoc_strntoi(const char *, size_t, int);
const char *mandoc_a2msec(const char*);
-void mdoc_free(struct mdoc *);
+void mdoc_free(struct mdoc *);
struct mdoc *mdoc_alloc(struct roff *, struct mparse *, char *, int);
void mdoc_reset(struct mdoc *);
-int mdoc_parseln(struct mdoc *, int, char *, int);
+int mdoc_parseln(struct mdoc *, int, char *, int);
int mdoc_endparse(struct mdoc *);
int mdoc_addspan(struct mdoc *, const struct tbl_span *);
int mdoc_addeqn(struct mdoc *, const struct eqn *);
-void man_free(struct man *);
+void man_free(struct man *);
struct man *man_alloc(struct roff *, struct mparse *, int);
void man_reset(struct man *);
-int man_parseln(struct man *, int, char *, int);
+int man_parseln(struct man *, int, char *, int);
int man_endparse(struct man *);
int man_addspan(struct man *, const struct tbl_span *);
int man_addeqn(struct man *, const struct eqn *);
-void roff_free(struct roff *);
+void roff_free(struct roff *);
struct roff *roff_alloc(struct mparse *, int);
void roff_reset(struct roff *);
-enum rofferr roff_parseln(struct roff *, int,
+enum rofferr roff_parseln(struct roff *, int,
char **, size_t *, int, int *);
void roff_endparse(struct roff *);
void roff_setreg(struct roff *, const char *, int, char sign);
int roff_getreg(const struct roff *, const char *);
char *roff_strdup(const struct roff *, const char *);
-int roff_getcontrol(const struct roff *,
+int roff_getcontrol(const struct roff *,
const char *, int *);
#if 0
char roff_eqndelim(const struct roff *);
-void roff_openeqn(struct roff *, const char *,
+void roff_openeqn(struct roff *, const char *,
int, int, const char *);
int roff_closeeqn(struct roff *);
#endif
-/* $Id: libmdoc.h,v 1.53 2014/01/05 20:26:27 schwarze Exp $ */
+/* $Id: libmdoc.h,v 1.54 2014/04/20 16:44:44 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013 Ingo Schwarze <schwarze@openbsd.org>
#define mdoc_nmsg(mdoc, n, t) \
mandoc_msg((t), (mdoc)->parse, (n)->line, (n)->pos, NULL)
int mdoc_macro(MACRO_PROT_ARGS);
-int mdoc_word_alloc(struct mdoc *,
+int mdoc_word_alloc(struct mdoc *,
int, int, const char *);
void mdoc_word_append(struct mdoc *, const char *);
-int mdoc_elem_alloc(struct mdoc *, int, int,
+int mdoc_elem_alloc(struct mdoc *, int, int,
enum mdoct, struct mdoc_arg *);
-int mdoc_block_alloc(struct mdoc *, int, int,
+int mdoc_block_alloc(struct mdoc *, int, int,
enum mdoct, struct mdoc_arg *);
int mdoc_head_alloc(struct mdoc *, int, int, enum mdoct);
int mdoc_tail_alloc(struct mdoc *, int, int, enum mdoct);
void mdoc_argv_free(struct mdoc_arg *);
enum margserr mdoc_args(struct mdoc *, int,
int *, char *, enum mdoct, char **);
-enum margserr mdoc_zargs(struct mdoc *, int,
+enum margserr mdoc_zargs(struct mdoc *, int,
int *, char *, char **);
int mdoc_macroend(struct mdoc *);
enum mdelim mdoc_isdelim(const char *);
-/* $Id: libroff.h,v 1.6 2013/05/31 21:37:08 schwarze Exp $ */
+/* $Id: libroff.h,v 1.7 2014/04/20 16:44:44 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
void tbl_restart(int, int, struct tbl_node *);
void tbl_free(struct tbl_node *);
void tbl_reset(struct tbl_node *);
-enum rofferr tbl_read(struct tbl_node *, int, const char *, int);
+enum rofferr tbl_read(struct tbl_node *, int, const char *, int);
int tbl_option(struct tbl_node *, int, const char *);
int tbl_layout(struct tbl_node *, int, const char *);
int tbl_data(struct tbl_node *, int, const char *);
struct eqn_node *eqn_alloc(const char *, int, int, struct mparse *);
enum rofferr eqn_end(struct eqn_node **);
void eqn_free(struct eqn_node *);
-enum rofferr eqn_read(struct eqn_node **, int,
+enum rofferr eqn_read(struct eqn_node **, int,
const char *, int, int *);
__END_DECLS
-/* $Id: main.c,v 1.89 2014/03/21 22:17:01 schwarze Exp $ */
+/* $Id: main.c,v 1.90 2014/04/20 16:44:44 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011, 2012, 2014 Ingo Schwarze <schwarze@openbsd.org>
struct mparse *mp;
enum mandoclevel wlevel; /* ignore messages below this */
int wstop; /* stop after a file with a warning */
- enum outt outtype; /* which output to use */
+ enum outt outtype; /* which output to use */
out_mdoc outmdoc; /* mdoc output ptr */
- out_man outman; /* man output ptr */
+ out_man outman; /* man output ptr */
out_free outfree; /* free output ptr */
void *outdata; /* data for output */
char outopts[BUFSIZ]; /* buf of output opts */
static int moptions(int *, char *);
static void mmsg(enum mandocerr, enum mandoclevel,
const char *, int, int, const char *);
-static void parse(struct curparse *, int,
+static void parse(struct curparse *, int,
const char *, enum mandoclevel *);
static int toptions(struct curparse *, char *);
static void usage(void) __attribute__((noreturn));
static const char *progname;
+
int
main(int argc, char *argv[])
{
curp.wlevel = MANDOCLEVEL_FATAL;
defos = NULL;
- /* LINTED */
while (-1 != (c = getopt(argc, argv, "I:m:O:T:VW:")))
switch (c) {
- case ('I'):
+ case 'I':
if (strncmp(optarg, "os=", 3)) {
- fprintf(stderr, "-I%s: Bad argument\n",
- optarg);
+ fprintf(stderr,
+ "-I%s: Bad argument\n", optarg);
return((int)MANDOCLEVEL_BADARG);
}
if (defos) {
- fprintf(stderr, "-I%s: Duplicate argument\n",
- optarg);
+ fprintf(stderr,
+ "-I%s: Duplicate argument\n",
+ optarg);
return((int)MANDOCLEVEL_BADARG);
}
defos = mandoc_strdup(optarg + 3);
break;
- case ('m'):
+ case 'm':
if ( ! moptions(&options, optarg))
return((int)MANDOCLEVEL_BADARG);
break;
- case ('O'):
+ case 'O':
(void)strlcat(curp.outopts, optarg, BUFSIZ);
(void)strlcat(curp.outopts, ",", BUFSIZ);
break;
- case ('T'):
+ case 'T':
if ( ! toptions(&curp, optarg))
return((int)MANDOCLEVEL_BADARG);
break;
- case ('W'):
+ case 'W':
if ( ! woptions(&curp, optarg))
return((int)MANDOCLEVEL_BADARG);
break;
- case ('V'):
+ case 'V':
version();
/* NOTREACHED */
default:
"[-Ooption] "
"[-Toutput] "
"[-Wlevel]\n"
- "\t [file ...]\n",
+ "\t [file ...]\n",
progname);
exit((int)MANDOCLEVEL_BADARG);
}
static void
-parse(struct curparse *curp, int fd,
- const char *file, enum mandoclevel *level)
+parse(struct curparse *curp, int fd, const char *file,
+ enum mandoclevel *level)
{
enum mandoclevel rc;
struct mdoc *mdoc;
if ( ! (curp->outman && curp->outmdoc)) {
switch (curp->outtype) {
- case (OUTT_XHTML):
+ case OUTT_XHTML:
curp->outdata = xhtml_alloc(curp->outopts);
curp->outfree = html_free;
break;
- case (OUTT_HTML):
+ case OUTT_HTML:
curp->outdata = html_alloc(curp->outopts);
curp->outfree = html_free;
break;
- case (OUTT_UTF8):
+ case OUTT_UTF8:
curp->outdata = utf8_alloc(curp->outopts);
curp->outfree = ascii_free;
break;
- case (OUTT_LOCALE):
+ case OUTT_LOCALE:
curp->outdata = locale_alloc(curp->outopts);
curp->outfree = ascii_free;
break;
- case (OUTT_ASCII):
+ case OUTT_ASCII:
curp->outdata = ascii_alloc(curp->outopts);
curp->outfree = ascii_free;
break;
- case (OUTT_PDF):
+ case OUTT_PDF:
curp->outdata = pdf_alloc(curp->outopts);
curp->outfree = pspdf_free;
break;
- case (OUTT_PS):
+ case OUTT_PS:
curp->outdata = ps_alloc(curp->outopts);
curp->outfree = pspdf_free;
break;
}
switch (curp->outtype) {
- case (OUTT_HTML):
+ case OUTT_HTML:
/* FALLTHROUGH */
- case (OUTT_XHTML):
+ case OUTT_XHTML:
curp->outman = html_man;
curp->outmdoc = html_mdoc;
break;
- case (OUTT_TREE):
+ case OUTT_TREE:
curp->outman = tree_man;
curp->outmdoc = tree_mdoc;
break;
- case (OUTT_MAN):
+ case OUTT_MAN:
curp->outmdoc = man_mdoc;
curp->outman = man_man;
break;
- case (OUTT_PDF):
+ case OUTT_PDF:
/* FALLTHROUGH */
- case (OUTT_ASCII):
+ case OUTT_ASCII:
/* FALLTHROUGH */
- case (OUTT_UTF8):
+ case OUTT_UTF8:
/* FALLTHROUGH */
- case (OUTT_LOCALE):
+ case OUTT_LOCALE:
/* FALLTHROUGH */
- case (OUTT_PS):
+ case OUTT_PS:
curp->outman = terminal_man;
curp->outmdoc = terminal_mdoc;
break;
woptions(struct curparse *curp, char *arg)
{
char *v, *o;
- const char *toks[6];
+ const char *toks[6];
toks[0] = "stop";
toks[1] = "all";
while (*arg) {
o = arg;
switch (getsubopt(&arg, UNCONST(toks), &v)) {
- case (0):
+ case 0:
curp->wstop = 1;
break;
- case (1):
+ case 1:
/* FALLTHROUGH */
- case (2):
+ case 2:
curp->wlevel = MANDOCLEVEL_WARNING;
break;
- case (3):
+ case 3:
curp->wlevel = MANDOCLEVEL_ERROR;
break;
- case (4):
+ case 4:
curp->wlevel = MANDOCLEVEL_FATAL;
break;
default:
}
static void
-mmsg(enum mandocerr t, enum mandoclevel lvl,
+mmsg(enum mandocerr t, enum mandoclevel lvl,
const char *file, int line, int col, const char *msg)
{
- fprintf(stderr, "%s:%d:%d: %s: %s",
- file, line, col + 1,
- mparse_strlevel(lvl),
- mparse_strerror(t));
+ fprintf(stderr, "%s:%d:%d: %s: %s", file, line, col + 1,
+ mparse_strlevel(lvl), mparse_strerror(t));
if (msg)
fprintf(stderr, ": %s", msg);
-/* $Id: main.h,v 1.10 2011/10/09 17:59:56 schwarze Exp $ */
+/* $Id: main.h,v 1.11 2014/04/20 16:44:44 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
#define UNCONST(a) ((void *)(uintptr_t)(const void *)(a))
-/*
+/*
* Definitions for main.c-visible output device functions, e.g., -Thtml
* and -Tascii. Note that ascii_alloc() is named as such in
* anticipation of latin1_alloc() and so on, all of which map into the
-/* $Id: man.c,v 1.78 2014/03/30 19:47:32 schwarze Exp $ */
+/* $Id: man.c,v 1.79 2014/04/20 16:44:44 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
#include "libman.h"
#include "libmandoc.h"
-const char *const __man_macronames[MAN_MAX] = {
+const char *const __man_macronames[MAN_MAX] = {
"br", "TH", "SH", "SS",
- "TP", "LP", "PP", "P",
+ "TP", "LP", "PP", "P",
"IP", "HP", "SM", "SB",
"BI", "IB", "BR", "RB",
"R", "B", "I", "IR",
const char * const *man_macronames = __man_macronames;
-static struct man_node *man_node_alloc(struct man *, int, int,
+static struct man_node *man_node_alloc(struct man *, int, int,
enum man_type, enum mant);
-static int man_node_append(struct man *,
+static int man_node_append(struct man *,
struct man_node *);
static void man_node_free(struct man_node *);
-static void man_node_unlink(struct man *,
+static void man_node_unlink(struct man *,
struct man_node *);
static int man_ptext(struct man *, int, char *, int);
static int man_pmacro(struct man *, int, char *, int);
return(man->first);
}
-
const struct man_meta *
man_meta(const struct man *man)
{
return(&man->meta);
}
-
void
man_reset(struct man *man)
{
man_alloc1(man);
}
-
void
man_free(struct man *man)
{
free(man);
}
-
struct man *
man_alloc(struct roff *roff, struct mparse *parse, int quick)
{
return(p);
}
-
int
man_endparse(struct man *man)
{
return(0);
}
-
int
man_parseln(struct man *man, int ln, char *buf, int offs)
{
assert( ! (MAN_HALT & man->flags));
return (roff_getcontrol(man->roff, buf, &offs) ?
- man_pmacro(man, ln, buf, offs) :
- man_ptext(man, ln, buf, offs));
+ man_pmacro(man, ln, buf, offs) :
+ man_ptext(man, ln, buf, offs));
}
-
static void
man_free1(struct man *man)
{
free(man->meta.msec);
}
-
static void
man_alloc1(struct man *man)
{
assert(MAN_ROOT != p->type);
switch (man->next) {
- case (MAN_NEXT_SIBLING):
+ case MAN_NEXT_SIBLING:
man->last->next = p;
p->prev = man->last;
p->parent = man->last->parent;
break;
- case (MAN_NEXT_CHILD):
+ case MAN_NEXT_CHILD:
man->last->child = p;
p->parent = man->last;
break;
abort();
/* NOTREACHED */
}
-
+
assert(p->parent);
p->parent->nchild++;
return(0);
switch (p->type) {
- case (MAN_HEAD):
+ case MAN_HEAD:
assert(MAN_BLOCK == p->parent->type);
p->parent->head = p;
break;
- case (MAN_TAIL):
+ case MAN_TAIL:
assert(MAN_BLOCK == p->parent->type);
p->parent->tail = p;
break;
- case (MAN_BODY):
+ case MAN_BODY:
assert(MAN_BLOCK == p->parent->type);
p->parent->body = p;
break;
man->last = p;
switch (p->type) {
- case (MAN_TBL):
+ case MAN_TBL:
/* FALLTHROUGH */
- case (MAN_TEXT):
+ case MAN_TEXT:
if ( ! man_valid_post(man))
return(0);
break;
return(1);
}
-
static struct man_node *
-man_node_alloc(struct man *man, int line, int pos,
+man_node_alloc(struct man *man, int line, int pos,
enum man_type type, enum mant tok)
{
struct man_node *p;
return(p);
}
-
int
man_elem_alloc(struct man *man, int line, int pos, enum mant tok)
{
return(1);
}
-
int
man_tail_alloc(struct man *man, int line, int pos, enum mant tok)
{
return(1);
}
-
int
man_head_alloc(struct man *man, int line, int pos, enum mant tok)
{
return(1);
}
-
int
man_body_alloc(struct man *man, int line, int pos, enum mant tok)
{
return(1);
}
-
int
man_block_alloc(struct man *man, int line, int pos, enum mant tok)
{
return(1);
}
-
/*
* Free all of the resources held by a node. This does NOT unlink a
* node from its context; for that, see man_node_unlink().
free(p);
}
-
void
man_node_delete(struct man *man, struct man_node *p)
{
return(1);
}
- /*
+ /*
* Warn if the last un-escaped character is whitespace. Then
- * strip away the remaining spaces (tabs stay!).
+ * strip away the remaining spaces (tabs stay!).
*/
i = (int)strlen(buf);
*/
i = 0;
- while (i < 4 && '\0' != buf[offs] &&
- ' ' != buf[offs] && '\t' != buf[offs])
+ while (i < 4 && '\0' != buf[offs] && ' ' != buf[offs] &&
+ '\t' != buf[offs])
mac[i++] = buf[offs++];
mac[i] = '\0';
tok = (i > 0 && i < 4) ? man_hash_find(mac) : MAN_MAX;
if (MAN_MAX == tok) {
- mandoc_vmsg(MANDOCERR_MACRO, man->parse, ln,
- ppos, "%s", buf + ppos - 1);
+ mandoc_vmsg(MANDOCERR_MACRO, man->parse, ln, ppos,
+ "%s", buf + ppos - 1);
return(1);
}
while (buf[offs] && ' ' == buf[offs])
offs++;
- /*
+ /*
* Trailing whitespace. Note that tabs are allowed to be passed
* into the parser as "text", so we only warn about spaces here.
*/
if ('\0' == buf[offs] && ' ' == buf[offs - 1])
man_pmsg(man, ln, offs - 1, MANDOCERR_EOLNSPACE);
- /*
+ /*
* Remove prior ELINE macro, as it's being clobbered by a new
* macro. Note that NSCOPED macros do not close out ELINE
* macros---they don't print text---so we let those slip by.
if (MAN_NSCOPED & man_macros[n->tok].flags)
n = n->parent;
- mandoc_vmsg(MANDOCERR_LINESCOPE, man->parse, n->line,
+ mandoc_vmsg(MANDOCERR_LINESCOPE, man->parse, n->line,
n->pos, "%s breaks %s", man_macronames[tok],
man_macronames[n->tok]);
assert(MAN_BLOCK == n->type);
assert(MAN_SCOPED & man_macros[n->tok].flags);
- mandoc_vmsg(MANDOCERR_LINESCOPE, man->parse, n->line,
+ mandoc_vmsg(MANDOCERR_LINESCOPE, man->parse, n->line,
n->pos, "%s breaks %s", man_macronames[tok],
man_macronames[n->tok]);
strcmp(man->last->prev->child->string, "NAME"))
return(2);
- /*
+ /*
* We weren't in a block-line scope when entering the
* above-parsed macro, so return.
*/
if ( ! (MAN_BPLINE & man->flags)) {
- man->flags &= ~MAN_ILINE;
+ man->flags &= ~MAN_ILINE;
return(1);
}
man->flags &= ~MAN_BPLINE;
return(1);
}
- /*
+ /*
* If we've opened a new next-line element scope, then return
* now, as the next line will close out the block scope.
*/
-/* $Id: man_hash.c,v 1.16 2014/03/21 22:17:01 schwarze Exp $ */
+/* $Id: man_hash.c,v 1.17 2014/04/20 16:44:44 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
*/
static unsigned char table[26 * HASH_DEPTH];
+
/*
* XXX - this hash has global scope, so if intended for use as a library
* with multiple callers, it will need re-invocation protection.
memset(table, UCHAR_MAX, sizeof(table));
- assert(/* LINTED */
- MAN_MAX < UCHAR_MAX);
+ assert(MAN_MAX < UCHAR_MAX);
for (i = 0; i < (int)MAN_MAX; i++) {
x = man_macronames[i][0];
}
}
-
enum mant
man_hash_find(const char *tmp)
{
-/* $Id: man_html.c,v 1.51 2014/03/30 19:47:32 schwarze Exp $ */
+/* $Id: man_html.c,v 1.52 2014/04/20 16:44:44 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
int (*post)(MAN_ARGS);
};
-static void print_bvspace(struct html *,
+static void print_bvspace(struct html *,
const struct man_node *);
static void print_man(MAN_ARGS);
static void print_man_head(MAN_ARGS);
{ man_PP_pre, NULL }, /* PP */
{ man_PP_pre, NULL }, /* P */
{ man_IP_pre, NULL }, /* IP */
- { man_HP_pre, NULL }, /* HP */
+ { man_HP_pre, NULL }, /* HP */
{ man_SM_pre, NULL }, /* SM */
{ man_SM_pre, NULL }, /* SB */
{ man_alt_pre, NULL }, /* BI */
{ man_ign_pre, NULL }, /* ll */
};
+
/*
* Printing leading vertical space before a block.
* This is used for the paragraph macros.
}
static void
-print_man(MAN_ARGS)
+print_man(MAN_ARGS)
{
struct tag *t, *tt;
struct htmlpair tag;
print_tagq(h, tt);
print_otag(h, TAG_BODY, 0, NULL);
print_otag(h, TAG_DIV, 1, &tag);
- } else
+ } else
t = print_otag(h, TAG_DIV, 1, &tag);
print_man_nodelist(man, n, mh, h);
print_tagq(h, t);
}
-
-/* ARGSUSED */
static void
print_man_head(MAN_ARGS)
{
print_text(h, h->buf);
}
-
static void
print_man_nodelist(MAN_ARGS)
{
print_man_nodelist(man, n->next, mh, h);
}
-
static void
print_man_node(MAN_ARGS)
{
t = h->tags.head;
switch (n->type) {
- case (MAN_ROOT):
+ case MAN_ROOT:
man_root_pre(man, n, mh, h);
break;
- case (MAN_TEXT):
+ case MAN_TEXT:
/*
* If we have a blank line, output a vertical space.
* If we have a space as the first character, break
print_text(h, n->string);
return;
- case (MAN_EQN):
+ case MAN_EQN:
print_eqn(h, n->eqn);
break;
- case (MAN_TBL):
+ case MAN_TBL:
/*
* This will take care of initialising all of the table
* state data for the first table, then tearing it down
print_tbl(h, n->span);
return;
default:
- /*
+ /*
* Close out scope of font prior to opening a macro
* scope.
*/
print_stagq(h, t);
switch (n->type) {
- case (MAN_ROOT):
+ case MAN_ROOT:
man_root_post(man, n, mh, h);
break;
- case (MAN_EQN):
+ case MAN_EQN:
break;
default:
if (mans[n->tok].post)
}
}
-
static int
a2width(const struct man_node *n, struct roffsu *su)
{
return(0);
}
-
-/* ARGSUSED */
static void
man_root_pre(MAN_ARGS)
{
print_tagq(h, t);
}
-
-/* ARGSUSED */
static void
man_root_post(MAN_ARGS)
{
}
-/* ARGSUSED */
static int
man_br_pre(MAN_ARGS)
{
return(0);
}
-/* ARGSUSED */
static int
man_SH_pre(MAN_ARGS)
{
return(1);
}
-/* ARGSUSED */
static int
man_alt_pre(MAN_ARGS)
{
enum htmltag fp;
struct tag *t;
- if ((savelit = mh->fl & MANH_LITERAL))
+ if ((savelit = mh->fl & MANH_LITERAL))
print_otag(h, TAG_BR, 0, NULL);
mh->fl &= ~MANH_LITERAL;
for (i = 0, nn = n->child; nn; nn = nn->next, i++) {
t = NULL;
switch (n->tok) {
- case (MAN_BI):
+ case MAN_BI:
fp = i % 2 ? TAG_I : TAG_B;
break;
- case (MAN_IB):
+ case MAN_IB:
fp = i % 2 ? TAG_B : TAG_I;
break;
- case (MAN_RI):
+ case MAN_RI:
fp = i % 2 ? TAG_I : TAG_MAX;
break;
- case (MAN_IR):
+ case MAN_IR:
fp = i % 2 ? TAG_MAX : TAG_I;
break;
- case (MAN_BR):
+ case MAN_BR:
fp = i % 2 ? TAG_MAX : TAG_B;
break;
- case (MAN_RB):
+ case MAN_RB:
fp = i % 2 ? TAG_B : TAG_MAX;
break;
default:
return(0);
}
-/* ARGSUSED */
static int
man_SM_pre(MAN_ARGS)
{
-
+
print_otag(h, TAG_SMALL, 0, NULL);
if (MAN_SB == n->tok)
print_otag(h, TAG_B, 0, NULL);
return(1);
}
-/* ARGSUSED */
static int
man_SS_pre(MAN_ARGS)
{
return(1);
}
-/* ARGSUSED */
static int
man_PP_pre(MAN_ARGS)
{
return(1);
}
-/* ARGSUSED */
static int
man_IP_pre(MAN_ARGS)
{
const struct man_node *nn;
- if (MAN_BODY == n->type) {
+ if (MAN_BODY == n->type) {
print_otag(h, TAG_DD, 0, NULL);
return(1);
} else if (MAN_HEAD != n->type) {
return(0);
}
-/* ARGSUSED */
static int
man_HP_pre(MAN_ARGS)
{
return(1);
}
-/* ARGSUSED */
static int
man_OP_pre(MAN_ARGS)
{
return(0);
}
-
-/* ARGSUSED */
static int
man_B_pre(MAN_ARGS)
{
return(1);
}
-/* ARGSUSED */
static int
man_I_pre(MAN_ARGS)
{
-
+
print_otag(h, TAG_I, 0, NULL);
return(1);
}
-/* ARGSUSED */
static int
man_literal_pre(MAN_ARGS)
{
return(0);
}
-/* ARGSUSED */
static int
man_in_pre(MAN_ARGS)
{
return(0);
}
-/* ARGSUSED */
static int
man_ign_pre(MAN_ARGS)
{
return(0);
}
-/* ARGSUSED */
static int
man_RS_pre(MAN_ARGS)
{
return(1);
}
-/* ARGSUSED */
static int
man_UR_pre(MAN_ARGS)
{
-/* $Id: man_macro.c,v 1.44 2014/03/30 19:47:32 schwarze Exp $ */
+/* $Id: man_macro.c,v 1.45 2014/04/20 16:44:44 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2012, 2013 Ingo Schwarze <schwarze@openbsd.org>
static int blk_exp(MACRO_PROT_ARGS);
static int blk_imp(MACRO_PROT_ARGS);
static int in_line_eoln(MACRO_PROT_ARGS);
-static int man_args(struct man *, int,
+static int man_args(struct man *, int,
int *, char *, char **);
-static int rew_scope(enum man_type,
+static int rew_scope(enum man_type,
struct man *, enum mant);
-static enum rew rew_dohalt(enum mant, enum man_type,
+static enum rew rew_dohalt(enum mant, enum man_type,
const struct man_node *);
-static enum rew rew_block(enum mant, enum man_type,
+static enum rew rew_block(enum mant, enum man_type,
const struct man_node *);
-static void rew_warn(struct man *,
+static void rew_warn(struct man *,
struct man_node *, enum mandocerr);
const struct man_macro __man_macros[MAN_MAX] = {
man_nmsg(man, n, er);
}
-
/*
* Rewind scope. If a code "er" != MANDOCERR_MAX has been provided, it
* will be used if an explicit block scope is being closed out.
*/
int
-man_unscope(struct man *man, const struct man_node *to,
+man_unscope(struct man *man, const struct man_node *to,
enum mandocerr er)
{
struct man_node *n;
man->next = MAN_NEXT_SIBLING;
- /* LINTED */
while (man->last != to) {
/*
* Save the parent here, because we may delete the
return(1);
}
-
static enum rew
rew_block(enum mant ntok, enum man_type type, const struct man_node *n)
{
- if (MAN_BLOCK == type && ntok == n->parent->tok &&
- MAN_BODY == n->parent->type)
+ if (MAN_BLOCK == type && ntok == n->parent->tok &&
+ MAN_BODY == n->parent->type)
return(REW_REWIND);
return(ntok == n->tok ? REW_HALT : REW_NOHALT);
}
-
/*
* 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).
*/
-static enum rew
+static enum rew
rew_dohalt(enum mant tok, enum man_type type, const struct man_node *n)
{
enum rew c;
return(REW_REWIND);
}
- /*
+ /*
* Next follow the implicit scope-smashings as defined by man.7:
* section, sub-section, etc.
*/
switch (tok) {
- case (MAN_SH):
+ case MAN_SH:
break;
- case (MAN_SS):
+ case MAN_SS:
/* Rewind to a section, if a block. */
if (REW_NOHALT != (c = rew_block(MAN_SH, type, n)))
return(c);
break;
- case (MAN_RS):
+ case MAN_RS:
/* Preserve empty paragraphs before RS. */
if (0 == n->nchild && (MAN_P == n->tok ||
MAN_PP == n->tok || MAN_LP == n->tok))
return(REW_NOHALT);
}
-
/*
* Rewinding entails ascending the parse tree until a coherent point,
* for example, the `SH' macro will close out any intervening `SS'
struct man_node *n;
enum rew c;
- /* LINTED */
for (n = man->last; n; n = n->parent) {
- /*
+ /*
* Whether we should stop immediately (REW_HALT), stop
* and rewind until this point (REW_REWIND), or keep
* rewinding (REW_NOHALT).
break;
}
- /*
+ /*
* Rewind until the current point. Warn if we're a roff
* instruction that's mowing over explicit scopes.
*/
/*
* Close out a generic explicit macro.
*/
-/* ARGSUSED */
int
blk_close(MACRO_PROT_ARGS)
{
- enum mant ntok;
+ enum mant ntok;
const struct man_node *nn;
switch (tok) {
- case (MAN_RE):
+ case MAN_RE:
ntok = MAN_RS;
break;
- case (MAN_UE):
+ case MAN_UE:
ntok = MAN_UR;
break;
default:
man_pmsg(man, line, ppos, MANDOCERR_NOSCOPE);
if ( ! rew_scope(MAN_BLOCK, man, MAN_PP))
return(0);
- } else
+ } else
man_unscope(man, nn, MANDOCERR_MAX);
return(1);
}
-
-/* ARGSUSED */
int
blk_exp(MACRO_PROT_ARGS)
{
return(man_body_alloc(man, line, ppos, tok));
}
-
-
/*
* 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
* routines.
*/
-/* ARGSUSED */
int
blk_imp(MACRO_PROT_ARGS)
{
return(man_body_alloc(man, line, ppos, tok));
}
-
-/* ARGSUSED */
int
in_line_eoln(MACRO_PROT_ARGS)
{
assert( ! (MAN_NSCOPED & man_macros[tok].flags));
man->flags |= MAN_ELINE;
return(1);
- }
+ }
/* Set ignorable context, if applicable. */
assert(MAN_ROOT != man->last->type);
man->next = MAN_NEXT_SIBLING;
-
+
/*
* 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
assert(man->last);
/*
- * Same here regarding whether we're back at the root.
+ * Same here regarding whether we're back at the root.
*/
if (man->last->type != MAN_ROOT && ! man_valid_post(man))
-/* $Id: man_term.c,v 1.99 2014/04/08 07:13:01 schwarze Exp $ */
+/* $Id: man_term.c,v 1.100 2014/04/20 16:44:44 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
int pardist; /* vert. space before par., unit: [v] */
};
-#define DECL_ARGS struct termp *p, \
+#define DECL_ARGS struct termp *p, \
struct mtermp *mt, \
const struct man_node *n, \
const struct man_meta *meta
static void print_man_node(DECL_ARGS);
static void print_man_head(struct termp *, const void *);
static void print_man_foot(struct termp *, const void *);
-static void print_bvspace(struct termp *,
+static void print_bvspace(struct termp *,
const struct man_node *, int);
static int pre_B(DECL_ARGS);
{ pre_PP, NULL, 0 }, /* PP */
{ pre_PP, NULL, 0 }, /* P */
{ pre_IP, post_IP, 0 }, /* IP */
- { pre_HP, post_HP, 0 }, /* HP */
+ { pre_HP, post_HP, 0 }, /* HP */
{ NULL, NULL, 0 }, /* SM */
{ pre_B, NULL, 0 }, /* SB */
{ pre_alternate, NULL, 0 }, /* BI */
};
-
void
terminal_man(void *arg, const struct man *man)
{
return(term_vspan(p, &su));
}
-
static int
a2width(const struct termp *p, const char *cp)
{
term_vspace(p);
}
-/* ARGSUSED */
+
static int
pre_ign(DECL_ARGS)
{
return(0);
}
-
-/* ARGSUSED */
static int
pre_ll(DECL_ARGS)
{
return(0);
}
-
-/* ARGSUSED */
static int
pre_I(DECL_ARGS)
{
return(1);
}
-
-/* ARGSUSED */
static int
pre_literal(DECL_ARGS)
{
return(0);
}
-/* ARGSUSED */
static int
pre_PD(DECL_ARGS)
{
return(0);
}
-/* ARGSUSED */
static int
pre_alternate(DECL_ARGS)
{
int savelit, i;
switch (n->tok) {
- case (MAN_RB):
+ case MAN_RB:
font[0] = TERMFONT_NONE;
font[1] = TERMFONT_BOLD;
break;
- case (MAN_RI):
+ case MAN_RI:
font[0] = TERMFONT_NONE;
font[1] = TERMFONT_UNDER;
break;
- case (MAN_BR):
+ case MAN_BR:
font[0] = TERMFONT_BOLD;
font[1] = TERMFONT_NONE;
break;
- case (MAN_BI):
+ case MAN_BI:
font[0] = TERMFONT_BOLD;
font[1] = TERMFONT_UNDER;
break;
- case (MAN_IR):
+ case MAN_IR:
font[0] = TERMFONT_UNDER;
font[1] = TERMFONT_NONE;
break;
- case (MAN_IB):
+ case MAN_IB:
font[0] = TERMFONT_UNDER;
font[1] = TERMFONT_BOLD;
break;
return(0);
}
-/* ARGSUSED */
static int
pre_B(DECL_ARGS)
{
return(1);
}
-/* ARGSUSED */
static int
pre_OP(DECL_ARGS)
{
return(0);
}
-/* ARGSUSED */
static int
pre_ft(DECL_ARGS)
{
cp = n->child->string;
switch (*cp) {
- case ('4'):
+ case '4':
/* FALLTHROUGH */
- case ('3'):
+ case '3':
/* FALLTHROUGH */
- case ('B'):
+ case 'B':
term_fontrepl(p, TERMFONT_BOLD);
break;
- case ('2'):
+ case '2':
/* FALLTHROUGH */
- case ('I'):
+ case 'I':
term_fontrepl(p, TERMFONT_UNDER);
break;
- case ('P'):
+ case 'P':
term_fontlast(p);
break;
- case ('1'):
+ case '1':
/* FALLTHROUGH */
- case ('C'):
+ case 'C':
/* FALLTHROUGH */
- case ('R'):
+ case 'R':
term_fontrepl(p, TERMFONT_NONE);
break;
default:
return(0);
}
-/* ARGSUSED */
static int
pre_in(DECL_ARGS)
{
p->offset -= p->offset > v ? v : p->offset;
else if (less > 0)
p->offset += v;
- else
+ else
p->offset = v;
/* Don't let this creep beyond the right margin. */
return(0);
}
-
-/* ARGSUSED */
static int
pre_sp(DECL_ARGS)
{
if ((NULL == n->prev && n->parent)) {
switch (n->parent->tok) {
- case (MAN_SH):
+ case MAN_SH:
/* FALLTHROUGH */
- case (MAN_SS):
+ case MAN_SS:
/* FALLTHROUGH */
- case (MAN_PP):
+ case MAN_PP:
/* FALLTHROUGH */
- case (MAN_LP):
+ case MAN_LP:
/* FALLTHROUGH */
- case (MAN_P):
+ case MAN_P:
/* FALLTHROUGH */
return(0);
default:
neg = 0;
switch (n->tok) {
- case (MAN_br):
+ case MAN_br:
len = 0;
break;
default:
return(0);
}
-
-/* ARGSUSED */
static int
pre_HP(DECL_ARGS)
{
const struct man_node *nn;
switch (n->type) {
- case (MAN_BLOCK):
+ case MAN_BLOCK:
print_bvspace(p, n, mt->pardist);
return(1);
- case (MAN_BODY):
+ case MAN_BODY:
break;
default:
return(0);
return(1);
}
-
-/* ARGSUSED */
static void
post_HP(DECL_ARGS)
{
switch (n->type) {
- case (MAN_BODY):
+ case MAN_BODY:
term_newln(p);
p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND);
p->trailspace = 0;
}
}
-
-/* ARGSUSED */
static int
pre_PP(DECL_ARGS)
{
switch (n->type) {
- case (MAN_BLOCK):
+ case MAN_BLOCK:
mt->lmargin[mt->lmargincur] = term_len(p, p->defindent);
print_bvspace(p, n, mt->pardist);
break;
return(MAN_HEAD != n->type);
}
-
-/* ARGSUSED */
static int
pre_IP(DECL_ARGS)
{
int savelit, ival;
switch (n->type) {
- case (MAN_BODY):
+ case MAN_BODY:
p->flags |= TERMP_NOSPACE;
break;
- case (MAN_HEAD):
+ case MAN_HEAD:
p->flags |= TERMP_NOBREAK;
p->trailspace = 1;
break;
- case (MAN_BLOCK):
+ case MAN_BLOCK:
print_bvspace(p, n, mt->pardist);
/* FALLTHROUGH */
default:
len = (size_t)ival;
switch (n->type) {
- case (MAN_HEAD):
+ case MAN_HEAD:
/* Handle zero-width lengths. */
if (0 == len)
len = term_len(p, 1);
mt->fl |= MANT_LITERAL;
return(0);
- case (MAN_BODY):
+ case MAN_BODY:
p->offset = mt->offset + len;
p->rmargin = p->maxrmargin > p->offset ?
- p->maxrmargin : p->offset;
+ p->maxrmargin : p->offset;
break;
default:
break;
return(1);
}
-
-/* ARGSUSED */
static void
post_IP(DECL_ARGS)
{
switch (n->type) {
- case (MAN_HEAD):
+ case MAN_HEAD:
term_flushln(p);
p->flags &= ~TERMP_NOBREAK;
p->trailspace = 0;
p->rmargin = p->maxrmargin;
break;
- case (MAN_BODY):
+ case MAN_BODY:
term_newln(p);
p->offset = mt->offset;
break;
}
}
-
-/* ARGSUSED */
static int
pre_TP(DECL_ARGS)
{
int savelit, ival;
switch (n->type) {
- case (MAN_HEAD):
+ case MAN_HEAD:
p->flags |= TERMP_NOBREAK;
p->trailspace = 1;
break;
- case (MAN_BODY):
+ case MAN_BODY:
p->flags |= TERMP_NOSPACE;
break;
- case (MAN_BLOCK):
+ case MAN_BLOCK:
print_bvspace(p, n, mt->pardist);
/* FALLTHROUGH */
default:
len = (size_t)ival;
switch (n->type) {
- case (MAN_HEAD):
+ case MAN_HEAD:
/* Handle zero-length properly. */
if (0 == len)
len = term_len(p, 1);
mt->lmargin[mt->lmargincur] = (size_t)ival;
return(0);
- case (MAN_BODY):
+ case MAN_BODY:
p->offset = mt->offset + len;
p->rmargin = p->maxrmargin > p->offset ?
- p->maxrmargin : p->offset;
+ p->maxrmargin : p->offset;
p->trailspace = 0;
p->flags &= ~TERMP_NOBREAK;
break;
return(1);
}
-
-/* ARGSUSED */
static void
post_TP(DECL_ARGS)
{
switch (n->type) {
- case (MAN_HEAD):
+ case MAN_HEAD:
term_flushln(p);
break;
- case (MAN_BODY):
+ case MAN_BODY:
term_newln(p);
p->offset = mt->offset;
break;
}
}
-
-/* ARGSUSED */
static int
pre_SS(DECL_ARGS)
{
int i;
switch (n->type) {
- case (MAN_BLOCK):
+ case MAN_BLOCK:
mt->fl &= ~MANT_LITERAL;
mt->lmargin[mt->lmargincur] = term_len(p, p->defindent);
mt->offset = term_len(p, p->defindent);
for (i = 0; i < mt->pardist; i++)
term_vspace(p);
break;
- case (MAN_HEAD):
+ case MAN_HEAD:
term_fontrepl(p, TERMFONT_BOLD);
p->offset = term_len(p, 3);
break;
- case (MAN_BODY):
+ case MAN_BODY:
p->offset = mt->offset;
break;
default:
return(1);
}
-
-/* ARGSUSED */
static void
post_SS(DECL_ARGS)
{
-
+
switch (n->type) {
- case (MAN_HEAD):
+ case MAN_HEAD:
term_newln(p);
break;
- case (MAN_BODY):
+ case MAN_BODY:
term_newln(p);
break;
default:
}
}
-
-/* ARGSUSED */
static int
pre_SH(DECL_ARGS)
{
int i;
switch (n->type) {
- case (MAN_BLOCK):
+ case MAN_BLOCK:
mt->fl &= ~MANT_LITERAL;
mt->lmargin[mt->lmargincur] = term_len(p, p->defindent);
mt->offset = term_len(p, p->defindent);
for (i = 0; i < mt->pardist; i++)
term_vspace(p);
break;
- case (MAN_HEAD):
+ case MAN_HEAD:
term_fontrepl(p, TERMFONT_BOLD);
p->offset = 0;
break;
- case (MAN_BODY):
+ case MAN_BODY:
p->offset = mt->offset;
break;
default:
return(1);
}
-
-/* ARGSUSED */
static void
post_SH(DECL_ARGS)
{
-
+
switch (n->type) {
- case (MAN_HEAD):
+ case MAN_HEAD:
term_newln(p);
break;
- case (MAN_BODY):
+ case MAN_BODY:
term_newln(p);
break;
default:
}
}
-/* ARGSUSED */
static int
pre_RS(DECL_ARGS)
{
size_t sz;
switch (n->type) {
- case (MAN_BLOCK):
+ case MAN_BLOCK:
term_newln(p);
return(1);
- case (MAN_HEAD):
+ case MAN_HEAD:
return(0);
default:
break;
sz = term_len(p, p->defindent);
if (NULL != (n = n->parent->head->child))
- if ((ival = a2width(p, n->string)) >= 0)
+ if ((ival = a2width(p, n->string)) >= 0)
sz = (size_t)ival;
mt->offset += sz;
p->offset = mt->offset;
p->rmargin = p->maxrmargin > p->offset ?
- p->maxrmargin : p->offset;
+ p->maxrmargin : p->offset;
if (++mt->lmarginsz < MAXMARGINS)
mt->lmargincur = mt->lmarginsz;
return(1);
}
-/* ARGSUSED */
static void
post_RS(DECL_ARGS)
{
size_t sz;
switch (n->type) {
- case (MAN_BLOCK):
+ case MAN_BLOCK:
return;
- case (MAN_HEAD):
+ case MAN_HEAD:
return;
default:
term_newln(p);
sz = term_len(p, p->defindent);
- if (NULL != (n = n->parent->head->child))
- if ((ival = a2width(p, n->string)) >= 0)
+ if (NULL != (n = n->parent->head->child))
+ if ((ival = a2width(p, n->string)) >= 0)
sz = (size_t)ival;
mt->offset = mt->offset < sz ? 0 : mt->offset - sz;
mt->lmargincur = mt->lmarginsz;
}
-/* ARGSUSED */
static int
pre_UR(DECL_ARGS)
{
return (MAN_HEAD != n->type);
}
-/* ARGSUSED */
static void
post_UR(DECL_ARGS)
{
int c;
switch (n->type) {
- case(MAN_TEXT):
+ case MAN_TEXT:
/*
* If we have a blank line, output a vertical space.
* If we have a space as the first character, break
term_word(p, n->string);
goto out;
- case (MAN_EQN):
+ case MAN_EQN:
term_eqn(p, n->eqn);
return;
- case (MAN_TBL):
+ case MAN_TBL:
/*
* Tables are preceded by a newline. Then process a
* table line, which will cause line termination,
*/
- if (TBL_SPAN_FIRST & n->span->flags)
+ if (TBL_SPAN_FIRST & n->span->flags)
term_newln(p);
term_tbl(p, n->span);
return;
print_man_nodelist(p, mt, n->next, meta);
}
-
static void
print_man_foot(struct termp *p, const void *arg)
{
term_flushln(p);
}
-
static void
print_man_head(struct termp *p, const void *arg)
{
p->trailspace = 1;
p->offset = 0;
p->rmargin = 2 * (titlen+1) + buflen < p->maxrmargin ?
- (p->maxrmargin -
+ (p->maxrmargin -
term_strlen(p, buf) + term_len(p, 1)) / 2 :
p->maxrmargin - buflen;
p->offset = 0;
p->rmargin = p->maxrmargin;
- /*
+ /*
* Groff prints three blank lines before the content.
* Do the same, except in the temporary, undocumented
* mode imitating mdoc(7) output.
-/* $Id: man_validate.c,v 1.62 2014/03/30 19:47:32 schwarze Exp $ */
+/* $Id: man_validate.c,v 1.63 2014/04/20 16:44:44 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
v_check *cp;
switch (n->type) {
- case (MAN_TEXT):
+ case MAN_TEXT:
/* FALLTHROUGH */
- case (MAN_ROOT):
+ case MAN_ROOT:
/* FALLTHROUGH */
- case (MAN_EQN):
+ case MAN_EQN:
/* FALLTHROUGH */
- case (MAN_TBL):
+ case MAN_TBL:
return(1);
default:
break;
if (NULL == (cp = man_valids[n->tok].pres))
return(1);
for ( ; *cp; cp++)
- if ( ! (*cp)(man, n))
+ if ( ! (*cp)(man, n))
return(0);
return(1);
}
-
int
man_valid_post(struct man *man)
{
man->last->flags |= MAN_VALID;
switch (man->last->type) {
- case (MAN_TEXT):
+ case MAN_TEXT:
check_text(man, man->last);
return(1);
- case (MAN_ROOT):
+ case MAN_ROOT:
return(check_root(man, man->last));
- case (MAN_EQN):
+ case MAN_EQN:
/* FALLTHROUGH */
- case (MAN_TBL):
+ case MAN_TBL:
return(1);
default:
break;
return(1);
}
-
static int
-check_root(CHKARGS)
+check_root(CHKARGS)
{
if (MAN_BLINE & man->flags)
* implication, date and section also aren't set).
*/
- man->meta.title = mandoc_strdup("unknown");
+ man->meta.title = mandoc_strdup("unknown");
man->meta.msec = mandoc_strdup("1");
man->meta.date = man->quick ? mandoc_strdup("") :
mandoc_normdate(man->parse, NULL, n->line, n->pos);
if (n->nchild ineq (x)) \
return(1); \
mandoc_vmsg(MANDOCERR_ARGCOUNT, man->parse, n->line, n->pos, \
- "line arguments %s %d (have %d)", \
- #ineq, (x), n->nchild); \
+ "line arguments %s %d (have %d)", \
+ #ineq, (x), n->nchild); \
return(1); \
}
ok = 0;
cp = n->child->string;
switch (*cp) {
- case ('1'):
+ case '1':
/* FALLTHROUGH */
- case ('2'):
+ case '2':
/* FALLTHROUGH */
- case ('3'):
+ case '3':
/* FALLTHROUGH */
- case ('4'):
+ case '4':
/* FALLTHROUGH */
- case ('I'):
+ case 'I':
/* FALLTHROUGH */
- case ('P'):
+ case 'P':
/* FALLTHROUGH */
- case ('R'):
+ case 'R':
if ('\0' == cp[1])
ok = 1;
break;
- case ('B'):
+ case 'B':
if ('\0' == cp[1] || ('I' == cp[1] && '\0' == cp[2]))
ok = 1;
break;
- case ('C'):
+ case 'C':
if ('W' == cp[1] && '\0' == cp[2])
ok = 1;
break;
}
if (0 == ok) {
- mandoc_vmsg
- (MANDOCERR_BADFONT, man->parse,
- n->line, n->pos, "%s", cp);
+ mandoc_vmsg(MANDOCERR_BADFONT, man->parse, n->line,
+ n->pos, "%s", cp);
*cp = '\0';
}
if (1 < n->nchild)
- mandoc_vmsg
- (MANDOCERR_ARGCOUNT, man->parse, n->line,
- n->pos, "want one child (have %d)",
- n->nchild);
+ mandoc_vmsg(MANDOCERR_ARGCOUNT, man->parse, n->line,
+ n->pos, "want one child (have %d)", n->nchild);
return(1);
}
post_sec(CHKARGS)
{
- if ( ! (MAN_HEAD == n->type && 0 == n->nchild))
+ if ( ! (MAN_HEAD == n->type && 0 == n->nchild))
return(1);
man_nmsg(man, n, MANDOCERR_SYNTARGCOUNT);
{
if (MAN_BODY == n->type && 0 == n->nchild)
- mandoc_msg(MANDOCERR_ARGCWARN, man->parse, n->line,
- n->pos, "want children (have none)");
+ mandoc_msg(MANDOCERR_ARGCWARN, man->parse, n->line,
+ n->pos, "want children (have none)");
return(1);
}
-
static int
check_par(CHKARGS)
{
switch (n->type) {
- case (MAN_BLOCK):
+ case MAN_BLOCK:
if (0 == n->body->nchild)
man_node_delete(man, n);
break;
- case (MAN_BODY):
+ case MAN_BODY:
if (0 == n->nchild)
man_nmsg(man, n, MANDOCERR_IGNPAR);
break;
- case (MAN_HEAD):
+ case MAN_HEAD:
if (n->nchild)
man_nmsg(man, n, MANDOCERR_ARGSLOST);
break;
{
switch (n->type) {
- case (MAN_BLOCK):
+ case MAN_BLOCK:
if (0 == n->head->nchild && 0 == n->body->nchild)
man_node_delete(man, n);
break;
- case (MAN_BODY):
+ case MAN_BODY:
if (0 == n->parent->head->nchild && 0 == n->nchild)
man_nmsg(man, n, MANDOCERR_IGNPAR);
break;
free(man->meta.date);
man->meta.title = man->meta.vol = man->meta.date =
- man->meta.msec = man->meta.source = NULL;
+ man->meta.msec = man->meta.source = NULL;
/* ->TITLE<- MSEC DATE SOURCE VOL */
if (n && n->string) {
for (p = n->string; '\0' != *p; p++) {
/* Only warn about this once... */
- if (isalpha((unsigned char)*p) &&
- ! isupper((unsigned char)*p)) {
+ if (isalpha((unsigned char)*p) &&
+ ! isupper((unsigned char)*p)) {
man_nmsg(man, n, MANDOCERR_UPPERCASE);
break;
}
return(1);
switch (n->parent->tok) {
- case (MAN_SH):
+ case MAN_SH:
/* FALLTHROUGH */
- case (MAN_SS):
+ case MAN_SS:
man_nmsg(man, n, MANDOCERR_IGNPAR);
/* FALLTHROUGH */
- case (MAN_MAX):
- /*
+ case MAN_MAX:
+ /*
* Don't warn about this because it occurs in pod2man
* and would cause considerable (unfixable) warnage.
*/
-/* $Id: mandoc.c,v 1.47 2014/04/08 01:36:50 schwarze Exp $ */
+/* $Id: mandoc.c,v 1.48 2014/04/20 16:44:44 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
const char *local_start;
int local_sz;
char term;
- enum mandoc_esc gly;
+ enum mandoc_esc gly;
/*
* When the caller doesn't provide return storage,
* these, but each eventually returns a substring of the glyph
* name.
*/
- case ('('):
+ case '(':
gly = ESCAPE_SPECIAL;
*sz = 2;
break;
- case ('['):
+ case '[':
gly = ESCAPE_SPECIAL;
/*
* Unicode escapes are defined in groff as \[uXXXX] to
gly = ESCAPE_UNICODE;
term = ']';
break;
- case ('C'):
+ case 'C':
if ('\'' != **start)
return(ESCAPE_ERROR);
*start = ++*end;
/*
* Escapes taking no arguments at all.
*/
- case ('d'):
+ case 'd':
/* FALLTHROUGH */
- case ('u'):
+ case 'u':
return(ESCAPE_IGNORE);
/*
* The \z escape is supposed to output the following
- * character without advancing the cursor position.
+ * character without advancing the cursor position.
* Since we are mostly dealing with terminal mode,
* let us just skip the next character.
*/
- case ('z'):
+ case 'z':
return(ESCAPE_SKIPCHAR);
/*
* Handle all triggers matching \X(xy, \Xx, and \X[xxxx], where
* 'X' is the trigger. These have opaque sub-strings.
*/
- case ('F'):
+ case 'F':
/* FALLTHROUGH */
- case ('g'):
+ case 'g':
/* FALLTHROUGH */
- case ('k'):
+ case 'k':
/* FALLTHROUGH */
- case ('M'):
+ case 'M':
/* FALLTHROUGH */
- case ('m'):
+ case 'm':
/* FALLTHROUGH */
- case ('n'):
+ case 'n':
/* FALLTHROUGH */
- case ('V'):
+ case 'V':
/* FALLTHROUGH */
- case ('Y'):
+ case 'Y':
gly = ESCAPE_IGNORE;
/* FALLTHROUGH */
- case ('f'):
+ case 'f':
if (ESCAPE_ERROR == gly)
gly = ESCAPE_FONT;
switch (**start) {
- case ('('):
+ case '(':
*start = ++*end;
*sz = 2;
break;
- case ('['):
+ case '[':
*start = ++*end;
term = ']';
break;
* and 'Y' is any string. These have opaque sub-strings.
* The \B and \w escapes are handled in roff.c, roff_res().
*/
- case ('A'):
+ case 'A':
/* FALLTHROUGH */
- case ('b'):
+ case 'b':
/* FALLTHROUGH */
- case ('D'):
+ case 'D':
/* FALLTHROUGH */
- case ('o'):
+ case 'o':
/* FALLTHROUGH */
- case ('R'):
+ case 'R':
/* FALLTHROUGH */
- case ('X'):
+ case 'X':
/* FALLTHROUGH */
- case ('Z'):
+ case 'Z':
if ('\0' == **start)
return(ESCAPE_ERROR);
gly = ESCAPE_IGNORE;
* These escapes are of the form \X'N', where 'X' is the trigger
* and 'N' resolves to a numerical expression.
*/
- case ('h'):
+ case 'h':
/* FALLTHROUGH */
- case ('H'):
+ case 'H':
/* FALLTHROUGH */
- case ('L'):
+ case 'L':
/* FALLTHROUGH */
- case ('l'):
+ case 'l':
/* FALLTHROUGH */
- case ('S'):
+ case 'S':
/* FALLTHROUGH */
- case ('v'):
+ case 'v':
/* FALLTHROUGH */
- case ('x'):
+ case 'x':
if (strchr("\0 %&()*+-./0123456789:<=>", **start))
return(ESCAPE_ERROR);
gly = ESCAPE_IGNORE;
* Special handling for the numbered character escape.
* XXX Do any other escapes need similar handling?
*/
- case ('N'):
+ case 'N':
if ('\0' == **start)
return(ESCAPE_ERROR);
(*end)++;
(*end)++;
return(ESCAPE_NUMBERED);
- /*
+ /*
* Sizes get a special category of their own.
*/
- case ('s'):
+ case 's':
gly = ESCAPE_IGNORE;
/* See +/- counts as a sign. */
(*end)++;
switch (**end) {
- case ('('):
+ case '(':
*start = ++*end;
*sz = 2;
break;
- case ('['):
+ case '[':
*start = ++*end;
term = ']';
break;
- case ('\''):
+ case '\'':
*start = ++*end;
term = '\'';
break;
if ('\0' != term) {
while (**end != term) {
switch (**end) {
- case ('\0'):
+ case '\0':
return(ESCAPE_ERROR);
- case ('\\'):
+ case '\\':
(*end)++;
if (ESCAPE_ERROR ==
mandoc_escape(end, NULL, NULL))
/* Run post-processors. */
switch (gly) {
- case (ESCAPE_FONT):
+ case ESCAPE_FONT:
if (2 == *sz) {
if ('C' == **start) {
/*
break;
switch (**start) {
- case ('3'):
+ case '3':
/* FALLTHROUGH */
- case ('B'):
+ case 'B':
gly = ESCAPE_FONTBOLD;
break;
- case ('2'):
+ case '2':
/* FALLTHROUGH */
- case ('I'):
+ case 'I':
gly = ESCAPE_FONTITALIC;
break;
- case ('P'):
+ case 'P':
gly = ESCAPE_FONTPREV;
break;
- case ('1'):
+ case '1':
/* FALLTHROUGH */
- case ('R'):
+ case 'R':
gly = ESCAPE_FONTROMAN;
break;
}
break;
- case (ESCAPE_SPECIAL):
+ case ESCAPE_SPECIAL:
if (1 == *sz && 'c' == **start)
gly = ESCAPE_NOSPACE;
break;
if ('"' == *start) {
quoted = 1;
start++;
- }
+ }
pairs = 0;
white = 0;
* backslashes and backslash-t to literal tabs.
*/
switch (cp[1]) {
- case ('t'):
+ case 't':
cp[0] = '\t';
/* FALLTHROUGH */
- case ('\\'):
+ case '\\':
pairs++;
cp++;
break;
- case (' '):
+ case ' ':
/* Skip escaped blanks. */
if (0 == quoted)
cp++;
enclosed = found = 0;
for (q = p + (int)sz - 1; q >= p; q--) {
switch (*q) {
- case ('\"'):
+ case '\"':
/* FALLTHROUGH */
- case ('\''):
+ case '\'':
/* FALLTHROUGH */
- case (']'):
+ case ']':
/* FALLTHROUGH */
- case (')'):
+ case ')':
if (0 == found)
enclosed = 1;
break;
- case ('.'):
+ case '.':
/* FALLTHROUGH */
- case ('!'):
+ case '!':
/* FALLTHROUGH */
- case ('?'):
+ case '?':
found = 1;
break;
default:
-/* $Id: mandoc.h,v 1.63 2014/03/28 23:25:54 schwarze Exp $ */
+/* $Id: mandoc.h,v 1.64 2014/04/20 16:44:44 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
/*
* An equation consists of a tree of expressions starting at a given
- * line and position.
+ * line and position.
*/
struct eqn {
char *name; /* identifier (or NULL) */
enum mandoc_esc mandoc_escape(const char **, const char **, int *);
struct mchars *mchars_alloc(void);
void mchars_free(struct mchars *);
-char mchars_num2char(const char *, size_t);
+char mchars_num2char(const char *, size_t);
int mchars_num2uc(const char *, size_t);
-int mchars_spec2cp(const struct mchars *,
+int mchars_spec2cp(const struct mchars *,
const char *, size_t);
-const char *mchars_spec2str(const struct mchars *,
+const char *mchars_spec2str(const struct mchars *,
const char *, size_t, size_t *);
struct mparse *mparse_alloc(int, enum mandoclevel, mandocmsg, char *);
void mparse_free(struct mparse *);
void mparse_keep(struct mparse *);
enum mandoclevel mparse_readfd(struct mparse *, int, const char *);
void mparse_reset(struct mparse *);
-void mparse_result(struct mparse *,
+void mparse_result(struct mparse *,
struct mdoc **, struct man **, char **);
const char *mparse_getkeep(const struct mparse *);
const char *mparse_strerror(enum mandocerr);
-/* $Id: mandocdb.c,v 1.97 2014/04/19 02:55:44 schwarze Exp $ */
+/* $Id: mandocdb.c,v 1.98 2014/04/20 16:44:44 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
static char *progname;
static int nodb; /* no database changes */
static int mparse_options; /* abort the parse early */
-static int use_all; /* use all found files */
-static int debug; /* print what we're doing */
-static int warnings; /* warn about crap */
+static int use_all; /* use all found files */
+static int debug; /* print what we're doing */
+static int warnings; /* warn about crap */
static int write_utf8; /* write UTF-8 output; else ASCII */
static int exitcode; /* to be returned by main */
-static enum op op; /* operational mode */
+static enum op op; /* operational mode */
static char basedir[PATH_MAX]; /* current base directory */
static struct ohash mpages; /* table of distinct manual pages */
static struct ohash mlinks; /* table of directory entries */
{ NULL, 0 }, /* Ta */
};
+
int
mandocdb(int argc, char *argv[])
{
++progname;
/*
- * We accept a few different invocations.
+ * We accept a few different invocations.
* The CHECKOP macro makes sure that invocation styles don't
* clobber each other.
*/
while (-1 != (ch = getopt(argc, argv, "aC:Dd:npQT:tu:v")))
switch (ch) {
- case ('a'):
+ case 'a':
use_all = 1;
break;
- case ('C'):
+ case 'C':
CHECKOP(op, ch);
path_arg = optarg;
op = OP_CONFFILE;
break;
- case ('D'):
+ case 'D':
debug++;
break;
- case ('d'):
+ case 'd':
CHECKOP(op, ch);
path_arg = optarg;
op = OP_UPDATE;
break;
- case ('n'):
+ case 'n':
nodb = 1;
break;
- case ('p'):
+ case 'p':
warnings = 1;
break;
- case ('Q'):
+ case 'Q':
mparse_options |= MPARSE_QUICK;
break;
- case ('T'):
+ case 'T':
if (strcmp(optarg, "utf8")) {
fprintf(stderr, "-T%s: Unsupported "
"output format\n", optarg);
}
write_utf8 = 1;
break;
- case ('t'):
+ case 't':
CHECKOP(op, ch);
dup2(STDOUT_FILENO, STDERR_FILENO);
op = OP_TEST;
nodb = warnings = 1;
break;
- case ('u'):
+ case 'u':
CHECKOP(op, ch);
path_arg = optarg;
op = OP_DELETE;
break;
- case ('v'):
+ case 'v':
/* Compatibility with espie@'s makewhatis. */
break;
default:
* manpath_parse() wants to do it.
*/
if (argc > 0) {
- dirs.paths = mandoc_calloc
- (argc, sizeof(char *));
+ dirs.paths = mandoc_calloc(argc,
+ sizeof(char *));
dirs.sz = (size_t)argc;
for (i = 0; i < argc; i++)
dirs.paths[i] = mandoc_strdup(argv[i]);
" %s [-DnpQ] [-Tutf8] -d dir [file ...]\n"
" %s [-Dnp] -u dir [file ...]\n"
" %s [-Q] -t file ...\n",
- progname, progname, progname,
+ progname, progname, progname,
progname, progname);
return((int)MANDOCLEVEL_BADARG);
* If use_all has been specified, grok all files.
* If not, sanitise paths to the following:
*
- * [./]man*[/<arch>]/<name>.<section>
+ * [./]man*[/<arch>]/<name>.<section>
* or
* [./]cat<section>[/<arch>]/<name>.0
*
* Symbolic links require various sanity checks,
* then get handled just like regular files.
*/
- case (FTS_SL):
+ case FTS_SL:
if (NULL == realpath(path, buf)) {
if (warnings)
say(path, "&realpath");
* If we're a regular file, add an mlink by using the
* stored directory data and handling the filename.
*/
- case (FTS_F):
+ case FTS_F:
if (0 == strcmp(path, MANDOC_DB))
continue;
if ( ! use_all && ff->fts_level < 2) {
mlink_add(mlink, ff->fts_statp);
continue;
- case (FTS_D):
+ case FTS_D:
/* FALLTHROUGH */
- case (FTS_DP):
+ case FTS_DP:
break;
default:
}
switch (ff->fts_level) {
- case (0):
+ case 0:
/* Ignore the root directory. */
break;
- case (1):
+ case 1:
/*
* This might contain manX/ or catX/.
* Try to infer this from the name.
dsec = NULL;
}
- if (NULL != dsec || use_all)
+ if (NULL != dsec || use_all)
break;
if (warnings)
say(path, "Unknown directory part");
fts_set(f, ff, FTS_SKIP);
break;
- case (2):
+ case 2:
/*
* Possibly our architecture.
* If we're descending, keep tabs on it.
* Try to infer the manual section, architecture, and page name from the
* path, assuming it looks like
*
- * [./]man*[/<arch>]/<name>.<section>
+ * [./]man*[/<arch>]/<name>.<section>
* or
* [./]cat<section>[/<arch>]/<name>.0
*
*++bufp = '\0';
strlcat(buf, mlink->dsec, PATH_MAX);
if (NULL == ohash_find(&mlinks,
- ohash_qlookup(&mlinks, buf)))
+ ohash_qlookup(&mlinks, buf)))
goto nextlink;
if (warnings)
say(mlink->file, "Man source exists: %s", buf);
goto nextpage;
}
switch (child_pid = fork()) {
- case (-1):
+ case -1:
exitcode = (int)MANDOCLEVEL_SYSERR;
say(mpage->mlinks->file, "&fork gunzip");
child_pid = 0;
close(fd[1]);
close(fd[0]);
goto nextpage;
- case (0):
+ case 0:
close(fd[0]);
if (-1 == dup2(fd[1], STDOUT_FILENO)) {
say(mpage->mlinks->file,
while (NULL != (line = fgetln(stream, &len)))
if ('\n' != *line && ' ' != *line)
break;
-
+
/*
* Read up until the next section into a buffer.
* Strip the leading and trailing newline from each read line,
if (0 == len) {
memmove(line, line + 1, plen--);
continue;
- }
+ }
memmove(line - 1, line + 1, plen - len);
plen -= 2;
}
body = n;
assert(body->parent);
if (NULL != (head = body->parent->head) &&
- 1 == head->nchild &&
- NULL != (head = (head->child)) &&
- MAN_TEXT == head->type &&
- 0 == strcmp(head->string, "NAME") &&
- NULL != body->child) {
+ 1 == head->nchild &&
+ NULL != (head = (head->child)) &&
+ MAN_TEXT == head->type &&
+ 0 == strcmp(head->string, "NAME") &&
+ NULL != body->child) {
/*
* Suck the entire NAME section into memory.
if (NULL == title)
return;
- /*
+ /*
* Go through a special heuristic dance here.
* Conventionally, one or more manual names are
* comma-specified prior to a whitespace, then a
assert(NULL != n);
for (n = n->child; NULL != n; n = n->next) {
switch (n->type) {
- case (MDOC_ELEM):
+ case MDOC_ELEM:
/* FALLTHROUGH */
- case (MDOC_BLOCK):
+ case MDOC_BLOCK:
/* FALLTHROUGH */
- case (MDOC_HEAD):
+ case MDOC_HEAD:
/* FALLTHROUGH */
- case (MDOC_BODY):
+ case MDOC_BODY:
/* FALLTHROUGH */
- case (MDOC_TAIL):
+ case MDOC_TAIL:
if (NULL != mdocs[n->tok].fp)
if (0 == (*mdocs[n->tok].fp)(mpage, n))
break;
size_t sz;
if (SEC_SYNOPSIS != n->sec ||
- NULL == (n = n->child) ||
- MDOC_TEXT != n->type)
+ NULL == (n = n->child) ||
+ MDOC_TEXT != n->type)
return(0);
/*
if (NULL == (n = n->child) || MDOC_TEXT != n->type)
return(0);
- /*
+ /*
* Parse: .Fn "struct type *name" "char *arg".
- * First strip away pointer symbol.
+ * First strip away pointer symbol.
* Then store the function name, then type.
- * Finally, store the arguments.
+ * Finally, store the arguments.
*/
if (NULL == (cp = strrchr(n->string, ' ')))
if (strcspn(val, res) == bsz) {
key->rendered = key->key;
return;
- }
+ }
/* Pre-allocate by the length of the input */
}
switch (*val) {
- case (ASCII_HYPH):
+ case ASCII_HYPH:
buf[pos++] = '-';
val++;
continue;
- case ('\t'):
+ case '\t':
/* FALLTHROUGH */
- case (ASCII_NBRSP):
+ case ASCII_NBRSP:
buf[pos++] = ' ';
val++;
/* FALLTHROUGH */
- case (ASCII_BREAK):
+ case ASCII_BREAK:
continue;
default:
break;
* predefined character or special character.
*/
- esc = mandoc_escape
- ((const char **)&val, &seq, &len);
+ esc = mandoc_escape((const char **)&val,
+ &seq, &len);
if (ESCAPE_ERROR == esc)
break;
if (ESCAPE_SPECIAL != esc)
}
switch (child = fork()) {
- case (-1):
+ case -1:
exitcode = (int)MANDOCLEVEL_SYSERR;
say("", "&fork cmp");
return;
- case (0):
+ case 0:
execlp("cmp", "cmp", "-s",
tempfilename, MANDOC_DB, NULL);
say("", "&exec cmp");
*strrchr(tempfilename, '/') = '\0';
switch (child = fork()) {
- case (-1):
+ case -1:
exitcode = (int)MANDOCLEVEL_SYSERR;
say("", "&fork rm");
return;
- case (0):
+ case 0:
execlp("rm", "rm", "-rf", tempfilename, NULL);
say("", "&exec rm");
exit((int)MANDOCLEVEL_SYSERR);
const char *sql;
int rc, ofl;
- if (nodb)
+ if (nodb)
return(1);
*tempfilename = '\0';
remove(MANDOC_DB "~");
rc = sqlite3_open_v2(MANDOC_DB "~", &db, ofl, NULL);
- if (SQLITE_OK == rc)
+ if (SQLITE_OK == rc)
goto create_tables;
if (MPARSE_QUICK & mparse_options) {
exitcode = (int)MANDOCLEVEL_SYSERR;
use_errno = 1;
if (NULL != format) {
switch (*format) {
- case ('&'):
+ case '&':
format++;
break;
- case ('\0'):
+ case '\0':
format = NULL;
break;
default:
-/* $Id: manpath.c,v 1.8 2014/03/21 22:17:01 schwarze Exp $ */
+/* $Id: manpath.c,v 1.9 2014/04/20 16:44:44 schwarze Exp $ */
/*
* Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
if (0 == strcmp(dirs->paths[i], dir))
return;
- dirs->paths = mandoc_realloc
- (dirs->paths,
- (dirs->sz + 1) * sizeof(char *));
+ dirs->paths = mandoc_realloc(dirs->paths,
+ (dirs->sz + 1) * sizeof(char *));
dirs->paths[dirs->sz++] = mandoc_strdup(cp);
}
-/* $Id: mansearch.c,v 1.23 2014/04/17 19:19:54 schwarze Exp $ */
+/* $Id: mansearch.c,v 1.24 2014/04/20 16:44:44 schwarze Exp $ */
/*
* Copyright (c) 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
} while (0)
struct expr {
- uint64_t bits; /* type-mask */
+ uint64_t bits; /* type-mask */
const char *substr; /* to search for, if applicable */
regex_t regexp; /* compiled regexp, if applicable */
int open; /* opening parentheses before */
static void *hash_alloc(size_t, void *);
static void hash_free(void *, size_t, void *);
static void *hash_halloc(size_t, void *);
-static struct expr *exprcomp(const struct mansearch *,
+static struct expr *exprcomp(const struct mansearch *,
int, char *[]);
static void exprfree(struct expr *);
static struct expr *exprspec(struct expr *, uint64_t,
int argc, sqlite3_value **argv);
static char *sql_statement(const struct expr *);
+
int
mansearch_setup(int start)
{
} else if (-1 == chdir(paths->paths[i])) {
perror(paths->paths[i]);
continue;
- }
+ }
- c = sqlite3_open_v2
- (MANDOC_DB, &db,
- SQLITE_OPEN_READONLY, NULL);
+ c = sqlite3_open_v2(MANDOC_DB, &db,
+ SQLITE_OPEN_READONLY, NULL);
if (SQLITE_OK != c) {
perror(MANDOC_DB);
*/
while (SQLITE_ROW == (c = sqlite3_step(s))) {
pageid = sqlite3_column_int64(s, 2);
- idx = ohash_lookup_memory
- (&htab, (char *)&pageid,
- sizeof(uint64_t), (uint32_t)pageid);
+ idx = ohash_lookup_memory(&htab,
+ (char *)&pageid, sizeof(uint64_t),
+ (uint32_t)pageid);
if (NULL != ohash_find(&htab, idx))
continue;
sqlite3_finalize(s);
- c = sqlite3_prepare_v2(db,
+ c = sqlite3_prepare_v2(db,
"SELECT * FROM mlinks WHERE pageid=?"
" ORDER BY sec, arch, name",
-1, &s, NULL);
mp = ohash_next(&htab, &idx)) {
if (cur + 1 > maxres) {
maxres += 1024;
- *res = mandoc_realloc
- (*res, maxres * sizeof(struct manpage));
+ *res = mandoc_realloc(*res,
+ maxres * sizeof(struct manpage));
}
mpage = *res + cur;
mpage->form = mp->form;
-/* $Id: mdoc.c,v 1.102 2014/03/30 19:47:32 schwarze Exp $ */
+/* $Id: mdoc.c,v 1.103 2014/04/20 16:44:44 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
#include "libmdoc.h"
#include "libmandoc.h"
-const char *const __mdoc_macronames[MDOC_MAX] = {
+const char *const __mdoc_macronames[MDOC_MAX] = {
"Ap", "Dd", "Dt", "Os",
"Sh", "Ss", "Pp", "D1",
"Dl", "Bd", "Ed", "Bl",
"Ic", "In", "Li", "Nd",
"Nm", "Op", "Ot", "Pa",
"Rv", "St", "Va", "Vt",
- /* LINTED */
"Xr", "%A", "%B", "%D",
- /* LINTED */
"%I", "%J", "%N", "%O",
- /* LINTED */
"%P", "%R", "%T", "%V",
"Ac", "Ao", "Aq", "At",
"Bc", "Bf", "Bo", "Bq",
"Bk", "Ek", "Bt", "Hf",
"Fr", "Ud", "Lb", "Lp",
"Lk", "Mt", "Brq", "Bro",
- /* LINTED */
"Brc", "%C", "Es", "En",
- /* LINTED */
"Dx", "%Q", "br", "sp",
- /* LINTED */
"%U", "Ta", "ll",
};
-const char *const __mdoc_argnames[MDOC_ARG_MAX] = {
+const char *const __mdoc_argnames[MDOC_ARG_MAX] = {
"split", "nosplit", "ragged",
- "unfilled", "literal", "file",
- "offset", "bullet", "dash",
- "hyphen", "item", "enum",
- "tag", "diag", "hang",
- "ohang", "inset", "column",
- "width", "compact", "std",
+ "unfilled", "literal", "file",
+ "offset", "bullet", "dash",
+ "hyphen", "item", "enum",
+ "tag", "diag", "hang",
+ "ohang", "inset", "column",
+ "width", "compact", "std",
"filled", "words", "emphasis",
"symbolic", "nested", "centered"
};
const char * const *mdoc_argnames = __mdoc_argnames;
static void mdoc_node_free(struct mdoc_node *);
-static void mdoc_node_unlink(struct mdoc *,
+static void mdoc_node_unlink(struct mdoc *,
struct mdoc_node *);
static void mdoc_free1(struct mdoc *);
static void mdoc_alloc1(struct mdoc *);
-static struct mdoc_node *node_alloc(struct mdoc *, int, int,
+static struct mdoc_node *node_alloc(struct mdoc *, int, int,
enum mdoct, enum mdoc_type);
-static int node_append(struct mdoc *,
+static int node_append(struct mdoc *,
struct mdoc_node *);
#if 0
static int mdoc_preptext(struct mdoc *, int, char *, int);
static int mdoc_ptext(struct mdoc *, int, char *, int);
static int mdoc_pmacro(struct mdoc *, int, char *, int);
+
const struct mdoc_node *
mdoc_node(const struct mdoc *mdoc)
{
return(mdoc->first);
}
-
const struct mdoc_meta *
mdoc_meta(const struct mdoc *mdoc)
{
return(&mdoc->meta);
}
-
/*
* Frees volatile resources (parse tree, meta-data, fields).
*/
free(mdoc->meta.date);
}
-
/*
* Allocate all volatile resources (parse tree, meta-data, fields).
*/
mdoc->next = MDOC_NEXT_CHILD;
}
-
/*
* Free up volatile resources (see mdoc_free1()) then re-initialises the
* data with mdoc_alloc1(). After invocation, parse data has been reset
mdoc_alloc1(mdoc);
}
-
/*
* Completely free up all volatile and non-volatile parse resources.
* After invocation, the pointer is no longer usable.
free(mdoc);
}
-
/*
- * Allocate volatile and non-volatile parse resources.
+ * Allocate volatile and non-volatile parse resources.
*/
struct mdoc *
mdoc_alloc(struct roff *roff, struct mparse *parse,
return(p);
}
-
/*
* Climb back up the parse tree, validating open scopes. Mostly calls
* through to macro_end() in macro.c.
return(1);
}
-
/*
* Main parse routine. Parses a single line -- really just hands off to
* the macro (mdoc_pmacro()) or text parser (mdoc_ptext()).
mdoc->flags &= ~MDOC_SYNOPSIS;
return(roff_getcontrol(mdoc->roff, buf, &offs) ?
- mdoc_pmacro(mdoc, ln, buf, offs) :
- mdoc_ptext(mdoc, ln, buf, offs));
+ mdoc_pmacro(mdoc, ln, buf, offs) :
+ mdoc_ptext(mdoc, ln, buf, offs));
}
int
/* If we're in the body, deny prologue calls. */
- if (MDOC_PROLOGUE & mdoc_macros[tok].flags &&
- MDOC_PBODY & mdoc->flags) {
+ if (MDOC_PROLOGUE & mdoc_macros[tok].flags &&
+ MDOC_PBODY & mdoc->flags) {
mdoc_pmsg(mdoc, line, ppos, MANDOCERR_BADBODY);
return(1);
}
/* If we're in the prologue, deny "body" macros. */
- if ( ! (MDOC_PROLOGUE & mdoc_macros[tok].flags) &&
- ! (MDOC_PBODY & mdoc->flags)) {
+ if ( ! (MDOC_PROLOGUE & mdoc_macros[tok].flags) &&
+ ! (MDOC_PBODY & mdoc->flags)) {
mdoc_pmsg(mdoc, line, ppos, MANDOCERR_BADPROLOG);
if (NULL == mdoc->meta.msec)
mdoc->meta.msec = mandoc_strdup("1");
assert(MDOC_ROOT != p->type);
switch (mdoc->next) {
- case (MDOC_NEXT_SIBLING):
+ case MDOC_NEXT_SIBLING:
mdoc->last->next = p;
p->prev = mdoc->last;
p->parent = mdoc->last->parent;
break;
- case (MDOC_NEXT_CHILD):
+ case MDOC_NEXT_CHILD:
mdoc->last->child = p;
p->parent = mdoc->last;
break;
*/
switch (p->type) {
- case (MDOC_BODY):
+ case MDOC_BODY:
if (ENDBODY_NOT != p->end)
break;
/* FALLTHROUGH */
- case (MDOC_TAIL):
+ case MDOC_TAIL:
/* FALLTHROUGH */
- case (MDOC_HEAD):
+ case MDOC_HEAD:
p->norm = p->parent->norm;
break;
default:
return(0);
switch (p->type) {
- case (MDOC_HEAD):
+ case MDOC_HEAD:
assert(MDOC_BLOCK == p->parent->type);
p->parent->head = p;
break;
- case (MDOC_TAIL):
+ case MDOC_TAIL:
assert(MDOC_BLOCK == p->parent->type);
p->parent->tail = p;
break;
- case (MDOC_BODY):
+ case MDOC_BODY:
if (p->end)
break;
assert(MDOC_BLOCK == p->parent->type);
mdoc->last = p;
switch (p->type) {
- case (MDOC_TBL):
+ case MDOC_TBL:
/* FALLTHROUGH */
- case (MDOC_TEXT):
+ case MDOC_TEXT:
if ( ! mdoc_valid_post(mdoc))
return(0);
break;
return(1);
}
-
static struct mdoc_node *
-node_alloc(struct mdoc *mdoc, int line, int pos,
+node_alloc(struct mdoc *mdoc, int line, int pos,
enum mdoct tok, enum mdoc_type type)
{
struct mdoc_node *p;
return(p);
}
-
int
mdoc_tail_alloc(struct mdoc *mdoc, int line, int pos, enum mdoct tok)
{
return(1);
}
-
int
mdoc_head_alloc(struct mdoc *mdoc, int line, int pos, enum mdoct tok)
{
return(1);
}
-
int
mdoc_body_alloc(struct mdoc *mdoc, int line, int pos, enum mdoct tok)
{
return(1);
}
-
int
mdoc_endbody_alloc(struct mdoc *mdoc, int line, int pos, enum mdoct tok,
struct mdoc_node *body, enum mdoc_endbody end)
return(1);
}
-
int
-mdoc_block_alloc(struct mdoc *mdoc, int line, int pos,
+mdoc_block_alloc(struct mdoc *mdoc, int line, int pos,
enum mdoct tok, struct mdoc_arg *args)
{
struct mdoc_node *p;
(args->refcnt)++;
switch (tok) {
- case (MDOC_Bd):
+ case MDOC_Bd:
/* FALLTHROUGH */
- case (MDOC_Bf):
+ case MDOC_Bf:
/* FALLTHROUGH */
- case (MDOC_Bl):
+ case MDOC_Bl:
/* FALLTHROUGH */
- case (MDOC_Rs):
+ case MDOC_Rs:
p->norm = mandoc_calloc(1, sizeof(union mdoc_data));
break;
default:
return(1);
}
-
int
-mdoc_elem_alloc(struct mdoc *mdoc, int line, int pos,
+mdoc_elem_alloc(struct mdoc *mdoc, int line, int pos,
enum mdoct tok, struct mdoc_arg *args)
{
struct mdoc_node *p;
(args->refcnt)++;
switch (tok) {
- case (MDOC_An):
+ case MDOC_An:
p->norm = mandoc_calloc(1, sizeof(union mdoc_data));
break;
default:
free(p);
}
-
static void
mdoc_node_unlink(struct mdoc *mdoc, struct mdoc_node *n)
{
mdoc->first = NULL;
}
-
void
mdoc_node_delete(struct mdoc *mdoc, struct mdoc_node *p)
{
if ( ! mdoc_addeqn(mdoc, roff_eqn(mdoc->roff)))
return(0);
offs += (end - (buf + offs));
- }
+ }
return(1);
}
*/
if (MDOC_Bl == n->tok && MDOC_BODY == n->type &&
- LIST_column == n->norm->Bl.type) {
+ LIST_column == n->norm->Bl.type) {
/* `Bl' is open without any children. */
mdoc->flags |= MDOC_FREECOL;
return(mdoc_macro(mdoc, MDOC_It, line, offs, &offs, buf));
}
if (MDOC_It == n->tok && MDOC_BLOCK == n->type &&
- NULL != n->parent &&
- MDOC_Bl == n->parent->tok &&
- LIST_column == n->parent->norm->Bl.type) {
+ NULL != n->parent &&
+ MDOC_Bl == n->parent->tok &&
+ LIST_column == n->parent->norm->Bl.type) {
/* `Bl' has block-level `It' children. */
mdoc->flags |= MDOC_FREECOL;
return(mdoc_macro(mdoc, MDOC_It, line, offs, &offs, buf));
return(1);
}
-
/*
* Parse a macro line, that is, a line beginning with the control
* character.
sv = offs;
- /*
+ /*
* Copy the first word into a nil-terminated buffer.
* Stop copying when a tab, space, or eoln is encountered.
*/
i = 0;
- while (i < 4 && '\0' != buf[offs] &&
- ' ' != buf[offs] && '\t' != buf[offs])
+ while (i < 4 && '\0' != buf[offs] && ' ' != buf[offs] &&
+ '\t' != buf[offs])
mac[i++] = buf[offs++];
mac[i] = '\0';
tok = (i > 1 || i < 4) ? mdoc_hash_find(mac) : MDOC_MAX;
if (MDOC_MAX == tok) {
- mandoc_vmsg(MANDOCERR_MACRO, mdoc->parse,
- ln, sv, "%s", buf + sv - 1);
+ mandoc_vmsg(MANDOCERR_MACRO, mdoc->parse,
+ ln, sv, "%s", buf + sv - 1);
return(1);
}
while (buf[offs] && ' ' == buf[offs])
offs++;
- /*
+ /*
* Trailing whitespace. Note that tabs are allowed to be passed
* into the parser as "text", so we only warn about spaces here.
*/
*/
if (NULL == mdoc->last || MDOC_It == tok || MDOC_El == tok) {
- if ( ! mdoc_macro(mdoc, tok, ln, sv, &offs, buf))
+ if ( ! mdoc_macro(mdoc, tok, ln, sv, &offs, buf))
goto err;
return(1);
}
*/
if (MDOC_Bl == n->tok && MDOC_BODY == n->type &&
- LIST_column == n->norm->Bl.type) {
+ LIST_column == n->norm->Bl.type) {
mdoc->flags |= MDOC_FREECOL;
if ( ! mdoc_macro(mdoc, MDOC_It, ln, sv, &sv, buf))
goto err;
*/
if (MDOC_It == n->tok && MDOC_BLOCK == n->type &&
- NULL != n->parent &&
- MDOC_Bl == n->parent->tok &&
- LIST_column == n->parent->norm->Bl.type) {
+ NULL != n->parent &&
+ MDOC_Bl == n->parent->tok &&
+ LIST_column == n->parent->norm->Bl.type) {
mdoc->flags |= MDOC_FREECOL;
- if ( ! mdoc_macro(mdoc, MDOC_It, ln, sv, &sv, buf))
+ if ( ! mdoc_macro(mdoc, MDOC_It, ln, sv, &sv, buf))
goto err;
return(1);
}
/* Normal processing of a macro. */
- if ( ! mdoc_macro(mdoc, tok, ln, sv, &offs, buf))
+ if ( ! mdoc_macro(mdoc, tok, ln, sv, &offs, buf))
goto err;
/* In quick mode (for mandocdb), abort after the NAME section. */
if ('\0' == p[1])
switch (p[0]) {
- case('('):
+ case '(':
/* FALLTHROUGH */
- case('['):
+ case '[':
return(DELIM_OPEN);
- case('|'):
+ case '|':
return(DELIM_MIDDLE);
- case('.'):
+ case '.':
/* FALLTHROUGH */
- case(','):
+ case ',':
/* FALLTHROUGH */
- case(';'):
+ case ';':
/* FALLTHROUGH */
- case(':'):
+ case ':':
/* FALLTHROUGH */
- case('?'):
+ case '?':
/* FALLTHROUGH */
- case('!'):
+ case '!':
/* FALLTHROUGH */
- case(')'):
+ case ')':
/* FALLTHROUGH */
- case(']'):
+ case ']':
return(DELIM_CLOSE);
default:
return(DELIM_NONE);
-/* $Id: mdoc.h,v 1.52 2014/03/31 00:02:45 dlg Exp $ */
+/* $Id: mdoc.h,v 1.53 2014/04/20 16:44:44 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
MDOC_ROOT
};
-/*
+/*
* Section (named/unnamed) of `Sh'. Note that these appear in the
* conventional order imposed by mdoc.7. In the case of SEC_NONE, no
* section has been invoked (this shouldn't happen). SEC_CUSTOM refers
SEC_CAVEATS, /* CAVEATS */
SEC_BUGS, /* BUGS */
SEC_SECURITY, /* SECURITY */
- SEC_CUSTOM,
+ SEC_CUSTOM,
SEC__MAX
};
char *name; /* leading `Nm' name */
};
-/*
- * An argument to a macro (multiple values = `-column xxx yyy').
+/*
+ * An argument to a macro (multiple values = `-column xxx yyy').
*/
struct mdoc_argv {
- enum mdocargt arg; /* type of argument */
+ enum mdocargt arg; /* type of argument */
int line;
int pos;
size_t sz; /* elements in "value" */
* blocks have multiple instances of the same arguments spread across
* the HEAD, BODY, TAIL, and BLOCK node types.
*/
-struct mdoc_arg {
+struct mdoc_arg {
size_t argc;
struct mdoc_argv *argv;
unsigned int refcnt;
* provided, etc.
*/
union mdoc_data {
- struct mdoc_an An;
+ struct mdoc_an An;
struct mdoc_bd Bd;
struct mdoc_bf Bf;
struct mdoc_bl Bl;
struct mdoc_rs Rs;
};
-/*
- * Single node in tree-linked AST.
+/*
+ * Single node in tree-linked AST.
*/
struct mdoc_node {
struct mdoc_node *parent; /* parent AST node */
-/* $Id: mdoc_argv.c,v 1.48 2014/03/30 19:47:32 schwarze Exp $ */
+/* $Id: mdoc_argv.c,v 1.49 2014/04/20 16:44:44 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2012 Ingo Schwarze <schwarze@openbsd.org>
#include "libmandoc.h"
#define MULTI_STEP 5 /* pre-allocate argument values */
-#define DELIMSZ 6 /* max possible size of a delimiter */
+#define DELIMSZ 6 /* max possible size of a delimiter */
enum argsflag {
ARGSFL_NONE = 0,
};
static void argn_free(struct mdoc_arg *, int);
-static enum margserr args(struct mdoc *, int, int *,
+static enum margserr args(struct mdoc *, int, int *,
char *, enum argsflag, char **);
static int args_checkpunct(const char *, int);
-static int argv_multi(struct mdoc *, int,
+static int argv_multi(struct mdoc *, int,
struct mdoc_argv *, int *, char *);
-static int argv_single(struct mdoc *, int,
+static int argv_single(struct mdoc *, int,
struct mdoc_argv *, int *, char *);
static const enum argvflag argvflags[MDOC_ARG_MAX] = {
{ ARGSFL_NONE, NULL }, /* Dt */
{ ARGSFL_NONE, NULL }, /* Os */
{ ARGSFL_NONE, NULL }, /* Sh */
- { ARGSFL_NONE, NULL }, /* Ss */
- { ARGSFL_NONE, NULL }, /* Pp */
+ { ARGSFL_NONE, NULL }, /* Ss */
+ { ARGSFL_NONE, NULL }, /* Pp */
{ ARGSFL_DELIM, NULL }, /* D1 */
{ ARGSFL_DELIM, NULL }, /* Dl */
{ ARGSFL_NONE, args_Bd }, /* Bd */
{ ARGSFL_NONE, args_Bl }, /* Bl */
{ ARGSFL_NONE, NULL }, /* El */
{ ARGSFL_NONE, NULL }, /* It */
- { ARGSFL_DELIM, NULL }, /* Ad */
+ { ARGSFL_DELIM, NULL }, /* Ad */
{ ARGSFL_DELIM, args_An }, /* An */
{ ARGSFL_DELIM, NULL }, /* Ar */
{ ARGSFL_DELIM, NULL }, /* Cd */
{ ARGSFL_DELIM, NULL }, /* Cm */
- { ARGSFL_DELIM, NULL }, /* Dv */
- { ARGSFL_DELIM, NULL }, /* Er */
- { ARGSFL_DELIM, NULL }, /* Ev */
+ { ARGSFL_DELIM, NULL }, /* Dv */
+ { ARGSFL_DELIM, NULL }, /* Er */
+ { ARGSFL_DELIM, NULL }, /* Ev */
{ ARGSFL_NONE, args_Ex }, /* Ex */
- { ARGSFL_DELIM, NULL }, /* Fa */
- { ARGSFL_NONE, NULL }, /* Fd */
+ { ARGSFL_DELIM, NULL }, /* Fa */
+ { ARGSFL_NONE, NULL }, /* Fd */
{ ARGSFL_DELIM, NULL }, /* Fl */
- { ARGSFL_DELIM, NULL }, /* Fn */
- { ARGSFL_DELIM, NULL }, /* Ft */
- { ARGSFL_DELIM, NULL }, /* Ic */
- { ARGSFL_DELIM, NULL }, /* In */
+ { ARGSFL_DELIM, NULL }, /* Fn */
+ { ARGSFL_DELIM, NULL }, /* Ft */
+ { ARGSFL_DELIM, NULL }, /* Ic */
+ { ARGSFL_DELIM, NULL }, /* In */
{ ARGSFL_DELIM, NULL }, /* Li */
- { ARGSFL_NONE, NULL }, /* Nd */
- { ARGSFL_DELIM, NULL }, /* Nm */
+ { ARGSFL_NONE, NULL }, /* Nd */
+ { ARGSFL_DELIM, NULL }, /* Nm */
{ ARGSFL_DELIM, NULL }, /* Op */
{ ARGSFL_NONE, NULL }, /* Ot */
{ ARGSFL_DELIM, NULL }, /* Pa */
{ ARGSFL_NONE, args_Ex }, /* Rv */
- { ARGSFL_DELIM, NULL }, /* St */
+ { ARGSFL_DELIM, NULL }, /* St */
{ ARGSFL_DELIM, NULL }, /* Va */
- { ARGSFL_DELIM, NULL }, /* Vt */
+ { ARGSFL_DELIM, NULL }, /* Vt */
{ ARGSFL_DELIM, NULL }, /* Xr */
{ ARGSFL_NONE, NULL }, /* %A */
{ ARGSFL_NONE, NULL }, /* %B */
{ ARGSFL_DELIM, NULL }, /* Aq */
{ ARGSFL_DELIM, NULL }, /* At */
{ ARGSFL_DELIM, NULL }, /* Bc */
- { ARGSFL_NONE, args_Bf }, /* Bf */
+ { ARGSFL_NONE, args_Bf }, /* Bf */
{ ARGSFL_NONE, NULL }, /* Bo */
{ ARGSFL_DELIM, NULL }, /* Bq */
{ ARGSFL_DELIM, NULL }, /* Bsx */
{ ARGSFL_DELIM, NULL }, /* Dq */
{ ARGSFL_DELIM, NULL }, /* Ec */
{ ARGSFL_NONE, NULL }, /* Ef */
- { ARGSFL_DELIM, NULL }, /* Em */
+ { ARGSFL_DELIM, NULL }, /* Em */
{ ARGSFL_NONE, NULL }, /* Eo */
{ ARGSFL_DELIM, NULL }, /* Fx */
{ ARGSFL_DELIM, NULL }, /* Ms */
{ ARGSFL_DELIM, NULL }, /* Ux */
{ ARGSFL_DELIM, NULL }, /* Xc */
{ ARGSFL_NONE, NULL }, /* Xo */
- { ARGSFL_NONE, NULL }, /* Fo */
- { ARGSFL_DELIM, NULL }, /* Fc */
+ { ARGSFL_NONE, NULL }, /* Fo */
+ { ARGSFL_DELIM, NULL }, /* Fc */
{ ARGSFL_NONE, NULL }, /* Oo */
{ ARGSFL_DELIM, NULL }, /* Oc */
{ ARGSFL_NONE, args_Bk }, /* Bk */
if (' ' == buf[*pos] && '\\' != buf[*pos - 1])
break;
- /*
+ /*
* We want to nil-terminate the word to look it up (it's easier
* that way). But we may not have a flag, in which case we need
* to restore the line as-is. So keep around the stray byte,
* which we'll reset upon exiting (if necessary).
*/
- if ('\0' != (sv = buf[*pos]))
+ if ('\0' != (sv = buf[*pos]))
buf[(*pos)++] = '\0';
/*
break;
if (MDOC_ARG_MAX == tmp.arg) {
- /*
+ /*
* The flag was not found.
* Restore saved zeroed byte and return as a word.
*/
(*pos)++;
switch (argvflags[tmp.arg]) {
- case (ARGV_SINGLE):
+ case ARGV_SINGLE:
if ( ! argv_single(mdoc, line, &tmp, pos, buf))
return(ARGV_ERROR);
break;
- case (ARGV_MULTI):
+ case ARGV_MULTI:
if ( ! argv_multi(mdoc, line, &tmp, pos, buf))
return(ARGV_ERROR);
break;
- case (ARGV_NONE):
+ case ARGV_NONE:
break;
}
arg = *v = mandoc_calloc(1, sizeof(struct mdoc_arg));
arg->argc++;
- arg->argv = mandoc_realloc
- (arg->argv, arg->argc * sizeof(struct mdoc_argv));
+ arg->argv = mandoc_realloc(arg->argv,
+ arg->argc * sizeof(struct mdoc_argv));
- memcpy(&arg->argv[(int)arg->argc - 1],
- &tmp, sizeof(struct mdoc_argv));
+ memcpy(&arg->argv[(int)arg->argc - 1], &tmp,
+ sizeof(struct mdoc_argv));
return(ARGV_ARG);
}
arg = &p->argv[iarg];
if (arg->sz && arg->value) {
- for (j = (int)arg->sz - 1; j >= 0; j--)
+ for (j = (int)arg->sz - 1; j >= 0; j--)
free(arg->value[j]);
free(arg->value);
}
}
enum margserr
-mdoc_args(struct mdoc *mdoc, int line, int *pos,
+mdoc_args(struct mdoc *mdoc, int line, int *pos,
char *buf, enum mdoct tok, char **v)
{
enum argsflag fl;
}
static enum margserr
-args(struct mdoc *mdoc, int line, int *pos,
+args(struct mdoc *mdoc, int line, int *pos,
char *buf, enum argsflag fl, char **v)
{
char *p, *pp;
pp = NULL;
/* Scan ahead to unescaped `Ta'. */
- if ( ! (MDOC_PHRASELIT & mdoc->flags))
+ if ( ! (MDOC_PHRASELIT & mdoc->flags))
for (pp = *v; ; pp++) {
if (NULL == (pp = strstr(pp, "Ta")))
break;
/* By default, assume a phrase. */
rc = ARGS_PHRASE;
- /*
+ /*
* Adjust new-buffer position to be beyond delimiter
* mark (e.g., Ta -> end + 2).
*/
return(ARGS_WORD);
}
-/*
+/*
* Check if the string consists only of space-separated closing
* delimiters. This is a bit of a dance: the first must be a close
* delimiter, but it may be followed by middle delimiters. Arbitrary
i++;
/* Remaining must NOT be open/none. */
-
+
while (buf[i]) {
j = 0;
while (buf[i] && ' ' != buf[i] && j < DELIMSZ)
}
static int
-argv_multi(struct mdoc *mdoc, int line,
+argv_multi(struct mdoc *mdoc, int line,
struct mdoc_argv *v, int *pos, char *buf)
{
enum margserr ac;
break;
if (0 == v->sz % MULTI_STEP)
- v->value = mandoc_realloc(v->value,
- (v->sz + MULTI_STEP) * sizeof(char *));
+ v->value = mandoc_realloc(v->value,
+ (v->sz + MULTI_STEP) * sizeof(char *));
v->value[(int)v->sz] = mandoc_strdup(p);
}
}
static int
-argv_single(struct mdoc *mdoc, int line,
+argv_single(struct mdoc *mdoc, int line,
struct mdoc_argv *v, int *pos, char *buf)
{
enum margserr ac;
-/* $Id: mdoc_hash.c,v 1.14 2014/03/21 22:17:01 schwarze Exp $ */
+/* $Id: mdoc_hash.c,v 1.15 2014/04/20 16:44:44 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
*
static unsigned char table[27 * 12];
+
/*
* XXX - this hash has global scope, so if intended for use as a library
* with multiple callers, it will need re-invocation protection.
major = 12 * (tolower((unsigned char)p[1]) - 97);
else if ('1' == p[1])
major = 12 * 26;
- else
+ else
return(MDOC_MAX);
if (p[2] && p[3])
-/* $Id: mdoc_html.c,v 1.70 2014/03/30 19:47:32 schwarze Exp $ */
+/* $Id: mdoc_html.c,v 1.71 2014/04/20 16:44:44 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org>
static void print_mdoc_head(MDOC_ARGS);
static void print_mdoc_node(MDOC_ARGS);
static void print_mdoc_nodelist(MDOC_ARGS);
-static void synopsis_pre(struct html *,
+static void synopsis_pre(struct html *,
const struct mdoc_node *);
static void a2width(const char *, struct roffsu *);
{NULL, NULL}, /* Dt */
{NULL, NULL}, /* Os */
{mdoc_sh_pre, NULL }, /* Sh */
- {mdoc_ss_pre, NULL }, /* Ss */
- {mdoc_pp_pre, NULL}, /* Pp */
+ {mdoc_ss_pre, NULL }, /* Ss */
+ {mdoc_pp_pre, NULL}, /* Pp */
{mdoc_d1_pre, NULL}, /* D1 */
{mdoc_d1_pre, NULL}, /* Dl */
{mdoc_bd_pre, NULL}, /* Bd */
{mdoc_bl_pre, NULL}, /* Bl */
{NULL, NULL}, /* El */
{mdoc_it_pre, NULL}, /* It */
- {mdoc_ad_pre, NULL}, /* Ad */
+ {mdoc_ad_pre, NULL}, /* Ad */
{mdoc_an_pre, NULL}, /* An */
{mdoc_ar_pre, NULL}, /* Ar */
{mdoc_cd_pre, NULL}, /* Cd */
{mdoc_fl_pre, NULL}, /* Cm */
- {mdoc_dv_pre, NULL}, /* Dv */
- {mdoc_er_pre, NULL}, /* Er */
- {mdoc_ev_pre, NULL}, /* Ev */
+ {mdoc_dv_pre, NULL}, /* Dv */
+ {mdoc_er_pre, NULL}, /* Er */
+ {mdoc_ev_pre, NULL}, /* Ev */
{mdoc_ex_pre, NULL}, /* Ex */
- {mdoc_fa_pre, NULL}, /* Fa */
- {mdoc_fd_pre, NULL}, /* Fd */
+ {mdoc_fa_pre, NULL}, /* Fa */
+ {mdoc_fd_pre, NULL}, /* Fd */
{mdoc_fl_pre, NULL}, /* Fl */
- {mdoc_fn_pre, NULL}, /* Fn */
- {mdoc_ft_pre, NULL}, /* Ft */
- {mdoc_ic_pre, NULL}, /* Ic */
- {mdoc_in_pre, NULL}, /* In */
+ {mdoc_fn_pre, NULL}, /* Fn */
+ {mdoc_ft_pre, NULL}, /* Ft */
+ {mdoc_ic_pre, NULL}, /* Ic */
+ {mdoc_in_pre, NULL}, /* In */
{mdoc_li_pre, NULL}, /* Li */
- {mdoc_nd_pre, NULL}, /* Nd */
- {mdoc_nm_pre, NULL}, /* Nm */
+ {mdoc_nd_pre, NULL}, /* Nd */
+ {mdoc_nm_pre, NULL}, /* Nm */
{mdoc_quote_pre, mdoc_quote_post}, /* Op */
{NULL, NULL}, /* Ot */
{mdoc_pa_pre, NULL}, /* Pa */
{mdoc_rv_pre, NULL}, /* Rv */
- {NULL, NULL}, /* St */
+ {NULL, NULL}, /* St */
{mdoc_va_pre, NULL}, /* Va */
- {mdoc_vt_pre, NULL}, /* Vt */
+ {mdoc_vt_pre, NULL}, /* Vt */
{mdoc_xr_pre, NULL}, /* Xr */
{mdoc__x_pre, mdoc__x_post}, /* %A */
{mdoc__x_pre, mdoc__x_post}, /* %B */
{mdoc_quote_pre, mdoc_quote_post}, /* Aq */
{NULL, NULL}, /* At */
{NULL, NULL}, /* Bc */
- {mdoc_bf_pre, NULL}, /* Bf */
+ {mdoc_bf_pre, NULL}, /* Bf */
{mdoc_quote_pre, mdoc_quote_post}, /* Bo */
{mdoc_quote_pre, mdoc_quote_post}, /* Bq */
{mdoc_xx_pre, NULL}, /* Bsx */
{mdoc_quote_pre, mdoc_quote_post}, /* Dq */
{NULL, NULL}, /* Ec */ /* FIXME: no space */
{NULL, NULL}, /* Ef */
- {mdoc_em_pre, NULL}, /* Em */
+ {mdoc_em_pre, NULL}, /* Em */
{mdoc_quote_pre, mdoc_quote_post}, /* Eo */
{mdoc_xx_pre, NULL}, /* Fx */
{mdoc_ms_pre, NULL}, /* Ms */
{NULL, NULL}, /* Sc */
{mdoc_quote_pre, mdoc_quote_post}, /* So */
{mdoc_quote_pre, mdoc_quote_post}, /* Sq */
- {mdoc_sm_pre, NULL}, /* Sm */
+ {mdoc_sm_pre, NULL}, /* Sm */
{mdoc_sx_pre, NULL}, /* Sx */
{mdoc_sy_pre, NULL}, /* Sy */
{NULL, NULL}, /* Tn */
{mdoc_xx_pre, NULL}, /* Ux */
{NULL, NULL}, /* Xc */
{NULL, NULL}, /* Xo */
- {mdoc_fo_pre, mdoc_fo_post}, /* Fo */
- {NULL, NULL}, /* Fc */
+ {mdoc_fo_pre, mdoc_fo_post}, /* Fo */
+ {NULL, NULL}, /* Fc */
{mdoc_quote_pre, mdoc_quote_post}, /* Oo */
{NULL, NULL}, /* Oc */
{mdoc_bk_pre, mdoc_bk_post}, /* Bk */
{NULL, NULL}, /* Fr */
{mdoc_ud_pre, NULL}, /* Ud */
{mdoc_lb_pre, NULL}, /* Lb */
- {mdoc_pp_pre, NULL}, /* Lp */
- {mdoc_lk_pre, NULL}, /* Lk */
- {mdoc_mt_pre, NULL}, /* Mt */
- {mdoc_quote_pre, mdoc_quote_post}, /* Brq */
- {mdoc_quote_pre, mdoc_quote_post}, /* Bro */
- {NULL, NULL}, /* Brc */
- {mdoc__x_pre, mdoc__x_post}, /* %C */
+ {mdoc_pp_pre, NULL}, /* Lp */
+ {mdoc_lk_pre, NULL}, /* Lk */
+ {mdoc_mt_pre, NULL}, /* Mt */
+ {mdoc_quote_pre, mdoc_quote_post}, /* Brq */
+ {mdoc_quote_pre, mdoc_quote_post}, /* Bro */
+ {NULL, NULL}, /* Brc */
+ {mdoc__x_pre, mdoc__x_post}, /* %C */
{NULL, NULL}, /* Es */ /* TODO */
{NULL, NULL}, /* En */ /* TODO */
- {mdoc_xx_pre, NULL}, /* Dx */
- {mdoc__x_pre, mdoc__x_post}, /* %Q */
+ {mdoc_xx_pre, NULL}, /* Dx */
+ {mdoc__x_pre, mdoc__x_post}, /* %Q */
{mdoc_sp_pre, NULL}, /* br */
- {mdoc_sp_pre, NULL}, /* sp */
- {mdoc__x_pre, mdoc__x_post}, /* %U */
- {NULL, NULL}, /* Ta */
+ {mdoc_sp_pre, NULL}, /* sp */
+ {mdoc__x_pre, mdoc__x_post}, /* %U */
+ {NULL, NULL}, /* Ta */
{mdoc_ll_pre, NULL}, /* ll */
};
"list-tag"
};
+
void
html_mdoc(void *arg, const struct mdoc *mdoc)
{
print_mdoc(mdoc_meta(mdoc), mdoc_node(mdoc),
- (struct html *)arg);
+ (struct html *)arg);
putchar('\n');
}
-
/*
* Calculate the scaling unit passed in a `-width' argument. This uses
* either a native scaling unit (e.g., 1i, 2m) or the string length of
}
}
-
/*
* See the same function in mdoc_term.c for documentation.
*/
if (NULL == n->prev || ! (MDOC_SYNPRETTY & n->flags))
return;
- if (n->prev->tok == n->tok &&
- MDOC_Fo != n->tok &&
- MDOC_Ft != n->tok &&
- MDOC_Fn != n->tok) {
+ if (n->prev->tok == n->tok &&
+ MDOC_Fo != n->tok &&
+ MDOC_Ft != n->tok &&
+ MDOC_Fn != n->tok) {
print_otag(h, TAG_BR, 0, NULL);
return;
}
switch (n->prev->tok) {
- case (MDOC_Fd):
+ case MDOC_Fd:
/* FALLTHROUGH */
- case (MDOC_Fn):
+ case MDOC_Fn:
/* FALLTHROUGH */
- case (MDOC_Fo):
+ case MDOC_Fo:
/* FALLTHROUGH */
- case (MDOC_In):
+ case MDOC_In:
/* FALLTHROUGH */
- case (MDOC_Vt):
+ case MDOC_Vt:
print_otag(h, TAG_P, 0, NULL);
break;
- case (MDOC_Ft):
+ case MDOC_Ft:
if (MDOC_Fn != n->tok && MDOC_Fo != n->tok) {
print_otag(h, TAG_P, 0, NULL);
break;
}
}
-
/*
* Calculate the scaling unit passed in an `-offset' argument. This
* uses either a native scaling unit (e.g., 1i, 2m), one of a set of
SCALE_HS_INIT(su, html_strlen(p));
}
-
static void
print_mdoc(MDOC_ARGS)
{
print_tagq(h, tt);
print_otag(h, TAG_BODY, 0, NULL);
print_otag(h, TAG_DIV, 1, &tag);
- } else
+ } else
t = print_otag(h, TAG_DIV, 1, &tag);
print_mdoc_nodelist(meta, n, h);
print_tagq(h, t);
}
-
-/* ARGSUSED */
static void
print_mdoc_head(MDOC_ARGS)
{
print_text(h, h->buf);
}
-
static void
print_mdoc_nodelist(MDOC_ARGS)
{
print_mdoc_nodelist(meta, n->next, h);
}
-
static void
print_mdoc_node(MDOC_ARGS)
{
t = h->tags.head;
switch (n->type) {
- case (MDOC_ROOT):
+ case MDOC_ROOT:
child = mdoc_root_pre(meta, n, h);
break;
- case (MDOC_TEXT):
+ case MDOC_TEXT:
/* No tables in this mode... */
assert(NULL == h->tblt);
if (MDOC_DELIMO & n->flags)
h->flags |= HTML_NOSPACE;
return;
- case (MDOC_EQN):
+ case MDOC_EQN:
print_eqn(h, n->eqn);
break;
- case (MDOC_TBL):
+ case MDOC_TBL:
/*
* This will take care of initialising all of the table
* state data for the first table, then tearing it down
print_stagq(h, t);
switch (n->type) {
- case (MDOC_ROOT):
+ case MDOC_ROOT:
mdoc_root_post(meta, n, h);
break;
- case (MDOC_EQN):
+ case MDOC_EQN:
break;
default:
if (mdocs[n->tok].post && ENDBODY_NOT == n->end)
}
}
-/* ARGSUSED */
static void
mdoc_root_post(MDOC_ARGS)
{
print_tagq(h, t);
}
-
-/* ARGSUSED */
static int
mdoc_root_pre(MDOC_ARGS)
{
return(1);
}
-
-/* ARGSUSED */
static int
mdoc_sh_pre(MDOC_ARGS)
{
return(1);
}
-/* ARGSUSED */
static int
mdoc_ss_pre(MDOC_ARGS)
{
return(1);
}
-
-/* ARGSUSED */
static int
mdoc_fl_pre(MDOC_ARGS)
{
return(1);
}
-
-/* ARGSUSED */
static int
mdoc_nd_pre(MDOC_ARGS)
{
return(1);
}
-
static int
mdoc_nm_pre(MDOC_ARGS)
{
int len;
switch (n->type) {
- case (MDOC_ELEM):
+ case MDOC_ELEM:
synopsis_pre(h, n);
PAIR_CLASS_INIT(&tag, "name");
print_otag(h, TAG_B, 1, &tag);
if (NULL == n->child && meta->name)
print_text(h, meta->name);
return(1);
- case (MDOC_HEAD):
+ case MDOC_HEAD:
print_otag(h, TAG_TD, 0, NULL);
if (NULL == n->child && meta->name)
print_text(h, meta->name);
return(1);
- case (MDOC_BODY):
+ case MDOC_BODY:
print_otag(h, TAG_TD, 0, NULL);
return(1);
default:
return(1);
}
-
-/* ARGSUSED */
static int
mdoc_xr_pre(MDOC_ARGS)
{
PAIR_CLASS_INIT(&tag[0], "link-man");
if (h->base_man) {
- buffmt_man(h, n->child->string,
- n->child->next ?
- n->child->next->string : NULL);
+ buffmt_man(h, n->child->string,
+ n->child->next ?
+ n->child->next->string : NULL);
PAIR_HREF_INIT(&tag[1], h->buf);
print_otag(h, TAG_A, 2, tag);
} else
return(0);
}
-
-/* ARGSUSED */
static int
mdoc_ns_pre(MDOC_ARGS)
{
return(1);
}
-
-/* ARGSUSED */
static int
mdoc_ar_pre(MDOC_ARGS)
{
return(1);
}
-
-/* ARGSUSED */
static int
mdoc_xx_pre(MDOC_ARGS)
{
int flags;
switch (n->tok) {
- case (MDOC_Bsx):
+ case MDOC_Bsx:
pp = "BSD/OS";
break;
- case (MDOC_Dx):
+ case MDOC_Dx:
pp = "DragonFly";
break;
- case (MDOC_Fx):
+ case MDOC_Fx:
pp = "FreeBSD";
break;
- case (MDOC_Nx):
+ case MDOC_Nx:
pp = "NetBSD";
break;
- case (MDOC_Ox):
+ case MDOC_Ox:
pp = "OpenBSD";
break;
- case (MDOC_Ux):
+ case MDOC_Ux:
pp = "UNIX";
break;
default:
return(0);
}
-
-/* ARGSUSED */
static int
mdoc_bx_pre(MDOC_ARGS)
{
return(0);
}
-/* ARGSUSED */
static int
mdoc_it_pre(MDOC_ARGS)
{
if (MDOC_HEAD == n->type) {
switch (type) {
- case(LIST_bullet):
+ case LIST_bullet:
/* FALLTHROUGH */
- case(LIST_dash):
+ case LIST_dash:
/* FALLTHROUGH */
- case(LIST_item):
+ case LIST_item:
/* FALLTHROUGH */
- case(LIST_hyphen):
+ case LIST_hyphen:
/* FALLTHROUGH */
- case(LIST_enum):
+ case LIST_enum:
return(0);
- case(LIST_diag):
+ case LIST_diag:
/* FALLTHROUGH */
- case(LIST_hang):
+ case LIST_hang:
/* FALLTHROUGH */
- case(LIST_inset):
+ case LIST_inset:
/* FALLTHROUGH */
- case(LIST_ohang):
+ case LIST_ohang:
/* FALLTHROUGH */
- case(LIST_tag):
+ case LIST_tag:
SCALE_VS_INIT(&su, ! bl->norm->Bl.comp);
bufcat_su(h, "margin-top", &su);
PAIR_STYLE_INIT(&tag[1], h);
PAIR_CLASS_INIT(&tag[0], "diag");
print_otag(h, TAG_B, 1, tag);
break;
- case(LIST_column):
+ case LIST_column:
break;
default:
break;
}
} else if (MDOC_BODY == n->type) {
switch (type) {
- case(LIST_bullet):
+ case LIST_bullet:
/* FALLTHROUGH */
- case(LIST_hyphen):
+ case LIST_hyphen:
/* FALLTHROUGH */
- case(LIST_dash):
+ case LIST_dash:
/* FALLTHROUGH */
- case(LIST_enum):
+ case LIST_enum:
/* FALLTHROUGH */
- case(LIST_item):
+ case LIST_item:
SCALE_VS_INIT(&su, ! bl->norm->Bl.comp);
bufcat_su(h, "margin-top", &su);
PAIR_STYLE_INIT(&tag[1], h);
print_otag(h, TAG_LI, 2, tag);
break;
- case(LIST_diag):
+ case LIST_diag:
/* FALLTHROUGH */
- case(LIST_hang):
+ case LIST_hang:
/* FALLTHROUGH */
- case(LIST_inset):
+ case LIST_inset:
/* FALLTHROUGH */
- case(LIST_ohang):
+ case LIST_ohang:
/* FALLTHROUGH */
- case(LIST_tag):
+ case LIST_tag:
if (NULL == bl->norm->Bl.width) {
print_otag(h, TAG_DD, 1, tag);
break;
PAIR_STYLE_INIT(&tag[1], h);
print_otag(h, TAG_DD, 2, tag);
break;
- case(LIST_column):
+ case LIST_column:
SCALE_VS_INIT(&su, ! bl->norm->Bl.comp);
bufcat_su(h, "margin-top", &su);
PAIR_STYLE_INIT(&tag[1], h);
}
} else {
switch (type) {
- case (LIST_column):
+ case LIST_column:
print_otag(h, TAG_TR, 1, tag);
break;
default:
return(1);
}
-/* ARGSUSED */
static int
mdoc_bl_pre(MDOC_ARGS)
{
}
switch (n->norm->Bl.type) {
- case(LIST_bullet):
+ case LIST_bullet:
/* FALLTHROUGH */
- case(LIST_dash):
+ case LIST_dash:
/* FALLTHROUGH */
- case(LIST_hyphen):
+ case LIST_hyphen:
/* FALLTHROUGH */
- case(LIST_item):
+ case LIST_item:
print_otag(h, TAG_UL, 2, tag);
break;
- case(LIST_enum):
+ case LIST_enum:
print_otag(h, TAG_OL, 2, tag);
break;
- case(LIST_diag):
+ case LIST_diag:
/* FALLTHROUGH */
- case(LIST_hang):
+ case LIST_hang:
/* FALLTHROUGH */
- case(LIST_inset):
+ case LIST_inset:
/* FALLTHROUGH */
- case(LIST_ohang):
+ case LIST_ohang:
/* FALLTHROUGH */
- case(LIST_tag):
+ case LIST_tag:
print_otag(h, TAG_DL, 2, tag);
break;
- case(LIST_column):
+ case LIST_column:
print_otag(h, TAG_TABLE, 2, tag);
break;
default:
return(1);
}
-/* ARGSUSED */
static int
mdoc_ex_pre(MDOC_ARGS)
{
else
print_text(h, "utility exits");
- print_text(h, "0 on success, and >0 if an error occurs.");
+ print_text(h, "0 on success, and >0 if an error occurs.");
return(0);
}
-
-/* ARGSUSED */
static int
mdoc_em_pre(MDOC_ARGS)
{
return(1);
}
-
-/* ARGSUSED */
static int
mdoc_d1_pre(MDOC_ARGS)
{
if (MDOC_Dl == n->tok) {
PAIR_CLASS_INIT(&tag[0], "lit");
print_otag(h, TAG_CODE, 1, tag);
- }
+ }
return(1);
}
-
-/* ARGSUSED */
static int
mdoc_sx_pre(MDOC_ARGS)
{
return(1);
}
-
-/* ARGSUSED */
static int
mdoc_bd_pre(MDOC_ARGS)
{
- struct htmlpair tag[2];
- int comp, sv;
+ struct htmlpair tag[2];
+ int comp, sv;
const struct mdoc_node *nn;
struct roffsu su;
SCALE_HS_INIT(&su, 0);
if (n->norm->Bd.offs)
a2offs(n->norm->Bd.offs, &su);
-
+
bufinit(h);
bufcat_su(h, "margin-left", &su);
PAIR_STYLE_INIT(&tag[0], h);
- if (DISP_unfilled != n->norm->Bd.type &&
- DISP_literal != n->norm->Bd.type) {
+ if (DISP_unfilled != n->norm->Bd.type &&
+ DISP_literal != n->norm->Bd.type) {
PAIR_CLASS_INIT(&tag[1], "display");
print_otag(h, TAG_DIV, 2, tag);
return(1);
* anyway, so don't sweat it.
*/
switch (nn->tok) {
- case (MDOC_Sm):
+ case MDOC_Sm:
/* FALLTHROUGH */
- case (MDOC_br):
+ case MDOC_br:
/* FALLTHROUGH */
- case (MDOC_sp):
+ case MDOC_sp:
/* FALLTHROUGH */
- case (MDOC_Bl):
+ case MDOC_Bl:
/* FALLTHROUGH */
- case (MDOC_D1):
+ case MDOC_D1:
/* FALLTHROUGH */
- case (MDOC_Dl):
+ case MDOC_Dl:
/* FALLTHROUGH */
- case (MDOC_Lp):
+ case MDOC_Lp:
/* FALLTHROUGH */
- case (MDOC_Pp):
+ case MDOC_Pp:
continue;
default:
break;
return(0);
}
-
-/* ARGSUSED */
static int
mdoc_pa_pre(MDOC_ARGS)
{
return(1);
}
-
-/* ARGSUSED */
static int
mdoc_ad_pre(MDOC_ARGS)
{
return(1);
}
-
-/* ARGSUSED */
static int
mdoc_an_pre(MDOC_ARGS)
{
return(1);
}
-
-/* ARGSUSED */
static int
mdoc_cd_pre(MDOC_ARGS)
{
return(1);
}
-
-/* ARGSUSED */
static int
mdoc_dv_pre(MDOC_ARGS)
{
return(1);
}
-
-/* ARGSUSED */
static int
mdoc_ev_pre(MDOC_ARGS)
{
return(1);
}
-
-/* ARGSUSED */
static int
mdoc_er_pre(MDOC_ARGS)
{
return(1);
}
-
-/* ARGSUSED */
static int
mdoc_fa_pre(MDOC_ARGS)
{
return(0);
}
-
-/* ARGSUSED */
static int
mdoc_fd_pre(MDOC_ARGS)
{
if (NULL != (n = n->next)) {
assert(MDOC_TEXT == n->type);
- strlcpy(buf, '<' == *n->string || '"' == *n->string ?
- n->string + 1 : n->string, BUFSIZ);
+ strlcpy(buf, '<' == *n->string || '"' == *n->string ?
+ n->string + 1 : n->string, BUFSIZ);
sz = strlen(buf);
if (sz && ('>' == buf[sz - 1] || '"' == buf[sz - 1]))
buf[sz - 1] = '\0';
PAIR_CLASS_INIT(&tag[0], "link-includes");
-
+
i = 1;
if (h->base_includes) {
buffmt_includes(h, buf);
PAIR_HREF_INIT(&tag[i], h->buf);
i++;
- }
+ }
t = print_otag(h, TAG_A, i, tag);
print_text(h, n->string);
return(0);
}
-
-/* ARGSUSED */
static int
mdoc_vt_pre(MDOC_ARGS)
{
return(1);
}
-
-/* ARGSUSED */
static int
mdoc_ft_pre(MDOC_ARGS)
{
return(1);
}
-
-/* ARGSUSED */
static int
mdoc_fn_pre(MDOC_ARGS)
{
if (NULL != ep) {
PAIR_CLASS_INIT(&tag[0], "ftype");
t = print_otag(h, TAG_I, 1, tag);
-
+
while (ep) {
sz = MIN((int)(ep - sp), BUFSIZ - 1);
(void)memcpy(nbuf, sp, (size_t)sz);
return(0);
}
-
-/* ARGSUSED */
static int
mdoc_sm_pre(MDOC_ARGS)
{
assert(n->child && MDOC_TEXT == n->child->type);
if (0 == strcmp("on", n->child->string)) {
- /*
+ /*
* FIXME: no p->col to check. Thus, if we have
* .Bd -literal
* .Sm off
return(0);
}
-/* ARGSUSED */
static int
mdoc_ll_pre(MDOC_ARGS)
{
return(0);
}
-/* ARGSUSED */
static int
mdoc_pp_pre(MDOC_ARGS)
{
return(0);
}
-/* ARGSUSED */
static int
mdoc_sp_pre(MDOC_ARGS)
{
}
-/* ARGSUSED */
static int
mdoc_lk_pre(MDOC_ARGS)
{
return(0);
}
-
-/* ARGSUSED */
static int
mdoc_mt_pre(MDOC_ARGS)
{
print_text(h, n->string);
print_tagq(h, t);
}
-
+
return(0);
}
-
-/* ARGSUSED */
static int
mdoc_fo_pre(MDOC_ARGS)
{
return(0);
}
-
-/* ARGSUSED */
static void
mdoc_fo_post(MDOC_ARGS)
{
print_text(h, ";");
}
-
-/* ARGSUSED */
static int
mdoc_in_pre(MDOC_ARGS)
{
buffmt_includes(h, n->string);
PAIR_HREF_INIT(&tag[i], h->buf);
i++;
- }
+ }
t = print_otag(h, TAG_A, i, tag);
print_text(h, n->string);
return(0);
}
-
-/* ARGSUSED */
static int
mdoc_ic_pre(MDOC_ARGS)
{
return(1);
}
-
-/* ARGSUSED */
static int
mdoc_rv_pre(MDOC_ARGS)
{
else
print_text(h, "function returns");
- print_text(h, "the value 0 if successful; otherwise the value "
- "-1 is returned and the global variable");
+ print_text(h, "the value 0 if successful; otherwise the "
+ "value -1 is returned and the global variable");
PAIR_CLASS_INIT(&tag, "var");
t = print_otag(h, TAG_B, 1, &tag);
print_text(h, "errno");
print_tagq(h, t);
- print_text(h, "is set to indicate the error.");
+ print_text(h, "is set to indicate the error.");
return(0);
}
-
-/* ARGSUSED */
static int
mdoc_va_pre(MDOC_ARGS)
{
return(1);
}
-
-/* ARGSUSED */
static int
mdoc_ap_pre(MDOC_ARGS)
{
-
+
h->flags |= HTML_NOSPACE;
print_text(h, "\\(aq");
h->flags |= HTML_NOSPACE;
return(1);
}
-
-/* ARGSUSED */
static int
mdoc_bf_pre(MDOC_ARGS)
{
else if (MDOC_BODY != n->type)
return(1);
- if (FONT_Em == n->norm->Bf.font)
+ if (FONT_Em == n->norm->Bf.font)
PAIR_CLASS_INIT(&tag[0], "emph");
- else if (FONT_Sy == n->norm->Bf.font)
+ else if (FONT_Sy == n->norm->Bf.font)
PAIR_CLASS_INIT(&tag[0], "symb");
- else if (FONT_Li == n->norm->Bf.font)
+ else if (FONT_Li == n->norm->Bf.font)
PAIR_CLASS_INIT(&tag[0], "lit");
else
PAIR_CLASS_INIT(&tag[0], "none");
- /*
+ /*
* We want this to be inline-formatted, but needs to be div to
- * accept block children.
+ * accept block children.
*/
bufinit(h);
bufcat_style(h, "display", "inline");
return(1);
}
-
-/* ARGSUSED */
static int
mdoc_ms_pre(MDOC_ARGS)
{
return(1);
}
-
-/* ARGSUSED */
static int
mdoc_igndelim_pre(MDOC_ARGS)
{
return(1);
}
-
-/* ARGSUSED */
static void
mdoc_pf_post(MDOC_ARGS)
{
h->flags |= HTML_NOSPACE;
}
-
-/* ARGSUSED */
static int
mdoc_rs_pre(MDOC_ARGS)
{
return(1);
}
-
-
-/* ARGSUSED */
static int
mdoc_li_pre(MDOC_ARGS)
{
return(1);
}
-
-/* ARGSUSED */
static int
mdoc_sy_pre(MDOC_ARGS)
{
return(1);
}
-
-/* ARGSUSED */
static int
mdoc_bt_pre(MDOC_ARGS)
{
return(0);
}
-
-/* ARGSUSED */
static int
mdoc_ud_pre(MDOC_ARGS)
{
return(0);
}
-
-/* ARGSUSED */
static int
mdoc_lb_pre(MDOC_ARGS)
{
return(1);
}
-
-/* ARGSUSED */
static int
mdoc__x_pre(MDOC_ARGS)
{
t = TAG_SPAN;
switch (n->tok) {
- case(MDOC__A):
+ case MDOC__A:
PAIR_CLASS_INIT(&tag[0], "ref-auth");
if (n->prev && MDOC__A == n->prev->tok)
if (NULL == n->next || MDOC__A != n->next->tok)
print_text(h, "and");
break;
- case(MDOC__B):
+ case MDOC__B:
PAIR_CLASS_INIT(&tag[0], "ref-book");
t = TAG_I;
break;
- case(MDOC__C):
+ case MDOC__C:
PAIR_CLASS_INIT(&tag[0], "ref-city");
break;
- case(MDOC__D):
+ case MDOC__D:
PAIR_CLASS_INIT(&tag[0], "ref-date");
break;
- case(MDOC__I):
+ case MDOC__I:
PAIR_CLASS_INIT(&tag[0], "ref-issue");
t = TAG_I;
break;
- case(MDOC__J):
+ case MDOC__J:
PAIR_CLASS_INIT(&tag[0], "ref-jrnl");
t = TAG_I;
break;
- case(MDOC__N):
+ case MDOC__N:
PAIR_CLASS_INIT(&tag[0], "ref-num");
break;
- case(MDOC__O):
+ case MDOC__O:
PAIR_CLASS_INIT(&tag[0], "ref-opt");
break;
- case(MDOC__P):
+ case MDOC__P:
PAIR_CLASS_INIT(&tag[0], "ref-page");
break;
- case(MDOC__Q):
+ case MDOC__Q:
PAIR_CLASS_INIT(&tag[0], "ref-corp");
break;
- case(MDOC__R):
+ case MDOC__R:
PAIR_CLASS_INIT(&tag[0], "ref-rep");
break;
- case(MDOC__T):
+ case MDOC__T:
PAIR_CLASS_INIT(&tag[0], "ref-title");
break;
- case(MDOC__U):
+ case MDOC__U:
PAIR_CLASS_INIT(&tag[0], "link-ref");
break;
- case(MDOC__V):
+ case MDOC__V:
PAIR_CLASS_INIT(&tag[0], "ref-vol");
break;
default:
return(1);
}
-
-/* ARGSUSED */
static void
mdoc__x_post(MDOC_ARGS)
{
print_text(h, n->next ? "," : ".");
}
-
-/* ARGSUSED */
static int
mdoc_bk_pre(MDOC_ARGS)
{
switch (n->type) {
- case (MDOC_BLOCK):
+ case MDOC_BLOCK:
break;
- case (MDOC_HEAD):
+ case MDOC_HEAD:
return(0);
- case (MDOC_BODY):
+ case MDOC_BODY:
if (n->parent->args || 0 == n->prev->nchild)
h->flags |= HTML_PREKEEP;
break;
return(1);
}
-
-/* ARGSUSED */
static void
mdoc_bk_post(MDOC_ARGS)
{
h->flags &= ~(HTML_KEEP | HTML_PREKEEP);
}
-
-/* ARGSUSED */
static int
mdoc_quote_pre(MDOC_ARGS)
{
return(1);
switch (n->tok) {
- case (MDOC_Ao):
+ case MDOC_Ao:
/* FALLTHROUGH */
- case (MDOC_Aq):
+ case MDOC_Aq:
print_text(h, "\\(la");
break;
- case (MDOC_Bro):
+ case MDOC_Bro:
/* FALLTHROUGH */
- case (MDOC_Brq):
+ case MDOC_Brq:
print_text(h, "\\(lC");
break;
- case (MDOC_Bo):
+ case MDOC_Bo:
/* FALLTHROUGH */
- case (MDOC_Bq):
+ case MDOC_Bq:
print_text(h, "\\(lB");
break;
- case (MDOC_Oo):
+ case MDOC_Oo:
/* FALLTHROUGH */
- case (MDOC_Op):
+ case MDOC_Op:
print_text(h, "\\(lB");
h->flags |= HTML_NOSPACE;
PAIR_CLASS_INIT(&tag, "opt");
print_otag(h, TAG_SPAN, 1, &tag);
break;
- case (MDOC_Eo):
+ case MDOC_Eo:
break;
- case (MDOC_Do):
+ case MDOC_Do:
/* FALLTHROUGH */
- case (MDOC_Dq):
+ case MDOC_Dq:
/* FALLTHROUGH */
- case (MDOC_Qo):
+ case MDOC_Qo:
/* FALLTHROUGH */
- case (MDOC_Qq):
+ case MDOC_Qq:
print_text(h, "\\(lq");
break;
- case (MDOC_Po):
+ case MDOC_Po:
/* FALLTHROUGH */
- case (MDOC_Pq):
+ case MDOC_Pq:
print_text(h, "(");
break;
- case (MDOC_Ql):
+ case MDOC_Ql:
print_text(h, "\\(oq");
h->flags |= HTML_NOSPACE;
PAIR_CLASS_INIT(&tag, "lit");
print_otag(h, TAG_CODE, 1, &tag);
break;
- case (MDOC_So):
+ case MDOC_So:
/* FALLTHROUGH */
- case (MDOC_Sq):
+ case MDOC_Sq:
print_text(h, "\\(oq");
break;
default:
return(1);
}
-
-/* ARGSUSED */
static void
mdoc_quote_post(MDOC_ARGS)
{
h->flags |= HTML_NOSPACE;
switch (n->tok) {
- case (MDOC_Ao):
+ case MDOC_Ao:
/* FALLTHROUGH */
- case (MDOC_Aq):
+ case MDOC_Aq:
print_text(h, "\\(ra");
break;
- case (MDOC_Bro):
+ case MDOC_Bro:
/* FALLTHROUGH */
- case (MDOC_Brq):
+ case MDOC_Brq:
print_text(h, "\\(rC");
break;
- case (MDOC_Oo):
+ case MDOC_Oo:
/* FALLTHROUGH */
- case (MDOC_Op):
+ case MDOC_Op:
/* FALLTHROUGH */
- case (MDOC_Bo):
+ case MDOC_Bo:
/* FALLTHROUGH */
- case (MDOC_Bq):
+ case MDOC_Bq:
print_text(h, "\\(rB");
break;
- case (MDOC_Eo):
+ case MDOC_Eo:
break;
- case (MDOC_Qo):
+ case MDOC_Qo:
/* FALLTHROUGH */
- case (MDOC_Qq):
+ case MDOC_Qq:
/* FALLTHROUGH */
- case (MDOC_Do):
+ case MDOC_Do:
/* FALLTHROUGH */
- case (MDOC_Dq):
+ case MDOC_Dq:
print_text(h, "\\(rq");
break;
- case (MDOC_Po):
+ case MDOC_Po:
/* FALLTHROUGH */
- case (MDOC_Pq):
+ case MDOC_Pq:
print_text(h, ")");
break;
- case (MDOC_Ql):
+ case MDOC_Ql:
/* FALLTHROUGH */
- case (MDOC_So):
+ case MDOC_So:
/* FALLTHROUGH */
- case (MDOC_Sq):
+ case MDOC_Sq:
print_text(h, "\\(cq");
break;
default:
/* NOTREACHED */
}
}
-
-
-/* $Id: mdoc_macro.c,v 1.87 2014/03/30 19:47:32 schwarze Exp $ */
+/* $Id: mdoc_macro.c,v 1.88 2014/04/20 16:44:44 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012, 2013 Ingo Schwarze <schwarze@openbsd.org>
REWIND_ERROR
};
-static int blk_full(MACRO_PROT_ARGS);
-static int blk_exp_close(MACRO_PROT_ARGS);
-static int blk_part_exp(MACRO_PROT_ARGS);
-static int blk_part_imp(MACRO_PROT_ARGS);
-static int ctx_synopsis(MACRO_PROT_ARGS);
-static int in_line_eoln(MACRO_PROT_ARGS);
-static int in_line_argn(MACRO_PROT_ARGS);
-static int in_line(MACRO_PROT_ARGS);
-static int obsolete(MACRO_PROT_ARGS);
-static int phrase_ta(MACRO_PROT_ARGS);
+static int blk_full(MACRO_PROT_ARGS);
+static int blk_exp_close(MACRO_PROT_ARGS);
+static int blk_part_exp(MACRO_PROT_ARGS);
+static int blk_part_imp(MACRO_PROT_ARGS);
+static int ctx_synopsis(MACRO_PROT_ARGS);
+static int in_line_eoln(MACRO_PROT_ARGS);
+static int in_line_argn(MACRO_PROT_ARGS);
+static int in_line(MACRO_PROT_ARGS);
+static int obsolete(MACRO_PROT_ARGS);
+static int phrase_ta(MACRO_PROT_ARGS);
static int dword(struct mdoc *, int, int, const char *,
enum mdelim, int);
-static int append_delims(struct mdoc *,
+static int append_delims(struct mdoc *,
int, int *, char *);
static enum mdoct lookup(enum mdoct, const char *);
static enum mdoct lookup_raw(const char *);
static int make_pending(struct mdoc_node *, enum mdoct,
struct mdoc *, int, int);
-static int phrase(struct mdoc *, int, int, char *);
-static enum mdoct rew_alt(enum mdoct);
-static enum rew rew_dohalt(enum mdoct, enum mdoc_type,
+static int phrase(struct mdoc *, int, int, char *);
+static enum mdoct rew_alt(enum mdoct);
+static enum rew rew_dohalt(enum mdoct, enum mdoc_type,
const struct mdoc_node *);
-static int rew_elem(struct mdoc *, enum mdoct);
-static int rew_last(struct mdoc *,
+static int rew_elem(struct mdoc *, enum mdoct);
+static int rew_last(struct mdoc *,
const struct mdoc_node *);
-static int rew_sub(enum mdoc_type, struct mdoc *,
+static int rew_sub(enum mdoc_type, struct mdoc *,
enum mdoct, int, int);
const struct mdoc_macro __mdoc_macros[MDOC_MAX] = {
/* Scan for open explicit scopes. */
n = MDOC_VALID & mdoc->last->flags ?
- mdoc->last->parent : mdoc->last;
+ mdoc->last->parent : mdoc->last;
for ( ; n; n = n->parent)
if (MDOC_BLOCK == n->type &&
return(rew_last(mdoc, mdoc->first));
}
-
/*
* Look up a macro from within a subsequent context.
*/
return(lookup_raw(p));
}
-
/*
* Lookup a macro following the initial line macro.
*/
return(MDOC_MAX);
}
-
static int
rew_last(struct mdoc *mdoc, const struct mdoc_node *to)
{
assert(to);
mdoc->next = MDOC_NEXT_SIBLING;
- /* LINTED */
+
while (mdoc->last != to) {
/*
* Save the parent here, because we may delete the
return(mdoc_valid_post(mdoc));
}
-
/*
* For a block closing macro, return the corresponding opening one.
* Otherwise, return the macro itself.
rew_alt(enum mdoct tok)
{
switch (tok) {
- case (MDOC_Ac):
+ case MDOC_Ac:
return(MDOC_Ao);
- case (MDOC_Bc):
+ case MDOC_Bc:
return(MDOC_Bo);
- case (MDOC_Brc):
+ case MDOC_Brc:
return(MDOC_Bro);
- case (MDOC_Dc):
+ case MDOC_Dc:
return(MDOC_Do);
- case (MDOC_Ec):
+ case MDOC_Ec:
return(MDOC_Eo);
- case (MDOC_Ed):
+ case MDOC_Ed:
return(MDOC_Bd);
- case (MDOC_Ef):
+ case MDOC_Ef:
return(MDOC_Bf);
- case (MDOC_Ek):
+ case MDOC_Ek:
return(MDOC_Bk);
- case (MDOC_El):
+ case MDOC_El:
return(MDOC_Bl);
- case (MDOC_Fc):
+ case MDOC_Fc:
return(MDOC_Fo);
- case (MDOC_Oc):
+ case MDOC_Oc:
return(MDOC_Oo);
- case (MDOC_Pc):
+ case MDOC_Pc:
return(MDOC_Po);
- case (MDOC_Qc):
+ case MDOC_Qc:
return(MDOC_Qo);
- case (MDOC_Re):
+ case MDOC_Re:
return(MDOC_Rs);
- case (MDOC_Sc):
+ case MDOC_Sc:
return(MDOC_So);
- case (MDOC_Xc):
+ case MDOC_Xc:
return(MDOC_Xo);
default:
return(tok);
/* NOTREACHED */
}
-
/*
* Rewinding to tok, how do we have to handle *p?
* REWIND_NONE: *p would delimit tok, but no tok scope is open
* REWIND_ERROR: No tok block is open at all.
*/
static enum rew
-rew_dohalt(enum mdoct tok, enum mdoc_type type,
+rew_dohalt(enum mdoct tok, enum mdoc_type type,
const struct mdoc_node *p)
{
REWIND_ERROR : REWIND_NONE);
/*
- * When starting to rewind, skip plain text
+ * When starting to rewind, skip plain text
* and nodes that have already been rewound.
*/
if (MDOC_TEXT == p->type || MDOC_VALID & p->flags)
/*
* Blocks delimited by our target token get REWIND_MORE.
- * Blocks delimiting our target token get REWIND_NONE.
+ * Blocks delimiting our target token get REWIND_NONE.
*/
switch (tok) {
- case (MDOC_Bl):
+ case MDOC_Bl:
if (MDOC_It == p->tok)
return(REWIND_MORE);
break;
- case (MDOC_It):
+ case MDOC_It:
if (MDOC_BODY == p->type && MDOC_Bl == p->tok)
return(REWIND_NONE);
break;
* This is an incomplete and extremely ugly workaround,
* required to let the OpenBSD tree build.
*/
- case (MDOC_Oo):
+ case MDOC_Oo:
if (MDOC_Op == p->tok)
return(REWIND_MORE);
break;
- case (MDOC_Nm):
+ case MDOC_Nm:
return(REWIND_NONE);
- case (MDOC_Nd):
+ case MDOC_Nd:
/* FALLTHROUGH */
- case (MDOC_Ss):
+ case MDOC_Ss:
if (MDOC_BODY == p->type && MDOC_Sh == p->tok)
return(REWIND_NONE);
/* FALLTHROUGH */
- case (MDOC_Sh):
+ case MDOC_Sh:
if (MDOC_Nd == p->tok || MDOC_Ss == p->tok ||
MDOC_Sh == p->tok)
return(REWIND_MORE);
REWIND_FORCE : REWIND_LATER);
}
-
static int
rew_elem(struct mdoc *mdoc, enum mdoct tok)
{
return(rew_last(mdoc, n));
}
-
/*
* We are trying to close a block identified by tok,
* but the child block *broken is still open.
}
broken->pending = breaker;
mandoc_vmsg(MANDOCERR_SCOPENEST, mdoc->parse, line, ppos,
- "%s breaks %s", mdoc_macronames[tok],
- mdoc_macronames[broken->tok]);
+ "%s breaks %s", mdoc_macronames[tok],
+ mdoc_macronames[broken->tok]);
return(1);
}
return(0);
}
-
static int
-rew_sub(enum mdoc_type t, struct mdoc *mdoc,
+rew_sub(enum mdoc_type t, struct mdoc *mdoc,
enum mdoct tok, int line, int ppos)
{
struct mdoc_node *n;
n = mdoc->last;
while (n) {
switch (rew_dohalt(tok, t, n)) {
- case (REWIND_NONE):
+ case REWIND_NONE:
return(1);
- case (REWIND_THIS):
+ case REWIND_THIS:
n->lastline = line -
(MDOC_NEWLINE & mdoc->flags &&
! (MDOC_EXPLICIT & mdoc_macros[tok].flags));
break;
- case (REWIND_FORCE):
- mandoc_vmsg(MANDOCERR_SCOPEBROKEN, mdoc->parse,
- line, ppos, "%s breaks %s",
- mdoc_macronames[tok],
- mdoc_macronames[n->tok]);
+ case REWIND_FORCE:
+ mandoc_vmsg(MANDOCERR_SCOPEBROKEN, mdoc->parse,
+ line, ppos, "%s breaks %s",
+ mdoc_macronames[tok],
+ mdoc_macronames[n->tok]);
/* FALLTHROUGH */
- case (REWIND_MORE):
+ case REWIND_MORE:
n->lastline = line -
(MDOC_NEWLINE & mdoc->flags ? 1 : 0);
n = n->parent;
continue;
- case (REWIND_LATER):
+ case REWIND_LATER:
if (make_pending(n, tok, mdoc, line, ppos) ||
MDOC_BLOCK != t)
return(1);
/* FALLTHROUGH */
- case (REWIND_ERROR):
+ case REWIND_ERROR:
mdoc_pmsg(mdoc, line, ppos, MANDOCERR_NOSCOPE);
return(1);
}
dword(struct mdoc *mdoc, int line, int col, const char *p,
enum mdelim d, int may_append)
{
-
+
if (DELIM_MAX == d)
d = mdoc_isdelim(p);
*/
else if (DELIM_CLOSE == d && mdoc->last->prev &&
- mdoc->last->prev->tok != MDOC_No &&
- mdoc->last->parent->tok != MDOC_Fd)
+ mdoc->last->prev->tok != MDOC_No &&
+ mdoc->last->parent->tok != MDOC_Fd)
mdoc->last->flags |= MDOC_DELIMC;
return(1);
return(1);
}
-
/*
- * Close out block partial/full explicit.
+ * Close out block partial/full explicit.
*/
static int
blk_exp_close(MACRO_PROT_ARGS)
struct mdoc_node *later; /* A sub-block starting later. */
struct mdoc_node *n; /* For searching backwards. */
- int j, lastarg, maxargs, flushed, nl;
+ int j, lastarg, maxargs, flushed, nl;
enum margserr ac;
enum mdoct atok, ntok;
char *p;
nl = MDOC_NEWLINE & mdoc->flags;
switch (tok) {
- case (MDOC_Ec):
+ case MDOC_Ec:
maxargs = 1;
break;
- case (MDOC_Ek):
+ case MDOC_Ek:
mdoc->flags &= ~MDOC_KEEP;
default:
maxargs = 0;
if (NULL == later)
break;
- /*
+ /*
* When there is a pending sub block,
* postpone closing out the current block
* until the rew_sub() closing out the sub-block.
if ( ! (MDOC_CALLABLE & mdoc_macros[tok].flags)) {
/* FIXME: do this in validate */
- if (buf[*pos])
+ if (buf[*pos])
mdoc_pmsg(mdoc, line, ppos, MANDOCERR_ARGSLOST);
if ( ! rew_sub(MDOC_BODY, mdoc, tok, line, ppos))
if ( ! rew_sub(MDOC_BODY, mdoc, tok, line, ppos))
return(0);
- if (NULL == later && maxargs > 0)
+ if (NULL == later && maxargs > 0)
if ( ! mdoc_tail_alloc(mdoc, line, ppos, rew_alt(tok)))
return(0);
return(append_delims(mdoc, line, pos, buf));
}
-
static int
in_line(MACRO_PROT_ARGS)
{
*/
switch (tok) {
- case (MDOC_An):
+ case MDOC_An:
/* FALLTHROUGH */
- case (MDOC_Ar):
+ case MDOC_Ar:
/* FALLTHROUGH */
- case (MDOC_Fl):
+ case MDOC_Fl:
/* FALLTHROUGH */
- case (MDOC_Mt):
+ case MDOC_Mt:
/* FALLTHROUGH */
- case (MDOC_Nm):
+ case MDOC_Nm:
/* FALLTHROUGH */
- case (MDOC_Pa):
+ case MDOC_Pa:
nc = 1;
break;
default:
if (ARGV_WORD == av) {
*pos = la;
break;
- }
+ }
if (ARGV_EOLN == av)
break;
if (ARGV_ARG == av)
ntok = ARGS_QWORD == ac ? MDOC_MAX : lookup(tok, p);
- /*
+ /*
* In this case, we've located a submacro and must
* execute it. Close out scope, if open. If no
* elements have been generated, either create one (nc)
if (scope && ! rew_elem(mdoc, tok))
return(0);
if (nc && 0 == cnt) {
- if ( ! mdoc_elem_alloc(mdoc, line,
- ppos, tok, arg))
+ if ( ! mdoc_elem_alloc(mdoc,
+ line, ppos, tok, arg))
return(0);
if ( ! rew_last(mdoc, mdoc->last))
return(0);
} else if ( ! nc && 0 == cnt) {
mdoc_argv_free(arg);
mdoc_pmsg(mdoc, line, ppos,
- MANDOCERR_MACROEMPTY);
+ MANDOCERR_MACROEMPTY);
}
if ( ! mdoc_macro(mdoc, ntok, line, la, pos, buf))
if ( ! nl)
return(1);
return(append_delims(mdoc, line, pos, buf));
- }
+ }
- /*
+ /*
* Non-quote-enclosed punctuation. Set up our scope, if
* a word; rewind the scope, if a delimiter; then append
- * the word.
+ * the word.
*/
d = ARGS_QWORD == ac ? DELIM_NONE : mdoc_isdelim(p);
* this once per invocation. There may be more
* of these (all of them?).
*/
- if (0 == cnt && (nc || MDOC_Li == tok) &&
- DELIM_CLOSE == d && ! scope) {
- if ( ! mdoc_elem_alloc(mdoc, line,
- ppos, tok, arg))
+ if (0 == cnt && (nc || MDOC_Li == tok) &&
+ DELIM_CLOSE == d && ! scope) {
+ if ( ! mdoc_elem_alloc(mdoc,
+ line, ppos, tok, arg))
return(0);
- if (MDOC_Ar == tok || MDOC_Li == tok ||
- MDOC_Fl == tok)
+ if (MDOC_Ar == tok || MDOC_Li == tok ||
+ MDOC_Fl == tok)
cnt++;
scope = 1;
}
return(append_delims(mdoc, line, pos, buf));
}
-
static int
blk_full(MACRO_PROT_ARGS)
{
if (ARGV_WORD == av) {
*pos = la;
break;
- }
+ }
if (ARGV_EOLN == av)
break;
* parsed, even though `It' macros in general are parsed.
*/
nparsed = MDOC_It == tok &&
- MDOC_Bl == mdoc->last->parent->tok &&
- LIST_diag == mdoc->last->parent->norm->Bl.type;
+ MDOC_Bl == mdoc->last->parent->tok &&
+ LIST_diag == mdoc->last->parent->norm->Bl.type;
/*
* The `Nd' macro has all arguments in its body: it's a hybrid
break;
}
- /*
+ /*
* Emit leading punctuation (i.e., punctuation before
* the MDOC_HEAD) for non-phrase types.
*/
- if (NULL == head &&
- ARGS_PEND != ac &&
- ARGS_PHRASE != ac &&
- ARGS_PPHRASE != ac &&
- ARGS_QWORD != ac &&
- DELIM_OPEN == mdoc_isdelim(p)) {
+ if (NULL == head &&
+ ARGS_PEND != ac &&
+ ARGS_PHRASE != ac &&
+ ARGS_PPHRASE != ac &&
+ ARGS_QWORD != ac &&
+ DELIM_OPEN == mdoc_isdelim(p)) {
if ( ! dword(mdoc, line, la, p, DELIM_OPEN, 0))
return(0);
continue;
head = mdoc->last;
}
- if (ARGS_PHRASE == ac ||
- ARGS_PEND == ac ||
- ARGS_PPHRASE == ac) {
+ if (ARGS_PHRASE == ac ||
+ ARGS_PEND == ac ||
+ ARGS_PPHRASE == ac) {
/*
* If we haven't opened a body yet, rewind the
* head; if we have, rewind that instead.
mtt = body ? MDOC_BODY : MDOC_HEAD;
if ( ! rew_sub(mtt, mdoc, tok, line, ppos))
return(0);
-
+
/* Then allocate our body context. */
if ( ! mdoc_body_alloc(mdoc, line, ppos, tok))
continue;
}
- ntok = nparsed || ARGS_QWORD == ac ?
- MDOC_MAX : lookup(tok, p);
+ ntok = nparsed || ARGS_QWORD == ac ?
+ MDOC_MAX : lookup(tok, p);
if (MDOC_MAX == ntok) {
if ( ! dword(mdoc, line, la, p, DELIM_MAX,
return(0);
head = mdoc->last;
}
-
+
if (nl && ! append_delims(mdoc, line, pos, buf))
return(0);
* sub-block.
*/
for (n = mdoc->last; n && n != head; n = n->parent) {
- if (MDOC_BLOCK == n->type &&
- MDOC_EXPLICIT & mdoc_macros[n->tok].flags &&
- ! (MDOC_VALID & n->flags)) {
+ if (MDOC_BLOCK == n->type &&
+ MDOC_EXPLICIT & mdoc_macros[n->tok].flags &&
+ ! (MDOC_VALID & n->flags)) {
n->pending = head;
return(1);
}
return(1);
}
-
static int
blk_part_imp(MACRO_PROT_ARGS)
{
break;
if (NULL == body && ARGS_QWORD != ac &&
- DELIM_OPEN == mdoc_isdelim(p)) {
+ DELIM_OPEN == mdoc_isdelim(p)) {
if ( ! dword(mdoc, line, la, p, DELIM_OPEN, 0))
return(0);
continue;
* until the rew_sub() call closing out the sub-block.
*/
for (n = mdoc->last; n && n != body && n != blk->parent;
- n = n->parent) {
+ n = n->parent) {
if (MDOC_BLOCK == n->type &&
MDOC_EXPLICIT & mdoc_macros[n->tok].flags &&
! (MDOC_VALID & n->flags)) {
}
}
- /*
+ /*
* If we can't rewind to our body, then our scope has already
* been closed by another macro (like `Oc' closing `Op'). This
* is ugly behaviour nodding its head to OpenBSD's overwhelming
* crufty use of `Op' breakage.
*/
if (n != body)
- mandoc_vmsg(MANDOCERR_SCOPENEST, mdoc->parse, line, ppos,
- "%s broken", mdoc_macronames[tok]);
+ mandoc_vmsg(MANDOCERR_SCOPENEST, mdoc->parse, line,
+ ppos, "%s broken", mdoc_macronames[tok]);
if (n && ! rew_sub(MDOC_BODY, mdoc, tok, line, ppos))
return(0);
return(1);
}
-
static int
blk_part_exp(MACRO_PROT_ARGS)
{
*/
if ( ! mdoc_block_alloc(mdoc, line, ppos, tok, NULL))
- return(0);
+ return(0);
for (head = body = NULL; ; ) {
la = *pos;
/* Flush out leading punctuation. */
if (NULL == head && ARGS_QWORD != ac &&
- DELIM_OPEN == mdoc_isdelim(p)) {
+ DELIM_OPEN == mdoc_isdelim(p)) {
assert(NULL == body);
if ( ! dword(mdoc, line, la, p, DELIM_OPEN, 0))
return(0);
return(append_delims(mdoc, line, pos, buf));
}
-
-/* ARGSUSED */
static int
in_line_argn(MACRO_PROT_ARGS)
{
*/
switch (tok) {
- case (MDOC_Ap):
+ case MDOC_Ap:
/* FALLTHROUGH */
- case (MDOC_No):
+ case MDOC_No:
/* FALLTHROUGH */
- case (MDOC_Ns):
+ case MDOC_Ns:
/* FALLTHROUGH */
- case (MDOC_Ux):
+ case MDOC_Ux:
maxargs = 0;
break;
- case (MDOC_Bx):
+ case MDOC_Bx:
/* FALLTHROUGH */
- case (MDOC_Xr):
+ case MDOC_Xr:
maxargs = 2;
break;
default:
if (ARGV_WORD == av) {
*pos = la;
break;
- }
+ }
if (ARGV_EOLN == av)
break;
if (ARGS_EOLN == ac)
break;
- if ( ! (MDOC_IGNDELIM & mdoc_macros[tok].flags) &&
- ARGS_QWORD != ac && 0 == j &&
- DELIM_OPEN == mdoc_isdelim(p)) {
+ if ( ! (MDOC_IGNDELIM & mdoc_macros[tok].flags) &&
+ ARGS_QWORD != ac && 0 == j &&
+ DELIM_OPEN == mdoc_isdelim(p)) {
if ( ! dword(mdoc, line, la, p, DELIM_OPEN, 0))
return(0);
continue;
}
if ( ! (MDOC_IGNDELIM & mdoc_macros[tok].flags) &&
- ARGS_QWORD != ac &&
- ! flushed &&
- DELIM_NONE != mdoc_isdelim(p)) {
+ ARGS_QWORD != ac &&
+ ! flushed &&
+ DELIM_NONE != mdoc_isdelim(p)) {
if ( ! rew_elem(mdoc, tok))
return(0);
flushed = 1;
return(append_delims(mdoc, line, pos, buf));
}
-
static int
in_line_eoln(MACRO_PROT_ARGS)
{
*pos = la;
break;
}
- if (ARGV_EOLN == av)
+ if (ARGV_EOLN == av)
break;
if (ARGV_ARG == av)
continue;
return(rew_elem(mdoc, tok));
}
-
-/* ARGSUSED */
static int
ctx_synopsis(MACRO_PROT_ARGS)
{
return(blk_part_imp(mdoc, tok, line, ppos, pos, buf));
}
-
-/* ARGSUSED */
static int
obsolete(MACRO_PROT_ARGS)
{
return(1);
}
-
/*
* Phrases occur within `Bl -column' entries, separated by `Ta' or tabs.
* They're unusual because they're basically free-form text until a
return(1);
}
-
-/* ARGSUSED */
static int
phrase_ta(MACRO_PROT_ARGS)
{
-/* $Id: mdoc_man.c,v 1.60 2014/03/30 19:47:32 schwarze Exp $ */
+/* $Id: mdoc_man.c,v 1.61 2014/04/20 16:44:44 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
*
size_t size;
} fontqueue;
+
static void
font_push(char newfont)
{
if (fontqueue.head + fontqueue.size <= ++fontqueue.tail) {
fontqueue.size += 8;
fontqueue.head = mandoc_realloc(fontqueue.head,
- fontqueue.size);
+ fontqueue.size);
}
*fontqueue.tail = newfont;
print_word("");
{
if ((MMAN_PP | MMAN_sp | MMAN_br | MMAN_nl) & outflags) {
- /*
+ /*
* If we need a newline, print it now and start afresh.
*/
if (MMAN_PP & outflags) {
for ( ; *s; s++) {
switch (*s) {
- case (ASCII_NBRSP):
+ case ASCII_NBRSP:
printf("\\ ");
break;
- case (ASCII_HYPH):
+ case ASCII_HYPH:
putchar('-');
break;
- case (ASCII_BREAK):
+ case ASCII_BREAK:
printf("\\:");
break;
- case (' '):
+ case ' ':
if (MMAN_nbrword & outflags) {
printf("\\ ");
break;
/* XXX Rough estimation, might have multiple parts. */
chsz = (NULL != child && MDOC_TEXT == child->type) ?
- strlen(child->string) : 0;
+ strlen(child->string) : 0;
/* Maybe we are inside an enclosing list? */
mid_it();
n = mdoc_node(mdoc);
printf(".TH \"%s\" \"%s\" \"%s\" \"%s\" \"%s\"\n",
- meta->title, meta->msec, meta->date,
- meta->os, meta->vol);
+ meta->title, meta->msec, meta->date,
+ meta->os, meta->vol);
/* Disable hyphenation and if nroff, disable justification. */
printf(".nh\n.if n .ad l");
* Make sure that we don't happen to start with a
* control character at the start of a line.
*/
- if (MMAN_nl & outflags && ('.' == *n->string ||
- '\'' == *n->string)) {
+ if (MMAN_nl & outflags &&
+ ('.' == *n->string || '\'' == *n->string)) {
print_word("");
printf("\\&");
outflags &= ~MMAN_spc;
do_sub = (*act->pre)(meta, n);
}
- /*
+ /*
* Conditionally run all child nodes.
* Note that this iterates over children instead of using
* recursion. This prevents unnecessary depth in the stack.
pre__t(DECL_ARGS)
{
- if (n->parent && MDOC_Rs == n->parent->tok &&
- n->parent->norm->Rs.quote_T) {
+ if (n->parent && MDOC_Rs == n->parent->tok &&
+ n->parent->norm->Rs.quote_T) {
print_word("");
putchar('\"');
outflags &= ~MMAN_spc;
post__t(DECL_ARGS)
{
- if (n->parent && MDOC_Rs == n->parent->tok &&
- n->parent->norm->Rs.quote_T) {
+ if (n->parent && MDOC_Rs == n->parent->tok &&
+ n->parent->norm->Rs.quote_T) {
outflags &= ~MMAN_spc;
print_word("");
putchar('\"');
return;
if (n->prev->tok == n->tok &&
- MDOC_Ft != n->tok &&
- MDOC_Fo != n->tok &&
- MDOC_Fn != n->tok) {
+ MDOC_Ft != n->tok &&
+ MDOC_Fo != n->tok &&
+ MDOC_Fn != n->tok) {
outflags |= MMAN_br;
return;
}
switch (n->prev->tok) {
- case (MDOC_Fd):
+ case MDOC_Fd:
/* FALLTHROUGH */
- case (MDOC_Fn):
+ case MDOC_Fn:
/* FALLTHROUGH */
- case (MDOC_Fo):
+ case MDOC_Fo:
/* FALLTHROUGH */
- case (MDOC_In):
+ case MDOC_In:
/* FALLTHROUGH */
- case (MDOC_Vt):
+ case MDOC_Vt:
outflags |= MMAN_sp;
break;
- case (MDOC_Ft):
+ case MDOC_Ft:
if (MDOC_Fn != n->tok && MDOC_Fo != n->tok) {
outflags |= MMAN_sp;
break;
{
switch (n->norm->An.auth) {
- case (AUTH_split):
+ case AUTH_split:
outflags &= ~MMAN_An_nosplit;
outflags |= MMAN_An_split;
return(0);
- case (AUTH_nosplit):
+ case AUTH_nosplit:
outflags &= ~MMAN_An_split;
outflags |= MMAN_An_nosplit;
return(0);
{
switch (n->type) {
- case (MDOC_BLOCK):
+ case MDOC_BLOCK:
return(1);
- case (MDOC_BODY):
+ case MDOC_BODY:
break;
default:
return(0);
}
switch (n->norm->Bf.font) {
- case (FONT_Em):
+ case FONT_Em:
font_push('I');
break;
- case (FONT_Sy):
+ case FONT_Sy:
font_push('B');
break;
default:
{
switch (n->type) {
- case (MDOC_BLOCK):
+ case MDOC_BLOCK:
return(1);
- case (MDOC_BODY):
+ case MDOC_BODY:
outflags |= MMAN_Bk;
return(1);
default:
}
switch (n->norm->Bl.type) {
- case (LIST_enum):
+ case LIST_enum:
n->norm->Bl.count = 0;
return(1);
- case (LIST_column):
+ case LIST_column:
break;
default:
return(1);
{
switch (n->norm->Bl.type) {
- case (LIST_column):
+ case LIST_column:
print_line(".TE", 0);
break;
- case (LIST_enum):
+ case LIST_enum:
n->norm->Bl.count = 0;
break;
default:
{
switch (n->type) {
- case (MDOC_BLOCK):
+ case MDOC_BLOCK:
pre_syn(n);
break;
- case (MDOC_HEAD):
+ case MDOC_HEAD:
if (MDOC_SYNPRETTY & n->flags)
print_block(".HP 4n", MMAN_nl);
font_push('B');
break;
- case (MDOC_BODY):
+ case MDOC_BODY:
outflags &= ~MMAN_spc;
print_word("(");
outflags &= ~MMAN_spc;
{
switch (n->type) {
- case (MDOC_HEAD):
+ case MDOC_HEAD:
font_pop();
break;
- case (MDOC_BODY):
+ case MDOC_BODY:
post_fn(meta, n);
break;
default:
const struct mdoc_node *bln;
switch (n->type) {
- case (MDOC_HEAD):
+ case MDOC_HEAD:
outflags |= MMAN_PP | MMAN_nl;
bln = n->parent->parent;
if (0 == bln->norm->Bl.comp ||
outflags |= MMAN_sp;
outflags &= ~MMAN_br;
switch (bln->norm->Bl.type) {
- case (LIST_item):
+ case LIST_item:
return(0);
- case (LIST_inset):
+ case LIST_inset:
/* FALLTHROUGH */
- case (LIST_diag):
+ case LIST_diag:
/* FALLTHROUGH */
- case (LIST_ohang):
+ case LIST_ohang:
if (bln->norm->Bl.type == LIST_diag)
print_line(".B \"", 0);
else
print_line(".R \"", 0);
outflags &= ~MMAN_spc;
return(1);
- case (LIST_bullet):
+ case LIST_bullet:
/* FALLTHROUGH */
- case (LIST_dash):
+ case LIST_dash:
/* FALLTHROUGH */
- case (LIST_hyphen):
+ case LIST_hyphen:
print_width(bln->norm->Bl.width, NULL, 0);
TPremain = 0;
outflags |= MMAN_nl;
print_word("-");
font_pop();
break;
- case (LIST_enum):
+ case LIST_enum:
print_width(bln->norm->Bl.width, NULL, 0);
TPremain = 0;
outflags |= MMAN_nl;
print_count(&bln->norm->Bl.count);
break;
- case (LIST_hang):
+ case LIST_hang:
print_width(bln->norm->Bl.width, n->child, 6);
TPremain = 0;
break;
- case (LIST_tag):
+ case LIST_tag:
print_width(bln->norm->Bl.width, n->child, 0);
putchar('\n');
outflags &= ~MMAN_spc;
bln = n->parent->parent;
switch (n->type) {
- case (MDOC_HEAD):
+ case MDOC_HEAD:
switch (bln->norm->Bl.type) {
- case (LIST_diag):
+ case LIST_diag:
outflags &= ~MMAN_spc;
print_word("\\ ");
break;
- case (LIST_ohang):
+ case LIST_ohang:
outflags |= MMAN_br;
break;
default:
break;
}
break;
- case (MDOC_BODY):
+ case MDOC_BODY:
switch (bln->norm->Bl.type) {
- case (LIST_bullet):
+ case LIST_bullet:
/* FALLTHROUGH */
- case (LIST_dash):
+ case LIST_dash:
/* FALLTHROUGH */
- case (LIST_hyphen):
+ case LIST_hyphen:
/* FALLTHROUGH */
- case (LIST_enum):
+ case LIST_enum:
/* FALLTHROUGH */
- case (LIST_hang):
+ case LIST_hang:
/* FALLTHROUGH */
- case (LIST_tag):
+ case LIST_tag:
assert(Bl_stack_len);
Bl_stack[--Bl_stack_len] = 0;
Bl_stack_post[Bl_stack_len] = 0;
}
break;
- case (LIST_column):
+ case LIST_column:
if (NULL != n->next) {
putchar('\t');
outflags &= ~MMAN_spc;
{
switch (n->type) {
- case (MDOC_BLOCK):
+ case MDOC_BLOCK:
outflags &= ~MMAN_Bk;
break;
- case (MDOC_HEAD):
+ case MDOC_HEAD:
/* FALLTHROUGH */
- case (MDOC_ELEM):
+ case MDOC_ELEM:
font_pop();
break;
default:
if (MDOC_SYNPRETTY & n->flags) {
switch (n->type) {
- case (MDOC_BLOCK):
+ case MDOC_BLOCK:
pre_syn(n);
return(1);
- case (MDOC_BODY):
+ case MDOC_BODY:
break;
default:
return(0);
-/* $Id: mdoc_term.c,v 1.165 2014/04/08 07:13:01 schwarze Exp $ */
+/* $Id: mdoc_term.c,v 1.166 2014/04/20 16:44:44 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
#define DECL_ARGS struct termp *p, \
struct termpair *pair, \
- const struct mdoc_meta *meta, \
+ const struct mdoc_meta *meta, \
struct mdoc_node *n
struct termact {
static void print_bvspace(struct termp *,
const struct mdoc_node *,
const struct mdoc_node *);
-static void print_mdoc_node(DECL_ARGS);
+static void print_mdoc_node(DECL_ARGS);
static void print_mdoc_nodelist(DECL_ARGS);
static void print_mdoc_head(struct termp *, const void *);
static void print_mdoc_foot(struct termp *, const void *);
-static void synopsis_pre(struct termp *,
+static void synopsis_pre(struct termp *,
const struct mdoc_node *);
static void termp____post(DECL_ARGS);
{ NULL, NULL }, /* Dt */
{ NULL, NULL }, /* Os */
{ termp_sh_pre, termp_sh_post }, /* Sh */
- { termp_ss_pre, termp_ss_post }, /* Ss */
- { termp_sp_pre, NULL }, /* Pp */
+ { termp_ss_pre, termp_ss_post }, /* Ss */
+ { termp_sp_pre, NULL }, /* Pp */
{ termp_d1_pre, termp_bl_post }, /* D1 */
{ termp_d1_pre, termp_bl_post }, /* Dl */
{ termp_bd_pre, termp_bd_post }, /* Bd */
{ termp_bl_pre, termp_bl_post }, /* Bl */
{ NULL, NULL }, /* El */
{ termp_it_pre, termp_it_post }, /* It */
- { termp_under_pre, NULL }, /* Ad */
+ { termp_under_pre, NULL }, /* Ad */
{ termp_an_pre, termp_an_post }, /* An */
{ termp_under_pre, NULL }, /* Ar */
{ termp_cd_pre, NULL }, /* Cd */
{ termp_bold_pre, NULL }, /* Cm */
- { NULL, NULL }, /* Dv */
- { NULL, NULL }, /* Er */
- { NULL, NULL }, /* Ev */
+ { NULL, NULL }, /* Dv */
+ { NULL, NULL }, /* Er */
+ { NULL, NULL }, /* Ev */
{ termp_ex_pre, NULL }, /* Ex */
- { termp_fa_pre, NULL }, /* Fa */
- { termp_fd_pre, termp_fd_post }, /* Fd */
+ { termp_fa_pre, NULL }, /* Fa */
+ { termp_fd_pre, termp_fd_post }, /* Fd */
{ termp_fl_pre, NULL }, /* Fl */
- { termp_fn_pre, NULL }, /* Fn */
- { termp_ft_pre, NULL }, /* Ft */
- { termp_bold_pre, NULL }, /* Ic */
- { termp_in_pre, termp_in_post }, /* In */
+ { termp_fn_pre, NULL }, /* Fn */
+ { termp_ft_pre, NULL }, /* Ft */
+ { termp_bold_pre, NULL }, /* Ic */
+ { termp_in_pre, termp_in_post }, /* In */
{ termp_li_pre, NULL }, /* Li */
- { termp_nd_pre, NULL }, /* Nd */
- { termp_nm_pre, termp_nm_post }, /* Nm */
+ { termp_nd_pre, NULL }, /* Nd */
+ { termp_nm_pre, termp_nm_post }, /* Nm */
{ termp_quote_pre, termp_quote_post }, /* Op */
{ NULL, NULL }, /* Ot */
{ termp_under_pre, NULL }, /* Pa */
{ termp_rv_pre, NULL }, /* Rv */
- { NULL, NULL }, /* St */
+ { NULL, NULL }, /* St */
{ termp_under_pre, NULL }, /* Va */
{ termp_vt_pre, NULL }, /* Vt */
{ termp_xr_pre, NULL }, /* Xr */
{ termp_quote_pre, termp_quote_post }, /* Aq */
{ NULL, NULL }, /* At */
{ NULL, NULL }, /* Bc */
- { termp_bf_pre, NULL }, /* Bf */
+ { termp_bf_pre, NULL }, /* Bf */
{ termp_quote_pre, termp_quote_post }, /* Bo */
{ termp_quote_pre, termp_quote_post }, /* Bq */
{ termp_xx_pre, NULL }, /* Bsx */
{ termp_quote_pre, termp_quote_post }, /* Dq */
{ NULL, NULL }, /* Ec */ /* FIXME: no space */
{ NULL, NULL }, /* Ef */
- { termp_under_pre, NULL }, /* Em */
+ { termp_under_pre, NULL }, /* Em */
{ termp_quote_pre, termp_quote_post }, /* Eo */
{ termp_xx_pre, NULL }, /* Fx */
{ termp_bold_pre, NULL }, /* Ms */
{ termp_xx_pre, NULL }, /* Ux */
{ NULL, NULL }, /* Xc */
{ NULL, NULL }, /* Xo */
- { termp_fo_pre, termp_fo_post }, /* Fo */
- { NULL, NULL }, /* Fc */
+ { termp_fo_pre, termp_fo_post }, /* Fo */
+ { NULL, NULL }, /* Fc */
{ termp_quote_pre, termp_quote_post }, /* Oo */
{ NULL, NULL }, /* Oc */
{ termp_bk_pre, termp_bk_post }, /* Bk */
{ NULL, NULL }, /* Fr */
{ termp_ud_pre, NULL }, /* Ud */
{ NULL, termp_lb_post }, /* Lb */
- { termp_sp_pre, NULL }, /* Lp */
- { termp_lk_pre, NULL }, /* Lk */
- { termp_under_pre, NULL }, /* Mt */
- { termp_quote_pre, termp_quote_post }, /* Brq */
- { termp_quote_pre, termp_quote_post }, /* Bro */
- { NULL, NULL }, /* Brc */
- { NULL, termp____post }, /* %C */
+ { termp_sp_pre, NULL }, /* Lp */
+ { termp_lk_pre, NULL }, /* Lk */
+ { termp_under_pre, NULL }, /* Mt */
+ { termp_quote_pre, termp_quote_post }, /* Brq */
+ { termp_quote_pre, termp_quote_post }, /* Bro */
+ { NULL, NULL }, /* Brc */
+ { NULL, termp____post }, /* %C */
{ NULL, NULL }, /* Es */ /* TODO */
{ NULL, NULL }, /* En */ /* TODO */
- { termp_xx_pre, NULL }, /* Dx */
- { NULL, termp____post }, /* %Q */
+ { termp_xx_pre, NULL }, /* Dx */
+ { NULL, termp____post }, /* %Q */
{ termp_sp_pre, NULL }, /* br */
- { termp_sp_pre, NULL }, /* sp */
- { NULL, termp____post }, /* %U */
- { NULL, NULL }, /* Ta */
+ { termp_sp_pre, NULL }, /* sp */
+ { NULL, termp____post }, /* %U */
+ { NULL, NULL }, /* Ta */
{ termp_ll_pre, NULL }, /* ll */
};
term_end(p);
}
-
static void
print_mdoc_nodelist(DECL_ARGS)
{
print_mdoc_nodelist(p, pair, meta, n->next);
}
-
-/* ARGSUSED */
static void
print_mdoc_node(DECL_ARGS)
{
*/
switch (n->type) {
- case (MDOC_TEXT):
+ case MDOC_TEXT:
if (' ' == *n->string && MDOC_LINE & n->flags)
term_newln(p);
if (MDOC_DELIMC & n->flags)
if (MDOC_DELIMO & n->flags)
p->flags |= TERMP_NOSPACE;
break;
- case (MDOC_EQN):
+ case MDOC_EQN:
term_eqn(p, n->eqn);
break;
- case (MDOC_TBL):
+ case MDOC_TBL:
term_tbl(p, n->span);
break;
default:
(ENDBODY_NOT == n->end ? n : n->pending)->prev_font);
switch (n->type) {
- case (MDOC_TEXT):
+ case MDOC_TEXT:
break;
- case (MDOC_TBL):
+ case MDOC_TBL:
break;
- case (MDOC_EQN):
+ case MDOC_EQN:
break;
default:
if ( ! termacts[n->tok].post || MDOC_ENDED & n->flags)
}
}
-
static void
print_mdoc_foot(struct termp *p, const void *arg)
{
term_fontrepl(p, TERMFONT_NONE);
- /*
+ /*
* Output the footer in new-groff style, that is, three columns
* with the middle being the manual date and flanking columns
* being the operating system:
term_vspace(p);
p->offset = 0;
- p->rmargin = (p->maxrmargin -
- term_strlen(p, meta->date) + term_len(p, 1)) / 2;
+ p->rmargin = (p->maxrmargin -
+ term_strlen(p, meta->date) + term_len(p, 1)) / 2;
p->trailspace = 1;
p->flags |= TERMP_NOSPACE | TERMP_NOBREAK;
p->flags = 0;
}
-
static void
print_mdoc_head(struct termp *p, const void *arg)
{
p->rmargin = p->maxrmargin;
}
-
static size_t
a2height(const struct termp *p, const char *v)
{
return(term_vspan(p, &su));
}
-
static size_t
a2width(const struct termp *p, const char *v)
{
return(term_hspan(p, &su));
}
-
static size_t
a2offs(const struct termp *p, const char *v)
{
return(term_hspan(p, &su));
}
-
/*
* Determine how much space to print out before block elements of `It'
* (and thus `Bl') and `Bd'. And then go ahead and print that space,
* too.
*/
static void
-print_bvspace(struct termp *p,
- const struct mdoc_node *bl,
- const struct mdoc_node *n)
+print_bvspace(struct termp *p,
+ const struct mdoc_node *bl,
+ const struct mdoc_node *n)
{
const struct mdoc_node *nn;
}
-/* ARGSUSED */
static int
termp_ll_pre(DECL_ARGS)
{
return(0);
}
-
-/* ARGSUSED */
static int
termp_it_pre(DECL_ARGS)
{
const struct mdoc_node *bl, *nn;
- char buf[7];
- int i;
- size_t width, offset, ncols, dcol;
+ char buf[7];
+ int i;
+ size_t width, offset, ncols, dcol;
enum mdoc_list type;
if (MDOC_BLOCK == n->type) {
bl = n->parent->parent->parent;
type = bl->norm->Bl.type;
- /*
+ /*
* First calculate width and offset. This is pretty easy unless
* we're a -column list, in which case all prior columns must
* be accounted for.
offset = a2offs(p, bl->norm->Bl.offs);
switch (type) {
- case (LIST_column):
+ case LIST_column:
if (MDOC_HEAD == n->type)
break;
* - For more than 5 columns, add only one column.
*/
ncols = bl->norm->Bl.ncols;
-
- /* LINTED */
- dcol = ncols < 5 ? term_len(p, 4) :
- ncols == 5 ? term_len(p, 3) : term_len(p, 1);
+ dcol = ncols < 5 ? term_len(p, 4) :
+ ncols == 5 ? term_len(p, 3) : term_len(p, 1);
/*
* Calculate the offset by applying all prior MDOC_BODY,
* so we stop at the MDOC_HEAD (NULL == nn->prev).
*/
- for (i = 0, nn = n->prev;
- nn->prev && i < (int)ncols;
- nn = nn->prev, i++)
- offset += dcol + a2width
- (p, bl->norm->Bl.cols[i]);
+ for (i = 0, nn = n->prev;
+ nn->prev && i < (int)ncols;
+ nn = nn->prev, i++)
+ offset += dcol + a2width(p,
+ bl->norm->Bl.cols[i]);
/*
* When exceeding the declared number of columns, leave
if (NULL == bl->norm->Bl.width)
break;
- /*
+ /*
* Note: buffer the width by 2, which is groff's magic
* number for buffering single arguments. See the above
* handling for column for how this changes.
break;
}
- /*
+ /*
* List-type can override the width in the case of fixed-head
* values (bullet, dash/hyphen, enum). Tags need a non-zero
* offset.
*/
switch (type) {
- case (LIST_bullet):
+ case LIST_bullet:
/* FALLTHROUGH */
- case (LIST_dash):
+ case LIST_dash:
/* FALLTHROUGH */
- case (LIST_hyphen):
+ case LIST_hyphen:
/* FALLTHROUGH */
- case (LIST_enum):
+ case LIST_enum:
if (width < term_len(p, 2))
width = term_len(p, 2);
break;
- case (LIST_hang):
+ case LIST_hang:
if (0 == width)
width = term_len(p, 8);
break;
- case (LIST_column):
+ case LIST_column:
/* FALLTHROUGH */
- case (LIST_tag):
+ case LIST_tag:
if (0 == width)
width = term_len(p, 10);
break;
break;
}
- /*
+ /*
* Whitespace control. Inset bodies need an initial space,
* while diagonal bodies need two.
*/
p->flags |= TERMP_NOSPACE;
switch (type) {
- case (LIST_diag):
+ case LIST_diag:
if (MDOC_BODY == n->type)
term_word(p, "\\ \\ ");
break;
- case (LIST_inset):
- if (MDOC_BODY == n->type)
+ case LIST_inset:
+ if (MDOC_BODY == n->type)
term_word(p, "\\ ");
break;
default:
p->flags |= TERMP_NOSPACE;
switch (type) {
- case (LIST_diag):
+ case LIST_diag:
if (MDOC_HEAD == n->type)
term_fontpush(p, TERMFONT_BOLD);
break;
*/
switch (type) {
- case (LIST_enum):
+ case LIST_enum:
/*
* Weird special case.
* Very narrow enum lists actually hang.
if (width == term_len(p, 2))
p->flags |= TERMP_HANG;
/* FALLTHROUGH */
- case (LIST_bullet):
+ case LIST_bullet:
/* FALLTHROUGH */
- case (LIST_dash):
+ case LIST_dash:
/* FALLTHROUGH */
- case (LIST_hyphen):
+ case LIST_hyphen:
if (MDOC_HEAD != n->type)
break;
p->flags |= TERMP_NOBREAK;
p->trailspace = 1;
break;
- case (LIST_hang):
+ case LIST_hang:
if (MDOC_HEAD != n->type)
break;
* the "overstep" effect in term_flushln() and treat
* this as a `-ohang' list instead.
*/
- if (n->next->child &&
- (MDOC_Bl == n->next->child->tok ||
- MDOC_Bd == n->next->child->tok))
+ if (n->next->child &&
+ (MDOC_Bl == n->next->child->tok ||
+ MDOC_Bd == n->next->child->tok))
break;
p->flags |= TERMP_NOBREAK | TERMP_BRIND | TERMP_HANG;
p->trailspace = 1;
break;
- case (LIST_tag):
+ case LIST_tag:
if (MDOC_HEAD != n->type)
break;
if (NULL == n->next || NULL == n->next->child)
p->flags |= TERMP_DANGLE;
break;
- case (LIST_column):
+ case LIST_column:
if (MDOC_HEAD == n->type)
break;
}
break;
- case (LIST_diag):
+ case LIST_diag:
if (MDOC_HEAD != n->type)
break;
p->flags |= TERMP_NOBREAK | TERMP_BRIND;
break;
}
- /*
+ /*
* Margin control. Set-head-width lists have their right
* margins shortened. The body for these lists has the offset
* necessarily lengthened. Everybody gets the offset.
p->offset += offset;
switch (type) {
- case (LIST_hang):
+ case LIST_hang:
/*
* Same stipulation as above, regarding `-hang'. We
* don't want to recalculate rmargin and offsets when
* using `Bd' or `Bl' within `-hang' overstep lists.
*/
if (MDOC_HEAD == n->type && n->next->child &&
- (MDOC_Bl == n->next->child->tok ||
- MDOC_Bd == n->next->child->tok))
+ (MDOC_Bl == n->next->child->tok ||
+ MDOC_Bd == n->next->child->tok))
break;
/* FALLTHROUGH */
- case (LIST_bullet):
+ case LIST_bullet:
/* FALLTHROUGH */
- case (LIST_dash):
+ case LIST_dash:
/* FALLTHROUGH */
- case (LIST_enum):
+ case LIST_enum:
/* FALLTHROUGH */
- case (LIST_hyphen):
+ case LIST_hyphen:
/* FALLTHROUGH */
- case (LIST_tag):
+ case LIST_tag:
assert(width);
if (MDOC_HEAD == n->type)
p->rmargin = p->offset + width;
p->rmargin = p->offset;
}
break;
- case (LIST_column):
+ case LIST_column:
assert(width);
p->rmargin = p->offset + width;
- /*
+ /*
* XXX - this behaviour is not documented: the
* right-most column is filled to the right margin.
*/
break;
}
- /*
+ /*
* The dash, hyphen, bullet and enum lists all have a special
- * HEAD character (temporarily bold, in some cases).
+ * HEAD character (temporarily bold, in some cases).
*/
if (MDOC_HEAD == n->type)
switch (type) {
- case (LIST_bullet):
+ case LIST_bullet:
term_fontpush(p, TERMFONT_BOLD);
term_word(p, "\\[bu]");
term_fontpop(p);
break;
- case (LIST_dash):
+ case LIST_dash:
/* FALLTHROUGH */
- case (LIST_hyphen):
+ case LIST_hyphen:
term_fontpush(p, TERMFONT_BOLD);
term_word(p, "\\(hy");
term_fontpop(p);
break;
- case (LIST_enum):
+ case LIST_enum:
(pair->ppair->ppair->count)++;
- snprintf(buf, sizeof(buf), "%d.",
- pair->ppair->ppair->count);
+ snprintf(buf, sizeof(buf), "%d.",
+ pair->ppair->ppair->count);
term_word(p, buf);
break;
default:
break;
}
- /*
+ /*
* If we're not going to process our children, indicate so here.
*/
switch (type) {
- case (LIST_bullet):
+ case LIST_bullet:
/* FALLTHROUGH */
- case (LIST_item):
+ case LIST_item:
/* FALLTHROUGH */
- case (LIST_dash):
+ case LIST_dash:
/* FALLTHROUGH */
- case (LIST_hyphen):
+ case LIST_hyphen:
/* FALLTHROUGH */
- case (LIST_enum):
+ case LIST_enum:
if (MDOC_HEAD == n->type)
return(0);
break;
- case (LIST_column):
+ case LIST_column:
if (MDOC_HEAD == n->type)
return(0);
break;
return(1);
}
-
-/* ARGSUSED */
static void
termp_it_post(DECL_ARGS)
{
type = n->parent->parent->parent->norm->Bl.type;
switch (type) {
- case (LIST_item):
+ case LIST_item:
/* FALLTHROUGH */
- case (LIST_diag):
+ case LIST_diag:
/* FALLTHROUGH */
- case (LIST_inset):
+ case LIST_inset:
if (MDOC_BODY == n->type)
term_newln(p);
break;
- case (LIST_column):
+ case LIST_column:
if (MDOC_BODY == n->type)
term_flushln(p);
break;
break;
}
- /*
+ /*
* Now that our output is flushed, we can reset our tags. Since
* only `It' sets these flags, we're free to assume that nobody
* has munged them in the meanwhile.
p->trailspace = 0;
}
-
-/* ARGSUSED */
static int
termp_nm_pre(DECL_ARGS)
{
return(1);
}
-
-/* ARGSUSED */
static void
termp_nm_post(DECL_ARGS)
{
term_flushln(p);
}
-
-/* ARGSUSED */
static int
termp_fl_pre(DECL_ARGS)
{
return(1);
}
-
-/* ARGSUSED */
static int
termp__a_pre(DECL_ARGS)
{
return(1);
}
-
-/* ARGSUSED */
static int
termp_an_pre(DECL_ARGS)
{
* with other macros/text, are split. -split, in this case,
* will override the condition of the implied first -nosplit.
*/
-
+
if (n->sec == SEC_AUTHORS) {
if ( ! (TERMP_ANPREC & p->flags)) {
if (TERMP_SPLIT & p->flags)
return(1);
}
-
-/* ARGSUSED */
static void
termp_an_post(DECL_ARGS)
{
}
-
-/* ARGSUSED */
static int
termp_ns_pre(DECL_ARGS)
{
return(1);
}
-
-/* ARGSUSED */
static int
termp_rs_pre(DECL_ARGS)
{
return(1);
}
-
-/* ARGSUSED */
static int
termp_rv_pre(DECL_ARGS)
{
else
term_word(p, "function returns");
- term_word(p, "the value 0 if successful; otherwise the value "
- "-1 is returned and the global variable");
+ term_word(p, "the value 0 if successful; otherwise the "
+ "value -1 is returned and the global variable");
term_fontpush(p, TERMFONT_UNDER);
term_word(p, "errno");
term_fontpop(p);
- term_word(p, "is set to indicate the error.");
+ term_word(p, "is set to indicate the error.");
p->flags |= TERMP_SENTENCE;
return(0);
}
-
-/* ARGSUSED */
static int
termp_ex_pre(DECL_ARGS)
{
else
term_word(p, "utility exits");
- term_word(p, "0 on success, and >0 if an error occurs.");
+ term_word(p, "0 on success, and >0 if an error occurs.");
p->flags |= TERMP_SENTENCE;
return(0);
}
-
-/* ARGSUSED */
static int
termp_nd_pre(DECL_ARGS)
{
return(1);
}
-
-/* ARGSUSED */
static int
termp_bl_pre(DECL_ARGS)
{
return(MDOC_HEAD != n->type);
}
-
-/* ARGSUSED */
static void
termp_bl_post(DECL_ARGS)
{
term_newln(p);
}
-/* ARGSUSED */
static int
termp_xr_pre(DECL_ARGS)
{
assert(MDOC_TEXT == n->type);
term_word(p, n->string);
- if (NULL == (n = n->next))
+ if (NULL == (n = n->next))
return(0);
p->flags |= TERMP_NOSPACE;
static void
synopsis_pre(struct termp *p, const struct mdoc_node *n)
{
- /*
+ /*
* Obviously, if we're not in a SYNOPSIS or no prior macros
* exist, do nothing.
*/
* newline and return. UNLESS we're `Fo', `Fn', `Fn', in which
* case we soldier on.
*/
- if (n->prev->tok == n->tok &&
- MDOC_Ft != n->tok &&
- MDOC_Fo != n->tok &&
- MDOC_Fn != n->tok) {
+ if (n->prev->tok == n->tok &&
+ MDOC_Ft != n->tok &&
+ MDOC_Fo != n->tok &&
+ MDOC_Fn != n->tok) {
term_newln(p);
return;
}
* vertical space, else only newline and move on.
*/
switch (n->prev->tok) {
- case (MDOC_Fd):
+ case MDOC_Fd:
/* FALLTHROUGH */
- case (MDOC_Fn):
+ case MDOC_Fn:
/* FALLTHROUGH */
- case (MDOC_Fo):
+ case MDOC_Fo:
/* FALLTHROUGH */
- case (MDOC_In):
+ case MDOC_In:
/* FALLTHROUGH */
- case (MDOC_Vt):
+ case MDOC_Vt:
term_vspace(p);
break;
- case (MDOC_Ft):
+ case MDOC_Ft:
if (MDOC_Fn != n->tok && MDOC_Fo != n->tok) {
term_vspace(p);
break;
}
}
-
static int
termp_vt_pre(DECL_ARGS)
{
return(termp_under_pre(p, pair, meta, n));
}
-
-/* ARGSUSED */
static int
termp_bold_pre(DECL_ARGS)
{
return(1);
}
-
-/* ARGSUSED */
static int
termp_fd_pre(DECL_ARGS)
{
return(termp_bold_pre(p, pair, meta, n));
}
-
-/* ARGSUSED */
static void
termp_fd_post(DECL_ARGS)
{
term_newln(p);
}
-
-/* ARGSUSED */
static int
termp_sh_pre(DECL_ARGS)
{
/* No vspace between consecutive `Sh' calls. */
switch (n->type) {
- case (MDOC_BLOCK):
+ case MDOC_BLOCK:
if (n->prev && MDOC_Sh == n->prev->tok)
if (NULL == n->prev->body->child)
break;
term_vspace(p);
break;
- case (MDOC_HEAD):
+ case MDOC_HEAD:
term_fontpush(p, TERMFONT_BOLD);
break;
- case (MDOC_BODY):
+ case MDOC_BODY:
p->offset = term_len(p, p->defindent);
if (SEC_AUTHORS == n->sec)
p->flags &= ~(TERMP_SPLIT|TERMP_NOSPLIT);
return(1);
}
-
-/* ARGSUSED */
static void
termp_sh_post(DECL_ARGS)
{
switch (n->type) {
- case (MDOC_HEAD):
+ case MDOC_HEAD:
term_newln(p);
break;
- case (MDOC_BODY):
+ case MDOC_BODY:
term_newln(p);
p->offset = 0;
break;
}
}
-
-/* ARGSUSED */
static int
termp_bt_pre(DECL_ARGS)
{
return(0);
}
-
-/* ARGSUSED */
static void
termp_lb_post(DECL_ARGS)
{
term_newln(p);
}
-
-/* ARGSUSED */
static int
termp_ud_pre(DECL_ARGS)
{
return(0);
}
-
-/* ARGSUSED */
static int
termp_d1_pre(DECL_ARGS)
{
return(1);
}
-
-/* ARGSUSED */
static int
termp_ft_pre(DECL_ARGS)
{
return(1);
}
-
-/* ARGSUSED */
static int
termp_fn_pre(DECL_ARGS)
{
return(0);
}
-
-/* ARGSUSED */
static int
termp_fa_pre(DECL_ARGS)
{
return(0);
}
-
-/* ARGSUSED */
static int
termp_bd_pre(DECL_ARGS)
{
* for macro lines, a newline is appended to the line. Blank
* lines are allowed.
*/
-
- if (DISP_literal != n->norm->Bd.type &&
- DISP_unfilled != n->norm->Bd.type)
+
+ if (DISP_literal != n->norm->Bd.type &&
+ DISP_unfilled != n->norm->Bd.type)
return(1);
tabwidth = p->tabwidth;
* anyway, so don't sweat it.
*/
switch (nn->tok) {
- case (MDOC_Sm):
+ case MDOC_Sm:
/* FALLTHROUGH */
- case (MDOC_br):
+ case MDOC_br:
/* FALLTHROUGH */
- case (MDOC_sp):
+ case MDOC_sp:
/* FALLTHROUGH */
- case (MDOC_Bl):
+ case MDOC_Bl:
/* FALLTHROUGH */
- case (MDOC_D1):
+ case MDOC_D1:
/* FALLTHROUGH */
- case (MDOC_Dl):
+ case MDOC_Dl:
/* FALLTHROUGH */
- case (MDOC_Lp):
+ case MDOC_Lp:
/* FALLTHROUGH */
- case (MDOC_Pp):
+ case MDOC_Pp:
continue;
default:
break;
return(0);
}
-
-/* ARGSUSED */
static void
termp_bd_post(DECL_ARGS)
{
size_t rm, rmax;
- if (MDOC_BODY != n->type)
+ if (MDOC_BODY != n->type)
return;
rm = p->rmargin;
rmax = p->maxrmargin;
- if (DISP_literal == n->norm->Bd.type ||
- DISP_unfilled == n->norm->Bd.type)
+ if (DISP_literal == n->norm->Bd.type ||
+ DISP_unfilled == n->norm->Bd.type)
p->rmargin = p->maxrmargin = TERM_MAXMARGIN;
p->flags |= TERMP_NOSPACE;
p->maxrmargin = rmax;
}
-
-/* ARGSUSED */
static int
termp_bx_pre(DECL_ARGS)
{
return(0);
}
-
-/* ARGSUSED */
static int
termp_xx_pre(DECL_ARGS)
{
pp = NULL;
switch (n->tok) {
- case (MDOC_Bsx):
+ case MDOC_Bsx:
pp = "BSD/OS";
break;
- case (MDOC_Dx):
+ case MDOC_Dx:
pp = "DragonFly";
break;
- case (MDOC_Fx):
+ case MDOC_Fx:
pp = "FreeBSD";
break;
- case (MDOC_Nx):
+ case MDOC_Nx:
pp = "NetBSD";
break;
- case (MDOC_Ox):
+ case MDOC_Ox:
pp = "OpenBSD";
break;
- case (MDOC_Ux):
+ case MDOC_Ux:
pp = "UNIX";
break;
default:
return(0);
}
-
-/* ARGSUSED */
static void
termp_pf_post(DECL_ARGS)
{
p->flags |= TERMP_NOSPACE;
}
-
-/* ARGSUSED */
static int
termp_ss_pre(DECL_ARGS)
{
switch (n->type) {
- case (MDOC_BLOCK):
+ case MDOC_BLOCK:
term_newln(p);
if (n->prev)
term_vspace(p);
break;
- case (MDOC_HEAD):
+ case MDOC_HEAD:
term_fontpush(p, TERMFONT_BOLD);
p->offset = term_len(p, (p->defindent+1)/2);
break;
return(1);
}
-
-/* ARGSUSED */
static void
termp_ss_post(DECL_ARGS)
{
term_newln(p);
}
-
-/* ARGSUSED */
static int
termp_cd_pre(DECL_ARGS)
{
return(1);
}
-
-/* ARGSUSED */
static int
termp_in_pre(DECL_ARGS)
{
return(1);
}
-
-/* ARGSUSED */
static void
termp_in_post(DECL_ARGS)
{
term_fontpop(p);
}
-
-/* ARGSUSED */
static int
termp_sp_pre(DECL_ARGS)
{
size_t i, len;
switch (n->tok) {
- case (MDOC_sp):
+ case MDOC_sp:
len = n->child ? a2height(p, n->child->string) : 1;
break;
- case (MDOC_br):
+ case MDOC_br:
len = 0;
break;
default:
return(0);
}
-
-/* ARGSUSED */
static int
termp_quote_pre(DECL_ARGS)
{
return(1);
switch (n->tok) {
- case (MDOC_Ao):
+ case MDOC_Ao:
/* FALLTHROUGH */
- case (MDOC_Aq):
+ case MDOC_Aq:
term_word(p, "<");
break;
- case (MDOC_Bro):
+ case MDOC_Bro:
/* FALLTHROUGH */
- case (MDOC_Brq):
+ case MDOC_Brq:
term_word(p, "{");
break;
- case (MDOC_Oo):
+ case MDOC_Oo:
/* FALLTHROUGH */
- case (MDOC_Op):
+ case MDOC_Op:
/* FALLTHROUGH */
- case (MDOC_Bo):
+ case MDOC_Bo:
/* FALLTHROUGH */
- case (MDOC_Bq):
+ case MDOC_Bq:
term_word(p, "[");
break;
- case (MDOC_Do):
+ case MDOC_Do:
/* FALLTHROUGH */
- case (MDOC_Dq):
+ case MDOC_Dq:
term_word(p, "\\(lq");
break;
- case (MDOC_Eo):
+ case MDOC_Eo:
break;
- case (MDOC_Po):
+ case MDOC_Po:
/* FALLTHROUGH */
- case (MDOC_Pq):
+ case MDOC_Pq:
term_word(p, "(");
break;
- case (MDOC__T):
+ case MDOC__T:
/* FALLTHROUGH */
- case (MDOC_Qo):
+ case MDOC_Qo:
/* FALLTHROUGH */
- case (MDOC_Qq):
+ case MDOC_Qq:
term_word(p, "\"");
break;
- case (MDOC_Ql):
+ case MDOC_Ql:
/* FALLTHROUGH */
- case (MDOC_So):
+ case MDOC_So:
/* FALLTHROUGH */
- case (MDOC_Sq):
+ case MDOC_Sq:
term_word(p, "\\(oq");
break;
default:
return(1);
}
-
-/* ARGSUSED */
static void
termp_quote_post(DECL_ARGS)
{
p->flags |= TERMP_NOSPACE;
switch (n->tok) {
- case (MDOC_Ao):
+ case MDOC_Ao:
/* FALLTHROUGH */
- case (MDOC_Aq):
+ case MDOC_Aq:
term_word(p, ">");
break;
- case (MDOC_Bro):
+ case MDOC_Bro:
/* FALLTHROUGH */
- case (MDOC_Brq):
+ case MDOC_Brq:
term_word(p, "}");
break;
- case (MDOC_Oo):
+ case MDOC_Oo:
/* FALLTHROUGH */
- case (MDOC_Op):
+ case MDOC_Op:
/* FALLTHROUGH */
- case (MDOC_Bo):
+ case MDOC_Bo:
/* FALLTHROUGH */
- case (MDOC_Bq):
+ case MDOC_Bq:
term_word(p, "]");
break;
- case (MDOC_Do):
+ case MDOC_Do:
/* FALLTHROUGH */
- case (MDOC_Dq):
+ case MDOC_Dq:
term_word(p, "\\(rq");
break;
- case (MDOC_Eo):
+ case MDOC_Eo:
break;
- case (MDOC_Po):
+ case MDOC_Po:
/* FALLTHROUGH */
- case (MDOC_Pq):
+ case MDOC_Pq:
term_word(p, ")");
break;
- case (MDOC__T):
+ case MDOC__T:
/* FALLTHROUGH */
- case (MDOC_Qo):
+ case MDOC_Qo:
/* FALLTHROUGH */
- case (MDOC_Qq):
+ case MDOC_Qq:
term_word(p, "\"");
break;
- case (MDOC_Ql):
+ case MDOC_Ql:
/* FALLTHROUGH */
- case (MDOC_So):
+ case MDOC_So:
/* FALLTHROUGH */
- case (MDOC_Sq):
+ case MDOC_Sq:
term_word(p, "\\(cq");
break;
default:
}
}
-
-/* ARGSUSED */
static int
termp_fo_pre(DECL_ARGS)
{
return(0);
}
-
-/* ARGSUSED */
static void
termp_fo_post(DECL_ARGS)
{
- if (MDOC_BODY != n->type)
+ if (MDOC_BODY != n->type)
return;
p->flags |= TERMP_NOSPACE;
}
}
-
-/* ARGSUSED */
static int
termp_bf_pre(DECL_ARGS)
{
else if (MDOC_BODY != n->type)
return(1);
- if (FONT_Em == n->norm->Bf.font)
+ if (FONT_Em == n->norm->Bf.font)
term_fontpush(p, TERMFONT_UNDER);
- else if (FONT_Sy == n->norm->Bf.font)
+ else if (FONT_Sy == n->norm->Bf.font)
term_fontpush(p, TERMFONT_BOLD);
- else
+ else
term_fontpush(p, TERMFONT_NONE);
return(1);
}
-
-/* ARGSUSED */
static int
termp_sm_pre(DECL_ARGS)
{
return(0);
}
-
-/* ARGSUSED */
static int
termp_ap_pre(DECL_ARGS)
{
return(1);
}
-
-/* ARGSUSED */
static void
termp____post(DECL_ARGS)
{
term_word(p, ",");
}
-
-/* ARGSUSED */
static int
termp_li_pre(DECL_ARGS)
{
return(1);
}
-
-/* ARGSUSED */
static int
termp_lk_pre(DECL_ARGS)
{
return(0);
}
-
-/* ARGSUSED */
static int
termp_bk_pre(DECL_ARGS)
{
switch (n->type) {
- case (MDOC_BLOCK):
+ case MDOC_BLOCK:
break;
- case (MDOC_HEAD):
+ case MDOC_HEAD:
return(0);
- case (MDOC_BODY):
+ case MDOC_BODY:
if (n->parent->args || 0 == n->prev->nchild)
p->flags |= TERMP_PREKEEP;
break;
return(1);
}
-
-/* ARGSUSED */
static void
termp_bk_post(DECL_ARGS)
{
p->flags &= ~(TERMP_KEEP | TERMP_PREKEEP);
}
-/* ARGSUSED */
static void
termp__t_post(DECL_ARGS)
{
* us instead of underlining us (for disambiguation).
*/
if (n->parent && MDOC_Rs == n->parent->tok &&
- n->parent->norm->Rs.quote_T)
+ n->parent->norm->Rs.quote_T)
termp_quote_post(p, pair, meta, n);
termp____post(p, pair, meta, n);
}
-/* ARGSUSED */
static int
termp__t_pre(DECL_ARGS)
{
* us instead of underlining us (for disambiguation).
*/
if (n->parent && MDOC_Rs == n->parent->tok &&
- n->parent->norm->Rs.quote_T)
+ n->parent->norm->Rs.quote_T)
return(termp_quote_pre(p, pair, meta, n));
term_fontpush(p, TERMFONT_UNDER);
return(1);
}
-/* ARGSUSED */
static int
termp_under_pre(DECL_ARGS)
{
-/* $Id: mdoc_validate.c,v 1.127 2014/04/15 00:41:02 schwarze Exp $ */
+/* $Id: mdoc_validate.c,v 1.128 2014/04/20 16:44:44 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
v_post *post;
};
-static int check_count(struct mdoc *, enum mdoc_type,
+static int check_count(struct mdoc *, enum mdoc_type,
enum check_lvl, enum check_ineq, int);
static int check_parent(PRE_ARGS, enum mdoct, enum mdoc_type);
static void check_text(struct mdoc *, int, int, char *);
-static void check_argv(struct mdoc *,
+static void check_argv(struct mdoc *,
struct mdoc_node *, struct mdoc_argv *);
static void check_args(struct mdoc *, struct mdoc_node *);
static enum mdoc_sec a2sec(const char *);
{ pres_dd, posts_dd }, /* Dd */
{ pres_dt, posts_dt }, /* Dt */
{ pres_os, posts_os }, /* Os */
- { pres_sh, posts_sh }, /* Sh */
- { pres_ss, posts_ss }, /* Ss */
- { pres_pp, posts_pp }, /* Pp */
+ { pres_sh, posts_sh }, /* Sh */
+ { pres_ss, posts_ss }, /* Ss */
+ { pres_pp, posts_pp }, /* Pp */
{ pres_d1, posts_d1 }, /* D1 */
{ pres_dl, posts_dl }, /* Dl */
{ pres_bd, posts_bd }, /* Bd */
{ NULL, NULL }, /* Ed */
- { pres_bl, posts_bl }, /* Bl */
+ { pres_bl, posts_bl }, /* Bl */
{ NULL, NULL }, /* El */
{ pres_it, posts_it }, /* It */
- { NULL, NULL }, /* Ad */
- { pres_an, posts_an }, /* An */
+ { NULL, NULL }, /* Ad */
+ { pres_an, posts_an }, /* An */
{ NULL, posts_defaults }, /* Ar */
- { NULL, NULL }, /* Cd */
+ { NULL, NULL }, /* Cd */
{ NULL, NULL }, /* Cm */
- { NULL, NULL }, /* Dv */
- { NULL, NULL }, /* Er */
- { NULL, NULL }, /* Ev */
- { pres_std, posts_std }, /* Ex */
- { NULL, NULL }, /* Fa */
+ { NULL, NULL }, /* Dv */
+ { NULL, NULL }, /* Er */
+ { NULL, NULL }, /* Ev */
+ { pres_std, posts_std }, /* Ex */
+ { NULL, NULL }, /* Fa */
{ NULL, posts_text }, /* Fd */
{ NULL, NULL }, /* Fl */
- { NULL, NULL }, /* Fn */
- { NULL, NULL }, /* Ft */
- { NULL, NULL }, /* Ic */
- { NULL, posts_text1 }, /* In */
+ { NULL, NULL }, /* Fn */
+ { NULL, NULL }, /* Ft */
+ { NULL, NULL }, /* Ic */
+ { NULL, posts_text1 }, /* In */
{ NULL, posts_defaults }, /* Li */
{ NULL, posts_nd }, /* Nd */
{ NULL, posts_nm }, /* Nm */
{ NULL, NULL }, /* Ot */
{ NULL, posts_defaults }, /* Pa */
{ pres_std, posts_std }, /* Rv */
- { NULL, posts_st }, /* St */
+ { NULL, posts_st }, /* St */
{ NULL, NULL }, /* Va */
- { NULL, posts_vt }, /* Vt */
- { NULL, posts_text }, /* Xr */
+ { NULL, posts_vt }, /* Vt */
+ { NULL, posts_text }, /* Xr */
{ NULL, posts_text }, /* %A */
{ NULL, posts_hyphtext }, /* %B */ /* FIXME: can be used outside Rs/Re. */
{ NULL, posts_text }, /* %D */
{ NULL, NULL }, /* Ac */
{ NULL, NULL }, /* Ao */
{ NULL, NULL }, /* Aq */
- { NULL, posts_at }, /* At */
+ { NULL, posts_at }, /* At */
{ NULL, NULL }, /* Bc */
{ NULL, posts_bf }, /* Bf */
{ NULL, NULL }, /* Bo */
{ NULL, NULL }, /* Do */
{ NULL, NULL }, /* Dq */
{ NULL, NULL }, /* Ec */
- { NULL, NULL }, /* Ef */
- { NULL, NULL }, /* Em */
+ { NULL, NULL }, /* Ef */
+ { NULL, NULL }, /* Em */
{ NULL, NULL }, /* Eo */
{ NULL, NULL }, /* Fx */
- { NULL, NULL }, /* Ms */
+ { NULL, NULL }, /* Ms */
{ NULL, posts_notext }, /* No */
{ NULL, posts_ns }, /* Ns */
{ NULL, NULL }, /* Nx */
{ NULL, NULL }, /* Sc */
{ NULL, NULL }, /* So */
{ NULL, NULL }, /* Sq */
- { NULL, posts_bool }, /* Sm */
+ { NULL, posts_bool }, /* Sm */
{ NULL, posts_hyph }, /* Sx */
{ NULL, NULL }, /* Sy */
{ NULL, NULL }, /* Tn */
{ NULL, NULL }, /* Ux */
{ NULL, NULL }, /* Xc */
{ NULL, NULL }, /* Xo */
- { NULL, posts_fo }, /* Fo */
- { NULL, NULL }, /* Fc */
+ { NULL, posts_fo }, /* Fo */
+ { NULL, NULL }, /* Fc */
{ NULL, NULL }, /* Oo */
{ NULL, NULL }, /* Oc */
{ NULL, posts_bk }, /* Bk */
{ NULL, NULL }, /* Fr */
{ NULL, posts_eoln }, /* Ud */
{ NULL, posts_lb }, /* Lb */
- { pres_pp, posts_pp }, /* Lp */
- { NULL, NULL }, /* Lk */
- { NULL, posts_defaults }, /* Mt */
- { NULL, NULL }, /* Brq */
- { NULL, NULL }, /* Bro */
- { NULL, NULL }, /* Brc */
+ { pres_pp, posts_pp }, /* Lp */
+ { NULL, NULL }, /* Lk */
+ { NULL, posts_defaults }, /* Mt */
+ { NULL, NULL }, /* Brq */
+ { NULL, NULL }, /* Bro */
+ { NULL, NULL }, /* Brc */
{ NULL, posts_text }, /* %C */
{ NULL, NULL }, /* Es */
{ NULL, NULL }, /* En */
NULL
};
+
int
mdoc_valid_pre(struct mdoc *mdoc, struct mdoc_node *n)
{
char *tp;
switch (n->type) {
- case (MDOC_TEXT):
+ case MDOC_TEXT:
tp = n->string;
line = n->line;
pos = n->pos;
check_text(mdoc, line, pos, tp);
/* FALLTHROUGH */
- case (MDOC_TBL):
+ case MDOC_TBL:
/* FALLTHROUGH */
- case (MDOC_EQN):
+ case MDOC_EQN:
/* FALLTHROUGH */
- case (MDOC_ROOT):
+ case MDOC_ROOT:
return(1);
default:
break;
if (NULL == mdoc_valids[n->tok].pre)
return(1);
for (p = mdoc_valids[n->tok].pre; *p; p++)
- if ( ! (*p)(mdoc, n))
+ if ( ! (*p)(mdoc, n))
return(0);
return(1);
}
-
int
mdoc_valid_post(struct mdoc *mdoc)
{
mdoc->last->flags |= MDOC_VALID;
switch (mdoc->last->type) {
- case (MDOC_TEXT):
+ case MDOC_TEXT:
/* FALLTHROUGH */
- case (MDOC_EQN):
+ case MDOC_EQN:
/* FALLTHROUGH */
- case (MDOC_TBL):
+ case MDOC_TBL:
return(1);
- case (MDOC_ROOT):
+ case MDOC_ROOT:
return(post_root(mdoc));
default:
break;
if (NULL == mdoc_valids[mdoc->last->tok].post)
return(1);
for (p = mdoc_valids[mdoc->last->tok].post; *p; p++)
- if ( ! (*p)(mdoc))
+ if ( ! (*p)(mdoc))
return(0);
return(1);
}
static int
-check_count(struct mdoc *mdoc, enum mdoc_type type,
+check_count(struct mdoc *mdoc, enum mdoc_type type,
enum check_lvl lvl, enum check_ineq ineq, int val)
{
const char *p;
if (mdoc->last->type != type)
return(1);
-
+
switch (ineq) {
- case (CHECK_LT):
+ case CHECK_LT:
p = "less than ";
if (mdoc->last->nchild < val)
return(1);
break;
- case (CHECK_GT):
+ case CHECK_GT:
p = "more than ";
if (mdoc->last->nchild > val)
return(1);
break;
- case (CHECK_EQ):
+ case CHECK_EQ:
p = "";
if (val == mdoc->last->nchild)
return(1);
}
t = lvl == CHECK_WARN ? MANDOCERR_ARGCWARN : MANDOCERR_ARGCOUNT;
- mandoc_vmsg(t, mdoc->parse, mdoc->last->line, mdoc->last->pos,
- "want %s%d children (have %d)",
- p, val, mdoc->last->nchild);
+ mandoc_vmsg(t, mdoc->parse, mdoc->last->line,
+ mdoc->last->pos, "want %s%d children (have %d)",
+ p, val, mdoc->last->nchild);
return(1);
}
(t == n->parent->type))
return(1);
- mandoc_vmsg(MANDOCERR_SYNTCHILD, mdoc->parse, n->line,
- n->pos, "want parent %s", MDOC_ROOT == t ?
- "<root>" : mdoc_macronames[tok]);
+ mandoc_vmsg(MANDOCERR_SYNTCHILD, mdoc->parse,
+ n->line, n->pos, "want parent %s",
+ MDOC_ROOT == t ? "<root>" : mdoc_macronames[tok]);
return(0);
}
if (MDOC_BLOCK != n->type)
return(1);
- for (node = mdoc->last->parent; node; node = node->parent)
+ for (node = mdoc->last->parent; node; node = node->parent)
if (MDOC_BLOCK == node->type)
if (MDOC_Bd == node->tok)
break;
return(1);
}
-
static int
pre_bl(PRE_ARGS)
{
return(1);
}
- /*
+ /*
* First figure out which kind of list to use: bind ourselves to
* the first mentioned list type and warn about any remaining
* ones. If we find no list type, we default to LIST_item.
*/
- /* LINTED */
for (i = 0; n->args && i < (int)n->args->argc; i++) {
lt = LIST__NONE;
dup = comp = 0;
width = offs = NULL;
switch (n->args->argv[i].arg) {
/* Set list types. */
- case (MDOC_Bullet):
+ case MDOC_Bullet:
lt = LIST_bullet;
break;
- case (MDOC_Dash):
+ case MDOC_Dash:
lt = LIST_dash;
break;
- case (MDOC_Enum):
+ case MDOC_Enum:
lt = LIST_enum;
break;
- case (MDOC_Hyphen):
+ case MDOC_Hyphen:
lt = LIST_hyphen;
break;
- case (MDOC_Item):
+ case MDOC_Item:
lt = LIST_item;
break;
- case (MDOC_Tag):
+ case MDOC_Tag:
lt = LIST_tag;
break;
- case (MDOC_Diag):
+ case MDOC_Diag:
lt = LIST_diag;
break;
- case (MDOC_Hang):
+ case MDOC_Hang:
lt = LIST_hang;
break;
- case (MDOC_Ohang):
+ case MDOC_Ohang:
lt = LIST_ohang;
break;
- case (MDOC_Inset):
+ case MDOC_Inset:
lt = LIST_inset;
break;
- case (MDOC_Column):
+ case MDOC_Column:
lt = LIST_column;
break;
/* Set list arguments. */
- case (MDOC_Compact):
+ case MDOC_Compact:
dup = n->norm->Bl.comp;
comp = 1;
break;
- case (MDOC_Width):
+ case MDOC_Width:
/* NB: this can be empty! */
if (n->args->argv[i].sz) {
width = n->args->argv[i].value[0];
}
mdoc_nmsg(mdoc, n, MANDOCERR_IGNARGV);
break;
- case (MDOC_Offset):
+ case MDOC_Offset:
/* NB: this can be empty! */
if (n->args->argv[i].sz) {
offs = n->args->argv[i].value[0];
n->norm->Bl.type = lt;
/* Set column information, too. */
if (LIST_column == lt) {
- n->norm->Bl.ncols =
- n->args->argv[i].sz;
+ n->norm->Bl.ncols =
+ n->args->argv[i].sz;
n->norm->Bl.cols = (void *)
- n->args->argv[i].value;
+ n->args->argv[i].value;
}
}
/* The list type should come first. */
if (n->norm->Bl.type == LIST__NONE)
- if (n->norm->Bl.width ||
- n->norm->Bl.offs ||
- n->norm->Bl.comp)
+ if (n->norm->Bl.width ||
+ n->norm->Bl.offs ||
+ n->norm->Bl.comp)
mdoc_nmsg(mdoc, n, MANDOCERR_LISTFIRST);
continue;
n->norm->Bl.type = LIST_item;
}
- /*
+ /*
* Validate the width field. Some list types don't need width
* types and should be warned about them. Others should have it
* and must also be warned. Yet others have a default and need
*/
switch (n->norm->Bl.type) {
- case (LIST_tag):
+ case LIST_tag:
if (NULL == n->norm->Bl.width)
mdoc_nmsg(mdoc, n, MANDOCERR_NOWIDTHARG);
break;
- case (LIST_column):
+ case LIST_column:
/* FALLTHROUGH */
- case (LIST_diag):
+ case LIST_diag:
/* FALLTHROUGH */
- case (LIST_ohang):
+ case LIST_ohang:
/* FALLTHROUGH */
- case (LIST_inset):
+ case LIST_inset:
/* FALLTHROUGH */
- case (LIST_item):
+ case LIST_item:
if (n->norm->Bl.width)
mdoc_nmsg(mdoc, n, MANDOCERR_IGNARGV);
break;
- case (LIST_bullet):
+ case LIST_bullet:
/* FALLTHROUGH */
- case (LIST_dash):
+ case LIST_dash:
/* FALLTHROUGH */
- case (LIST_hyphen):
+ case LIST_hyphen:
if (NULL == n->norm->Bl.width)
n->norm->Bl.width = "2n";
break;
- case (LIST_enum):
+ case LIST_enum:
if (NULL == n->norm->Bl.width)
n->norm->Bl.width = "3n";
break;
return(1);
}
-
static int
pre_bd(PRE_ARGS)
{
int i, dup, comp;
- enum mdoc_disp dt;
+ enum mdoc_disp dt;
const char *offs;
struct mdoc_node *np;
return(1);
}
- /* LINTED */
for (i = 0; n->args && i < (int)n->args->argc; i++) {
dt = DISP__NONE;
dup = comp = 0;
offs = NULL;
switch (n->args->argv[i].arg) {
- case (MDOC_Centred):
+ case MDOC_Centred:
dt = DISP_centred;
break;
- case (MDOC_Ragged):
+ case MDOC_Ragged:
dt = DISP_ragged;
break;
- case (MDOC_Unfilled):
+ case MDOC_Unfilled:
dt = DISP_unfilled;
break;
- case (MDOC_Filled):
+ case MDOC_Filled:
dt = DISP_filled;
break;
- case (MDOC_Literal):
+ case MDOC_Literal:
dt = DISP_literal;
break;
- case (MDOC_File):
+ case MDOC_File:
mdoc_nmsg(mdoc, n, MANDOCERR_BADDISP);
return(0);
- case (MDOC_Offset):
+ case MDOC_Offset:
/* NB: this can be empty! */
if (n->args->argv[i].sz) {
offs = n->args->argv[i].value[0];
}
mdoc_nmsg(mdoc, n, MANDOCERR_IGNARGV);
break;
- case (MDOC_Compact):
+ case MDOC_Compact:
comp = 1;
dup = n->norm->Bd.comp;
break;
return(1);
}
-
static int
pre_ss(PRE_ARGS)
{
return(check_parent(mdoc, n, MDOC_Sh, MDOC_BODY));
}
-
static int
pre_sh(PRE_ARGS)
{
return(check_parent(mdoc, n, MDOC_MAX, MDOC_ROOT));
}
-
static int
pre_it(PRE_ARGS)
{
return(check_parent(mdoc, n, MDOC_Bl, MDOC_BODY));
}
-
static int
pre_an(PRE_ARGS)
{
if (NULL == n->args)
return(1);
-
+
for (i = 1; i < (int)n->args->argc; i++)
- mdoc_pmsg(mdoc, n->args->argv[i].line,
- n->args->argv[i].pos, MANDOCERR_IGNARGV);
+ mdoc_pmsg(mdoc, n->args->argv[i].line,
+ n->args->argv[i].pos, MANDOCERR_IGNARGV);
if (MDOC_Split == n->args->argv[0].arg)
n->norm->An.auth = AUTH_split;
return(1);
}
-
static int
post_bf(POST_ARGS)
{
np = mdoc->last->pending->parent->head;
} else if (MDOC_BLOCK != mdoc->last->type) {
np = mdoc->last->parent->head;
- } else
+ } else
np = mdoc->last->head;
assert(np);
assert(MDOC_BLOCK == np->parent->type);
assert(MDOC_Bf == np->parent->tok);
- /*
+ /*
* Cannot have both argument and parameter.
- * If neither is specified, let it through with a warning.
+ * If neither is specified, let it through with a warning.
*/
if (np->parent->args && np->child) {
}
/* Extract argument into data. */
-
+
if (np->parent->args) {
arg = np->parent->args->argv[0].arg;
if (MDOC_Emphasis == arg)
np->norm->Bf.font = FONT_Li;
else if (0 == strcmp(np->child->string, "Sy"))
np->norm->Bf.font = FONT_Sy;
- else
+ else
mdoc_nmsg(mdoc, np, MANDOCERR_FONTTYPE);
return(1);
/* If not, use "library ``xxxx''. */
- sz = strlen(mdoc->last->child->string) +
- 2 + strlen("\\(lqlibrary\\(rq");
+ sz = strlen(mdoc->last->child->string) + 2 +
+ strlen("\\(lqlibrary\\(rq");
buf = mandoc_malloc(sz);
- snprintf(buf, sz, "library \\(lq%s\\(rq",
- mdoc->last->child->string);
+ snprintf(buf, sz, "library \\(lq%s\\(rq",
+ mdoc->last->child->string);
free(mdoc->last->child->string);
mdoc->last->child->string = buf;
return(1);
return(1);
}
-
static int
post_vt(POST_ARGS)
{
if (MDOC_BODY != mdoc->last->type)
return(1);
-
+
for (n = mdoc->last->child; n; n = n->next)
- if (MDOC_TEXT != n->type)
+ if (MDOC_TEXT != n->type)
mdoc_nmsg(mdoc, n, MANDOCERR_CHILD);
return(1);
}
-
static int
post_nm(POST_ARGS)
{
static int
post_literal(POST_ARGS)
{
-
+
/*
* The `Dl' (note "el" not "one") and `Bd' macros unset the
* MDOC_LITERAL flag as they leave. Note that `Bd' only sets
if (mdoc->last->child)
return(1);
-
+
nn = mdoc->last;
mdoc->next = MDOC_NEXT_CHILD;
switch (nn->tok) {
- case (MDOC_Ar):
+ case MDOC_Ar:
if ( ! mdoc_word_alloc(mdoc, nn->line, nn->pos, "file"))
return(0);
if ( ! mdoc_word_alloc(mdoc, nn->line, nn->pos, "..."))
return(0);
break;
- case (MDOC_At):
+ case MDOC_At:
if ( ! mdoc_word_alloc(mdoc, nn->line, nn->pos, "AT&T"))
return(0);
if ( ! mdoc_word_alloc(mdoc, nn->line, nn->pos, "UNIX"))
return(0);
break;
- case (MDOC_Li):
+ case MDOC_Li:
if ( ! mdoc_word_alloc(mdoc, nn->line, nn->pos, ""))
return(0);
break;
- case (MDOC_Pa):
+ case MDOC_Pa:
/* FALLTHROUGH */
- case (MDOC_Mt):
+ case MDOC_Mt:
if ( ! mdoc_word_alloc(mdoc, nn->line, nn->pos, "~"))
return(0);
break;
default:
abort();
/* NOTREACHED */
- }
+ }
mdoc->last = nn;
return(1);
* key exist, use that instead of the child; if it doesn't,
* prefix "AT&T UNIX " to the existing data.
*/
-
+
if (NULL == mdoc->last->child)
return(1);
return(1);
}
-
static int
post_it(POST_ARGS)
{
}
switch (lt) {
- case (LIST_tag):
+ case LIST_tag:
if (mdoc->last->head->child)
break;
/* FIXME: give this a dummy value. */
mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_NOARGS);
break;
- case (LIST_hang):
+ case LIST_hang:
/* FALLTHROUGH */
- case (LIST_ohang):
+ case LIST_ohang:
/* FALLTHROUGH */
- case (LIST_inset):
+ case LIST_inset:
/* FALLTHROUGH */
- case (LIST_diag):
+ case LIST_diag:
if (NULL == mdoc->last->head->child)
mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_NOARGS);
break;
- case (LIST_bullet):
+ case LIST_bullet:
/* FALLTHROUGH */
- case (LIST_dash):
+ case LIST_dash:
/* FALLTHROUGH */
- case (LIST_enum):
+ case LIST_enum:
/* FALLTHROUGH */
- case (LIST_hyphen):
+ case LIST_hyphen:
if (NULL == mdoc->last->body->child)
mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_NOBODY);
/* FALLTHROUGH */
- case (LIST_item):
+ case LIST_item:
if (mdoc->last->head->child)
mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_ARGSLOST);
break;
- case (LIST_column):
+ case LIST_column:
cols = (int)n->norm->Bl.ncols;
assert(NULL == mdoc->last->head->child);
else
er = MANDOCERR_SYNTARGCOUNT;
- mandoc_vmsg(er, mdoc->parse, mdoc->last->line,
- mdoc->last->pos,
- "columns == %d (have %d)", cols, i);
+ mandoc_vmsg(er, mdoc->parse,
+ mdoc->last->line, mdoc->last->pos,
+ "columns == %d (have %d)", cols, i);
return(MANDOCERR_ARGCOUNT == er);
default:
break;
}
static int
-post_bl_block(POST_ARGS)
+post_bl_block(POST_ARGS)
{
struct mdoc_node *n, *ni, *nc;
n = mdoc->last;
- if (LIST_tag == n->norm->Bl.type &&
- NULL == n->norm->Bl.width) {
+ if (LIST_tag == n->norm->Bl.type &&
+ NULL == n->norm->Bl.width) {
if ( ! post_bl_block_tag(mdoc))
return(0);
assert(n->norm->Bl.width);
nc = ni->body->last;
while (NULL != nc) {
switch (nc->tok) {
- case (MDOC_Pp):
+ case MDOC_Pp:
/* FALLTHROUGH */
- case (MDOC_Lp):
+ case MDOC_Lp:
/* FALLTHROUGH */
- case (MDOC_br):
+ case MDOC_br:
break;
default:
nc = NULL;
assert(n->args);
- for (i = 0; i < (int)n->args->argc; i++)
+ for (i = 0; i < (int)n->args->argc; i++)
if (MDOC_Width == n->args->argv[i].arg)
break;
sz = ssz;
break;
- }
+ }
/* Defaults to ten ens. */
assert(n->args);
i = (int)(n->args->argc)++;
- n->args->argv = mandoc_realloc(n->args->argv,
- n->args->argc * sizeof(struct mdoc_argv));
+ n->args->argv = mandoc_realloc(n->args->argv,
+ n->args->argc * sizeof(struct mdoc_argv));
n->args->argv[i].arg = MDOC_Width;
n->args->argv[i].line = n->line;
return(1);
}
-
static int
-post_bl_head(POST_ARGS)
+post_bl_head(POST_ARGS)
{
struct mdoc_node *np, *nn, *nnp;
int i, j;
/* First, disallow both types and allow normal-form. */
- /*
+ /*
* TODO: technically, we can accept both and just merge the two
* lists, but I'll leave that for another day.
*/
np = mdoc->last->parent;
assert(np->args);
- for (j = 0; j < (int)np->args->argc; j++)
+ for (j = 0; j < (int)np->args->argc; j++)
if (MDOC_Column == np->args->argv[j].arg)
break;
*/
np->args->argv[j].sz = (size_t)mdoc->last->nchild;
- np->args->argv[j].value = mandoc_malloc
- ((size_t)mdoc->last->nchild * sizeof(char *));
+ np->args->argv[j].value = mandoc_malloc(
+ (size_t)mdoc->last->nchild * sizeof(char *));
mdoc->last->norm->Bl.ncols = np->args->argv[j].sz;
mdoc->last->norm->Bl.cols = (void *)np->args->argv[j].value;
nbody = mdoc->last;
switch (nbody->type) {
- case (MDOC_BLOCK):
+ case MDOC_BLOCK:
return(post_bl_block(mdoc));
- case (MDOC_HEAD):
+ case MDOC_HEAD:
return(post_bl_head(mdoc));
- case (MDOC_BODY):
+ case MDOC_BODY:
break;
default:
return(1);
n = mdoc->first;
assert(n);
-
+
/* Check that we begin with a proper `Sh'. */
if (NULL == n->child) {
erc++;
mdoc_nmsg(mdoc, n, MANDOCERR_NODOCBODY);
- } else if (MDOC_BLOCK != n->child->type ||
- MDOC_Sh != n->child->tok) {
+ } else if (MDOC_BLOCK != n->child->type ||
+ MDOC_Sh != n->child->tok) {
erc++;
/* Can this be lifted? See rxdebug.1 for example. */
mdoc_nmsg(mdoc, n, MANDOCERR_NODOCBODY);
int i, j;
switch (mdoc->last->type) {
- case (MDOC_HEAD):
+ case MDOC_HEAD:
check_count(mdoc, MDOC_HEAD, CHECK_WARN, CHECK_EQ, 0);
return(1);
- case (MDOC_BODY):
+ case MDOC_BODY:
if (mdoc->last->child)
break;
check_count(mdoc, MDOC_BODY, CHECK_WARN, CHECK_GT, 0);
if (rsord[i] == nn->tok)
break;
- /*
+ /*
* Remove `nn' from the chain. This somewhat
* repeats mdoc_node_unlink(), but since we're
* just re-ordering, there's no need for the
* full unlink process.
*/
-
+
if (NULL != (next = nn->next))
next->prev = nn->prev;
nn->prev = nn->next = NULL;
- /*
+ /*
* Scan back until we reach a node that's
* ordered before `nn'.
*/
n = mdoc->last;
switch (n->type) {
- case (MDOC_HEAD):
+ case MDOC_HEAD:
if (MDOC_Sh == n->tok || MDOC_Ss == n->tok)
break;
return(1);
- case (MDOC_BODY):
+ case MDOC_BODY:
if (MDOC_D1 == n->tok || MDOC_Nd == n->tok)
break;
return(1);
- case (MDOC_ELEM):
+ case MDOC_ELEM:
break;
default:
return(1);
assert(mdoc->meta.msec);
switch (sec) {
- case (SEC_ERRORS):
+ case SEC_ERRORS:
if (*mdoc->meta.msec == '4')
break;
/* FALLTHROUGH */
- case (SEC_RETURN_VALUES):
+ case SEC_RETURN_VALUES:
/* FALLTHROUGH */
- case (SEC_LIBRARY):
+ case SEC_LIBRARY:
if (*mdoc->meta.msec == '2')
break;
if (*mdoc->meta.msec == '3')
break;
/* FALLTHROUGH */
- case (SEC_CONTEXT):
+ case SEC_CONTEXT:
if (*mdoc->meta.msec == '9')
break;
mandoc_msg(MANDOCERR_SECMSEC, mdoc->parse,
if (MDOC_ELEM != n->type && MDOC_BLOCK != n->type)
return(1);
- /*
+ /*
* Don't allow prior `Lp' or `Pp' prior to a paragraph-type
* block: `Lp', `Pp', or non-compact `Bd' or `Bl'.
*/
*/
switch (n->tok) {
- case (MDOC_Dl):
+ case MDOC_Dl:
mdoc->flags |= MDOC_LITERAL;
break;
- case (MDOC_Bd):
+ case MDOC_Bd:
if (DISP_literal == n->norm->Bd.type)
mdoc->flags |= MDOC_LITERAL;
if (DISP_unfilled == n->norm->Bd.type)
abort();
/* NOTREACHED */
}
-
+
return(1);
}
if (toupper((unsigned char)*p) == *p)
continue;
- /*
+ /*
* FIXME: don't be lazy: have this make all
* characters be uppercase and just warn once.
*/
break;
}
- /* Handles: `.Dt'
- * --> title = unknown, volume = local, msec = 0, arch = NULL
+ /* Handles: `.Dt'
+ * title = unknown, volume = local, msec = 0, arch = NULL
*/
if (NULL == (nn = n->child)) {
return(1);
}
- /* Handles: `.Dt TITLE'
- * --> title = TITLE, volume = local, msec = 0, arch = NULL
+ /* Handles: `.Dt TITLE'
+ * title = TITLE, volume = local, msec = 0, arch = NULL
*/
- mdoc->meta.title = mandoc_strdup
- ('\0' == nn->string[0] ? "UNKNOWN" : nn->string);
+ mdoc->meta.title = mandoc_strdup(
+ '\0' == nn->string[0] ? "UNKNOWN" : nn->string);
if (NULL == (nn = nn->next)) {
/* FIXME: warn about missing msec. */
}
/* Handles: `.Dt TITLE SEC'
- * --> title = TITLE, volume = SEC is msec ?
- * format(msec) : SEC,
- * msec = SEC is msec ? atoi(msec) : 0,
- * arch = NULL
+ * title = TITLE,
+ * volume = SEC is msec ? format(msec) : SEC,
+ * msec = SEC is msec ? atoi(msec) : 0,
+ * arch = NULL
*/
cp = mandoc_a2msec(nn->string);
mdoc_nmsg(mdoc, n, MANDOCERR_BADMSEC);
mdoc->meta.vol = mandoc_strdup(nn->string);
mdoc->meta.msec = mandoc_strdup(nn->string);
- }
+ }
if (NULL == (nn = nn->next))
return(1);
/* Handles: `.Dt TITLE SEC VOL'
- * --> title = TITLE, volume = VOL is vol ?
- * format(VOL) :
- * VOL is arch ? format(arch) :
- * VOL
+ * title = TITLE,
+ * volume = VOL is vol ? format(VOL) :
+ * VOL is arch ? format(arch) :
+ * VOL
*/
cp = mdoc_a2vol(nn->string);
mdoc_nmsg(mdoc, nn, MANDOCERR_BADVOLARCH);
free(mdoc->meta.vol);
mdoc->meta.vol = mandoc_strdup(nn->string);
- } else
+ } else
mdoc->meta.arch = mandoc_strdup(cp);
- }
+ }
/* Ignore any subsequent parameters... */
/* FIXME: warn about subsequent parameters. */
{
struct mdoc_node *n;
- /*
+ /*
* Make `Bx's second argument always start with an uppercase
* letter. Groff checks if it's an "accepted" term, but we just
* uppercase blindly.
n = mdoc->last->child;
if (n && NULL != (n = n->next))
- *n->string = (char)toupper
- ((unsigned char)*n->string);
+ *n->string = (char)toupper((unsigned char)*n->string);
return(1);
}
* 2. the -Ios=foo command line argument, if provided
* 3. -DOSNAME="\"foo\"", if provided during compilation
* 4. "sysname release" from uname(3)
- */
+ */
free(mdoc->meta.os);
mdoc->meta.os = NULL;
if (NULL == defbuf) {
if (-1 == uname(&utsname)) {
mdoc_nmsg(mdoc, n, MANDOCERR_UNAME);
- defbuf = mandoc_strdup("UNKNOWN");
- } else
+ defbuf = mandoc_strdup("UNKNOWN");
+ } else
mandoc_asprintf(&defbuf, "%s %s",
utsname.sysname, utsname.release);
}
if (NULL == mdoc->meta.name)
return(1);
-
+
nn = n;
mdoc->next = MDOC_NEXT_CHILD;
return(1);
}
-static enum mdoc_sec
+static enum mdoc_sec
a2sec(const char *p)
{
int i;
- for (i = 0; i < (int)SEC__MAX; i++)
+ for (i = 0; i < (int)SEC__MAX; i++)
if (secnames[i] && 0 == strcmp(p, secnames[i]))
return((enum mdoc_sec)i);
{
switch (macro) {
- case(MDOC_Ad):
+ case MDOC_Ad:
return(12);
- case(MDOC_Ao):
+ case MDOC_Ao:
return(12);
- case(MDOC_An):
+ case MDOC_An:
return(12);
- case(MDOC_Aq):
+ case MDOC_Aq:
return(12);
- case(MDOC_Ar):
+ case MDOC_Ar:
return(12);
- case(MDOC_Bo):
+ case MDOC_Bo:
return(12);
- case(MDOC_Bq):
+ case MDOC_Bq:
return(12);
- case(MDOC_Cd):
+ case MDOC_Cd:
return(12);
- case(MDOC_Cm):
+ case MDOC_Cm:
return(10);
- case(MDOC_Do):
+ case MDOC_Do:
return(10);
- case(MDOC_Dq):
+ case MDOC_Dq:
return(12);
- case(MDOC_Dv):
+ case MDOC_Dv:
return(12);
- case(MDOC_Eo):
+ case MDOC_Eo:
return(12);
- case(MDOC_Em):
+ case MDOC_Em:
return(10);
- case(MDOC_Er):
+ case MDOC_Er:
return(17);
- case(MDOC_Ev):
+ case MDOC_Ev:
return(15);
- case(MDOC_Fa):
+ case MDOC_Fa:
return(12);
- case(MDOC_Fl):
+ case MDOC_Fl:
return(10);
- case(MDOC_Fo):
+ case MDOC_Fo:
return(16);
- case(MDOC_Fn):
+ case MDOC_Fn:
return(16);
- case(MDOC_Ic):
+ case MDOC_Ic:
return(10);
- case(MDOC_Li):
+ case MDOC_Li:
return(16);
- case(MDOC_Ms):
+ case MDOC_Ms:
return(6);
- case(MDOC_Nm):
+ case MDOC_Nm:
return(10);
- case(MDOC_No):
+ case MDOC_No:
return(12);
- case(MDOC_Oo):
+ case MDOC_Oo:
return(10);
- case(MDOC_Op):
+ case MDOC_Op:
return(14);
- case(MDOC_Pa):
+ case MDOC_Pa:
return(32);
- case(MDOC_Pf):
+ case MDOC_Pf:
return(12);
- case(MDOC_Po):
+ case MDOC_Po:
return(12);
- case(MDOC_Pq):
+ case MDOC_Pq:
return(12);
- case(MDOC_Ql):
+ case MDOC_Ql:
return(16);
- case(MDOC_Qo):
+ case MDOC_Qo:
return(12);
- case(MDOC_So):
+ case MDOC_So:
return(12);
- case(MDOC_Sq):
+ case MDOC_Sq:
return(12);
- case(MDOC_Sy):
+ case MDOC_Sy:
return(6);
- case(MDOC_Sx):
+ case MDOC_Sx:
return(16);
- case(MDOC_Tn):
+ case MDOC_Tn:
return(10);
- case(MDOC_Va):
+ case MDOC_Va:
return(12);
- case(MDOC_Vt):
+ case MDOC_Vt:
return(12);
- case(MDOC_Xr):
+ case MDOC_Xr:
return(10);
default:
break;
-/* $Id: out.c,v 1.20 2014/03/21 22:17:01 schwarze Exp $ */
+/* $Id: out.c,v 1.21 2014/04/20 16:44:44 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org>
static void tblcalc_number(struct rofftbl *, struct roffcol *,
const struct tbl_opts *, const struct tbl_dat *);
-/*
+
+/*
* Convert a `scaling unit' to a consistent form, or fail. Scaling
* units are documented in groff.7, mdoc.7, man.7.
*/
i = hasd = 0;
switch (*src) {
- case ('+'):
+ case '+':
src++;
break;
- case ('-'):
+ case '-':
buf[i++] = *src++;
break;
default:
buf[i] = '\0';
switch (*src) {
- case ('c'):
+ case 'c':
unit = SCALE_CM;
break;
- case ('i'):
+ case 'i':
unit = SCALE_IN;
break;
- case ('P'):
+ case 'P':
unit = SCALE_PC;
break;
- case ('p'):
+ case 'p':
unit = SCALE_PT;
break;
- case ('f'):
+ case 'f':
unit = SCALE_FS;
break;
- case ('v'):
+ case 'v':
unit = SCALE_VS;
break;
- case ('m'):
+ case 'm':
unit = SCALE_EM;
break;
- case ('\0'):
+ case '\0':
if (SCALE_MAX == def)
return(0);
unit = SCALE_BU;
break;
- case ('u'):
+ case 'u':
unit = SCALE_BU;
break;
- case ('M'):
+ case 'M':
unit = SCALE_MM;
break;
- case ('n'):
+ case 'n':
unit = SCALE_EN;
break;
default:
*/
assert(NULL == tbl->cols);
- tbl->cols = mandoc_calloc
- ((size_t)sp->opts->cols, sizeof(struct roffcol));
+ tbl->cols = mandoc_calloc((size_t)sp->opts->cols,
+ sizeof(struct roffcol));
for ( ; sp; sp = sp->next) {
if (TBL_SPAN_DATA != sp->pos)
/* Branch down into data sub-types. */
switch (dp->layout->pos) {
- case (TBL_CELL_HORIZ):
+ case TBL_CELL_HORIZ:
/* FALLTHROUGH */
- case (TBL_CELL_DHORIZ):
+ case TBL_CELL_DHORIZ:
sz = (*tbl->len)(1, tbl->arg);
if (col->width < sz)
col->width = sz;
break;
- case (TBL_CELL_LONG):
+ case TBL_CELL_LONG:
/* FALLTHROUGH */
- case (TBL_CELL_CENTRE):
+ case TBL_CELL_CENTRE:
/* FALLTHROUGH */
- case (TBL_CELL_LEFT):
+ case TBL_CELL_LEFT:
/* FALLTHROUGH */
- case (TBL_CELL_RIGHT):
+ case TBL_CELL_RIGHT:
tblcalc_literal(tbl, col, dp);
break;
- case (TBL_CELL_NUMBER):
+ case TBL_CELL_NUMBER:
tblcalc_number(tbl, col, opts, dp);
break;
- case (TBL_CELL_DOWN):
+ case TBL_CELL_DOWN:
break;
default:
abort();
tblcalc_number(struct rofftbl *tbl, struct roffcol *col,
const struct tbl_opts *opts, const struct tbl_dat *dp)
{
- int i;
+ int i;
size_t sz, psz, ssz, d;
const char *str;
char *cp;
-/* $Id: out.h,v 1.12 2011/09/18 15:54:48 schwarze Exp $ */
+/* $Id: out.h,v 1.13 2014/04/20 16:44:44 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
(p)->scale = (v); } \
while (/* CONSTCOND */ 0)
-int a2roffsu(const char *, struct roffsu *, enum roffscale);
-void tblcalc(struct rofftbl *tbl, const struct tbl_span *);
+int a2roffsu(const char *, struct roffsu *, enum roffscale);
+void tblcalc(struct rofftbl *tbl, const struct tbl_span *);
__END_DECLS
-/* $Id: read.c,v 1.24 2014/03/21 22:17:01 schwarze Exp $ */
+/* $Id: read.c,v 1.25 2014/04/20 16:44:44 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
#define REPARSE_LIMIT 1000
struct buf {
- char *buf; /* binary input buffer */
+ char *buf; /* binary input buffer */
size_t sz; /* size of binary buffer */
};
char *sodest; /* filename pointed to by .so */
int reparse_count; /* finite interp. stack */
mandocmsg mmsg; /* warning/error message handler */
- const char *file;
+ const char *file;
struct buf *secondary;
char *defos; /* default operating system */
};
/* related to equations */
"unexpected literal in equation",
-
+
"generic error",
/* related to equations */
"SYSERR"
};
+
static void
resize_buf(struct buf *buf, size_t initial)
{
}
if (MPARSE_MDOC & curp->options) {
- if (NULL == curp->pmdoc)
+ if (NULL == curp->pmdoc)
curp->pmdoc = mdoc_alloc(
curp->roff, curp, curp->defos,
MPARSE_QUICK & curp->options ? 1 : 0);
curp->mdoc = curp->pmdoc;
return;
} else if (MPARSE_MAN & curp->options) {
- if (NULL == curp->pman)
+ if (NULL == curp->pman)
curp->pman = man_alloc(curp->roff, curp,
MPARSE_QUICK & curp->options ? 1 : 0);
assert(curp->pman);
}
if (pos >= 3 && 0 == memcmp(buf, ".Dd", 3)) {
- if (NULL == curp->pmdoc)
+ if (NULL == curp->pmdoc)
curp->pmdoc = mdoc_alloc(
curp->roff, curp, curp->defos,
MPARSE_QUICK & curp->options ? 1 : 0);
assert(curp->pmdoc);
curp->mdoc = curp->pmdoc;
return;
- }
+ }
- if (NULL == curp->pman)
+ if (NULL == curp->pman)
curp->pman = man_alloc(curp->roff, curp,
MPARSE_QUICK & curp->options ? 1 : 0);
assert(curp->pman);
memset(&ln, 0, sizeof(struct buf));
- lnn = curp->line;
- pos = 0;
+ lnn = curp->line;
+ pos = 0;
for (i = 0; i < (int)blk.sz; ) {
if (0 == pos && '\0' == blk.buf[i])
if (pos + 2 >= (int)ln.sz)
resize_buf(&ln, 256);
- /*
+ /*
* Warn about bogus characters. If you're using
* non-ASCII encoding, you're screwing your
* readers. Since I'd rather this not happen,
c = (unsigned char) blk.buf[i];
- if ( ! (isascii(c) &&
- (isgraph(c) || isblank(c)))) {
+ if ( ! (isascii(c) &&
+ (isgraph(c) || isblank(c)))) {
mandoc_msg(MANDOCERR_BADCHAR, curp,
- curp->line, pos, NULL);
+ curp->line, pos, NULL);
i++;
ln.buf[pos++] = '?';
continue;
c = (unsigned char) blk.buf[i+1];
- if ( ! (isascii(c) &&
- (isgraph(c) || isblank(c)))) {
+ if ( ! (isascii(c) &&
+ (isgraph(c) || isblank(c)))) {
mandoc_msg(MANDOCERR_BADCHAR, curp,
- curp->line, pos, NULL);
+ curp->line, pos, NULL);
i += 2;
ln.buf[pos++] = '?';
continue;
ln.buf[pos++] = blk.buf[i++];
}
- if (pos >= (int)ln.sz)
+ if (pos >= (int)ln.sz)
resize_buf(&ln, 256);
ln.buf[pos] = '\0';
*/
if (curp->secondary) {
- curp->secondary->buf =
- mandoc_realloc
- (curp->secondary->buf,
- curp->secondary->sz + pos + 2);
- memcpy(curp->secondary->buf +
- curp->secondary->sz,
- ln.buf, pos);
+ curp->secondary->buf = mandoc_realloc(
+ curp->secondary->buf,
+ curp->secondary->sz + pos + 2);
+ memcpy(curp->secondary->buf +
+ curp->secondary->sz,
+ ln.buf, pos);
curp->secondary->sz += pos;
curp->secondary->buf
[curp->secondary->sz] = '\n';
[curp->secondary->sz] = '\0';
}
rerun:
- rr = roff_parseln
- (curp->roff, curp->line,
- &ln.buf, &ln.sz, of, &of);
+ rr = roff_parseln(curp->roff, curp->line,
+ &ln.buf, &ln.sz, of, &of);
switch (rr) {
- case (ROFF_REPARSE):
+ case ROFF_REPARSE:
if (REPARSE_LIMIT >= ++curp->reparse_count)
mparse_buf_r(curp, ln, 0);
else
mandoc_msg(MANDOCERR_ROFFLOOP, curp,
- curp->line, pos, NULL);
+ curp->line, pos, NULL);
pos = 0;
continue;
- case (ROFF_APPEND):
+ case ROFF_APPEND:
pos = (int)strlen(ln.buf);
continue;
- case (ROFF_RERUN):
+ case ROFF_RERUN:
goto rerun;
- case (ROFF_IGN):
+ case ROFF_IGN:
pos = 0;
continue;
- case (ROFF_ERR):
+ case ROFF_ERR:
assert(MANDOCLEVEL_FATAL <= curp->file_status);
break;
- case (ROFF_SO):
+ case ROFF_SO:
if (0 == (MPARSE_SO & curp->options) &&
(i >= (int)blk.sz || '\0' == blk.buf[i])) {
curp->sodest = mandoc_strdup(ln.buf + of);
* buffer because we're going to descend into
* the file recursively.
*/
- if (curp->secondary)
+ if (curp->secondary)
curp->secondary->sz -= pos + 1;
mparse_readfd(curp, -1, ln.buf + of);
if (MANDOCLEVEL_FATAL <= curp->file_status)
if ( ! (curp->man || curp->mdoc))
pset(ln.buf + of, pos - of, curp);
- /*
+ /*
* Lastly, push down into the parsers themselves. One
* of these will have already been set in the pset()
* routine.
if (ROFF_TBL == rr)
while (NULL != (span = roff_span(curp->roff))) {
rc = curp->man ?
- man_addspan(curp->man, span) :
- mdoc_addspan(curp->mdoc, span);
+ man_addspan(curp->man, span) :
+ mdoc_addspan(curp->mdoc, span);
if (0 == rc)
break;
}
else if (ROFF_EQN == rr)
- rc = curp->mdoc ?
- mdoc_addeqn(curp->mdoc,
- roff_eqn(curp->roff)) :
- man_addeqn(curp->man,
- roff_eqn(curp->roff));
+ rc = curp->mdoc ?
+ mdoc_addeqn(curp->mdoc,
+ roff_eqn(curp->roff)) :
+ man_addeqn(curp->man,
+ roff_eqn(curp->roff));
else if (curp->man || curp->mdoc)
rc = curp->man ?
- man_parseln(curp->man,
- curp->line, ln.buf, of) :
- mdoc_parseln(curp->mdoc,
- curp->line, ln.buf, of);
+ man_parseln(curp->man,
+ curp->line, ln.buf, of) :
+ mdoc_parseln(curp->mdoc,
+ curp->line, ln.buf, of);
if (0 == rc) {
assert(MANDOCLEVEL_FATAL <= curp->file_status);
}
void
-mandoc_msg(enum mandocerr er, struct mparse *m,
+mandoc_msg(enum mandocerr er, struct mparse *m,
int ln, int col, const char *msg)
{
enum mandoclevel level;
-/* $Id: roff.c,v 1.79 2014/04/08 01:36:50 schwarze Exp $ */
+/* $Id: roff.c,v 1.80 2014/04/20 16:44:44 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
#define ROFF_ARGS struct roff *r, /* parse ctx */ \
enum rofft tok, /* tok of macro */ \
- char **bufp, /* input buffer */ \
+ char **bufp, /* input buffer */ \
size_t *szp, /* size of input buffer */ \
int ln, /* parse line */ \
int ppos, /* original pos in buffer */ \
static int roff_getregn(const struct roff *,
const char *, size_t);
static int roff_getregro(const char *name);
-static const char *roff_getstrn(const struct roff *,
+static const char *roff_getstrn(const struct roff *,
const char *, size_t);
static enum rofferr roff_it(ROFF_ARGS);
static enum rofferr roff_line_ignore(ROFF_ARGS);
int, int, const char *);
static enum rofft roff_parse(struct roff *, const char *, int *);
static enum rofferr roff_parsetext(char **, size_t *, int, int *);
-static enum rofferr roff_res(struct roff *,
+static enum rofferr roff_res(struct roff *,
char **, size_t *, int, int);
static enum rofferr roff_rm(ROFF_ARGS);
static enum rofferr roff_rr(ROFF_ARGS);
static void roff_setstr(struct roff *,
const char *, const char *, int);
-static void roff_setstrn(struct roffkv **, const char *,
+static void roff_setstrn(struct roffkv **, const char *,
size_t, const char *, size_t, int);
static enum rofferr roff_so(ROFF_ARGS);
static enum rofferr roff_tr(ROFF_ARGS);
static int roffit_lines; /* number of lines to delay */
static char *roffit_macro; /* nil-terminated macro line */
+
static void
roffhash_init(void)
{
return(ROFF_MAX);
}
-
/*
* Pop the current node off of the stack of roff instructions currently
* pending.
struct roffnode *p;
assert(r->last);
- p = r->last;
+ p = r->last;
r->last = r->last->parent;
free(p->name);
free(p);
}
-
/*
* Push a roff node onto the instruction stack. This must later be
* removed with roffnode_pop().
r->last = p;
}
-
static void
roff_free1(struct roff *r)
{
r->control = 0;
}
-
void
roff_free(struct roff *r)
{
free(r);
}
-
struct roff *
roff_alloc(struct mparse *parse, int options)
{
r->parse = parse;
r->options = options;
r->rstackpos = -1;
-
+
roffhash_init();
return(r);
term = '\0';
cp = stesc + 1;
switch (*cp) {
- case ('*'):
+ case '*':
res = NULL;
break;
- case ('B'):
+ case 'B':
/* FALLTHROUGH */
- case ('w'):
+ case 'w':
term = cp[1];
/* FALLTHROUGH */
- case ('n'):
+ case 'n':
res = ubuf;
break;
default:
if ('\0' == term) {
switch (*++cp) {
- case ('\0'):
+ case '\0':
maxl = 0;
break;
- case ('('):
+ case '(':
cp++;
maxl = 2;
break;
- case ('['):
+ case '[':
cp++;
term = ']';
maxl = 0;
for (naml = 0; 0 == maxl || naml < maxl; naml++, cp++) {
if ('\0' == *cp) {
- mandoc_msg
- (MANDOCERR_BADESCAPE,
- r->parse, ln,
- (int)(stesc - *bufp), NULL);
+ mandoc_msg(MANDOCERR_BADESCAPE, r->parse,
+ ln, (int)(stesc - *bufp), NULL);
break;
}
if (0 == maxl && *cp == term) {
*/
switch (stesc[1]) {
- case ('*'):
+ case '*':
res = roff_getstrn(r, stnam, naml);
break;
- case ('B'):
+ case 'B':
npos = 0;
irc = roff_evalnum(stnam, &npos, NULL, 0);
ubuf[0] = irc && stnam + npos + 1 == cp
? '1' : '0';
ubuf[1] = '\0';
break;
- case ('n'):
+ case 'n':
snprintf(ubuf, sizeof(ubuf), "%d",
roff_getregn(r, stnam, naml));
break;
- case ('w'):
+ case 'w':
snprintf(ubuf, sizeof(ubuf), "%d",
24 * (int)naml);
break;
}
if (NULL == res) {
- mandoc_msg
- (MANDOCERR_BADESCAPE, r->parse,
- ln, (int)(stesc - *bufp), NULL);
+ mandoc_msg(MANDOCERR_BADESCAPE, r->parse,
+ ln, (int)(stesc - *bufp), NULL);
res = "";
}
ressz = strlen(res);
}
enum rofferr
-roff_parseln(struct roff *r, int ln, char **bufp,
+roff_parseln(struct roff *r, int ln, char **bufp,
size_t *szp, int pos, int *offs)
{
enum rofft t;
if (r->last && ! ctl) {
t = r->last->tok;
assert(roffs[t].text);
- e = (*roffs[t].text)
- (r, t, bufp, szp, ln, pos, pos, offs);
+ e = (*roffs[t].text)(r, t, bufp, szp, ln, pos, pos, offs);
assert(ROFF_IGN == e || ROFF_CONT == e);
if (ROFF_CONT != e)
return(e);
if (r->last) {
t = r->last->tok;
assert(roffs[t].sub);
- return((*roffs[t].sub)
- (r, t, bufp, szp,
- ln, ppos, pos, offs));
+ return((*roffs[t].sub)(r, t, bufp, szp,
+ ln, ppos, pos, offs));
}
/*
return(ROFF_CONT);
assert(roffs[t].proc);
- return((*roffs[t].proc)
- (r, t, bufp, szp,
- ln, ppos, pos, offs));
+ return((*roffs[t].proc)(r, t, bufp, szp, ln, ppos, pos, offs));
}
-
void
roff_endparse(struct roff *r)
{
if (r->last)
mandoc_msg(MANDOCERR_SCOPEEXIT, r->parse,
- r->last->line, r->last->col, NULL);
+ r->last->line, r->last->col, NULL);
if (r->eqn) {
- mandoc_msg(MANDOCERR_SCOPEEXIT, r->parse,
- r->eqn->eqn.ln, r->eqn->eqn.pos, NULL);
+ mandoc_msg(MANDOCERR_SCOPEEXIT, r->parse,
+ r->eqn->eqn.ln, r->eqn->eqn.pos, NULL);
eqn_end(&r->eqn);
}
if (r->tbl) {
- mandoc_msg(MANDOCERR_SCOPEEXIT, r->parse,
- r->tbl->line, r->tbl->pos, NULL);
+ mandoc_msg(MANDOCERR_SCOPEEXIT, r->parse,
+ r->tbl->line, r->tbl->pos, NULL);
tbl_end(&r->tbl);
}
}
size_t maclen;
enum rofft t;
- if ('\0' == buf[*pos] || '"' == buf[*pos] ||
- '\t' == buf[*pos] || ' ' == buf[*pos])
+ if ('\0' == buf[*pos] || '"' == buf[*pos] ||
+ '\t' == buf[*pos] || ' ' == buf[*pos])
return(ROFF_MAX);
/* We stop the macro parse at an escape, tab, space, or nil. */
return(t);
}
-/* ARGSUSED */
static enum rofferr
roff_cblock(ROFF_ARGS)
{
}
switch (r->last->tok) {
- case (ROFF_am):
+ case ROFF_am:
/* FALLTHROUGH */
- case (ROFF_ami):
+ case ROFF_ami:
/* FALLTHROUGH */
- case (ROFF_am1):
+ case ROFF_am1:
/* FALLTHROUGH */
- case (ROFF_de):
+ case ROFF_de:
/* ROFF_de1 is remapped to ROFF_de in roff_block(). */
/* FALLTHROUGH */
- case (ROFF_dei):
+ case ROFF_dei:
/* FALLTHROUGH */
- case (ROFF_ig):
+ case ROFF_ig:
break;
default:
mandoc_msg(MANDOCERR_NOSCOPE, r->parse, ln, ppos, NULL);
}
-
static void
roffnode_cleanscope(struct roff *r)
{
}
}
-
static void
roff_ccond(struct roff *r, int ln, int ppos)
{
}
switch (r->last->tok) {
- case (ROFF_el):
+ case ROFF_el:
/* FALLTHROUGH */
- case (ROFF_ie):
+ case ROFF_ie:
/* FALLTHROUGH */
- case (ROFF_if):
+ case ROFF_if:
break;
default:
mandoc_msg(MANDOCERR_NOSCOPE, r->parse, ln, ppos, NULL);
return;
}
-
-/* ARGSUSED */
static enum rofferr
roff_block(ROFF_ARGS)
{
return(ROFF_IGN);
}
-
-/* ARGSUSED */
static enum rofferr
roff_block_sub(ROFF_ARGS)
{
if ((*bufp)[i] != r->last->end[j])
break;
- if ('\0' == r->last->end[j] &&
- ('\0' == (*bufp)[i] ||
- ' ' == (*bufp)[i] ||
- '\t' == (*bufp)[i])) {
+ if ('\0' == r->last->end[j] &&
+ ('\0' == (*bufp)[i] ||
+ ' ' == (*bufp)[i] ||
+ '\t' == (*bufp)[i])) {
roffnode_pop(r);
roffnode_cleanscope(r);
}
assert(roffs[t].proc);
- return((*roffs[t].proc)(r, t, bufp, szp,
- ln, ppos, pos, offs));
+ return((*roffs[t].proc)(r, t, bufp, szp, ln, ppos, pos, offs));
}
-
-/* ARGSUSED */
static enum rofferr
roff_block_text(ROFF_ARGS)
{
return(ROFF_IGN);
}
-
-/* ARGSUSED */
static enum rofferr
roff_cond_sub(ROFF_ARGS)
{
(rr || ROFFMAC_STRUCT & roffs[t].flags)) {
assert(roffs[t].proc);
return((*roffs[t].proc)(r, t, bufp, szp,
- ln, ppos, pos, offs));
+ ln, ppos, pos, offs));
}
/*
return(rr ? ROFF_CONT : ROFF_IGN);
}
-/* ARGSUSED */
static enum rofferr
roff_cond_text(ROFF_ARGS)
{
wanttrue = 1;
switch (v[*pos]) {
- case ('n'):
+ case 'n':
/* FALLTHROUGH */
- case ('o'):
+ case 'o':
(*pos)++;
return(wanttrue);
- case ('c'):
+ case 'c':
/* FALLTHROUGH */
- case ('d'):
+ case 'd':
/* FALLTHROUGH */
- case ('e'):
+ case 'e':
/* FALLTHROUGH */
- case ('r'):
+ case 'r':
/* FALLTHROUGH */
- case ('t'):
+ case 't':
(*pos)++;
return(!wanttrue);
default:
return(roff_evalstrcond(v, pos) == wanttrue);
}
-/* ARGSUSED */
static enum rofferr
roff_line_ignore(ROFF_ARGS)
{
return(ROFF_IGN);
}
-/* ARGSUSED */
static enum rofferr
roff_cond(ROFF_ARGS)
{
roffnode_push(r, tok, NULL, ln, ppos);
- /*
+ /*
* An `.el' has no conditional body: it will consume the value
* of the current rstack entry set in prior `ie' calls or
- * defaults to DENY.
+ * defaults to DENY.
*
* If we're not an `el', however, then evaluate the conditional.
*/
r->last->rule = ROFF_el == tok ?
- (r->rstackpos < 0 ? 0 : r->rstack[r->rstackpos--]) :
- roff_evalcond(*bufp, &pos);
+ (r->rstackpos < 0 ? 0 : r->rstack[r->rstackpos--]) :
+ roff_evalcond(*bufp, &pos);
/*
* An if-else will put the NEGATION of the current evaluated
if (ROFF_ie == tok) {
if (r->rstackpos == RSTACK_MAX - 1) {
- mandoc_msg(MANDOCERR_MEM,
- r->parse, ln, ppos, NULL);
+ mandoc_msg(MANDOCERR_MEM,
+ r->parse, ln, ppos, NULL);
return(ROFF_ERR);
}
r->rstack[++r->rstackpos] = !r->last->rule;
r->last->endspan = -1;
pos += 2;
goto out;
- }
+ }
/*
* Anything else following the conditional causes
return(ROFF_RERUN);
}
-
-/* ARGSUSED */
static enum rofferr
roff_ds(ROFF_ARGS)
{
*res = v[*pos];
switch (*res) {
- case ('+'):
+ case '+':
/* FALLTHROUGH */
- case ('-'):
+ case '-':
/* FALLTHROUGH */
- case ('*'):
+ case '*':
/* FALLTHROUGH */
- case ('/'):
+ case '/':
/* FALLTHROUGH */
- case ('%'):
+ case '%':
/* FALLTHROUGH */
- case ('&'):
+ case '&':
/* FALLTHROUGH */
- case (':'):
+ case ':':
break;
case '<':
switch (v[*pos + 1]) {
- case ('='):
+ case '=':
*res = 'l';
(*pos)++;
break;
- case ('>'):
+ case '>':
*res = '!';
(*pos)++;
break;
- case ('?'):
+ case '?':
*res = 'i';
(*pos)++;
break;
break;
case '>':
switch (v[*pos + 1]) {
- case ('='):
+ case '=':
*res = 'g';
(*pos)++;
break;
- case ('?'):
+ case '?':
*res = 'a';
(*pos)++;
break;
continue;
switch (operator) {
- case ('+'):
+ case '+':
*res += operand2;
break;
- case ('-'):
+ case '-':
*res -= operand2;
break;
- case ('*'):
+ case '*':
*res *= operand2;
break;
- case ('/'):
+ case '/':
*res /= operand2;
break;
- case ('%'):
+ case '%':
*res %= operand2;
break;
- case ('<'):
+ case '<':
*res = *res < operand2;
break;
- case ('>'):
+ case '>':
*res = *res > operand2;
break;
- case ('l'):
+ case 'l':
*res = *res <= operand2;
break;
- case ('g'):
+ case 'g':
*res = *res >= operand2;
break;
- case ('='):
+ case '=':
*res = *res == operand2;
break;
- case ('!'):
+ case '!':
*res = *res != operand2;
break;
- case ('&'):
+ case '&':
*res = *res && operand2;
break;
- case (':'):
+ case ':':
*res = *res || operand2;
break;
- case ('i'):
+ case 'i':
if (operand2 < *res)
*res = operand2;
break;
- case ('a'):
+ case 'a':
if (operand2 > *res)
*res = operand2;
break;
{
switch (*name) {
- case ('A'): /* ASCII approximation mode is always off. */
+ case 'A': /* ASCII approximation mode is always off. */
return(0);
- case ('g'): /* Groff compatibility mode is always on. */
+ case 'g': /* Groff compatibility mode is always on. */
return(1);
- case ('H'): /* Fixed horizontal resolution. */
+ case 'H': /* Fixed horizontal resolution. */
return (24);
- case ('j'): /* Always adjust left margin only. */
+ case 'j': /* Always adjust left margin only. */
return(0);
- case ('T'): /* Some output device is always defined. */
+ case 'T': /* Some output device is always defined. */
return(1);
- case ('V'): /* Fixed vertical resolution. */
+ case 'V': /* Fixed vertical resolution. */
return (40);
default:
return (-1);
return(ROFF_IGN);
}
-/* ARGSUSED */
static enum rofferr
roff_rm(ROFF_ARGS)
{
return(ROFF_IGN);
}
-/* ARGSUSED */
static enum rofferr
roff_it(ROFF_ARGS)
{
cp[len] = '\0';
if ((iv = mandoc_strntoi(cp, len, 10)) <= 0) {
mandoc_msg(MANDOCERR_NUMERIC, r->parse,
- ln, ppos, *bufp + 1);
+ ln, ppos, *bufp + 1);
return(ROFF_IGN);
}
cp += len + 1;
return(ROFF_IGN);
}
-/* ARGSUSED */
static enum rofferr
roff_Dd(ROFF_ARGS)
{
return(ROFF_CONT);
}
-/* ARGSUSED */
static enum rofferr
roff_TH(ROFF_ARGS)
{
return(ROFF_CONT);
}
-/* ARGSUSED */
static enum rofferr
roff_TE(ROFF_ARGS)
{
return(ROFF_IGN);
}
-/* ARGSUSED */
static enum rofferr
roff_T_(ROFF_ARGS)
{
#endif
static void
-roff_openeqn(struct roff *r, const char *name, int line,
+roff_openeqn(struct roff *r, const char *name, int line,
int offs, const char *buf)
{
struct eqn_node *e;
}
}
-/* ARGSUSED */
static enum rofferr
roff_EQ(ROFF_ARGS)
{
return(ROFF_IGN);
}
-/* ARGSUSED */
static enum rofferr
roff_EN(ROFF_ARGS)
{
return(ROFF_IGN);
}
-/* ARGSUSED */
static enum rofferr
roff_TS(ROFF_ARGS)
{
return(ROFF_IGN);
}
-/* ARGSUSED */
static enum rofferr
roff_cc(ROFF_ARGS)
{
return(ROFF_IGN);
}
-/* ARGSUSED */
static enum rofferr
roff_tr(ROFF_ARGS)
{
if ('\\' == *first) {
esc = mandoc_escape(&p, NULL, NULL);
if (ESCAPE_ERROR == esc) {
- mandoc_msg
- (MANDOCERR_BADESCAPE, r->parse,
- ln, (int)(p - *bufp), NULL);
+ mandoc_msg(MANDOCERR_BADESCAPE,
+ r->parse, ln,
+ (int)(p - *bufp), NULL);
return(ROFF_IGN);
}
fsz = (size_t)(p - first);
if ('\\' == *second) {
esc = mandoc_escape(&p, NULL, NULL);
if (ESCAPE_ERROR == esc) {
- mandoc_msg
- (MANDOCERR_BADESCAPE, r->parse,
- ln, (int)(p - *bufp), NULL);
+ mandoc_msg(MANDOCERR_BADESCAPE,
+ r->parse, ln,
+ (int)(p - *bufp), NULL);
return(ROFF_IGN);
}
ssz = (size_t)(p - second);
} else if ('\0' == *second) {
- mandoc_msg(MANDOCERR_ARGCOUNT, r->parse,
- ln, (int)(p - *bufp), NULL);
+ mandoc_msg(MANDOCERR_ARGCOUNT, r->parse,
+ ln, (int)(p - *bufp), NULL);
second = " ";
p--;
}
if (fsz > 1) {
- roff_setstrn(&r->xmbtab, first,
- fsz, second, ssz, 0);
+ roff_setstrn(&r->xmbtab, first, fsz,
+ second, ssz, 0);
continue;
}
if (NULL == r->xtab)
- r->xtab = mandoc_calloc
- (128, sizeof(struct roffstr));
+ r->xtab = mandoc_calloc(128,
+ sizeof(struct roffstr));
free(r->xtab[(int)*first].p);
r->xtab[(int)*first].p = mandoc_strndup(second, ssz);
return(ROFF_IGN);
}
-/* ARGSUSED */
static enum rofferr
roff_so(ROFF_ARGS)
{
return(ROFF_SO);
}
-/* ARGSUSED */
static enum rofferr
roff_userdef(ROFF_ARGS)
{
{
roff_setstrn(&r->strtab, name, strlen(name), string,
- string ? strlen(string) : 0, append);
+ string ? strlen(string) : 0, append);
}
static void
int i;
for (n = r->strtab; n; n = n->next)
- if (0 == strncmp(name, n->key.p, len) &&
- '\0' == n->key.p[(int)len])
+ if (0 == strncmp(name, n->key.p, len) &&
+ '\0' == n->key.p[(int)len])
return(n->val.p);
for (i = 0; i < PREDEFS_MAX; i++)
const struct tbl_span *
roff_span(const struct roff *r)
{
-
+
return(r->tbl ? tbl_span(r->tbl) : NULL);
}
const struct eqn *
roff_eqn(const struct roff *r)
{
-
+
return(r->last_eqn ? &r->last_eqn->eqn : NULL);
}
* Append the match to the array and move
* forward by its keysize.
*/
- res = mandoc_realloc
- (res, ssz + cp->val.sz + 1);
+ res = mandoc_realloc(res,
+ ssz + cp->val.sz + 1);
memcpy(res + ssz, cp->val.p, cp->val.sz);
ssz += cp->val.sz;
p += (int)cp->key.sz;
memcpy(res + ssz, pp, sz);
break;
}
- /*
- * We bail out on bad escapes.
+ /*
+ * We bail out on bad escapes.
* No need to warn: we already did so when
* roff_res() was called.
*/
}
/*
- * Find out whether a line is a macro line or not.
+ * Find out whether a line is a macro line or not.
* If it is, adjust the current position and return one; if it isn't,
* return zero and don't change the current position.
* If the control character has been set with `.cc', then let that grain
-/* $Id: st.in,v 1.17 2013/12/30 09:47:43 schwarze Exp $ */
+/* $Id: st.in,v 1.18 2014/04/20 16:44:44 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
* the formatted output string.
*
* Be sure to escape strings.
- * The non-breaking blanks prevent ending an output line right before
+ * The non-breaking blanks prevent ending an output line right before
* a number. Groff prevent line breaks at the same places.
*
* REMEMBER TO ADD NEW STANDARDS TO MDOC.7!
-/* $Id: tbl.c,v 1.9 2014/03/21 22:17:01 schwarze Exp $ */
+/* $Id: tbl.c,v 1.10 2014/04/20 16:44:44 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org>
#include "libmandoc.h"
#include "libroff.h"
+
enum rofferr
tbl_read(struct tbl_node *tbl, int ln, const char *p, int offs)
{
/* Now process each logical section of the table. */
switch (tbl->part) {
- case (TBL_PART_OPTS):
+ case TBL_PART_OPTS:
return(tbl_option(tbl, ln, p) ? ROFF_IGN : ROFF_ERR);
- case (TBL_PART_LAYOUT):
+ case TBL_PART_LAYOUT:
return(tbl_layout(tbl, ln, p) ? ROFF_IGN : ROFF_ERR);
- case (TBL_PART_CDATA):
+ case TBL_PART_CDATA:
return(tbl_cdata(tbl, ln, p) ? ROFF_TBL : ROFF_IGN);
default:
break;
tbl_restart(int line, int pos, struct tbl_node *tbl)
{
if (TBL_PART_CDATA == tbl->part)
- mandoc_msg(MANDOCERR_TBLBLOCK, tbl->parse,
- tbl->line, tbl->pos, NULL);
+ mandoc_msg(MANDOCERR_TBLBLOCK, tbl->parse,
+ tbl->line, tbl->pos, NULL);
tbl->part = TBL_PART_LAYOUT;
tbl->line = line;
if (NULL == tbl->first_span || NULL == tbl->first_span->first)
mandoc_msg(MANDOCERR_TBLNODATA, tbl->parse,
- tbl->line, tbl->pos, NULL);
+ tbl->line, tbl->pos, NULL);
}
const struct tbl_span *
*tblp = NULL;
if (NULL == tbl->first_span || NULL == tbl->first_span->first)
- mandoc_msg(MANDOCERR_TBLNODATA, tbl->parse,
- tbl->line, tbl->pos, NULL);
+ mandoc_msg(MANDOCERR_TBLNODATA, tbl->parse,
+ tbl->line, tbl->pos, NULL);
if (tbl->last_span)
tbl->last_span->flags |= TBL_SPAN_LAST;
if (TBL_PART_CDATA == tbl->part)
- mandoc_msg(MANDOCERR_TBLBLOCK, tbl->parse,
- tbl->line, tbl->pos, NULL);
+ mandoc_msg(MANDOCERR_TBLBLOCK, tbl->parse,
+ tbl->line, tbl->pos, NULL);
}
-
-/* $Id: tbl_data.c,v 1.16 2014/03/21 22:17:01 schwarze Exp $ */
+/* $Id: tbl_data.c,v 1.17 2014/04/20 16:44:44 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org>
#include "libmandoc.h"
#include "libroff.h"
-static int getdata(struct tbl_node *, struct tbl_span *,
+static int getdata(struct tbl_node *, struct tbl_span *,
int, const char *, int *);
-static struct tbl_span *newspan(struct tbl_node *, int,
+static struct tbl_span *newspan(struct tbl_node *, int,
struct tbl_row *);
+
static int
-getdata(struct tbl_node *tbl, struct tbl_span *dp,
+getdata(struct tbl_node *tbl, struct tbl_span *dp,
int ln, const char *p, int *pos)
{
struct tbl_dat *dat;
else if (NULL == dp->last)
cp = dp->layout->first;
- /*
+ /*
* Skip over spanners, since
* we want to match data with data layout cells in the header.
*/
*/
if (NULL == cp) {
- mandoc_msg(MANDOCERR_TBLEXTRADAT,
- tbl->parse, ln, *pos, NULL);
+ mandoc_msg(MANDOCERR_TBLEXTRADAT, tbl->parse,
+ ln, *pos, NULL);
/* Skip to the end... */
while (p[*pos])
(*pos)++;
spans++;
else
break;
-
+
dat->spans = spans;
if (dp->last) {
dat->pos = TBL_DATA_DATA;
if (TBL_CELL_HORIZ == dat->layout->pos ||
- TBL_CELL_DHORIZ == dat->layout->pos ||
- TBL_CELL_DOWN == dat->layout->pos)
+ TBL_CELL_DHORIZ == dat->layout->pos ||
+ TBL_CELL_DOWN == dat->layout->pos)
if (TBL_DATA_DATA == dat->pos && '\0' != *dat->string)
- mandoc_msg(MANDOCERR_TBLIGNDATA,
- tbl->parse, ln, sv, NULL);
+ mandoc_msg(MANDOCERR_TBLIGNDATA,
+ tbl->parse, ln, sv, NULL);
return(1);
}
-/* ARGSUSED */
int
tbl_cdata(struct tbl_node *tbl, int ln, const char *p)
{
struct tbl_dat *dat;
- size_t sz;
+ size_t sz;
int pos;
pos = 0;
} else
dat->string = mandoc_strdup(p);
- if (TBL_CELL_DOWN == dat->layout->pos)
- mandoc_msg(MANDOCERR_TBLIGNDATA,
- tbl->parse, ln, pos, NULL);
+ if (TBL_CELL_DOWN == dat->layout->pos)
+ mandoc_msg(MANDOCERR_TBLIGNDATA, tbl->parse,
+ ln, pos, NULL);
return(0);
}
return(0);
}
- /*
+ /*
* Choose a layout row: take the one following the last parsed
* span's. If that doesn't exist, use the last parsed span's.
* If there's no last parsed span, use the first row. Lastly,
for (rp = tbl->last_span->layout->next;
rp && rp->first; rp = rp->next) {
switch (rp->first->pos) {
- case (TBL_CELL_HORIZ):
+ case TBL_CELL_HORIZ:
dp = newspan(tbl, ln, rp);
dp->pos = TBL_SPAN_HORIZ;
continue;
- case (TBL_CELL_DHORIZ):
+ case TBL_CELL_DHORIZ:
dp = newspan(tbl, ln, rp);
dp->pos = TBL_SPAN_DHORIZ;
continue;
-/* $Id: tbl_html.c,v 1.6 2012/05/26 20:03:34 schwarze Exp $ */
+/* $Id: tbl_html.c,v 1.7 2014/04/20 16:44:44 schwarze Exp $ */
/*
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
static size_t html_tbl_len(size_t, void *);
static size_t html_tbl_strlen(const char *, void *);
-/* ARGSUSED */
+
static size_t
html_tbl_len(size_t sz, void *arg)
{
-
+
return(sz);
}
-/* ARGSUSED */
static size_t
html_tbl_strlen(const char *p, void *arg)
{
tt = print_otag(h, TAG_TR, 0, NULL);
switch (sp->pos) {
- case (TBL_SPAN_HORIZ):
+ case TBL_SPAN_HORIZ:
/* FALLTHROUGH */
- case (TBL_SPAN_DHORIZ):
+ case TBL_SPAN_DHORIZ:
PAIR_INIT(&tag, ATTR_COLSPAN, "0");
print_otag(h, TAG_TD, 1, &tag);
break;
-/* $Id: tbl_layout.c,v 1.13 2014/03/28 23:25:54 schwarze Exp $ */
+/* $Id: tbl_layout.c,v 1.14 2014/04/20 16:44:44 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2012, 2014 Ingo Schwarze <schwarze@openbsd.org>
{ '=', TBL_CELL_DHORIZ }
};
-static int mods(struct tbl_node *, struct tbl_cell *,
+static int mods(struct tbl_node *, struct tbl_cell *,
int, const char *, int *);
-static int cell(struct tbl_node *, struct tbl_row *,
+static int cell(struct tbl_node *, struct tbl_row *,
int, const char *, int *);
static void row(struct tbl_node *, int, const char *, int *);
static struct tbl_cell *cell_alloc(struct tbl_node *, struct tbl_row *,
enum tbl_cellt, int vert);
+
static int
-mods(struct tbl_node *tbl, struct tbl_cell *cp,
+mods(struct tbl_node *tbl, struct tbl_cell *cp,
int ln, const char *p, int *pos)
{
char buf[5];
/* Not all types accept modifiers. */
switch (cp->pos) {
- case (TBL_CELL_DOWN):
+ case TBL_CELL_DOWN:
/* FALLTHROUGH */
- case (TBL_CELL_HORIZ):
+ case TBL_CELL_HORIZ:
/* FALLTHROUGH */
- case (TBL_CELL_DHORIZ):
+ case TBL_CELL_DHORIZ:
return(1);
default:
break;
}
mod:
- /*
+ /*
* XXX: since, at least for now, modifiers are non-conflicting
* (are separable by value, regardless of position), we let
* modifiers come in any order. The existing tbl doesn't let
* this happen.
*/
switch (p[*pos]) {
- case ('\0'):
+ case '\0':
/* FALLTHROUGH */
- case (' '):
+ case ' ':
/* FALLTHROUGH */
- case ('\t'):
+ case '\t':
/* FALLTHROUGH */
- case (','):
+ case ',':
/* FALLTHROUGH */
- case ('.'):
+ case '.':
/* FALLTHROUGH */
- case ('|'):
+ case '|':
return(1);
default:
break;
(*pos)++;
goto mod;
}
- mandoc_msg(MANDOCERR_TBLLAYOUT,
- tbl->parse, ln, *pos, NULL);
+ mandoc_msg(MANDOCERR_TBLLAYOUT, tbl->parse,
+ ln, *pos, NULL);
return(0);
}
/* No greater than 4 digits. */
if (4 == i) {
- mandoc_msg(MANDOCERR_TBLLAYOUT, tbl->parse,
- ln, *pos, NULL);
+ mandoc_msg(MANDOCERR_TBLLAYOUT,
+ tbl->parse, ln, *pos, NULL);
return(0);
}
goto mod;
/* NOTREACHED */
- }
+ }
/* TODO: GNU has many more extensions. */
switch (tolower((unsigned char)p[(*pos)++])) {
- case ('z'):
+ case 'z':
cp->flags |= TBL_CELL_WIGN;
goto mod;
- case ('u'):
+ case 'u':
cp->flags |= TBL_CELL_UP;
goto mod;
- case ('e'):
+ case 'e':
cp->flags |= TBL_CELL_EQUAL;
goto mod;
- case ('t'):
+ case 't':
cp->flags |= TBL_CELL_TALIGN;
goto mod;
- case ('d'):
+ case 'd':
cp->flags |= TBL_CELL_BALIGN;
goto mod;
- case ('w'): /* XXX for now, ignore minimal column width */
+ case 'w': /* XXX for now, ignore minimal column width */
goto mod;
- case ('f'):
+ case 'f':
break;
- case ('r'):
+ case 'r':
/* FALLTHROUGH */
- case ('b'):
+ case 'b':
/* FALLTHROUGH */
- case ('i'):
+ case 'i':
(*pos)--;
break;
default:
mandoc_msg(MANDOCERR_TBLLAYOUT, tbl->parse,
- ln, *pos - 1, NULL);
+ ln, *pos - 1, NULL);
return(0);
}
switch (tolower((unsigned char)p[(*pos)++])) {
- case ('3'):
+ case '3':
/* FALLTHROUGH */
- case ('b'):
+ case 'b':
cp->flags |= TBL_CELL_BOLD;
goto mod;
- case ('2'):
+ case '2':
/* FALLTHROUGH */
- case ('i'):
+ case 'i':
cp->flags |= TBL_CELL_ITALIC;
goto mod;
- case ('1'):
+ case '1':
/* FALLTHROUGH */
- case ('r'):
+ case 'r':
goto mod;
default:
break;
}
mandoc_msg(MANDOCERR_TBLLAYOUT, tbl->parse,
- ln, *pos - 1, NULL);
+ ln, *pos - 1, NULL);
return(0);
}
static int
-cell(struct tbl_node *tbl, struct tbl_row *rp,
+cell(struct tbl_node *tbl, struct tbl_row *rp,
int ln, const char *p, int *pos)
{
int vert, i;
break;
if (KEYS_MAX == i) {
- mandoc_msg(MANDOCERR_TBLLAYOUT, tbl->parse,
- ln, *pos, NULL);
+ mandoc_msg(MANDOCERR_TBLLAYOUT, tbl->parse,
+ ln, *pos, NULL);
return(0);
}
if (TBL_CELL_SPAN == c) {
if (NULL == rp->first) {
mandoc_msg(MANDOCERR_TBLLAYOUT, tbl->parse,
- ln, *pos, NULL);
+ ln, *pos, NULL);
return(0);
} else if (rp->last)
switch (rp->last->pos) {
- case (TBL_CELL_HORIZ):
- case (TBL_CELL_DHORIZ):
- mandoc_msg(MANDOCERR_TBLLAYOUT, tbl->parse,
- ln, *pos, NULL);
+ case TBL_CELL_HORIZ:
+ /* FALLTHROUGH */
+ case TBL_CELL_DHORIZ:
+ mandoc_msg(MANDOCERR_TBLLAYOUT,
+ tbl->parse, ln, *pos, NULL);
return(0);
default:
break;
return(mods(tbl, cell_alloc(tbl, rp, c, vert), ln, p, pos));
}
-
static void
row(struct tbl_node *tbl, int ln, const char *p, int *pos)
{
if ('.' == p[*pos]) {
tbl->part = TBL_PART_DATA;
- if (NULL == tbl->first_row)
- mandoc_msg(MANDOCERR_TBLNOLAYOUT, tbl->parse,
- ln, *pos, NULL);
+ if (NULL == tbl->first_row)
+ mandoc_msg(MANDOCERR_TBLNOLAYOUT,
+ tbl->parse, ln, *pos, NULL);
(*pos)++;
return;
}
-/* $Id: tbl_opts.c,v 1.4 2011/04/24 16:22:02 schwarze Exp $ */
+/* $Id: tbl_opts.c,v 1.5 2014/04/20 16:44:44 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
static const struct tbl_phrase keys[KEY_MAXKEYS] = {
{ "center", TBL_OPT_CENTRE, KEY_CENTRE},
{ "centre", TBL_OPT_CENTRE, KEY_CENTRE},
- { "delim", 0, KEY_DELIM},
+ { "delim", 0, KEY_DELIM},
{ "expand", TBL_OPT_EXPAND, KEY_EXPAND},
- { "box", TBL_OPT_BOX, KEY_BOX},
- { "doublebox", TBL_OPT_DBOX, KEY_DBOX},
+ { "box", TBL_OPT_BOX, KEY_BOX},
+ { "doublebox", TBL_OPT_DBOX, KEY_DBOX},
{ "allbox", TBL_OPT_ALLBOX, KEY_ALLBOX},
{ "frame", TBL_OPT_BOX, KEY_FRAME},
{ "doubleframe", TBL_OPT_DBOX, KEY_DFRAME},
{ "nospaces", TBL_OPT_NOSPACE, KEY_NOSPACE},
};
-static int arg(struct tbl_node *, int,
+static int arg(struct tbl_node *, int,
const char *, int *, enum tbl_ident);
-static void opt(struct tbl_node *, int,
+static void opt(struct tbl_node *, int,
const char *, int *);
+
static int
arg(struct tbl_node *tbl, int ln, const char *p, int *pos, enum tbl_ident key)
{
/* Arguments always begin with a parenthesis. */
if ('(' != p[*pos]) {
- mandoc_msg(MANDOCERR_TBL, tbl->parse,
- ln, *pos, NULL);
+ mandoc_msg(MANDOCERR_TBL, tbl->parse,
+ ln, *pos, NULL);
return(0);
}
*/
switch (key) {
- case (KEY_DELIM):
+ case KEY_DELIM:
if ('\0' == p[(*pos)++]) {
mandoc_msg(MANDOCERR_TBL, tbl->parse,
- ln, *pos - 1, NULL);
+ ln, *pos - 1, NULL);
return(0);
- }
+ }
if ('\0' == p[(*pos)++]) {
mandoc_msg(MANDOCERR_TBL, tbl->parse,
- ln, *pos - 1, NULL);
+ ln, *pos - 1, NULL);
return(0);
- }
+ }
break;
- case (KEY_TAB):
+ case KEY_TAB:
if ('\0' != (tbl->opts.tab = p[(*pos)++]))
break;
mandoc_msg(MANDOCERR_TBL, tbl->parse,
- ln, *pos - 1, NULL);
+ ln, *pos - 1, NULL);
return(0);
- case (KEY_LINESIZE):
+ case KEY_LINESIZE:
for (i = 0; i < KEY_MAXNUMSZ && p[*pos]; i++, (*pos)++) {
buf[i] = p[*pos];
if ( ! isdigit((unsigned char)buf[i]))
mandoc_msg(MANDOCERR_TBL, tbl->parse, ln, *pos, NULL);
return(0);
- case (KEY_DPOINT):
+ case KEY_DPOINT:
if ('\0' != (tbl->opts.decimal = p[(*pos)++]))
break;
- mandoc_msg(MANDOCERR_TBL, tbl->parse,
- ln, *pos - 1, NULL);
+ mandoc_msg(MANDOCERR_TBL, tbl->parse,
+ ln, *pos - 1, NULL);
return(0);
default:
abort();
* options ::= option_list [:space:]* [;][\n]
* option_list ::= option option_tail
* option_tail ::= [:space:]+ option_list |
- * ::= epsilon
+ * ::= epsilon
* option ::= [:alpha:]+ args
* args ::= [:space:]* [(] [:alpha:]+ [)]
*/
while (isspace((unsigned char)p[*pos]))
(*pos)++;
- /*
+ /*
* Look through all of the available keys to find one that
* matches the input. FIXME: hashtable this.
*/
* of the sequence altogether.
*/
- if (keys[i].key)
+ if (keys[i].key)
tbl->opts.opts |= keys[i].key;
else if ( ! arg(tbl, ln, p, pos, keys[i].ident))
return;
break;
}
- /*
+ /*
* Allow us to recover from bad options by continuing to another
* parse sequence.
*/
-/* $Id: tbl_term.c,v 1.15 2014/03/28 23:25:54 schwarze Exp $ */
+/* $Id: tbl_term.c,v 1.16 2014/04/20 16:44:44 schwarze Exp $ */
/*
* Copyright (c) 2009, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011, 2012, 2014 Ingo Schwarze <schwarze@openbsd.org>
static size_t term_tbl_strlen(const char *, void *);
static void tbl_char(struct termp *, char, size_t);
static void tbl_data(struct termp *, const struct tbl_opts *,
- const struct tbl_dat *,
+ const struct tbl_dat *,
const struct roffcol *);
static size_t tbl_rulewidth(struct termp *, const struct tbl_head *);
static void tbl_hframe(struct termp *, const struct tbl_span *, int);
-static void tbl_literal(struct termp *, const struct tbl_dat *,
+static void tbl_literal(struct termp *, const struct tbl_dat *,
const struct roffcol *);
-static void tbl_number(struct termp *, const struct tbl_opts *,
- const struct tbl_dat *,
+static void tbl_number(struct termp *, const struct tbl_opts *,
+ const struct tbl_dat *,
const struct roffcol *);
static void tbl_hrule(struct termp *, const struct tbl_span *);
static void tbl_vrule(struct termp *, const struct tbl_head *);
const struct tbl_dat *dp;
struct roffcol *col;
int spans;
- size_t rmargin, maxrmargin;
+ size_t rmargin, maxrmargin;
rmargin = tp->rmargin;
maxrmargin = tp->maxrmargin;
if ((TBL_OPT_BOX | TBL_OPT_DBOX) & sp->opts->opts ||
sp->head->vert)
term_word(tp, TBL_SPAN_HORIZ == sp->pos ||
- TBL_SPAN_DHORIZ == sp->pos ? "+" : "|");
+ TBL_SPAN_DHORIZ == sp->pos ? "+" : "|");
/*
* Now print the actual data itself depending on the span type.
*/
switch (sp->pos) {
- case (TBL_SPAN_HORIZ):
+ case TBL_SPAN_HORIZ:
/* FALLTHROUGH */
- case (TBL_SPAN_DHORIZ):
+ case TBL_SPAN_DHORIZ:
tbl_hrule(tp, sp);
break;
- case (TBL_SPAN_DATA):
+ case TBL_SPAN_DATA:
/* Iterate over template headers. */
dp = sp->first;
spans = 0;
for (hp = sp->head; hp; hp = hp->next) {
- /*
+ /*
* If the current data header is invoked during
* a spanner ("spans" > 0), don't emit anything
* at all.
col = &tp->tbl.cols[hp->ident];
tbl_data(tp, sp->opts, dp, col);
- /*
+ /*
* Go to the next data cell and assign the
* number of subsequent spans, if applicable.
*/
if ((TBL_OPT_BOX | TBL_OPT_DBOX) & sp->opts->opts ||
sp->layout->vert)
term_word(tp, TBL_SPAN_HORIZ == sp->pos ||
- TBL_SPAN_DHORIZ == sp->pos ? "+" : " |");
+ TBL_SPAN_DHORIZ == sp->pos ? "+" : " |");
term_flushln(tp);
/*
static void
tbl_data(struct termp *tp, const struct tbl_opts *opts,
- const struct tbl_dat *dp,
- const struct roffcol *col)
+ const struct tbl_dat *dp,
+ const struct roffcol *col)
{
if (NULL == dp) {
assert(dp->layout);
switch (dp->pos) {
- case (TBL_DATA_NONE):
+ case TBL_DATA_NONE:
tbl_char(tp, ASCII_NBRSP, col->width);
return;
- case (TBL_DATA_HORIZ):
+ case TBL_DATA_HORIZ:
/* FALLTHROUGH */
- case (TBL_DATA_NHORIZ):
+ case TBL_DATA_NHORIZ:
tbl_char(tp, '-', col->width);
return;
- case (TBL_DATA_NDHORIZ):
+ case TBL_DATA_NDHORIZ:
/* FALLTHROUGH */
- case (TBL_DATA_DHORIZ):
+ case TBL_DATA_DHORIZ:
tbl_char(tp, '=', col->width);
return;
default:
break;
}
-
+
switch (dp->layout->pos) {
- case (TBL_CELL_HORIZ):
+ case TBL_CELL_HORIZ:
tbl_char(tp, '-', col->width);
break;
- case (TBL_CELL_DHORIZ):
+ case TBL_CELL_DHORIZ:
tbl_char(tp, '=', col->width);
break;
- case (TBL_CELL_LONG):
+ case TBL_CELL_LONG:
/* FALLTHROUGH */
- case (TBL_CELL_CENTRE):
+ case TBL_CELL_CENTRE:
/* FALLTHROUGH */
- case (TBL_CELL_LEFT):
+ case TBL_CELL_LEFT:
/* FALLTHROUGH */
- case (TBL_CELL_RIGHT):
+ case TBL_CELL_RIGHT:
tbl_literal(tp, dp, col);
break;
- case (TBL_CELL_NUMBER):
+ case TBL_CELL_NUMBER:
tbl_number(tp, opts, dp, col);
break;
- case (TBL_CELL_DOWN):
+ case TBL_CELL_DOWN:
tbl_char(tp, ASCII_NBRSP, col->width);
break;
default:
}
static void
-tbl_literal(struct termp *tp, const struct tbl_dat *dp,
+tbl_literal(struct termp *tp, const struct tbl_dat *dp,
const struct roffcol *col)
{
struct tbl_head *hp;
padl = 0;
switch (dp->layout->pos) {
- case (TBL_CELL_LONG):
+ case TBL_CELL_LONG:
padl = term_len(tp, 1);
padr = padr > padl ? padr - padl : 0;
break;
- case (TBL_CELL_CENTRE):
+ case TBL_CELL_CENTRE:
if (2 > padr)
break;
padl = padr / 2;
padr -= padl;
break;
- case (TBL_CELL_RIGHT):
+ case TBL_CELL_RIGHT:
padl = padr;
padr = 0;
break;
-/* $Id: term.c,v 1.82 2014/04/08 07:13:01 schwarze Exp $ */
+/* $Id: term.c,v 1.83 2014/04/20 16:44:44 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
static void encode(struct termp *, const char *, size_t);
static void encode1(struct termp *, int);
+
void
term_free(struct termp *p)
{
free(p);
}
-
void
-term_begin(struct termp *p, term_margin head,
+term_begin(struct termp *p, term_margin head,
term_margin foot, const void *arg)
{
(*p->begin)(p);
}
-
void
term_end(struct termp *p)
{
/* Regular word. */
/* Break at the hyphen point if we overrun. */
- if (vend > vis && vend < bp &&
+ if (vend > vis && vend < bp &&
(ASCII_HYPH == p->buf[j] ||
ASCII_BREAK == p->buf[j]))
jhy = j;
(*p->letter)(p, p->buf[i]);
if (8 == p->buf[i])
p->viscol -= (*p->width)(p, p->buf[i-1]);
- else
+ else
p->viscol += (*p->width)(p, p->buf[i]);
}
vis = vend;
if (TERMP_HANG & p->flags) {
p->overstep = (int)(vis - maxvis +
- p->trailspace * (*p->width)(p, ' '));
+ p->trailspace * (*p->width)(p, ' '));
/*
* If we have overstepped the margin, temporarily move
}
}
-
-/*
+/*
* A newline only breaks an existing line; it won't assert vertical
* space. All data in the output buffer is flushed prior to the newline
* assertion.
term_flushln(p);
}
-
/*
* Asserts a vertical space (a full, empty line-break between lines).
* Note that if used twice, this will cause two blank spaces and so on.
p->fontq[p->fonti] = f;
}
-
void
term_fontrepl(struct termp *p, enum termfont f)
{
p->fontq[p->fonti] = f;
}
-
void
term_fontpush(struct termp *p, enum termfont f)
{
p->fontq[++p->fonti] = f;
}
-
const void *
term_fontq(struct termp *p)
{
return(&p->fontq[p->fonti]);
}
-
enum termfont
term_fonttop(struct termp *p)
{
return(p->fontq[p->fonti]);
}
-
void
term_fontpopq(struct termp *p, const void *key)
{
assert(p->fonti >= 0);
}
-
void
term_fontpop(struct termp *p)
{
if (TERMENC_ASCII != p->enc)
switch (esc) {
- case (ESCAPE_UNICODE):
+ case ESCAPE_UNICODE:
uc = mchars_num2uc(seq + 1, sz - 1);
if ('\0' == uc)
break;
encode1(p, uc);
continue;
- case (ESCAPE_SPECIAL):
+ case ESCAPE_SPECIAL:
uc = mchars_spec2cp(p->symtab, seq, sz);
if (uc <= 0)
break;
}
switch (esc) {
- case (ESCAPE_UNICODE):
+ case ESCAPE_UNICODE:
encode1(p, '?');
break;
- case (ESCAPE_NUMBERED):
+ case ESCAPE_NUMBERED:
c = mchars_num2char(seq, sz);
if ('\0' != c)
encode(p, &c, 1);
break;
- case (ESCAPE_SPECIAL):
+ case ESCAPE_SPECIAL:
cp = mchars_spec2str(p->symtab, seq, sz, &ssz);
- if (NULL != cp)
+ if (NULL != cp)
encode(p, cp, ssz);
else if (1 == ssz)
encode(p, seq, sz);
break;
- case (ESCAPE_FONTBOLD):
+ case ESCAPE_FONTBOLD:
term_fontrepl(p, TERMFONT_BOLD);
break;
- case (ESCAPE_FONTITALIC):
+ case ESCAPE_FONTITALIC:
term_fontrepl(p, TERMFONT_UNDER);
break;
- case (ESCAPE_FONTBI):
+ case ESCAPE_FONTBI:
term_fontrepl(p, TERMFONT_BI);
break;
- case (ESCAPE_FONT):
+ case ESCAPE_FONT:
/* FALLTHROUGH */
- case (ESCAPE_FONTROMAN):
+ case ESCAPE_FONTROMAN:
term_fontrepl(p, TERMFONT_NONE);
break;
- case (ESCAPE_FONTPREV):
+ case ESCAPE_FONTPREV:
term_fontlast(p);
break;
- case (ESCAPE_NOSPACE):
+ case ESCAPE_NOSPACE:
if (TERMP_SKIPCHAR & p->flags)
p->flags &= ~TERMP_SKIPCHAR;
else if ('\0' == *word)
p->flags |= TERMP_NOSPACE;
break;
- case (ESCAPE_SKIPCHAR):
+ case ESCAPE_SKIPCHAR:
p->flags |= TERMP_SKIPCHAR;
break;
default:
*/
if (TERMFONT_NONE == term_fonttop(p)) {
- if (p->col + sz >= p->maxcols)
+ if (p->col + sz >= p->maxcols)
adjbuf(p, p->col + sz);
for (i = 0; i < sz; i++)
p->buf[p->col++] = word[i];
width = 0;
if (NULL != wstr) {
switch (*wstr) {
- case ('+'):
+ case '+':
iop = 1;
wstr++;
break;
- case ('-'):
+ case '-':
iop = -1;
wstr++;
break;
sz += cond_width(p, *cp++, &skip);
switch (*cp) {
- case ('\\'):
+ case '\\':
cp++;
esc = mandoc_escape(&cp, &seq, &ssz);
if (ESCAPE_ERROR == esc)
if (TERMENC_ASCII != p->enc)
switch (esc) {
- case (ESCAPE_UNICODE):
- c = mchars_num2uc
- (seq + 1, ssz - 1);
+ case ESCAPE_UNICODE:
+ c = mchars_num2uc(seq + 1,
+ ssz - 1);
if ('\0' == c)
break;
sz += cond_width(p, c, &skip);
continue;
- case (ESCAPE_SPECIAL):
- c = mchars_spec2cp
- (p->symtab, seq, ssz);
+ case ESCAPE_SPECIAL:
+ c = mchars_spec2cp(p->symtab,
+ seq, ssz);
if (c <= 0)
break;
sz += cond_width(p, c, &skip);
rhs = NULL;
switch (esc) {
- case (ESCAPE_UNICODE):
+ case ESCAPE_UNICODE:
sz += cond_width(p, '?', &skip);
break;
- case (ESCAPE_NUMBERED):
+ case ESCAPE_NUMBERED:
c = mchars_num2char(seq, ssz);
if ('\0' != c)
sz += cond_width(p, c, &skip);
break;
- case (ESCAPE_SPECIAL):
- rhs = mchars_spec2str
- (p->symtab, seq, ssz, &rsz);
+ case ESCAPE_SPECIAL:
+ rhs = mchars_spec2str(p->symtab,
+ seq, ssz, &rsz);
if (ssz != 1 || rhs)
break;
rhs = seq;
rsz = ssz;
break;
- case (ESCAPE_SKIPCHAR):
+ case ESCAPE_SKIPCHAR:
skip = 1;
break;
default:
for (i = 0; i < rsz; i++)
sz += (*p->width)(p, *rhs++);
break;
- case (ASCII_NBRSP):
+ case ASCII_NBRSP:
sz += cond_width(p, ' ', &skip);
cp++;
break;
- case (ASCII_HYPH):
+ case ASCII_HYPH:
sz += cond_width(p, '-', &skip);
cp++;
/* FALLTHROUGH */
- case (ASCII_BREAK):
+ case ASCII_BREAK:
break;
default:
break;
return(sz);
}
-/* ARGSUSED */
size_t
term_vspan(const struct termp *p, const struct roffsu *su)
{
double r;
switch (su->unit) {
- case (SCALE_CM):
+ case SCALE_CM:
r = su->scale * 2;
break;
- case (SCALE_IN):
+ case SCALE_IN:
r = su->scale * 6;
break;
- case (SCALE_PC):
+ case SCALE_PC:
r = su->scale;
break;
- case (SCALE_PT):
+ case SCALE_PT:
r = su->scale / 8;
break;
- case (SCALE_MM):
+ case SCALE_MM:
r = su->scale / 1000;
break;
- case (SCALE_VS):
+ case SCALE_VS:
r = su->scale;
break;
default:
if (r < 0.0)
r = 0.0;
- return(/* LINTED */(size_t)
- r);
+ return((size_t)r);
}
size_t
v = ((*p->hspan)(p, su));
if (v < 0.0)
v = 0.0;
- return((size_t) /* LINTED */
- v);
+ return((size_t)v);
}
-/* $Id: term.h,v 1.44 2014/04/08 07:13:01 schwarze Exp $ */
+/* $Id: term.h,v 1.45 2014/04/20 16:44:44 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
void term_vspace(struct termp *);
void term_word(struct termp *, const char *);
void term_flushln(struct termp *);
-void term_begin(struct termp *, term_margin,
+void term_begin(struct termp *, term_margin,
term_margin, const void *);
void term_end(struct termp *);
void term_setwidth(struct termp *, const char *);
-size_t term_hspan(const struct termp *,
+size_t term_hspan(const struct termp *,
const struct roffsu *);
size_t term_vspan(const struct termp *,
const struct roffsu *);
-/* $Id: term_ascii.c,v 1.13 2014/03/30 21:27:59 schwarze Exp $ */
+/* $Id: term_ascii.c,v 1.14 2014/04/20 16:44:44 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org>
static void locale_letter(struct termp *, int);
static size_t locale_width(const struct termp *, int);
+
static struct termp *
ascii_init(enum termenc enc, char *outopts)
{
if (TERMENC_ASCII != enc) {
v = TERMENC_LOCALE == enc ?
- setlocale(LC_ALL, "") :
- setlocale(LC_CTYPE, "en_US.UTF-8");
+ setlocale(LC_ALL, "") :
+ setlocale(LC_CTYPE, "en_US.UTF-8");
if (NULL != v && MB_CUR_MAX > 1) {
p->enc = enc;
p->advance = locale_advance;
while (outopts && *outopts)
switch (getsubopt(&outopts, UNCONST(toks), &v)) {
- case (0):
+ case 0:
p->defindent = (size_t)atoi(v);
break;
- case (1):
+ case 1:
p->defrmargin = (size_t)atoi(v);
break;
- case (2):
+ case 2:
/*
* Temporary, undocumented mode
* to imitate mdoc(7) output style.
return(ascii_init(TERMENC_UTF8, outopts));
}
-
void *
locale_alloc(char *outopts)
{
p->rmargin = p->maxrmargin = p->defrmargin;
}
-/* ARGSUSED */
static size_t
ascii_width(const struct termp *p, int c)
{
term_free((struct termp *)arg);
}
-/* ARGSUSED */
static void
ascii_letter(struct termp *p, int c)
{
-
+
putchar(c);
}
(*p->footf)(p, p->argf);
}
-/* ARGSUSED */
static void
ascii_endline(struct termp *p)
{
putchar('\n');
}
-/* ARGSUSED */
static void
ascii_advance(struct termp *p, size_t len)
{
- size_t i;
+ size_t i;
for (i = 0; i < len; i++)
putchar(' ');
}
-/* ARGSUSED */
static double
ascii_hspan(const struct termp *p, const struct roffsu *su)
{
*/
switch (su->unit) {
- case (SCALE_CM):
+ case SCALE_CM:
r = 4 * su->scale;
break;
- case (SCALE_IN):
+ case SCALE_IN:
r = 10 * su->scale;
break;
- case (SCALE_PC):
+ case SCALE_PC:
r = (10 * su->scale) / 6;
break;
- case (SCALE_PT):
+ case SCALE_PT:
r = (10 * su->scale) / 72;
break;
- case (SCALE_MM):
+ case SCALE_MM:
r = su->scale / 1000;
break;
- case (SCALE_VS):
+ case SCALE_VS:
r = su->scale * 2 - 1;
break;
default:
return(r);
}
-/* ARGSUSED */
static size_t
locale_width(const struct termp *p, int c)
{
return((rc = wcwidth(c)) < 0 ? 0 : rc);
}
-/* ARGSUSED */
static void
locale_advance(struct termp *p, size_t len)
{
- size_t i;
+ size_t i;
for (i = 0; i < len; i++)
putwchar(L' ');
}
-/* ARGSUSED */
static void
locale_endline(struct termp *p)
{
putwchar(L'\n');
}
-/* ARGSUSED */
static void
locale_letter(struct termp *p, int c)
{
-
+
putwchar(c);
}
-/* $Id: term_ps.c,v 1.23 2014/03/30 21:27:59 schwarze Exp $ */
+/* $Id: term_ps.c,v 1.24 2014/04/20 16:44:44 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org>
#define PS_BUFSLOP 128
/* Convert PostScript point "x" to an AFM unit. */
-#define PNT2AFM(p, x) /* LINTED */ \
+#define PNT2AFM(p, x) \
(size_t)((double)(x) * (1000.0 / (double)(p)->ps->scale))
/* Convert an AFM unit "x" to a PostScript points */
-#define AFM2PNT(p, x) /* LINTED */ \
+#define AFM2PNT(p, x) \
((double)(x) / (1000.0 / (double)(p)->ps->scale))
struct glyph {
size_t left; /* body left (AFM units) */
size_t header; /* header pos (AFM units) */
size_t footer; /* footer pos (AFM units) */
- size_t pdfbytes; /* current output byte */
+ size_t pdfbytes; /* current output byte */
size_t pdflastpg; /* byte of last page mark */
size_t pdfbody; /* start of body object */
size_t *pdfobjs; /* table of object offsets */
p->letter = ps_letter;
p->setwidth = ps_setwidth;
p->width = ps_width;
-
+
toks[0] = "paper";
toks[1] = NULL;
while (outopts && *outopts)
switch (getsubopt(&outopts, UNCONST(toks), &v)) {
- case (0):
+ case 0:
pp = v;
break;
default:
fprintf(stderr, "%s: Unknown paper\n", pp);
}
- /*
+ /*
* This MUST be defined before any PNT2AFM or AFM2PNT
* calculations occur.
*/
/* Margins are 1/9 the page x and y. */
- marginx = /* LINTED */
- (size_t)((double)pagex / 9.0);
- marginy = /* LINTED */
- (size_t)((double)pagey / 9.0);
+ marginx = (size_t)((double)pagex / 9.0);
+ marginy = (size_t)((double)pagey / 9.0);
/* Line-height is 1.4em. */
return(p);
}
-
static void
ps_setwidth(struct termp *p, int iop, size_t width)
{
p->ps->lastwidth = lastwidth;
}
-
void
pspdf_free(void *arg)
{
term_free(p);
}
-
static void
ps_printf(struct termp *p, const char *fmt, ...)
{
if ( ! (PS_MARGINS & p->ps->flags)) {
len = vprintf(fmt, ap);
va_end(ap);
- p->ps->pdfbytes += /* LINTED */
- len < 0 ? 0 : (size_t)len;
+ p->ps->pdfbytes += len < 0 ? 0 : (size_t)len;
return;
}
- /*
+ /*
* XXX: I assume that the in-margin print won't exceed
* PS_BUFSLOP (128 bytes), which is reasonable but still an
* assumption that will cause pukeage if it's not the case.
p->ps->psmargcur = strlen(p->ps->psmarg);
}
-
static void
ps_putchar(struct termp *p, char c)
{
/* See ps_printf(). */
if ( ! (PS_MARGINS & p->ps->flags)) {
- /* LINTED */
putchar(c);
p->ps->pdfbytes++;
return;
p->ps->psmarg[pos] = '\0';
}
-
static void
pdf_obj(struct termp *p, size_t obj)
{
if ((obj - 1) >= p->ps->pdfobjsz) {
p->ps->pdfobjsz = obj + 128;
- p->ps->pdfobjs = realloc
- (p->ps->pdfobjs,
- p->ps->pdfobjsz * sizeof(size_t));
+ p->ps->pdfobjs = realloc(p->ps->pdfobjs,
+ p->ps->pdfobjsz * sizeof(size_t));
if (NULL == p->ps->pdfobjs) {
perror(NULL);
exit((int)MANDOCLEVEL_SYSERR);
ps_printf(p, "%zu 0 obj\n", obj);
}
-
static void
ps_closepage(struct termp *p)
{
pdf_obj(p, base + 2);
ps_printf(p, "<<\n/ProcSet [/PDF /Text]\n");
ps_printf(p, "/Font <<\n");
- for (i = 0; i < (int)TERMFONT__MAX; i++)
+ for (i = 0; i < (int)TERMFONT__MAX; i++)
ps_printf(p, "/F%d %d 0 R\n", i, 3 + i);
ps_printf(p, ">>\n>>\n");
p->ps->flags |= PS_NEWPAGE;
}
-
-/* ARGSUSED */
static void
ps_end(struct termp *p)
{
ps_printf(p, "%%%%Pages: %zu\n", p->ps->pages);
ps_printf(p, "%%%%EOF\n");
return;
- }
+ }
pdf_obj(p, 2);
ps_printf(p, "<<\n/Type /Pages\n");
ps_printf(p, "/Kids [");
for (i = 0; i < p->ps->pages; i++)
- ps_printf(p, " %zu 0 R", i * 4 +
- p->ps->pdfbody + 3);
+ ps_printf(p, " %zu 0 R", i * 4 + p->ps->pdfbody + 3);
- base = (p->ps->pages - 1) * 4 +
- p->ps->pdfbody + 4;
+ base = (p->ps->pages - 1) * 4 + p->ps->pdfbody + 4;
ps_printf(p, "]\n>>\nendobj\n");
pdf_obj(p, base);
ps_printf(p, "0000000000 65535 f \n");
for (i = 0; i < base; i++)
- ps_printf(p, "%.10zu 00000 n \n",
- p->ps->pdfobjs[(int)i]);
+ ps_printf(p, "%.10zu 00000 n \n",
+ p->ps->pdfobjs[(int)i]);
ps_printf(p, "trailer\n");
ps_printf(p, "<<\n");
ps_printf(p, "%%%%EOF\n");
}
-
static void
ps_begin(struct termp *p)
{
time_t t;
int i;
- /*
+ /*
* Print margins into margin buffer. Nothing gets output to the
* screen yet, so we don't need to initialise the primary state.
*/
assert(p->ps->psmarg);
assert('\0' != p->ps->psmarg[0]);
- /*
+ /*
* Print header and initialise page state. Following this,
* stuff gets printed to the screen, so make sure we're sane.
*/
ps_printf(p, "%%%%Pages: (atend)\n");
ps_printf(p, "%%%%PageOrder: Ascend\n");
ps_printf(p, "%%%%DocumentMedia: "
- "Default %zu %zu 0 () ()\n",
- (size_t)AFM2PNT(p, p->ps->width),
- (size_t)AFM2PNT(p, p->ps->height));
+ "Default %zu %zu 0 () ()\n",
+ (size_t)AFM2PNT(p, p->ps->width),
+ (size_t)AFM2PNT(p, p->ps->height));
ps_printf(p, "%%%%DocumentNeededResources: font");
for (i = 0; i < (int)TERMFONT__MAX; i++)
ps_setfont(p, TERMFONT_NONE);
}
-
static void
ps_pletter(struct termp *p, int c)
{
if (PS_NEWPAGE & p->ps->flags) {
if (TERMTYPE_PS == p->type) {
- ps_printf(p, "%%%%Page: %zu %zu\n",
- p->ps->pages + 1,
- p->ps->pages + 1);
- ps_printf(p, "/%s %zu selectfont\n",
- fonts[(int)p->ps->lastf].name,
- p->ps->scale);
+ ps_printf(p, "%%%%Page: %zu %zu\n",
+ p->ps->pages + 1, p->ps->pages + 1);
+ ps_printf(p, "/%s %zu selectfont\n",
+ fonts[(int)p->ps->lastf].name,
+ p->ps->scale);
} else {
- pdf_obj(p, p->ps->pdfbody +
- p->ps->pages * 4);
+ pdf_obj(p, p->ps->pdfbody +
+ p->ps->pages * 4);
ps_printf(p, "<<\n");
- ps_printf(p, "/Length %zu 0 R\n",
- p->ps->pdfbody + 1 +
- p->ps->pages * 4);
+ ps_printf(p, "/Length %zu 0 R\n",
+ p->ps->pdfbody + 1 + p->ps->pages * 4);
ps_printf(p, ">>\nstream\n");
}
p->ps->pdflastpg = p->ps->pdfbytes;
p->ps->flags &= ~PS_NEWPAGE;
}
-
+
/*
* If we're not in a PostScript "word" context, then open one
* now at the current cursor.
if ( ! (PS_INLINE & p->ps->flags)) {
if (TERMTYPE_PS != p->type) {
- ps_printf(p, "BT\n/F%d %zu Tf\n",
- (int)p->ps->lastf,
- p->ps->scale);
+ ps_printf(p, "BT\n/F%d %zu Tf\n",
+ (int)p->ps->lastf, p->ps->scale);
ps_printf(p, "%.3f %.3f Td\n(",
- AFM2PNT(p, p->ps->pscol),
- AFM2PNT(p, p->ps->psrow));
+ AFM2PNT(p, p->ps->pscol),
+ AFM2PNT(p, p->ps->psrow));
} else
- ps_printf(p, "%.3f %.3f moveto\n(",
- AFM2PNT(p, p->ps->pscol),
- AFM2PNT(p, p->ps->psrow));
+ ps_printf(p, "%.3f %.3f moveto\n(",
+ AFM2PNT(p, p->ps->pscol),
+ AFM2PNT(p, p->ps->psrow));
p->ps->flags |= PS_INLINE;
}
*/
switch (c) {
- case ('('):
+ case '(':
/* FALLTHROUGH */
- case (')'):
+ case ')':
/* FALLTHROUGH */
- case ('\\'):
+ case '\\':
ps_putchar(p, '\\');
break;
default:
ps_putchar(p, ' ');
p->ps->pscol += (size_t)fonts[f].gly[0].wx;
return;
- }
+ }
ps_putchar(p, (char)c);
c -= 32;
p->ps->pscol += (size_t)fonts[f].gly[c].wx;
}
-
static void
ps_pclose(struct termp *p)
{
- /*
+ /*
* Spit out that we're exiting a word context (this is a
* "partial close" because we don't check the last-char buffer
* or anything).
if ( ! (PS_INLINE & p->ps->flags))
return;
-
+
if (TERMTYPE_PS != p->type) {
ps_printf(p, ") Tj\nET\n");
} else
p->ps->flags &= ~PS_INLINE;
}
-
static void
ps_fclose(struct termp *p)
{
ps_pclose(p);
}
-
static void
ps_letter(struct termp *p, int arg)
{
char cc, c;
- /* LINTED */
c = arg >= 128 || arg <= 0 ? '?' : arg;
/*
ps_pletter(p, c);
}
-
static void
ps_advance(struct termp *p, size_t len)
{
p->ps->pscol += len;
}
-
static void
ps_endline(struct termp *p)
{
/*
* If we're in the margin, don't try to recalculate our current
* row. XXX: if the column tries to be fancy with multiple
- * lines, we'll do nasty stuff.
+ * lines, we'll do nasty stuff.
*/
if (PS_MARGINS & p->ps->flags)
* showpage and restart our row.
*/
- if (p->ps->psrow >= p->ps->lineheight +
- p->ps->bottom) {
+ if (p->ps->psrow >= p->ps->lineheight + p->ps->bottom) {
p->ps->psrow -= p->ps->lineheight;
return;
}
ps_closepage(p);
}
-
static void
ps_setfont(struct termp *p, enum termfont f)
{
assert(f < TERMFONT__MAX);
p->ps->lastf = f;
-
+
/*
* If we're still at the top of the page, let the font-setting
* be delayed until we actually have stuff to print.
return;
if (TERMTYPE_PS == p->type)
- ps_printf(p, "/%s %zu selectfont\n",
- fonts[(int)f].name,
- p->ps->scale);
+ ps_printf(p, "/%s %zu selectfont\n",
+ fonts[(int)f].name, p->ps->scale);
else
- ps_printf(p, "/F%d %zu Tf\n",
- (int)f,
- p->ps->scale);
+ ps_printf(p, "/F%d %zu Tf\n",
+ (int)f, p->ps->scale);
}
-
-/* ARGSUSED */
static size_t
ps_width(const struct termp *p, int c)
{
return((size_t)fonts[(int)TERMFONT_NONE].gly[c].wx);
}
-
static double
ps_hspan(const struct termp *p, const struct roffsu *su)
{
double r;
-
+
/*
* All of these measurements are derived by converting from the
* native measurement to AFM units.
*/
switch (su->unit) {
- case (SCALE_CM):
+ case SCALE_CM:
r = PNT2AFM(p, su->scale * 28.34);
break;
- case (SCALE_IN):
+ case SCALE_IN:
r = PNT2AFM(p, su->scale * 72);
break;
- case (SCALE_PC):
+ case SCALE_PC:
r = PNT2AFM(p, su->scale * 12);
break;
- case (SCALE_PT):
+ case SCALE_PT:
r = PNT2AFM(p, su->scale * 100);
break;
- case (SCALE_EM):
+ case SCALE_EM:
r = su->scale *
- fonts[(int)TERMFONT_NONE].gly[109 - 32].wx;
+ fonts[(int)TERMFONT_NONE].gly[109 - 32].wx;
break;
- case (SCALE_MM):
+ case SCALE_MM:
r = PNT2AFM(p, su->scale * 2.834);
break;
- case (SCALE_EN):
+ case SCALE_EN:
r = su->scale *
- fonts[(int)TERMFONT_NONE].gly[110 - 32].wx;
+ fonts[(int)TERMFONT_NONE].gly[110 - 32].wx;
break;
- case (SCALE_VS):
+ case SCALE_VS:
r = su->scale * p->ps->lineheight;
break;
default:
p->ps->psmarg = mandoc_realloc
(p->ps->psmarg, p->ps->psmargsz);
}
-
-/* $Id: tree.c,v 1.20 2014/03/08 15:50:21 schwarze Exp $ */
+/* $Id: tree.c,v 1.21 2014/04/20 16:44:44 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
static void print_span(const struct tbl_span *, int);
-/* ARGSUSED */
void
tree_mdoc(void *arg, const struct mdoc *mdoc)
{
print_mdoc(mdoc_node(mdoc), 0);
}
-
-/* ARGSUSED */
void
tree_man(void *arg, const struct man *man)
{
print_man(man_node(man), 0);
}
-
static void
print_mdoc(const struct mdoc_node *n, int indent)
{
t = p = NULL;
switch (n->type) {
- case (MDOC_ROOT):
+ case MDOC_ROOT:
t = "root";
break;
- case (MDOC_BLOCK):
+ case MDOC_BLOCK:
t = "block";
break;
- case (MDOC_HEAD):
+ case MDOC_HEAD:
t = "block-head";
break;
- case (MDOC_BODY):
+ case MDOC_BODY:
if (n->end)
t = "body-end";
else
t = "block-body";
break;
- case (MDOC_TAIL):
+ case MDOC_TAIL:
t = "block-tail";
break;
- case (MDOC_ELEM):
+ case MDOC_ELEM:
t = "elem";
break;
- case (MDOC_TEXT):
+ case MDOC_TEXT:
t = "text";
break;
- case (MDOC_TBL):
+ case MDOC_TBL:
/* FALLTHROUGH */
- case (MDOC_EQN):
+ case MDOC_EQN:
break;
default:
abort();
}
switch (n->type) {
- case (MDOC_TEXT):
+ case MDOC_TEXT:
p = n->string;
break;
- case (MDOC_BODY):
+ case MDOC_BODY:
p = mdoc_macronames[n->tok];
break;
- case (MDOC_HEAD):
+ case MDOC_HEAD:
p = mdoc_macronames[n->tok];
break;
- case (MDOC_TAIL):
+ case MDOC_TAIL:
p = mdoc_macronames[n->tok];
break;
- case (MDOC_ELEM):
+ case MDOC_ELEM:
p = mdoc_macronames[n->tok];
if (n->args) {
argv = n->args->argv;
argc = n->args->argc;
}
break;
- case (MDOC_BLOCK):
+ case MDOC_BLOCK:
p = mdoc_macronames[n->tok];
if (n->args) {
argv = n->args->argv;
argc = n->args->argc;
}
break;
- case (MDOC_TBL):
+ case MDOC_TBL:
/* FALLTHROUGH */
- case (MDOC_EQN):
+ case MDOC_EQN:
break;
- case (MDOC_ROOT):
+ case MDOC_ROOT:
p = "root";
break;
default:
print_mdoc(n->next, indent);
}
-
static void
print_man(const struct man_node *n, int indent)
{
t = p = NULL;
switch (n->type) {
- case (MAN_ROOT):
+ case MAN_ROOT:
t = "root";
break;
- case (MAN_ELEM):
+ case MAN_ELEM:
t = "elem";
break;
- case (MAN_TEXT):
+ case MAN_TEXT:
t = "text";
break;
- case (MAN_BLOCK):
+ case MAN_BLOCK:
t = "block";
break;
- case (MAN_HEAD):
+ case MAN_HEAD:
t = "block-head";
break;
- case (MAN_BODY):
+ case MAN_BODY:
t = "block-body";
break;
- case (MAN_TAIL):
+ case MAN_TAIL:
t = "block-tail";
break;
- case (MAN_TBL):
+ case MAN_TBL:
/* FALLTHROUGH */
- case (MAN_EQN):
+ case MAN_EQN:
break;
default:
abort();
}
switch (n->type) {
- case (MAN_TEXT):
+ case MAN_TEXT:
p = n->string;
break;
- case (MAN_ELEM):
+ case MAN_ELEM:
/* FALLTHROUGH */
- case (MAN_BLOCK):
+ case MAN_BLOCK:
/* FALLTHROUGH */
- case (MAN_HEAD):
+ case MAN_HEAD:
/* FALLTHROUGH */
- case (MAN_TAIL):
+ case MAN_TAIL:
/* FALLTHROUGH */
- case (MAN_BODY):
+ case MAN_BODY:
p = man_macronames[n->tok];
break;
- case (MAN_ROOT):
+ case MAN_ROOT:
p = "root";
break;
- case (MAN_TBL):
+ case MAN_TBL:
/* FALLTHROUGH */
- case (MAN_EQN):
+ case MAN_EQN:
break;
default:
abort();
t = NULL;
switch (ep->type) {
- case (EQN_ROOT):
+ case EQN_ROOT:
t = "eqn-root";
break;
- case (EQN_LIST):
+ case EQN_LIST:
t = "eqn-list";
break;
- case (EQN_SUBEXPR):
+ case EQN_SUBEXPR:
t = "eqn-expr";
break;
- case (EQN_TEXT):
+ case EQN_TEXT:
t = "eqn-text";
break;
- case (EQN_MATRIX):
+ case EQN_MATRIX:
t = "eqn-matrix";
break;
}
assert(t);
- printf("%s(%d, %d, %d, %d, %d, \"%s\", \"%s\") %s\n",
- t, EQN_DEFSIZE == ep->size ? 0 : ep->size,
- ep->pos, ep->font, ep->mark, ep->pile,
- ep->left ? ep->left : "",
- ep->right ? ep->right : "",
- ep->text ? ep->text : "");
+ printf("%s(%d, %d, %d, %d, %d, \"%s\", \"%s\") %s\n",
+ t, EQN_DEFSIZE == ep->size ? 0 : ep->size,
+ ep->pos, ep->font, ep->mark, ep->pile,
+ ep->left ? ep->left : "",
+ ep->right ? ep->right : "",
+ ep->text ? ep->text : "");
print_box(ep->first, indent + 1);
print_box(ep->next, indent);
putchar('\t');
switch (sp->pos) {
- case (TBL_SPAN_HORIZ):
+ case TBL_SPAN_HORIZ:
putchar('-');
return;
- case (TBL_SPAN_DHORIZ):
+ case TBL_SPAN_DHORIZ:
putchar('=');
return;
default:
for (dp = sp->first; dp; dp = dp->next) {
switch (dp->pos) {
- case (TBL_DATA_HORIZ):
+ case TBL_DATA_HORIZ:
/* FALLTHROUGH */
- case (TBL_DATA_NHORIZ):
+ case TBL_DATA_NHORIZ:
putchar('-');
continue;
- case (TBL_DATA_DHORIZ):
+ case TBL_DATA_DHORIZ:
/* FALLTHROUGH */
- case (TBL_DATA_NDHORIZ):
+ case TBL_DATA_NDHORIZ:
putchar('=');
continue;
default: