Module Name: src
Committed By: wiz
Date: Sat May 24 21:01:58 UTC 2014
Modified Files:
src/usr.sbin/makemandb: makemandb.c
Log Message:
Replace non-breaking space with hyphen, and call hyphen replacement
from one more place.
Improves 'man -k midi' output.
>From Abhinav Upadhyay.
To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/usr.sbin/makemandb/makemandb.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.sbin/makemandb/makemandb.c
diff -u src/usr.sbin/makemandb/makemandb.c:1.22 src/usr.sbin/makemandb/makemandb.c:1.23
--- src/usr.sbin/makemandb/makemandb.c:1.22 Mon Feb 10 00:23:36 2014
+++ src/usr.sbin/makemandb/makemandb.c Sat May 24 21:01:58 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: makemandb.c,v 1.22 2014/02/10 00:23:36 chs Exp $ */
+/* $NetBSD: makemandb.c,v 1.23 2014/05/24 21:01:58 wiz Exp $ */
/*
* Copyright (c) 2011 Abhinav Upadhyay <[email protected]>
* Copyright (c) 2011 Kristaps Dzonsons <[email protected]>
@@ -17,7 +17,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: makemandb.c,v 1.22 2014/02/10 00:23:36 chs Exp $");
+__RCSID("$NetBSD: makemandb.c,v 1.23 2014/05/24 21:01:58 wiz Exp $");
#include <sys/stat.h>
#include <sys/types.h>
@@ -124,6 +124,7 @@ static void update_db(sqlite3 *, struct
__dead static void usage(void);
static void optimize(sqlite3 *);
static char *parse_escape(const char *);
+static void replace_hyph(char *);
static makemandb_flags mflags = { .verbosity = 1 };
typedef void (*pman_nf)(const struct man_node *n, mandb_rec *);
@@ -978,6 +979,7 @@ pmdoc_Nd(const struct mdoc_node *n, mand
*/
char *buf = NULL;
char *temp;
+ char *nd_text;
if (n == NULL)
return;
@@ -995,7 +997,10 @@ pmdoc_Nd(const struct mdoc_node *n, mand
free(buf);
free(temp);
} else {
- concat(&rec->name_desc, n->string);
+ nd_text = estrdup(n->string);
+ replace_hyph(nd_text);
+ concat(&rec->name_desc, nd_text);
+ free(nd_text);
}
rec->xr_found = 0;
} else if (mdocs[n->tok] == pmdoc_Xr) {
@@ -2009,6 +2014,10 @@ replace_hyph(char *str)
char *iter = str;
while ((iter = strchr(iter, ASCII_HYPH)) != NULL)
*iter = '-';
+
+ iter = str;
+ while ((iter = strchr(iter, ASCII_NBRSP)) != NULL)
+ *iter = '-';
}
static char *