diff options
-rw-r--r-- | libman.h | 3 | ||||
-rw-r--r-- | libmandoc.h | 4 | ||||
-rw-r--r-- | libmdoc.h | 3 | ||||
-rw-r--r-- | man.c | 4 | ||||
-rw-r--r-- | man_hash.c | 9 | ||||
-rw-r--r-- | mdoc.c | 3 | ||||
-rw-r--r-- | mdoc_hash.c | 9 | ||||
-rw-r--r-- | read.c | 12 |
8 files changed, 24 insertions, 23 deletions
@@ -1,4 +1,4 @@ -/* $Id: libman.h,v 1.71 2015/04/18 16:06:39 schwarze Exp $ */ +/* $Id: libman.h,v 1.72 2015/04/18 17:01:58 schwarze Exp $ */ /* * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org> @@ -43,7 +43,6 @@ 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 roff_man *); void man_valid_post(struct roff_man *); diff --git a/libmandoc.h b/libmandoc.h index 5aac4253..c16cf4d3 100644 --- a/libmandoc.h +++ b/libmandoc.h @@ -1,4 +1,4 @@ -/* $Id: libmandoc.h,v 1.56 2015/04/18 16:06:39 schwarze Exp $ */ +/* $Id: libmandoc.h,v 1.57 2015/04/18 17:01:58 schwarze Exp $ */ /* * Copyright (c) 2009, 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org> @@ -58,6 +58,7 @@ void mdoc_free(struct roff_man *); struct roff_man *mdoc_alloc(struct roff *, struct mparse *, const char *, int); void mdoc_reset(struct roff_man *); +void mdoc_hash_init(void); 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 *); @@ -67,6 +68,7 @@ void man_free(struct roff_man *); struct roff_man *man_alloc(struct roff *, struct mparse *, const char *, int); void man_reset(struct roff_man *); +void man_hash_init(void); 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 *); @@ -1,4 +1,4 @@ -/* $Id: libmdoc.h,v 1.100 2015/04/18 16:06:39 schwarze Exp $ */ +/* $Id: libmdoc.h,v 1.101 2015/04/18 17:01:58 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org> @@ -80,7 +80,6 @@ struct roff_node *mdoc_endbody_alloc(struct roff_man *, int, int, int, struct roff_node *, enum mdoc_endbody); 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_a2lib(const char *); @@ -1,4 +1,4 @@ -/* $Id: man.c,v 1.154 2015/04/18 16:34:25 schwarze Exp $ */ +/* $Id: man.c,v 1.155 2015/04/18 17:01:58 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org> @@ -101,8 +101,6 @@ man_alloc(struct roff *roff, struct mparse *parse, struct roff_man *p; p = mandoc_calloc(1, sizeof(*p)); - - man_hash_init(); p->parse = parse; p->defos = defos; p->quick = quick; @@ -1,4 +1,4 @@ -/* $Id: man_hash.c,v 1.31 2015/04/02 22:48:17 schwarze Exp $ */ +/* $Id: man_hash.c,v 1.32 2015/04/18 17:01:58 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -47,15 +47,14 @@ 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. - */ void man_hash_init(void) { int i, j, x; + if (*table != '\0') + return; + memset(table, UCHAR_MAX, sizeof(table)); assert(MAN_MAX < UCHAR_MAX); @@ -1,4 +1,4 @@ -/* $Id: mdoc.c,v 1.243 2015/04/18 16:34:25 schwarze Exp $ */ +/* $Id: mdoc.c,v 1.244 2015/04/18 17:01:58 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010, 2012-2015 Ingo Schwarze <schwarze@openbsd.org> @@ -187,7 +187,6 @@ mdoc_alloc(struct roff *roff, struct mparse *parse, p->quick = quick; p->roff = roff; - mdoc_hash_init(); mdoc_alloc1(p); return(p); } diff --git a/mdoc_hash.c b/mdoc_hash.c index cd576511..0da3c9a1 100644 --- a/mdoc_hash.c +++ b/mdoc_hash.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_hash.c,v 1.23 2015/04/02 22:48:17 schwarze Exp $ */ +/* $Id: mdoc_hash.c,v 1.24 2015/04/18 17:01:58 schwarze Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -32,16 +32,15 @@ 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. - */ void mdoc_hash_init(void) { int i, j, major; const char *p; + if (*table != '\0') + return; + memset(table, UCHAR_MAX, sizeof(table)); for (i = 0; i < (int)MDOC_MAX; i++) { @@ -1,4 +1,4 @@ -/* $Id: read.c,v 1.135 2015/04/18 16:34:25 schwarze Exp $ */ +/* $Id: read.c,v 1.136 2015/04/18 17:01:58 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org> @@ -296,6 +296,7 @@ choose_parser(struct mparse *curp) MPARSE_QUICK & curp->options ? 1 : 0); else curp->man->macroset = MACROSET_MDOC; + mdoc_hash_init(); return; } @@ -307,6 +308,7 @@ choose_parser(struct mparse *curp) MPARSE_QUICK & curp->options ? 1 : 0); else curp->man->macroset = MACROSET_MAN; + man_hash_init(); } /* @@ -890,14 +892,18 @@ mparse_alloc(int options, enum mandoclevel wlevel, mandocmsg mmsg, curp->mchars = mchars; curp->roff = roff_alloc(curp, curp->mchars, options); - if (curp->options & MPARSE_MDOC) + if (curp->options & MPARSE_MDOC) { curp->man = mdoc_alloc( curp->roff, curp, curp->defos, curp->options & MPARSE_QUICK ? 1 : 0); - if (curp->options & MPARSE_MAN) + mdoc_hash_init(); + } + if (curp->options & MPARSE_MAN) { curp->man = man_alloc( curp->roff, curp, curp->defos, curp->options & MPARSE_QUICK ? 1 : 0); + man_hash_init(); + } return(curp); } |