summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2016-08-17 18:59:37 +0000
committerIngo Schwarze <schwarze@openbsd.org>2016-08-17 18:59:37 +0000
commiteccbe40515e1ca229e250d389f02e0395c281098 (patch)
tree1a9e67925ac25b339a927582d29feca6acb42c78
parent77472d81dfad0b0e6e871a1beaf35cfcfd6a9067 (diff)
downloadmandoc-eccbe40515e1ca229e250d389f02e0395c281098.tar.gz
When reading back a mandoc.db(5) file in order to apply incremental
changes, do not prepend a stray NAME_FILE (0x10) byte to the first names of pages. Bug found while investigating another issue reported by sthen@.
-rw-r--r--dba.c3
-rw-r--r--dba_read.c5
2 files changed, 4 insertions, 4 deletions
diff --git a/dba.c b/dba.c
index b2737922..8762d78e 100644
--- a/dba.c
+++ b/dba.c
@@ -143,7 +143,8 @@ dba_page_new(struct dba_array *pages, const char *name, const char *sect,
page = dba_array_new(DBP_MAX, 0);
entry = dba_array_new(1, DBA_STR | DBA_GROW);
- dba_array_add(entry, prepend(name, NAME_FILE & NAME_MASK));
+ if (name != NULL)
+ dba_array_add(entry, prepend(name, NAME_FILE & NAME_MASK));
dba_array_add(page, entry);
entry = dba_array_new(1, DBA_STR | DBA_GROW);
dba_array_add(entry, (void *)sect);
diff --git a/dba_read.c b/dba_read.c
index 52b655c5..2825d061 100644
--- a/dba_read.c
+++ b/dba_read.c
@@ -48,10 +48,9 @@ dba_read(const char *fname)
dba = dba_new(npages < 128 ? 128 : npages);
for (ip = 0; ip < npages; ip++) {
pdata = dbm_page_get(ip);
- page = dba_page_new(dba->pages, pdata->name, pdata->sect,
+ page = dba_page_new(dba->pages, NULL, pdata->sect,
pdata->arch, pdata->desc, pdata->file + 1, *pdata->file);
- cp = pdata->name;
- while (*(cp = strchr(cp, '\0') + 1) != '\0')
+ for (cp = pdata->name; *cp != '\0'; cp = strchr(cp, '\0') + 1)
dba_page_add(page, DBP_NAME, cp);
cp = pdata->sect;
while (*(cp = strchr(cp, '\0') + 1) != '\0')