X-Git-Url: https://git.cameronkatri.com/mandoc.git/blobdiff_plain/ad9934ce8bce7df653e1eec762a8e13b6ca42b55..4808ca5f163154292de44c6e56a5c97a948e2dbc:/mandocdb.c diff --git a/mandocdb.c b/mandocdb.c index 85f0cca0..2798efca 100644 --- a/mandocdb.c +++ b/mandocdb.c @@ -1,4 +1,4 @@ -/* $Id: mandocdb.c,v 1.147 2014/05/07 15:10:36 schwarze Exp $ */ +/* $Id: mandocdb.c,v 1.149 2014/06/18 19:34:04 schwarze Exp $ */ /* * Copyright (c) 2011, 2012 Kristaps Dzonsons * Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze @@ -2036,13 +2036,22 @@ dbadd(struct mpage *mpage, struct mchars *mc) if (debug) say(mlink->file, "Adding to database"); + i = strlen(mpage->desc) + 1; + key = mandoc_calloc(1, sizeof(struct str) + i); + memcpy(key->key, mpage->desc, i); + render_key(mc, key); + i = 1; - SQL_BIND_TEXT(stmts[STMT_INSERT_PAGE], i, mpage->desc); + SQL_BIND_TEXT(stmts[STMT_INSERT_PAGE], i, key->rendered); SQL_BIND_INT(stmts[STMT_INSERT_PAGE], i, FORM_SRC == mpage->form); SQL_STEP(stmts[STMT_INSERT_PAGE]); mpage->pageid = sqlite3_last_insert_rowid(db); sqlite3_reset(stmts[STMT_INSERT_PAGE]); + if (key->rendered != key->key) + free(key->rendered); + free(key); + while (NULL != mlink) { dbadd_mlink(mlink); mlink = mlink->next; @@ -2221,7 +2230,8 @@ dbopen(int real) rc = sqlite3_open_v2(MANDOC_DB, &db, ofl, NULL); if (SQLITE_OK != rc) { exitcode = (int)MANDOCLEVEL_SYSERR; - say(MANDOC_DB, "%s", sqlite3_errstr(rc)); + if (SQLITE_CANTOPEN != rc) + say(MANDOC_DB, "%s", sqlite3_errstr(rc)); return(0); } goto prepare_statements;