summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-11-19 20:40:51 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-11-19 20:40:51 +0000
commite83d3f1920808345008b02a30870871c3f4e489d (patch)
treea80ac029458605cc811a776c5b133adb02868e3c
parentccbf554d2b7a5d479480e7fc4cd19af77a60b272 (diff)
downloadmandoc-e83d3f1920808345008b02a30870871c3f4e489d.tar.gz
Three fixes with respect to the names table:
1. Do not mask out NAME_FIRST before its first use. 2. Avoid duplicate NAME_FILE entries. 3. Correctly mask NAME_FILE for .so links.
-rw-r--r--mandocdb.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/mandocdb.c b/mandocdb.c
index 375b83df..2ed78b34 100644
--- a/mandocdb.c
+++ b/mandocdb.c
@@ -138,6 +138,7 @@ struct mdoc_handler {
static void dbclose(int);
static void dbadd(struct mpage *, struct mchars *);
static void dbadd_mlink(const struct mlink *mlink);
+static void dbadd_mlink_name(const struct mlink *mlink);
static int dbopen(int);
static void dbprune(void);
static void filescan(const char *);
@@ -1153,7 +1154,7 @@ mpages_merge(struct mchars *mc, struct mparse *mp)
*/
if (mpage_dest->pageid)
- dbadd_mlink(mlink);
+ dbadd_mlink_name(mlink);
if (NULL == mlink->next)
break;
@@ -1728,7 +1729,8 @@ putkeys(const struct mpage *mpage,
if (TYPE_Nm & v) {
htab = &names;
v &= name_mask;
- name_mask &= ~NAME_FIRST;
+ if (v & NAME_FIRST)
+ name_mask &= ~NAME_FIRST;
if (debug > 1)
say(mpage->mlinks->file,
"Adding name %*s", sz, cp);
@@ -1943,9 +1945,17 @@ dbadd_mlink(const struct mlink *mlink)
SQL_BIND_INT64(stmts[STMT_INSERT_LINK], i, mlink->mpage->pageid);
SQL_STEP(stmts[STMT_INSERT_LINK]);
sqlite3_reset(stmts[STMT_INSERT_LINK]);
+}
+
+static void
+dbadd_mlink_name(const struct mlink *mlink)
+{
+ size_t i;
+
+ dbadd_mlink(mlink);
i = 1;
- SQL_BIND_INT64(stmts[STMT_INSERT_NAME], i, NAME_FILE);
+ SQL_BIND_INT64(stmts[STMT_INSERT_NAME], i, NAME_FILE & NAME_MASK);
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]);