diff options
| author | Jerry Jelinek <jerry.jelinek@joyent.com> | 2016-08-18 11:22:02 +0000 |
|---|---|---|
| committer | Jerry Jelinek <jerry.jelinek@joyent.com> | 2016-08-18 11:22:02 +0000 |
| commit | e2384e44b3213551c4ea3de2e9b54f1a39eeb708 (patch) | |
| tree | 27853313eac66267f6845d2701dddf640705cd8d /usr/src/cmd/mandoc/mdoc_hash.c | |
| parent | 2284cf450f099ce8441493d7c9f2c1cb0bbf474f (diff) | |
| parent | 371584c2eae4cf827fd406ba26c14f021adaaa70 (diff) | |
| download | illumos-joyent-e2384e44b3213551c4ea3de2e9b54f1a39eeb708.tar.gz | |
[illumos-gate merge]
commit 371584c2eae4cf827fd406ba26c14f021adaaa70
7243 update mdocml to 1.13.4
commit 7a8b8fd18ff115f0caa89183db5373afb568b630
5166 sendmail package should be replaceable (followup)
Diffstat (limited to 'usr/src/cmd/mandoc/mdoc_hash.c')
| -rw-r--r-- | usr/src/cmd/mandoc/mdoc_hash.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/usr/src/cmd/mandoc/mdoc_hash.c b/usr/src/cmd/mandoc/mdoc_hash.c index 5e34fe8f58..476116d792 100644 --- a/usr/src/cmd/mandoc/mdoc_hash.c +++ b/usr/src/cmd/mandoc/mdoc_hash.c @@ -1,6 +1,7 @@ -/* $Id: mdoc_hash.c,v 1.21 2014/08/10 23:54:41 schwarze Exp $ */ +/* $Id: mdoc_hash.c,v 1.26 2015/10/06 18:32:19 schwarze Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv> + * Copyright (c) 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 @@ -25,22 +26,22 @@ #include <stdio.h> #include <string.h> +#include "roff.h" #include "mdoc.h" #include "libmdoc.h" 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++) { @@ -61,32 +62,32 @@ mdoc_hash_init(void) } } -enum mdoct +int mdoc_hash_find(const char *p) { int major, i, j; if (0 == p[0]) - return(MDOC_MAX); + return TOKEN_NONE; if ( ! isalpha((unsigned char)p[0]) && '%' != p[0]) - return(MDOC_MAX); + return TOKEN_NONE; if (isalpha((unsigned char)p[1])) major = 12 * (tolower((unsigned char)p[1]) - 97); else if ('1' == p[1]) major = 12 * 26; else - return(MDOC_MAX); + return TOKEN_NONE; if (p[2] && p[3]) - return(MDOC_MAX); + return TOKEN_NONE; for (j = 0; j < 12; j++) { if (UCHAR_MAX == (i = table[major + j])) break; if (0 == strcmp(p, mdoc_macronames[i])) - return((enum mdoct)i); + return i; } - return(MDOC_MAX); + return TOKEN_NONE; } |
