Almost completely mechanical, no functional change.
Written on the train from Exeter to London returning from p2k15.
-/* $OpenBSD: cgi.c,v 1.45 2015/03/27 21:17:16 schwarze Exp $ */
+/* $OpenBSD: cgi.c,v 1.46 2015/04/18 16:04:40 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@usta.de>
struct manoutput conf;
struct mparse *mp;
struct mchars *mchars;
- struct mdoc *mdoc;
- struct man *man;
+ struct roff_man *mdoc;
+ struct roff_man *man;
void *vp;
int fd;
int usepath;
-/* $OpenBSD: libman.h,v 1.45 2015/04/02 23:47:43 schwarze Exp $ */
+/* $OpenBSD: libman.h,v 1.46 2015/04/18 16:04:40 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-enum man_next {
- MAN_NEXT_SIBLING = 0,
- MAN_NEXT_CHILD
-};
-
-struct man {
- struct mparse *parse; /* parse pointer */
- const char *defos; /* default OS argument for .TH */
- int quick; /* abort parse early */
- int flags; /* parse flags */
-#define MAN_ELINE (1 << 1) /* Next-line element scope. */
-#define MAN_BLINE (1 << 2) /* Next-line block scope. */
-#define MAN_LITERAL (1 << 4) /* Literal input. */
-#define MAN_NEWLINE (1 << 6) /* first macro/text in a line */
- enum man_next next; /* where to put the next node */
- struct roff_node *last; /* the last parsed node */
- struct roff_node *first; /* the first parsed node */
- struct roff_meta meta; /* document meta-data */
- struct roff *roff;
-};
-
-#define MACRO_PROT_ARGS struct man *man, \
+#define MACRO_PROT_ARGS struct roff_man *man, \
int tok, \
int line, \
int ppos, \
__BEGIN_DECLS
-void man_word_alloc(struct man *, int, int, const char *);
-void man_word_append(struct man *, const char *);
-void man_block_alloc(struct man *, int, int, int);
-void man_head_alloc(struct man *, int, int, int);
-void man_body_alloc(struct man *, int, int, int);
-void man_elem_alloc(struct man *, int, int, int);
-void man_node_delete(struct man *, struct roff_node *);
+void man_word_alloc(struct roff_man *, int, int, const char *);
+void man_word_append(struct roff_man *, const char *);
+void man_block_alloc(struct roff_man *, int, int, int);
+void man_head_alloc(struct roff_man *, int, int, int);
+void man_body_alloc(struct roff_man *, int, int, int);
+void man_elem_alloc(struct roff_man *, int, int, int);
+void man_node_delete(struct roff_man *, struct roff_node *);
void man_hash_init(void);
int man_hash_find(const char *);
-void man_macroend(struct man *);
-void man_valid_post(struct man *);
-void man_unscope(struct man *, const struct roff_node *);
+void man_macroend(struct roff_man *);
+void man_valid_post(struct roff_man *);
+void man_unscope(struct roff_man *, const struct roff_node *);
__END_DECLS
-/* $OpenBSD: libmandoc.h,v 1.41 2015/01/15 04:26:06 schwarze Exp $ */
+/* $OpenBSD: libmandoc.h,v 1.42 2015/04/18 16:04:40 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
struct tbl_span;
struct eqn;
struct roff;
-struct mdoc;
-struct man;
+struct roff_man;
void mandoc_msg(enum mandocerr, struct mparse *,
int, int, const char *);
int mandoc_strntoi(const char *, size_t, int);
const char *mandoc_a2msec(const char*);
-void mdoc_free(struct mdoc *);
-struct mdoc *mdoc_alloc(struct roff *, struct mparse *,
+void mdoc_free(struct roff_man *);
+struct roff_man *mdoc_alloc(struct roff *, struct mparse *,
const char *, int);
-void mdoc_reset(struct mdoc *);
-int mdoc_parseln(struct mdoc *, int, char *, int);
-void mdoc_endparse(struct mdoc *);
-void mdoc_addspan(struct mdoc *, const struct tbl_span *);
-void mdoc_addeqn(struct mdoc *, const struct eqn *);
+void mdoc_reset(struct roff_man *);
+int mdoc_parseln(struct roff_man *, int, char *, int);
+void mdoc_endparse(struct roff_man *);
+void mdoc_addspan(struct roff_man *, const struct tbl_span *);
+void mdoc_addeqn(struct roff_man *, const struct eqn *);
-void man_free(struct man *);
-struct man *man_alloc(struct roff *, struct mparse *,
+void man_free(struct roff_man *);
+struct roff_man *man_alloc(struct roff *, struct mparse *,
const char *, int);
-void man_reset(struct man *);
-int man_parseln(struct man *, int, char *, int);
-void man_endparse(struct man *);
-void man_addspan(struct man *, const struct tbl_span *);
-void man_addeqn(struct man *, const struct eqn *);
+void man_reset(struct roff_man *);
+int man_parseln(struct roff_man *, int, char *, int);
+void man_endparse(struct roff_man *);
+void man_addspan(struct roff_man *, const struct tbl_span *);
+void man_addeqn(struct roff_man *, const struct eqn *);
int preconv_cue(const struct buf *, size_t);
int preconv_encode(struct buf *, size_t *,
-/* $OpenBSD: libmdoc.h,v 1.70 2015/04/02 23:47:43 schwarze Exp $ */
+/* $OpenBSD: libmdoc.h,v 1.71 2015/04/18 16:04:40 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-enum mdoc_next {
- MDOC_NEXT_SIBLING = 0,
- MDOC_NEXT_CHILD
-};
-
-struct mdoc {
- struct mparse *parse; /* parse pointer */
- const char *defos; /* default argument for .Os */
- int quick; /* abort parse early */
- int flags; /* parse flags */
-#define MDOC_LITERAL (1 << 1) /* in a literal scope */
-#define MDOC_PBODY (1 << 2) /* in the document body */
-#define MDOC_NEWLINE (1 << 3) /* first macro/text in a line */
-#define MDOC_PHRASELIT (1 << 4) /* literal within a partila phrase */
-#define MDOC_PPHRASE (1 << 5) /* within a partial phrase */
-#define MDOC_FREECOL (1 << 6) /* `It' invocation should close */
-#define MDOC_SYNOPSIS (1 << 7) /* SYNOPSIS-style formatting */
-#define MDOC_KEEP (1 << 8) /* in a word keep */
-#define MDOC_SMOFF (1 << 9) /* spacing is off */
-#define MDOC_NODELIMC (1 << 10) /* disable closing delimiter handling */
- enum mdoc_next next; /* where to put the next node */
- struct roff_node *last; /* the last node parsed */
- struct roff_node *first; /* the first node parsed */
- struct roff_node *last_es; /* the most recent Es node */
- struct roff_meta meta; /* document meta-data */
- enum roff_sec lastnamed;
- enum roff_sec lastsec;
- struct roff *roff;
-};
-
-#define MACRO_PROT_ARGS struct mdoc *mdoc, \
+#define MACRO_PROT_ARGS struct roff_man *mdoc, \
int tok, \
int line, \
int ppos, \
__BEGIN_DECLS
void mdoc_macro(MACRO_PROT_ARGS);
-void mdoc_word_alloc(struct mdoc *, int, int, const char *);
-void mdoc_word_append(struct mdoc *, const char *);
-void mdoc_elem_alloc(struct mdoc *, int, int,
+void mdoc_word_alloc(struct roff_man *, int, int, const char *);
+void mdoc_word_append(struct roff_man *, const char *);
+void mdoc_elem_alloc(struct roff_man *, int, int,
int, struct mdoc_arg *);
-struct roff_node *mdoc_block_alloc(struct mdoc *, int, int,
+struct roff_node *mdoc_block_alloc(struct roff_man *, int, int,
int, struct mdoc_arg *);
-struct roff_node *mdoc_head_alloc(struct mdoc *, int, int, int);
-void mdoc_tail_alloc(struct mdoc *, int, int, int);
-struct roff_node *mdoc_body_alloc(struct mdoc *, int, int, int);
-struct roff_node *mdoc_endbody_alloc(struct mdoc *, int, int, int,
+struct roff_node *mdoc_head_alloc(struct roff_man *, int, int, int);
+void mdoc_tail_alloc(struct roff_man *, int, int, int);
+struct roff_node *mdoc_body_alloc(struct roff_man *, int, int, int);
+struct roff_node *mdoc_endbody_alloc(struct roff_man *, int, int, int,
struct roff_node *, enum mdoc_endbody);
-void mdoc_node_delete(struct mdoc *, struct roff_node *);
-void mdoc_node_relink(struct mdoc *, struct roff_node *);
+void mdoc_node_delete(struct roff_man *, struct roff_node *);
+void mdoc_node_relink(struct roff_man *, struct roff_node *);
void mdoc_hash_init(void);
int mdoc_hash_find(const char *);
const char *mdoc_a2att(const char *);
const char *mdoc_a2st(const char *);
const char *mdoc_a2arch(const char *);
-void mdoc_valid_pre(struct mdoc *, struct roff_node *);
-void mdoc_valid_post(struct mdoc *);
-void mdoc_argv(struct mdoc *, int, int,
+void mdoc_valid_pre(struct roff_man *, struct roff_node *);
+void mdoc_valid_post(struct roff_man *);
+void mdoc_argv(struct roff_man *, int, int,
struct mdoc_arg **, int *, char *);
void mdoc_argv_free(struct mdoc_arg *);
-enum margserr mdoc_args(struct mdoc *, int,
+enum margserr mdoc_args(struct roff_man *, int,
int *, char *, int, char **);
-void mdoc_macroend(struct mdoc *);
+void mdoc_macroend(struct roff_man *);
enum mdelim mdoc_isdelim(const char *);
__END_DECLS
-/* $OpenBSD: main.c,v 1.138 2015/04/16 16:35:02 schwarze Exp $ */
+/* $OpenBSD: main.c,v 1.139 2015/04/18 16:04:40 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2012, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
OUTMODE_ONE
};
-typedef void (*out_mdoc)(void *, const struct mdoc *);
-typedef void (*out_man)(void *, const struct man *);
+typedef void (*out_mdoc)(void *, const struct roff_man *);
+typedef void (*out_man)(void *, const struct roff_man *);
typedef void (*out_free)(void *);
enum outt {
parse(struct curparse *curp, int fd, const char *file)
{
enum mandoclevel rctmp;
- struct mdoc *mdoc;
- struct man *man;
+ struct roff_man *mdoc;
+ struct roff_man *man;
/* Begin by parsing the file itself. */
-/* $OpenBSD: main.h,v 1.16 2015/03/27 21:17:16 schwarze Exp $ */
+/* $OpenBSD: main.h,v 1.17 2015/04/18 16:04:40 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
__BEGIN_DECLS
struct mchars;
-struct mdoc;
-struct man;
+struct roff_man;
struct manoutput;
/*
void *html_alloc(const struct mchars *,
const struct manoutput *);
-void html_mdoc(void *, const struct mdoc *);
-void html_man(void *, const struct man *);
+void html_mdoc(void *, const struct roff_man *);
+void html_man(void *, const struct roff_man *);
void html_free(void *);
-void tree_mdoc(void *, const struct mdoc *);
-void tree_man(void *, const struct man *);
+void tree_mdoc(void *, const struct roff_man *);
+void tree_man(void *, const struct roff_man *);
-void man_mdoc(void *, const struct mdoc *);
-void man_man(void *, const struct man *);
+void man_mdoc(void *, const struct roff_man *);
+void man_man(void *, const struct roff_man *);
void *locale_alloc(const struct mchars *,
const struct manoutput *);
const struct manoutput *);
void pspdf_free(void *);
-void terminal_mdoc(void *, const struct mdoc *);
-void terminal_man(void *, const struct man *);
+void terminal_mdoc(void *, const struct roff_man *);
+void terminal_man(void *, const struct roff_man *);
__END_DECLS
-/* $OpenBSD: man.c,v 1.100 2015/04/02 23:47:43 schwarze Exp $ */
+/* $OpenBSD: man.c,v 1.101 2015/04/18 16:04:40 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
const char * const *man_macronames = __man_macronames;
-static void man_alloc1(struct man *);
-static void man_breakscope(struct man *, int);
-static void man_descope(struct man *, int, int);
-static void man_free1(struct man *);
-static struct roff_node *man_node_alloc(struct man *, int, int,
+static void man_alloc1(struct roff_man *);
+static void man_breakscope(struct roff_man *, int);
+static void man_descope(struct roff_man *, int, int);
+static void man_free1(struct roff_man *);
+static struct roff_node *man_node_alloc(struct roff_man *, int, int,
enum roff_type, int);
-static void man_node_append(struct man *, struct roff_node *);
+static void man_node_append(struct roff_man *,
+ struct roff_node *);
static void man_node_free(struct roff_node *);
-static void man_node_unlink(struct man *, struct roff_node *);
-static int man_ptext(struct man *, int, char *, int);
-static int man_pmacro(struct man *, int, char *, int);
+static void man_node_unlink(struct roff_man *,
+ struct roff_node *);
+static int man_ptext(struct roff_man *, int, char *, int);
+static int man_pmacro(struct roff_man *, int, char *, int);
const struct roff_node *
-man_node(const struct man *man)
+man_node(const struct roff_man *man)
{
return(man->first);
}
const struct roff_meta *
-man_meta(const struct man *man)
+man_meta(const struct roff_man *man)
{
return(&man->meta);
}
void
-man_reset(struct man *man)
+man_reset(struct roff_man *man)
{
man_free1(man);
}
void
-man_free(struct man *man)
+man_free(struct roff_man *man)
{
man_free1(man);
free(man);
}
-struct man *
+struct roff_man *
man_alloc(struct roff *roff, struct mparse *parse,
const char *defos, int quick)
{
- struct man *p;
+ struct roff_man *p;
- p = mandoc_calloc(1, sizeof(struct man));
+ p = mandoc_calloc(1, sizeof(*p));
man_hash_init();
p->parse = parse;
}
void
-man_endparse(struct man *man)
+man_endparse(struct roff_man *man)
{
man_macroend(man);
}
int
-man_parseln(struct man *man, int ln, char *buf, int offs)
+man_parseln(struct roff_man *man, int ln, char *buf, int offs)
{
if (man->last->type != ROFFT_EQN || ln > man->last->line)
}
static void
-man_free1(struct man *man)
+man_free1(struct roff_man *man)
{
if (man->first)
}
static void
-man_alloc1(struct man *man)
+man_alloc1(struct roff_man *man)
{
memset(&man->meta, 0, sizeof(man->meta));
man->first = man->last;
man->last->type = ROFFT_ROOT;
man->last->tok = MAN_MAX;
- man->next = MAN_NEXT_CHILD;
+ man->next = ROFF_NEXT_CHILD;
}
static void
-man_node_append(struct man *man, struct roff_node *p)
+man_node_append(struct roff_man *man, struct roff_node *p)
{
assert(man->last);
assert(p->type != ROFFT_ROOT);
switch (man->next) {
- case MAN_NEXT_SIBLING:
+ case ROFF_NEXT_SIBLING:
man->last->next = p;
p->prev = man->last;
p->parent = man->last->parent;
break;
- case MAN_NEXT_CHILD:
+ case ROFF_NEXT_CHILD:
man->last->child = p;
p->parent = man->last;
break;
}
static struct roff_node *
-man_node_alloc(struct man *man, int line, int pos,
+man_node_alloc(struct roff_man *man, int line, int pos,
enum roff_type type, int tok)
{
struct roff_node *p;
}
void
-man_elem_alloc(struct man *man, int line, int pos, int tok)
+man_elem_alloc(struct roff_man *man, int line, int pos, int tok)
{
struct roff_node *p;
p = man_node_alloc(man, line, pos, ROFFT_ELEM, tok);
man_node_append(man, p);
- man->next = MAN_NEXT_CHILD;
+ man->next = ROFF_NEXT_CHILD;
}
void
-man_head_alloc(struct man *man, int line, int pos, int tok)
+man_head_alloc(struct roff_man *man, int line, int pos, int tok)
{
struct roff_node *p;
p = man_node_alloc(man, line, pos, ROFFT_HEAD, tok);
man_node_append(man, p);
- man->next = MAN_NEXT_CHILD;
+ man->next = ROFF_NEXT_CHILD;
}
void
-man_body_alloc(struct man *man, int line, int pos, int tok)
+man_body_alloc(struct roff_man *man, int line, int pos, int tok)
{
struct roff_node *p;
p = man_node_alloc(man, line, pos, ROFFT_BODY, tok);
man_node_append(man, p);
- man->next = MAN_NEXT_CHILD;
+ man->next = ROFF_NEXT_CHILD;
}
void
-man_block_alloc(struct man *man, int line, int pos, int tok)
+man_block_alloc(struct roff_man *man, int line, int pos, int tok)
{
struct roff_node *p;
p = man_node_alloc(man, line, pos, ROFFT_BLOCK, tok);
man_node_append(man, p);
- man->next = MAN_NEXT_CHILD;
+ man->next = ROFF_NEXT_CHILD;
}
void
-man_word_alloc(struct man *man, int line, int pos, const char *word)
+man_word_alloc(struct roff_man *man, int line, int pos, const char *word)
{
struct roff_node *n;
n = man_node_alloc(man, line, pos, ROFFT_TEXT, MAN_MAX);
n->string = roff_strdup(man->roff, word);
man_node_append(man, n);
- man->next = MAN_NEXT_SIBLING;
+ man->next = ROFF_NEXT_SIBLING;
}
void
-man_word_append(struct man *man, const char *word)
+man_word_append(struct roff_man *man, const char *word)
{
struct roff_node *n;
char *addstr, *newstr;
free(addstr);
free(n->string);
n->string = newstr;
- man->next = MAN_NEXT_SIBLING;
+ man->next = ROFF_NEXT_SIBLING;
}
/*
}
void
-man_node_delete(struct man *man, struct roff_node *p)
+man_node_delete(struct roff_man *man, struct roff_node *p)
{
while (p->child)
}
void
-man_addeqn(struct man *man, const struct eqn *ep)
+man_addeqn(struct roff_man *man, const struct eqn *ep)
{
struct roff_node *n;
if (ep->ln > man->last->line)
n->flags |= MAN_LINE;
man_node_append(man, n);
- man->next = MAN_NEXT_SIBLING;
+ man->next = ROFF_NEXT_SIBLING;
man_descope(man, ep->ln, ep->pos);
}
void
-man_addspan(struct man *man, const struct tbl_span *sp)
+man_addspan(struct roff_man *man, const struct tbl_span *sp)
{
struct roff_node *n;
n = man_node_alloc(man, sp->line, 0, ROFFT_TBL, MAN_MAX);
n->span = sp;
man_node_append(man, n);
- man->next = MAN_NEXT_SIBLING;
+ man->next = ROFF_NEXT_SIBLING;
man_descope(man, sp->line, 0);
}
static void
-man_descope(struct man *man, int line, int offs)
+man_descope(struct roff_man *man, int line, int offs)
{
/*
* Co-ordinate what happens with having a next-line scope open:
}
static int
-man_ptext(struct man *man, int line, char *buf, int offs)
+man_ptext(struct roff_man *man, int line, char *buf, int offs)
{
int i;
if (man->last->tok != MAN_SH &&
man->last->tok != MAN_SS) {
man_elem_alloc(man, line, offs, MAN_sp);
- man->next = MAN_NEXT_SIBLING;
+ man->next = ROFF_NEXT_SIBLING;
}
return(1);
}
}
static int
-man_pmacro(struct man *man, int ln, char *buf, int offs)
+man_pmacro(struct roff_man *man, int ln, char *buf, int offs)
{
struct roff_node *n;
const char *cp;
}
void
-man_breakscope(struct man *man, int tok)
+man_breakscope(struct roff_man *man, int tok)
{
struct roff_node *n;
* point will also be adjusted accordingly.
*/
static void
-man_node_unlink(struct man *man, struct roff_node *n)
+man_node_unlink(struct roff_man *man, struct roff_node *n)
{
/* Adjust siblings. */
/*assert(NULL == n->next);*/
if (n->prev) {
man->last = n->prev;
- man->next = MAN_NEXT_SIBLING;
+ man->next = ROFF_NEXT_SIBLING;
} else {
man->last = n->parent;
- man->next = MAN_NEXT_CHILD;
+ man->next = ROFF_NEXT_CHILD;
}
}
}
const struct mparse *
-man_mparse(const struct man *man)
+man_mparse(const struct roff_man *man)
{
assert(man && man->parse);
-/* $OpenBSD: man.h,v 1.52 2015/04/02 23:47:43 schwarze Exp $ */
+/* $OpenBSD: man.h,v 1.53 2015/04/18 16:04:40 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
__BEGIN_DECLS
-struct man;
+struct roff_man;
-const struct roff_node *man_node(const struct man *);
-const struct roff_meta *man_meta(const struct man *);
-const struct mparse *man_mparse(const struct man *);
+const struct roff_node *man_node(const struct roff_man *);
+const struct roff_meta *man_meta(const struct roff_man *);
+const struct mparse *man_mparse(const struct roff_man *);
void man_deroff(char **, const struct roff_node *);
__END_DECLS
-/* $OpenBSD: man_html.c,v 1.68 2015/04/02 23:47:43 schwarze Exp $ */
+/* $OpenBSD: man_html.c,v 1.69 2015/04/18 16:04:40 schwarze Exp $ */
/*
* Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
}
void
-html_man(void *arg, const struct man *man)
+html_man(void *arg, const struct roff_man *man)
{
struct mhtml mh;
-/* $OpenBSD: man_macro.c,v 1.66 2015/04/03 23:17:09 schwarze Exp $ */
+/* $OpenBSD: man_macro.c,v 1.67 2015/04/18 16:04:40 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2012, 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
static void blk_exp(MACRO_PROT_ARGS);
static void blk_imp(MACRO_PROT_ARGS);
static void in_line_eoln(MACRO_PROT_ARGS);
-static int man_args(struct man *, int,
+static int man_args(struct roff_man *, int,
int *, char *, char **);
-static void rew_scope(struct man *, int);
+static void rew_scope(struct roff_man *, int);
const struct man_macro __man_macros[MAN_MAX] = {
{ in_line_eoln, MAN_NSCOPED }, /* br */
void
-man_unscope(struct man *man, const struct roff_node *to)
+man_unscope(struct roff_man *man, const struct roff_node *to)
{
struct roff_node *n;
*/
man->next = (man->last == to) ?
- MAN_NEXT_CHILD : MAN_NEXT_SIBLING;
+ ROFF_NEXT_CHILD : ROFF_NEXT_SIBLING;
}
/*
* scopes. When a scope is closed, it must be validated and actioned.
*/
static void
-rew_scope(struct man *man, int tok)
+rew_scope(struct roff_man *man, int tok)
{
struct roff_node *n;
}
assert(man->last->type != ROFFT_ROOT);
- man->next = MAN_NEXT_SIBLING;
+ man->next = ROFF_NEXT_SIBLING;
/*
* Rewind our element scope. Note that when TH is pruned, we'll
void
-man_macroend(struct man *man)
+man_macroend(struct roff_man *man)
{
man_unscope(man, man->first);
}
static int
-man_args(struct man *man, int line, int *pos, char *buf, char **v)
+man_args(struct roff_man *man, int line, int *pos, char *buf, char **v)
{
char *start;
-/* $OpenBSD: man_term.c,v 1.132 2015/04/06 22:06:06 schwarze Exp $ */
+/* $OpenBSD: man_term.c,v 1.133 2015/04/18 16:04:40 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org>
void
-terminal_man(void *arg, const struct man *man)
+terminal_man(void *arg, const struct roff_man *man)
{
struct termp *p;
const struct roff_meta *meta;
-/* $OpenBSD: man_validate.c,v 1.87 2015/04/02 23:47:43 schwarze Exp $ */
+/* $OpenBSD: man_validate.c,v 1.88 2015/04/18 16:04:40 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012-2015 Ingo Schwarze <schwarze@openbsd.org>
#include "libmandoc.h"
#include "libman.h"
-#define CHKARGS struct man *man, struct roff_node *n
+#define CHKARGS struct roff_man *man, struct roff_node *n
typedef void (*v_check)(CHKARGS);
void
-man_valid_post(struct man *man)
+man_valid_post(struct roff_man *man)
{
struct roff_node *n;
v_check *cp;
-/* $OpenBSD: mandoc.h,v 1.143 2015/02/23 13:30:02 schwarze Exp $ */
+/* $OpenBSD: mandoc.h,v 1.144 2015/04/18 16:04:40 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org>
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
struct mparse;
struct mchars;
-struct mdoc;
-struct man;
+struct roff_man;
enum mandoc_esc mandoc_escape(const char **, const char **, int *);
struct mchars *mchars_alloc(void);
enum mandoclevel mparse_open(struct mparse *, int *, const char *);
enum mandoclevel mparse_readfd(struct mparse *, int, const char *);
void mparse_reset(struct mparse *);
-void mparse_result(struct mparse *,
- struct mdoc **, struct man **, char **);
+void mparse_result(struct mparse *, struct roff_man **,
+ struct roff_man **, char **);
const char *mparse_getkeep(const struct mparse *);
const char *mparse_strerror(enum mandocerr);
const char *mparse_strlevel(enum mandoclevel);
-/* $OpenBSD: mandocdb.c,v 1.143 2015/04/02 23:47:43 schwarze Exp $ */
+/* $OpenBSD: mandocdb.c,v 1.144 2015/04/18 16:04:40 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011-2015 Ingo Schwarze <schwarze@openbsd.org>
struct ohash_info str_info;
struct mpage *mpage, *mpage_dest;
struct mlink *mlink, *mlink_dest;
- struct mdoc *mdoc;
- struct man *man;
+ struct roff_man *mdoc;
+ struct roff_man *man;
char *sodest;
char *cp;
int fd;
-/* $OpenBSD: mdoc.c,v 1.130 2015/04/02 23:47:43 schwarze Exp $ */
+/* $OpenBSD: mdoc.c,v 1.131 2015/04/18 16:04:40 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012-2015 Ingo Schwarze <schwarze@openbsd.org>
const char * const *mdoc_argnames = __mdoc_argnames;
static void mdoc_node_free(struct roff_node *);
-static void mdoc_node_unlink(struct mdoc *,
+static void mdoc_node_unlink(struct roff_man *,
struct roff_node *);
-static void mdoc_free1(struct mdoc *);
-static void mdoc_alloc1(struct mdoc *);
-static struct roff_node *node_alloc(struct mdoc *, int, int,
+static void mdoc_free1(struct roff_man *);
+static void mdoc_alloc1(struct roff_man *);
+static struct roff_node *node_alloc(struct roff_man *, int, int,
int, enum roff_type);
-static void node_append(struct mdoc *, struct roff_node *);
-static int mdoc_ptext(struct mdoc *, int, char *, int);
-static int mdoc_pmacro(struct mdoc *, int, char *, int);
+static void node_append(struct roff_man *, struct roff_node *);
+static int mdoc_ptext(struct roff_man *, int, char *, int);
+static int mdoc_pmacro(struct roff_man *, int, char *, int);
const struct roff_node *
-mdoc_node(const struct mdoc *mdoc)
+mdoc_node(const struct roff_man *mdoc)
{
return(mdoc->first);
}
const struct roff_meta *
-mdoc_meta(const struct mdoc *mdoc)
+mdoc_meta(const struct roff_man *mdoc)
{
return(&mdoc->meta);
* Frees volatile resources (parse tree, meta-data, fields).
*/
static void
-mdoc_free1(struct mdoc *mdoc)
+mdoc_free1(struct roff_man *mdoc)
{
if (mdoc->first)
* Allocate all volatile resources (parse tree, meta-data, fields).
*/
static void
-mdoc_alloc1(struct mdoc *mdoc)
+mdoc_alloc1(struct roff_man *mdoc)
{
memset(&mdoc->meta, 0, sizeof(mdoc->meta));
mdoc->first = mdoc->last;
mdoc->last->type = ROFFT_ROOT;
mdoc->last->tok = MDOC_MAX;
- mdoc->next = MDOC_NEXT_CHILD;
+ mdoc->next = ROFF_NEXT_CHILD;
}
/*
* cross-parse non-volatile data is kept intact.
*/
void
-mdoc_reset(struct mdoc *mdoc)
+mdoc_reset(struct roff_man *mdoc)
{
mdoc_free1(mdoc);
* After invocation, the pointer is no longer usable.
*/
void
-mdoc_free(struct mdoc *mdoc)
+mdoc_free(struct roff_man *mdoc)
{
mdoc_free1(mdoc);
/*
* Allocate volatile and non-volatile parse resources.
*/
-struct mdoc *
+struct roff_man *
mdoc_alloc(struct roff *roff, struct mparse *parse,
const char *defos, int quick)
{
- struct mdoc *p;
+ struct roff_man *p;
- p = mandoc_calloc(1, sizeof(struct mdoc));
+ p = mandoc_calloc(1, sizeof(*p));
p->parse = parse;
p->defos = defos;
}
void
-mdoc_endparse(struct mdoc *mdoc)
+mdoc_endparse(struct roff_man *mdoc)
{
mdoc_macroend(mdoc);
}
void
-mdoc_addeqn(struct mdoc *mdoc, const struct eqn *ep)
+mdoc_addeqn(struct roff_man *mdoc, const struct eqn *ep)
{
struct roff_node *n;
if (ep->ln > mdoc->last->line)
n->flags |= MDOC_LINE;
node_append(mdoc, n);
- mdoc->next = MDOC_NEXT_SIBLING;
+ mdoc->next = ROFF_NEXT_SIBLING;
}
void
-mdoc_addspan(struct mdoc *mdoc, const struct tbl_span *sp)
+mdoc_addspan(struct roff_man *mdoc, const struct tbl_span *sp)
{
struct roff_node *n;
n = node_alloc(mdoc, sp->line, 0, MDOC_MAX, ROFFT_TBL);
n->span = sp;
node_append(mdoc, n);
- mdoc->next = MDOC_NEXT_SIBLING;
+ mdoc->next = ROFF_NEXT_SIBLING;
}
/*
* the macro (mdoc_pmacro()) or text parser (mdoc_ptext()).
*/
int
-mdoc_parseln(struct mdoc *mdoc, int ln, char *buf, int offs)
+mdoc_parseln(struct roff_man *mdoc, int ln, char *buf, int offs)
{
if (mdoc->last->type != ROFFT_EQN || ln > mdoc->last->line)
static void
-node_append(struct mdoc *mdoc, struct roff_node *p)
+node_append(struct roff_man *mdoc, struct roff_node *p)
{
assert(mdoc->last);
assert(p->type != ROFFT_ROOT);
switch (mdoc->next) {
- case MDOC_NEXT_SIBLING:
+ case ROFF_NEXT_SIBLING:
mdoc->last->next = p;
p->prev = mdoc->last;
p->parent = mdoc->last->parent;
break;
- case MDOC_NEXT_CHILD:
+ case ROFF_NEXT_CHILD:
mdoc->last->child = p;
p->parent = mdoc->last;
break;
}
static struct roff_node *
-node_alloc(struct mdoc *mdoc, int line, int pos,
+node_alloc(struct roff_man *mdoc, int line, int pos,
int tok, enum roff_type type)
{
struct roff_node *p;
}
void
-mdoc_tail_alloc(struct mdoc *mdoc, int line, int pos, int tok)
+mdoc_tail_alloc(struct roff_man *mdoc, int line, int pos, int tok)
{
struct roff_node *p;
p = node_alloc(mdoc, line, pos, tok, ROFFT_TAIL);
node_append(mdoc, p);
- mdoc->next = MDOC_NEXT_CHILD;
+ mdoc->next = ROFF_NEXT_CHILD;
}
struct roff_node *
-mdoc_head_alloc(struct mdoc *mdoc, int line, int pos, int tok)
+mdoc_head_alloc(struct roff_man *mdoc, int line, int pos, int tok)
{
struct roff_node *p;
assert(mdoc->last);
p = node_alloc(mdoc, line, pos, tok, ROFFT_HEAD);
node_append(mdoc, p);
- mdoc->next = MDOC_NEXT_CHILD;
+ mdoc->next = ROFF_NEXT_CHILD;
return(p);
}
struct roff_node *
-mdoc_body_alloc(struct mdoc *mdoc, int line, int pos, int tok)
+mdoc_body_alloc(struct roff_man *mdoc, int line, int pos, int tok)
{
struct roff_node *p;
p = node_alloc(mdoc, line, pos, tok, ROFFT_BODY);
node_append(mdoc, p);
- mdoc->next = MDOC_NEXT_CHILD;
+ mdoc->next = ROFF_NEXT_CHILD;
return(p);
}
struct roff_node *
-mdoc_endbody_alloc(struct mdoc *mdoc, int line, int pos, int tok,
+mdoc_endbody_alloc(struct roff_man *mdoc, int line, int pos, int tok,
struct roff_node *body, enum mdoc_endbody end)
{
struct roff_node *p;
p->norm = body->norm;
p->end = end;
node_append(mdoc, p);
- mdoc->next = MDOC_NEXT_SIBLING;
+ mdoc->next = ROFF_NEXT_SIBLING;
return(p);
}
struct roff_node *
-mdoc_block_alloc(struct mdoc *mdoc, int line, int pos,
+mdoc_block_alloc(struct roff_man *mdoc, int line, int pos,
int tok, struct mdoc_arg *args)
{
struct roff_node *p;
break;
}
node_append(mdoc, p);
- mdoc->next = MDOC_NEXT_CHILD;
+ mdoc->next = ROFF_NEXT_CHILD;
return(p);
}
void
-mdoc_elem_alloc(struct mdoc *mdoc, int line, int pos,
+mdoc_elem_alloc(struct roff_man *mdoc, int line, int pos,
int tok, struct mdoc_arg *args)
{
struct roff_node *p;
break;
}
node_append(mdoc, p);
- mdoc->next = MDOC_NEXT_CHILD;
+ mdoc->next = ROFF_NEXT_CHILD;
}
void
-mdoc_word_alloc(struct mdoc *mdoc, int line, int pos, const char *p)
+mdoc_word_alloc(struct roff_man *mdoc, int line, int pos, const char *p)
{
struct roff_node *n;
n = node_alloc(mdoc, line, pos, MDOC_MAX, ROFFT_TEXT);
n->string = roff_strdup(mdoc->roff, p);
node_append(mdoc, n);
- mdoc->next = MDOC_NEXT_SIBLING;
+ mdoc->next = ROFF_NEXT_SIBLING;
}
void
-mdoc_word_append(struct mdoc *mdoc, const char *p)
+mdoc_word_append(struct roff_man *mdoc, const char *p)
{
struct roff_node *n;
char *addstr, *newstr;
free(addstr);
free(n->string);
n->string = newstr;
- mdoc->next = MDOC_NEXT_SIBLING;
+ mdoc->next = ROFF_NEXT_SIBLING;
}
static void
}
static void
-mdoc_node_unlink(struct mdoc *mdoc, struct roff_node *n)
+mdoc_node_unlink(struct roff_man *mdoc, struct roff_node *n)
{
/* Adjust siblings. */
if (mdoc && mdoc->last == n) {
if (n->prev) {
mdoc->last = n->prev;
- mdoc->next = MDOC_NEXT_SIBLING;
+ mdoc->next = ROFF_NEXT_SIBLING;
} else {
mdoc->last = n->parent;
- mdoc->next = MDOC_NEXT_CHILD;
+ mdoc->next = ROFF_NEXT_CHILD;
}
}
}
void
-mdoc_node_delete(struct mdoc *mdoc, struct roff_node *p)
+mdoc_node_delete(struct roff_man *mdoc, struct roff_node *p)
{
while (p->child) {
}
void
-mdoc_node_relink(struct mdoc *mdoc, struct roff_node *p)
+mdoc_node_relink(struct roff_man *mdoc, struct roff_node *p)
{
mdoc_node_unlink(mdoc, p);
* control character.
*/
static int
-mdoc_ptext(struct mdoc *mdoc, int line, char *buf, int offs)
+mdoc_ptext(struct roff_man *mdoc, int line, char *buf, int offs)
{
struct roff_node *n;
char *c, *ws, *end;
* behaviour that we want to work around it.
*/
mdoc_elem_alloc(mdoc, line, offs, MDOC_sp, NULL);
- mdoc->next = MDOC_NEXT_SIBLING;
+ mdoc->next = ROFF_NEXT_SIBLING;
mdoc_valid_post(mdoc);
return(1);
}
* character.
*/
static int
-mdoc_pmacro(struct mdoc *mdoc, int ln, char *buf, int offs)
+mdoc_pmacro(struct roff_man *mdoc, int ln, char *buf, int offs)
{
struct roff_node *n;
const char *cp;
-/* $OpenBSD: mdoc.h,v 1.64 2015/04/02 23:47:43 schwarze Exp $ */
+/* $OpenBSD: mdoc.h,v 1.65 2015/04/18 16:04:40 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
__BEGIN_DECLS
-struct mdoc;
+struct roff_man;
-const struct roff_node *mdoc_node(const struct mdoc *);
-const struct roff_meta *mdoc_meta(const struct mdoc *);
+const struct roff_node *mdoc_node(const struct roff_man *);
+const struct roff_meta *mdoc_meta(const struct roff_man *);
void mdoc_deroff(char **, const struct roff_node *);
__END_DECLS
-/* $OpenBSD: mdoc_argv.c,v 1.58 2015/04/02 22:06:17 schwarze Exp $ */
+/* $OpenBSD: mdoc_argv.c,v 1.59 2015/04/18 16:04:40 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2012, 2014 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2012, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
};
static void argn_free(struct mdoc_arg *, int);
-static enum margserr args(struct mdoc *, int, int *,
+static enum margserr args(struct roff_man *, int, int *,
char *, enum argsflag, char **);
static int args_checkpunct(const char *, int);
-static void argv_multi(struct mdoc *, int,
+static void argv_multi(struct roff_man *, int,
struct mdoc_argv *, int *, char *);
-static void argv_single(struct mdoc *, int,
+static void argv_single(struct roff_man *, int,
struct mdoc_argv *, int *, char *);
static const enum argvflag argvflags[MDOC_ARG_MAX] = {
* Some flags take no argument, some one, some multiple.
*/
void
-mdoc_argv(struct mdoc *mdoc, int line, int tok,
+mdoc_argv(struct roff_man *mdoc, int line, int tok,
struct mdoc_arg **reta, int *pos, char *buf)
{
struct mdoc_argv tmpv;
}
enum margserr
-mdoc_args(struct mdoc *mdoc, int line, int *pos,
+mdoc_args(struct roff_man *mdoc, int line, int *pos,
char *buf, int tok, char **v)
{
struct roff_node *n;
}
static enum margserr
-args(struct mdoc *mdoc, int line, int *pos,
+args(struct roff_man *mdoc, int line, int *pos,
char *buf, enum argsflag fl, char **v)
{
char *p, *pp;
}
static void
-argv_multi(struct mdoc *mdoc, int line,
+argv_multi(struct roff_man *mdoc, int line,
struct mdoc_argv *v, int *pos, char *buf)
{
enum margserr ac;
}
static void
-argv_single(struct mdoc *mdoc, int line,
+argv_single(struct roff_man *mdoc, int line,
struct mdoc_argv *v, int *pos, char *buf)
{
enum margserr ac;
-/* $OpenBSD: mdoc_html.c,v 1.105 2015/04/16 20:21:08 schwarze Exp $ */
+/* $OpenBSD: mdoc_html.c,v 1.106 2015/04/18 16:04:40 schwarze Exp $ */
/*
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
void
-html_mdoc(void *arg, const struct mdoc *mdoc)
+html_mdoc(void *arg, const struct roff_man *mdoc)
{
print_mdoc(mdoc_meta(mdoc), mdoc_node(mdoc)->child,
-/* $OpenBSD: mdoc_macro.c,v 1.144 2015/04/05 23:04:22 schwarze Exp $ */
+/* $OpenBSD: mdoc_macro.c,v 1.145 2015/04/18 16:04:40 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012-2015 Ingo Schwarze <schwarze@openbsd.org>
static void in_line(MACRO_PROT_ARGS);
static void phrase_ta(MACRO_PROT_ARGS);
-static void append_delims(struct mdoc *, int, int *, char *);
-static void dword(struct mdoc *, int, int, const char *,
+static void append_delims(struct roff_man *, int, int *, char *);
+static void dword(struct roff_man *, int, int, const char *,
enum mdelim, int);
-static int find_pending(struct mdoc *, int, int, int,
+static int find_pending(struct roff_man *, int, int, int,
struct roff_node *);
-static int lookup(struct mdoc *, int, int, int, const char *);
+static int lookup(struct roff_man *, int, int, int, const char *);
static int macro_or_word(MACRO_PROT_ARGS, int);
-static int parse_rest(struct mdoc *, int, int, int *, char *);
+static int parse_rest(struct roff_man *, int, int, int *, char *);
static int rew_alt(int);
-static void rew_elem(struct mdoc *, int);
-static void rew_last(struct mdoc *, const struct roff_node *);
-static void rew_pending(struct mdoc *, const struct roff_node *);
+static void rew_elem(struct roff_man *, int);
+static void rew_last(struct roff_man *, const struct roff_node *);
+static void rew_pending(struct roff_man *,
+ const struct roff_node *);
const struct mdoc_macro __mdoc_macros[MDOC_MAX] = {
{ in_line_argn, MDOC_CALLABLE | MDOC_PARSED | MDOC_JOIN }, /* Ap */
* are errors.
*/
void
-mdoc_macroend(struct mdoc *mdoc)
+mdoc_macroend(struct roff_man *mdoc)
{
struct roff_node *n;
* or as a line macro if from == MDOC_MAX.
*/
static int
-lookup(struct mdoc *mdoc, int from, int line, int ppos, const char *p)
+lookup(struct roff_man *mdoc, int from, int line, int ppos, const char *p)
{
int res;
* Rewind up to and including a specific node.
*/
static void
-rew_last(struct mdoc *mdoc, const struct roff_node *to)
+rew_last(struct roff_man *mdoc, const struct roff_node *to)
{
struct roff_node *n, *np;
if (to->flags & MDOC_VALID)
return;
- mdoc->next = MDOC_NEXT_SIBLING;
+ mdoc->next = ROFF_NEXT_SIBLING;
while (mdoc->last != to) {
/*
* Save the parent here, because we may delete the
* Rewind up to a specific block, including all blocks that broke it.
*/
static void
-rew_pending(struct mdoc *mdoc, const struct roff_node *n)
+rew_pending(struct roff_man *mdoc, const struct roff_node *n)
{
for (;;) {
}
static void
-rew_elem(struct mdoc *mdoc, int tok)
+rew_elem(struct roff_man *mdoc, int tok)
{
struct roff_node *n;
* the rew_pending() call closing out the sub-block.
*/
static int
-find_pending(struct mdoc *mdoc, int tok, int line, int ppos,
+find_pending(struct roff_man *mdoc, int tok, int line, int ppos,
struct roff_node *target)
{
struct roff_node *n;
* Punctuation consists of those tokens found in mdoc_isdelim().
*/
static void
-dword(struct mdoc *mdoc, int line, int col, const char *p,
+dword(struct roff_man *mdoc, int line, int col, const char *p,
enum mdelim d, int may_append)
{
}
static void
-append_delims(struct mdoc *mdoc, int line, int *pos, char *buf)
+append_delims(struct roff_man *mdoc, int line, int *pos, char *buf)
{
char *p;
int la;
*/
if (maxargs)
- mdoc->next = MDOC_NEXT_CHILD;
+ mdoc->next = ROFF_NEXT_CHILD;
break;
}
if ((tok == MDOC_Pp || tok == MDOC_Lp) &&
! (mdoc->flags & MDOC_SYNOPSIS)) {
n = mdoc->last;
- if (mdoc->next == MDOC_NEXT_SIBLING)
+ if (mdoc->next == ROFF_NEXT_SIBLING)
n = n->parent;
if (n->tok == MDOC_Nm)
rew_last(mdoc, mdoc->last->parent);
* or until the next macro, call that macro, and return 1.
*/
static int
-parse_rest(struct mdoc *mdoc, int tok, int line, int *pos, char *buf)
+parse_rest(struct roff_man *mdoc, int tok, int line, int *pos, char *buf)
{
int la;
-/* $OpenBSD: mdoc_man.c,v 1.89 2015/04/02 23:47:43 schwarze Exp $ */
+/* $OpenBSD: mdoc_man.c,v 1.90 2015/04/18 16:04:40 schwarze Exp $ */
/*
* Copyright (c) 2011-2015 Ingo Schwarze <schwarze@openbsd.org>
*
}
void
-man_man(void *arg, const struct man *man)
+man_man(void *arg, const struct roff_man *man)
{
/*
}
void
-man_mdoc(void *arg, const struct mdoc *mdoc)
+man_mdoc(void *arg, const struct roff_man *mdoc)
{
const struct roff_meta *meta;
struct roff_node *n;
-/* $OpenBSD: mdoc_term.c,v 1.216 2015/04/04 17:46:58 schwarze Exp $ */
+/* $OpenBSD: mdoc_term.c,v 1.217 2015/04/18 16:04:40 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012-2015 Ingo Schwarze <schwarze@openbsd.org>
void
-terminal_mdoc(void *arg, const struct mdoc *mdoc)
+terminal_mdoc(void *arg, const struct roff_man *mdoc)
{
const struct roff_meta *meta;
struct roff_node *n;
-/* $OpenBSD: mdoc_validate.c,v 1.201 2015/04/02 22:06:17 schwarze Exp $ */
+/* $OpenBSD: mdoc_validate.c,v 1.202 2015/04/18 16:04:40 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org>
/* FIXME: .Bl -diag can't have non-text children in HEAD. */
-#define PRE_ARGS struct mdoc *mdoc, struct roff_node *n
-#define POST_ARGS struct mdoc *mdoc
+#define PRE_ARGS struct roff_man *mdoc, struct roff_node *n
+#define POST_ARGS struct roff_man *mdoc
enum check_ineq {
CHECK_LT,
v_post post;
};
-static void check_text(struct mdoc *, int, int, char *);
-static void check_argv(struct mdoc *,
+static void check_text(struct roff_man *, int, int, char *);
+static void check_argv(struct roff_man *,
struct roff_node *, struct mdoc_argv *);
-static void check_args(struct mdoc *, struct roff_node *);
+static void check_args(struct roff_man *, struct roff_node *);
static int child_an(const struct roff_node *);
static enum roff_sec a2sec(const char *);
static size_t macro2len(int);
void
-mdoc_valid_pre(struct mdoc *mdoc, struct roff_node *n)
+mdoc_valid_pre(struct roff_man *mdoc, struct roff_node *n)
{
v_pre p;
}
void
-mdoc_valid_post(struct mdoc *mdoc)
+mdoc_valid_post(struct roff_man *mdoc)
{
struct roff_node *n;
v_post p;
}
static void
-check_args(struct mdoc *mdoc, struct roff_node *n)
+check_args(struct roff_man *mdoc, struct roff_node *n)
{
int i;
}
static void
-check_argv(struct mdoc *mdoc, struct roff_node *n, struct mdoc_argv *v)
+check_argv(struct roff_man *mdoc, struct roff_node *n, struct mdoc_argv *v)
{
int i;
}
static void
-check_text(struct mdoc *mdoc, int ln, int pos, char *p)
+check_text(struct roff_man *mdoc, int ln, int pos, char *p)
{
char *cp;
return;
nn = mdoc->last;
- mdoc->next = MDOC_NEXT_CHILD;
+ mdoc->next = ROFF_NEXT_CHILD;
switch (nn->tok) {
case MDOC_Ar:
n = mdoc->last;
if (n->child == NULL) {
- mdoc->next = MDOC_NEXT_CHILD;
+ mdoc->next = ROFF_NEXT_CHILD;
mdoc_word_alloc(mdoc, n->line, n->pos, "AT&T UNIX");
mdoc->last = n;
return;
}
static void
-post_sm(struct mdoc *mdoc)
+post_sm(struct roff_man *mdoc)
{
struct roff_node *nch;
return;
}
- mdoc->next = MDOC_NEXT_CHILD;
+ mdoc->next = ROFF_NEXT_CHILD;
mdoc_word_alloc(mdoc, n->line, n->pos, mdoc->meta.name);
mdoc->last = n;
}
-/* $OpenBSD: read.c,v 1.108 2015/04/02 21:03:18 schwarze Exp $ */
+/* $OpenBSD: read.c,v 1.109 2015/04/18 16:04:40 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org>
#define REPARSE_LIMIT 1000
struct mparse {
- struct man *pman; /* persistent man parser */
- struct mdoc *pmdoc; /* persistent mdoc parser */
- struct man *man; /* man parser */
- struct mdoc *mdoc; /* mdoc parser */
+ struct roff_man *pman; /* persistent man parser */
+ struct roff_man *pmdoc; /* persistent mdoc parser */
+ struct roff_man *man; /* man parser */
+ struct roff_man *mdoc; /* mdoc parser */
struct roff *roff; /* roff parser (!NULL) */
const struct mchars *mchars; /* character table */
char *sodest; /* filename pointed to by .so */
}
void
-mparse_result(struct mparse *curp,
- struct mdoc **mdoc, struct man **man, char **sodest)
+mparse_result(struct mparse *curp, struct roff_man **mdoc,
+ struct roff_man **man, char **sodest)
{
if (sodest && NULL != (*sodest = curp->sodest)) {
-/* $OpenBSD: roff.h,v 1.12 2015/04/02 23:47:43 schwarze Exp $ */
+/* $OpenBSD: roff.h,v 1.13 2015/04/18 16:04:40 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
ROFFT_EQN
};
+enum roff_next {
+ ROFF_NEXT_SIBLING = 0,
+ ROFF_NEXT_CHILD
+};
+
/*
* Indicates that a BODY's formatting has ended, but
* the scope is still open. Used for badly nested blocks.
char *date; /* Normalized date. */
int hasbody; /* Document is not empty. */
};
+
+struct roff_man {
+ struct roff_meta meta; /* Document meta-data. */
+ struct mparse *parse; /* Parse pointer. */
+ struct roff *roff; /* Roff parser state data. */
+ const char *defos; /* Default operating system. */
+ struct roff_node *first; /* The first node parsed. */
+ struct roff_node *last; /* The last node parsed. */
+ struct roff_node *last_es; /* The most recent Es node. */
+ int quick; /* Abort parse early. */
+ int flags; /* Parse flags. */
+#define MDOC_LITERAL (1 << 1) /* In a literal scope. */
+#define MDOC_PBODY (1 << 2) /* In the document body. */
+#define MDOC_NEWLINE (1 << 3) /* First macro/text in a line. */
+#define MDOC_PHRASELIT (1 << 4) /* Literal within a partial phrase. */
+#define MDOC_PPHRASE (1 << 5) /* Within a partial phrase. */
+#define MDOC_FREECOL (1 << 6) /* `It' invocation should close. */
+#define MDOC_SYNOPSIS (1 << 7) /* SYNOPSIS-style formatting. */
+#define MDOC_KEEP (1 << 8) /* In a word keep. */
+#define MDOC_SMOFF (1 << 9) /* Spacing is off. */
+#define MDOC_NODELIMC (1 << 10) /* Disable closing delimiter handling. */
+#define MAN_ELINE (1 << 11) /* Next-line element scope. */
+#define MAN_BLINE (1 << 12) /* Next-line block scope. */
+#define MAN_LITERAL MDOC_LITERAL
+#define MAN_NEWLINE MDOC_NEWLINE
+ enum roff_sec lastsec; /* Last section seen. */
+ enum roff_sec lastnamed; /* Last standard section seen. */
+ enum roff_next next; /* Where to put the next node. */
+};
-/* $OpenBSD: tree.c,v 1.31 2015/04/02 22:06:17 schwarze Exp $ */
+/* $OpenBSD: tree.c,v 1.32 2015/04/18 16:04:40 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
void
-tree_mdoc(void *arg, const struct mdoc *mdoc)
+tree_mdoc(void *arg, const struct roff_man *mdoc)
{
print_mdoc(mdoc_node(mdoc)->child, 0);
}
void
-tree_man(void *arg, const struct man *man)
+tree_man(void *arg, const struct roff_man *man)
{
print_man(man_node(man)->child, 0);