Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/makemandb - handle section numbers that are not sin...



details:   https://anonhg.NetBSD.org/src/rev/5522efb93d0c
branches:  trunk
changeset: 806645:5522efb93d0c
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Mar 04 02:02:15 2015 +0000

description:
- handle section numbers that are not single digits
- don't allocate and free needlessly

diffstat:

 usr.sbin/makemandb/makemandb.c |  16 +++++-----------
 1 files changed, 5 insertions(+), 11 deletions(-)

diffs (48 lines):

diff -r 454f347aa3cf -r 5522efb93d0c usr.sbin/makemandb/makemandb.c
--- a/usr.sbin/makemandb/makemandb.c    Tue Mar 03 23:42:47 2015 +0000
+++ b/usr.sbin/makemandb/makemandb.c    Wed Mar 04 02:02:15 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: makemandb.c,v 1.26 2015/03/02 13:51:24 joerg Exp $     */
+/*     $NetBSD: makemandb.c,v 1.27 2015/03/04 02:02:15 christos Exp $  */
 /*
  * Copyright (c) 2011 Abhinav Upadhyay <er.abhinav.upadhyay%gmail.com@localhost>
  * Copyright (c) 2011 Kristaps Dzonsons <kristaps%bsd.lv@localhost>
@@ -17,7 +17,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: makemandb.c,v 1.26 2015/03/02 13:51:24 joerg Exp $");
+__RCSID("$NetBSD: makemandb.c,v 1.27 2015/03/04 02:02:15 christos Exp $");
 
 #include <sys/stat.h>
 #include <sys/types.h>
@@ -990,12 +990,11 @@
                         * An Xr macro was seen previously, so parse this
                         * and the next node.
                         */
-                       temp = estrdup(n->string);
+                       temp = n->string;
                        n = n->next;
                        easprintf(&buf, "%s(%s)", temp, n->string);
                        concat(&rec->name_desc, buf);
                        free(buf);
-                       free(temp);
                } else {
                        nd_text = estrdup(n->string);
                        replace_hyph(nd_text);
@@ -1052,13 +1051,8 @@
                        n = n->next;
 
                if (n && n->type == MDOC_TEXT) {
-                       size_t len = strlen(sn->string);
-                       char *buf = emalloc(len + 4);
-                       memcpy(buf, sn->string, len);
-                       buf[len] = '(';
-                       buf[len + 1] = n->string[0];
-                       buf[len + 2] = ')';
-                       buf[len + 3] = 0;
+                       char *buf;
+                       easprintf(&buf, "%s(%s)", sn->string, n->string);
                        mdoc_parse_section(n->sec, buf, rec);
                        free(buf);
                }



Home | Main Index | Thread Index | Old Index