Module Name:    src
Committed By:   uwe
Date:           Fri Jul 19 04:55:06 UTC 2013

Modified Files:
        src/usr.bin/man: man.c

Log Message:
manual_find_buildkeyword() - now that we control the format string, we
may use asterisk precision specification instead of temporary
modifying the _build string itself.


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/usr.bin/man/man.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.bin/man/man.c
diff -u src/usr.bin/man/man.c:1.52 src/usr.bin/man/man.c:1.53
--- src/usr.bin/man/man.c:1.52	Fri Jul 19 04:18:10 2013
+++ src/usr.bin/man/man.c	Fri Jul 19 04:55:05 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: man.c,v 1.52 2013/07/19 04:18:10 uwe Exp $	*/
+/*	$NetBSD: man.c,v 1.53 2013/07/19 04:55:05 uwe Exp $	*/
 
 /*
  * Copyright (c) 1987, 1993, 1994, 1995
@@ -40,7 +40,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 19
 #if 0
 static char sccsid[] = "@(#)man.c	8.17 (Berkeley) 1/31/95";
 #else
-__RCSID("$NetBSD: man.c,v 1.52 2013/07/19 04:18:10 uwe Exp $");
+__RCSID("$NetBSD: man.c,v 1.53 2013/07/19 04:55:05 uwe Exp $");
 #endif
 #endif /* not lint */
 
@@ -471,28 +471,26 @@ manual_find_buildkeyword(const char *pre
 	ENTRY *suffix;
 	int found;
 	char *p, buf[MAXPATHLEN];
+	int suflen;
 
 	found = 0;
 	/* Try the _build key words next. */
 	TAILQ_FOREACH(suffix, &mp->buildlist->entrylist, q) {
-		for (p = suffix->s;
+		for (p = suffix->s, suflen = 0;
 		    *p != '\0' && !isspace((unsigned char)*p);
 		    ++p)
-			continue;
+			++suflen;
 		if (*p == '\0')
 			continue;
 
-		*p = '\0';
-		(void)snprintf(buf, sizeof(buf), "%s%s%s",
-			       prefix, escpage, suffix->s);
+		(void)snprintf(buf, sizeof(buf), "%s%s%.*s",
+			       prefix, escpage, suflen, suffix->s);
 		if (!fnmatch(buf, pg->gl_pathv[cnt], 0)) {
 			if (!mp->where)
 				build_page(p + 1, &pg->gl_pathv[cnt], mp);
-			*p = ' ';
 			found = 1;
 			break;
-		}      
-		*p = ' ';
+		}
 	}
 
 	return found;

Reply via email to