* mdocml: correctly store .Dt and .TH information in the names table
@ 2014-12-04 20:13 schwarze
0 siblings, 0 replies; only message in thread
From: schwarze @ 2014-12-04 20:13 UTC (permalink / raw)
To: source
Log Message:
-----------
correctly store .Dt and .TH information in the names table
Modified Files:
--------------
mdocml:
mandocdb.c
Revision Data
-------------
Index: mandocdb.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mandocdb.c,v
retrieving revision 1.173
retrieving revision 1.174
diff -Lmandocdb.c -Lmandocdb.c -u -p -r1.173 -r1.174
--- mandocdb.c
+++ mandocdb.c
@@ -104,6 +104,7 @@ struct mpage {
char *desc; /* description from file content */
struct mlink *mlinks; /* singly linked list */
int form; /* format from file content */
+ int name_head_done;
};
struct mlink {
@@ -154,7 +155,8 @@ static void mpages_free(void);
static void mpages_merge(struct mchars *, struct mparse *);
static void names_check(void);
static void parse_cat(struct mpage *, int);
-static void parse_man(struct mpage *, const struct man_node *);
+static void parse_man(struct mpage *, const struct man_meta *,
+ const struct man_node *);
static void parse_mdoc(struct mpage *, const struct mdoc_meta *,
const struct mdoc_node *);
static int parse_mdoc_body(struct mpage *, const struct mdoc_meta *,
@@ -1225,16 +1227,14 @@ mpages_merge(struct mchars *mc, struct m
putkey(mpage, mlink->name, NAME_FILE);
}
- assert(NULL == mpage->desc);
- if (NULL != mdoc) {
- if (NULL != (cp = mdoc_meta(mdoc)->name))
- putkey(mpage, cp, NAME_HEAD);
+ assert(mpage->desc == NULL);
+ if (mdoc != NULL)
parse_mdoc(mpage, mdoc_meta(mdoc), mdoc_node(mdoc));
- } else if (NULL != man)
- parse_man(mpage, man_node(man));
+ else if (man != NULL)
+ parse_man(mpage, man_meta(man), man_node(man));
else
parse_cat(mpage, fd);
- if (NULL == mpage->desc)
+ if (mpage->desc == NULL)
mpage->desc = mandoc_strdup(mpage->mlinks->name);
if (warnings && !use_all)
@@ -1439,7 +1439,8 @@ putmdockey(const struct mpage *mpage,
}
static void
-parse_man(struct mpage *mpage, const struct man_node *n)
+parse_man(struct mpage *mpage, const struct man_meta *meta,
+ const struct man_node *n)
{
const struct man_node *head, *body;
char *start, *title;
@@ -1505,6 +1506,11 @@ parse_man(struct mpage *mpage, const str
break;
putkey(mpage, start, NAME_TITLE);
+ if ( ! (mpage->name_head_done ||
+ strcasecmp(start, meta->title))) {
+ putkey(mpage, start, NAME_HEAD);
+ mpage->name_head_done = 1;
+ }
if (' ' == byte) {
start += sz + 1;
@@ -1519,6 +1525,11 @@ parse_man(struct mpage *mpage, const str
if (start == title) {
putkey(mpage, start, NAME_TITLE);
+ if ( ! (mpage->name_head_done ||
+ strcasecmp(start, meta->title))) {
+ putkey(mpage, start, NAME_HEAD);
+ mpage->name_head_done = 1;
+ }
free(title);
return;
}
@@ -1549,7 +1560,7 @@ parse_man(struct mpage *mpage, const str
for (n = n->child; n; n = n->next) {
if (NULL != mpage->desc)
break;
- parse_man(mpage, n);
+ parse_man(mpage, meta, n);
}
}
@@ -1719,6 +1730,12 @@ parse_mdoc_Nm(struct mpage *mpage, const
putkey(mpage, meta->name, NAME_SYN);
else
putmdockey(mpage, n->child, NAME_SYN);
+ }
+ if ( ! (mpage->name_head_done ||
+ n->child == NULL || n->child->string == NULL ||
+ strcasecmp(n->child->string, meta->title))) {
+ putkey(mpage, n->child->string, NAME_HEAD);
+ mpage->name_head_done = 1;
}
return(0);
}
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2014-12-04 20:13 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-04 20:13 mdocml: correctly store .Dt and .TH information in the names table schwarze
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).