=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mandoc/mansearch.c,v retrieving revision 1.23 retrieving revision 1.24 diff -c -r1.23 -r1.24 *** src/usr.bin/mandoc/mansearch.c 2014/04/17 19:19:54 1.23 --- src/usr.bin/mandoc/mansearch.c 2014/04/20 16:44:44 1.24 *************** *** 1,4 **** ! /* $Id: mansearch.c,v 1.23 2014/04/17 19:19:54 schwarze Exp $ */ /* * Copyright (c) 2012 Kristaps Dzonsons * Copyright (c) 2013, 2014 Ingo Schwarze --- 1,4 ---- ! /* $Id: mansearch.c,v 1.24 2014/04/20 16:44:44 schwarze Exp $ */ /* * Copyright (c) 2012 Kristaps Dzonsons * Copyright (c) 2013, 2014 Ingo Schwarze *************** *** 56,62 **** } while (0) struct expr { ! 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 */ --- 56,62 ---- } while (0) struct expr { ! 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 */ *************** *** 79,85 **** 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 *, int, char *[]); static void exprfree(struct expr *); static struct expr *exprspec(struct expr *, uint64_t, --- 79,85 ---- 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 *, int, char *[]); static void exprfree(struct expr *); static struct expr *exprspec(struct expr *, uint64_t, *************** *** 93,98 **** --- 93,99 ---- int argc, sqlite3_value **argv); static char *sql_statement(const struct expr *); + int mansearch_setup(int start) { *************** *** 227,237 **** } else if (-1 == chdir(paths->paths[i])) { perror(paths->paths[i]); continue; ! } ! c = sqlite3_open_v2 ! (MANDOC_DB, &db, ! SQLITE_OPEN_READONLY, NULL); if (SQLITE_OK != c) { perror(MANDOC_DB); --- 228,237 ---- } else if (-1 == chdir(paths->paths[i])) { perror(paths->paths[i]); continue; ! } ! c = sqlite3_open_v2(MANDOC_DB, &db, ! SQLITE_OPEN_READONLY, NULL); if (SQLITE_OK != c) { perror(MANDOC_DB); *************** *** 280,288 **** */ 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); if (NULL != ohash_find(&htab, idx)) continue; --- 280,288 ---- */ 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); if (NULL != ohash_find(&htab, idx)) continue; *************** *** 301,307 **** sqlite3_finalize(s); ! c = sqlite3_prepare_v2(db, "SELECT * FROM mlinks WHERE pageid=?" " ORDER BY sec, arch, name", -1, &s, NULL); --- 301,307 ---- sqlite3_finalize(s); ! c = sqlite3_prepare_v2(db, "SELECT * FROM mlinks WHERE pageid=?" " ORDER BY sec, arch, name", -1, &s, NULL); *************** *** 319,326 **** mp = ohash_next(&htab, &idx)) { if (cur + 1 > maxres) { maxres += 1024; ! *res = mandoc_realloc ! (*res, maxres * sizeof(struct manpage)); } mpage = *res + cur; mpage->form = mp->form; --- 319,326 ---- mp = ohash_next(&htab, &idx)) { if (cur + 1 > maxres) { maxres += 1024; ! *res = mandoc_realloc(*res, ! maxres * sizeof(struct manpage)); } mpage = *res + cur; mpage->form = mp->form;