From 3f3ed8b5d3bdfdccaf28b637ce563f144c279163 Mon Sep 17 00:00:00 2001 From: schwarze Date: Wed, 17 Aug 2016 18:58:31 +0000 Subject: [PATCH] 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@. --- usr.bin/mandoc/dba.c | 5 +++-- usr.bin/mandoc/dba_read.c | 7 +++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/usr.bin/mandoc/dba.c b/usr.bin/mandoc/dba.c index 3b0cf14c9a9..f48aab94b5c 100644 --- a/usr.bin/mandoc/dba.c +++ b/usr.bin/mandoc/dba.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dba.c,v 1.3 2016/08/17 18:05:40 schwarze Exp $ */ +/* $OpenBSD: dba.c,v 1.4 2016/08/17 18:58:31 schwarze Exp $ */ /* * Copyright (c) 2016 Ingo Schwarze * @@ -135,7 +135,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/usr.bin/mandoc/dba_read.c b/usr.bin/mandoc/dba_read.c index b260ac1fca7..cd4db383112 100644 --- a/usr.bin/mandoc/dba_read.c +++ b/usr.bin/mandoc/dba_read.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dba_read.c,v 1.2 2016/08/04 09:33:53 schwarze Exp $ */ +/* $OpenBSD: dba_read.c,v 1.3 2016/08/17 18:58:31 schwarze Exp $ */ /* * Copyright (c) 2016 Ingo Schwarze * @@ -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') -- 2.20.1