summaryrefslogtreecommitdiffstats
path: root/mandocdb.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-12-04 21:48:48 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-12-04 21:48:48 +0000
commit00da30523681abb2b25dcfc0c8b45ce7cd9892b2 (patch)
tree282fa0bd38c60e14a1fbc461b66d07c80495859c /mandocdb.c
parent0c7f28060977550abf4631495890e36315968838 (diff)
downloadmandoc-00da30523681abb2b25dcfc0c8b45ce7cd9892b2.tar.gz
When finding a .so link after the page was already processed,
do not clobber the existing names flags; instead, OR the additional flags into them.
Diffstat (limited to 'mandocdb.c')
-rw-r--r--mandocdb.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/mandocdb.c b/mandocdb.c
index 14d58b11..a7c6b4b8 100644
--- a/mandocdb.c
+++ b/mandocdb.c
@@ -125,6 +125,7 @@ enum stmt {
STMT_INSERT_PAGE, /* insert mpage */
STMT_INSERT_LINK, /* insert mlink */
STMT_INSERT_NAME, /* insert name */
+ STMT_SELECT_NAME, /* retrieve existing name flags */
STMT_INSERT_KEY, /* insert parsed key */
STMT__MAX
};
@@ -1789,7 +1790,7 @@ putkeys(const struct mpage *mpage,
name_mask &= ~NAME_FIRST;
if (debug > 1)
say(mpage->mlinks->file,
- "Adding name %*s", sz, cp);
+ "Adding name %*s, bits=%d", sz, cp, v);
} else {
htab = &strings;
if (debug > 1)
@@ -2006,12 +2007,21 @@ dbadd_mlink(const struct mlink *mlink)
static void
dbadd_mlink_name(const struct mlink *mlink)
{
+ uint64_t bits;
size_t i;
dbadd_mlink(mlink);
i = 1;
- SQL_BIND_INT64(stmts[STMT_INSERT_NAME], i, NAME_FILE & NAME_MASK);
+ SQL_BIND_INT64(stmts[STMT_SELECT_NAME], i, mlink->mpage->pageid);
+ bits = NAME_FILE & NAME_MASK;
+ if (sqlite3_step(stmts[STMT_SELECT_NAME]) == SQLITE_ROW) {
+ bits |= sqlite3_column_int64(stmts[STMT_SELECT_NAME], 0);
+ sqlite3_reset(stmts[STMT_SELECT_NAME]);
+ }
+
+ i = 1;
+ SQL_BIND_INT64(stmts[STMT_INSERT_NAME], i, bits);
SQL_BIND_TEXT(stmts[STMT_INSERT_NAME], i, mlink->name);
SQL_BIND_INT64(stmts[STMT_INSERT_NAME], i, mlink->mpage->pageid);
SQL_STEP(stmts[STMT_INSERT_NAME]);
@@ -2324,7 +2334,8 @@ create_tables:
" \"bits\" INTEGER NOT NULL,\n"
" \"name\" TEXT NOT NULL,\n"
" \"pageid\" INTEGER NOT NULL REFERENCES mpages(pageid) "
- "ON DELETE CASCADE\n"
+ "ON DELETE CASCADE,\n"
+ " UNIQUE (\"name\", \"pageid\") ON CONFLICT REPLACE\n"
");\n"
"\n"
"CREATE TABLE \"keys\" (\n"
@@ -2362,6 +2373,8 @@ prepare_statements:
sql = "INSERT INTO mlinks "
"(sec,arch,name,pageid) VALUES (?,?,?,?)";
sqlite3_prepare_v2(db, sql, -1, &stmts[STMT_INSERT_LINK], NULL);
+ sql = "SELECT bits FROM names where pageid = ?";
+ sqlite3_prepare_v2(db, sql, -1, &stmts[STMT_SELECT_NAME], NULL);
sql = "INSERT INTO names "
"(bits,name,pageid) VALUES (?,?,?)";
sqlite3_prepare_v2(db, sql, -1, &stmts[STMT_INSERT_NAME], NULL);