Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/makemandb Also handle hyphen replacement if it was ...



details:   https://anonhg.NetBSD.org/src/rev/30983b757e7e
branches:  trunk
changeset: 777345:30983b757e7e
user:      joerg <joerg%NetBSD.org@localhost>
date:      Wed Feb 15 23:36:10 2012 +0000

description:
Also handle hyphen replacement if it was used as plain input and no
backslash sequence was used at all in the line.

diffstat:

 usr.sbin/makemandb/makemandb.c |  24 +++++++++++++++++-------
 1 files changed, 17 insertions(+), 7 deletions(-)

diffs (59 lines):

diff -r 10ed8bb10216 -r 30983b757e7e usr.sbin/makemandb/makemandb.c
--- a/usr.sbin/makemandb/makemandb.c    Wed Feb 15 23:35:00 2012 +0000
+++ b/usr.sbin/makemandb/makemandb.c    Wed Feb 15 23:36:10 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: makemandb.c,v 1.3 2012/02/15 23:35:00 joerg Exp $      */
+/*     $NetBSD: makemandb.c,v 1.4 2012/02/15 23:36:10 joerg 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.3 2012/02/15 23:35:00 joerg Exp $");
+__RCSID("$NetBSD: makemandb.c,v 1.4 2012/02/15 23:36:10 joerg Exp $");
 
 #include <sys/stat.h>
 #include <sys/types.h>
@@ -1846,6 +1846,14 @@
        free(rec->errors.data);
 }
 
+static void
+replace_hyph(char *str)
+{
+       char *iter = str;
+       while ((iter = strchr(iter, ASCII_HYPH)) != NULL)
+               *iter = '-';
+}
+
 static char *
 parse_escape(const char *str)
 {
@@ -1857,8 +1865,11 @@
 
        last_backslash = str;
        backslash = strchr(str, '\\');
-       if (backslash == NULL)
-               return estrdup(str);
+       if (backslash == NULL) {
+               result = estrdup(str);
+               replace_hyph(result);
+               return result;
+       }
 
        result = emalloc(strlen(str) + 1);
        iter = result;
@@ -1882,9 +1893,8 @@
        } while (backslash != NULL);
        if (last_backslash != NULL)
                strcpy(iter, last_backslash);
-       iter = result;
-       while ((iter = strchr(iter, ASCII_HYPH)) != NULL)
-               *iter = '-';
+       
+       replace_hyph(result);
        return result;
 }
 



Home | Main Index | Thread Index | Old Index