NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

bin/51006: makemandb(8) should parse escape sequences in the NAME section



>Number:         51006
>Category:       bin
>Synopsis:       makemandb(8) should parse escape sequences in the NAME section
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Mar 24 17:25:00 +0000 2016
>Originator:     Abhinav Upadhyay
>Release:        CURRENT
>Organization:
>Environment:
>Description:
makemandb(8) does not handle escape sequences like \- in the NAME section. 
>How-To-Repeat:
Index a man page which contains an escape sequence like \- in the NAME section. For example:

.Nm update\-binfmts

And try searching for it using apropos(1), the output would show the escape sequence as it is.

The attached patch handles this. It also removes a couple of unused includes and changes the type of a variable to size_t from int as it should have been.
>Fix:
Index: makemandb.c
===================================================================
RCS file: /cvsroot/src/usr.sbin/makemandb/makemandb.c,v
retrieving revision 1.31
diff -u -r1.31 makemandb.c
--- makemandb.c	28 Jan 2016 03:32:29 -0000	1.31
+++ makemandb.c	24 Mar 2016 17:18:49 -0000
@@ -23,7 +23,6 @@
 #include <sys/types.h>
 
 #include <assert.h>
-#include <ctype.h>
 #include <dirent.h>
 #include <err.h>
 #include <archive.h>
@@ -39,7 +38,6 @@
 #include "dist/man.h"
 #include "dist/mandoc.h"
 #include "dist/mdoc.h"
-#include "sqlite3.h"
 
 #define BUFLEN 1024
 #define MDOC 0	//If the page is of mdoc(7) type
@@ -1013,7 +1011,9 @@
 
 	for (n = n->child; n; n = n->next) {
 		if (n->type == MDOC_TEXT) {
-			concat(&rec->name, n->string);
+			char *escaped_name = parse_escape(n->string);
+			concat(&rec->name, escaped_name);
+			free(escaped_name);
 		}
 	}
 }
@@ -1045,8 +1045,7 @@
 			concat(&rec->name_desc, buf);
 			free(buf);
 		} else {
-			nd_text = estrdup(n->string);
-			replace_hyph(nd_text);
+			nd_text = parse_escape(n->string);
 			concat(&rec->name_desc, nd_text);
 			free(nd_text);
 		}
@@ -1329,7 +1328,7 @@
 	};
 	const struct man_node *head;
 	char *name_desc;
-	int sz;
+	size_t sz;
 	size_t i;
 
 	if ((head = n->parent->head) == NULL || (head = head->child) == NULL ||



Home | Main Index | Thread Index | Old Index