version 1.1, 2009/03/23 14:22:11 |
version 1.5, 2009/06/16 19:55:28 |
|
|
/* $Id$ */ |
/* $Id$ */ |
/* |
/* |
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@openbsd.org> |
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se> |
* |
* |
* Permission to use, copy, modify, and distribute this software for any |
* Permission to use, copy, modify, and distribute this software for any |
* purpose with or without fee is hereby granted, provided that the |
* purpose with or without fee is hereby granted, provided that the above |
* above copyright notice and this permission notice appear in all |
* copyright notice and this permission notice appear in all copies. |
* copies. |
|
* |
* |
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
* WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
* WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
* AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
* PERFORMANCE OF THIS SOFTWARE. |
|
*/ |
*/ |
#include <assert.h> |
#include <assert.h> |
#include <ctype.h> |
#include <ctype.h> |
#include <err.h> |
|
#include <stdlib.h> |
#include <stdlib.h> |
#include <stdio.h> |
#include <stdio.h> |
#include <string.h> |
#include <string.h> |
|
|
*/ |
*/ |
|
|
void |
void |
mdoc_tokhash_free(void *htab) |
mdoc_hash_free(void *htab) |
{ |
{ |
|
|
free(htab); |
free(htab); |
Line 40 mdoc_tokhash_free(void *htab) |
|
Line 37 mdoc_tokhash_free(void *htab) |
|
|
|
|
|
void * |
void * |
mdoc_tokhash_alloc(void) |
mdoc_hash_alloc(void) |
{ |
{ |
int i, major, minor, ind; |
int i, major, minor, ind; |
const void **htab; |
const void **htab; |
|
|
htab = calloc(27 * 26 * 3, sizeof(struct mdoc_macro *)); |
htab = calloc(27 * 26 * 3, sizeof(struct mdoc_macro *)); |
if (NULL == htab) |
if (NULL == htab) |
err(1, "calloc"); |
return(NULL); |
|
|
for (i = 1; i < MDOC_MAX; i++) { |
for (i = 0; i < MDOC_MAX; i++) { |
major = mdoc_macronames[i][0]; |
major = mdoc_macronames[i][0]; |
assert((major >= 65 && major <= 90) || |
assert((major >= 65 && major <= 90) || |
major == 37); |
major == 37); |
Line 95 mdoc_tokhash_alloc(void) |
|
Line 92 mdoc_tokhash_alloc(void) |
|
|
|
|
|
int |
int |
mdoc_tokhash_find(const void *arg, const char *tmp) |
mdoc_hash_find(const void *arg, const char *tmp) |
{ |
{ |
int major, minor, ind, slot; |
int major, minor, ind, slot; |
const void **htab; |
const void **htab; |