summaryrefslogtreecommitdiffstatshomepage
path: root/mandoc-db.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-04-12 14:48:42 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-04-12 14:48:42 +0000
commitab305b63a6468e3d5a6a74fb19fb34dca6bacc8e (patch)
tree5f69e5bbf79795d0bfacdc52314927b2ad8f3d7d /mandoc-db.c
parent5e986fcbc8a80b801650e0f47d6a0e556b200508 (diff)
downloadmandoc-ab305b63a6468e3d5a6a74fb19fb34dca6bacc8e.tar.gz
mandoc-ab305b63a6468e3d5a6a74fb19fb34dca6bacc8e.tar.zst
mandoc-ab305b63a6468e3d5a6a74fb19fb34dca6bacc8e.zip
Let mandoc-db also collect -man descriptions.
Diffstat (limited to 'mandoc-db.c')
-rw-r--r--mandoc-db.c32
1 files changed, 26 insertions, 6 deletions
diff --git a/mandoc-db.c b/mandoc-db.c
index 1f493b68..d3e28ed4 100644
--- a/mandoc-db.c
+++ b/mandoc-db.c
@@ -1,4 +1,4 @@
-/* $Id: mandoc-db.c,v 1.11 2011/04/11 22:56:25 kristaps Exp $ */
+/* $Id: mandoc-db.c,v 1.12 2011/04/12 14:48:42 kristaps Exp $ */
/*
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -731,7 +731,7 @@ static int
pman_node(MAN_ARGS)
{
const struct man_node *head, *body;
- const char *start;
+ const char *start, *sv;
const char nil = '\0';
size_t sz;
uint32_t fl;
@@ -760,7 +760,8 @@ pman_node(MAN_ARGS)
fl = MANDOC_NAME;
memcpy(val->data, &fl, 4);
- start = body->string;
+ assert(body->string);
+ start = sv = body->string;
/*
* Go through a special heuristic dance here.
@@ -771,7 +772,7 @@ pman_node(MAN_ARGS)
* the name parts here.
*/
- while (start) {
+ for ( ;; ) {
sz = strcspn(start, " ,");
if ('\0' == start[(int)sz])
break;
@@ -782,8 +783,10 @@ pman_node(MAN_ARGS)
dbt_put(db, dbn, key, val);
- if (' ' == start[(int)sz])
+ if (' ' == start[(int)sz]) {
+ start += (int)sz + 1;
break;
+ }
assert(',' == start[(int)sz]);
start += (int)sz + 1;
@@ -791,7 +794,24 @@ pman_node(MAN_ARGS)
start++;
}
- return(1);
+ if (sv == start) {
+ dbt_init(key, ksz);
+ dbt_append(key, ksz, start);
+ return(1);
+ }
+
+ while (' ' == *start)
+ start++;
+
+ if ('\\' == *start && '-' == *(start + 1))
+ start += 2;
+ else if ('-' == *start)
+ start++;
+
+ while (' ' == *start)
+ start++;
+
+ dbt_appendb(rval, rsz, start, strlen(start) + 1);
}
}