Thu Jul 18 04:05:32 2013 UTC ()
Revert previous; other errors from WARNS=3 obscured the error in jump().


(uwe)
diff -r1.46 -r1.47 src/usr.bin/man/man.c

cvs diff -r1.46 -r1.47 src/usr.bin/man/man.c (expand / switch to unified diff)

--- src/usr.bin/man/man.c 2013/07/18 04:02:31 1.46
+++ src/usr.bin/man/man.c 2013/07/18 04:05:32 1.47
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: man.c,v 1.46 2013/07/18 04:02:31 uwe Exp $ */ 1/* $NetBSD: man.c,v 1.47 2013/07/18 04:05:32 uwe Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1987, 1993, 1994, 1995 4 * Copyright (c) 1987, 1993, 1994, 1995
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -30,27 +30,27 @@ @@ -30,27 +30,27 @@
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33 33
34#ifndef lint 34#ifndef lint
35__COPYRIGHT("@(#) Copyright (c) 1987, 1993, 1994, 1995\ 35__COPYRIGHT("@(#) Copyright (c) 1987, 1993, 1994, 1995\
36 The Regents of the University of California. All rights reserved."); 36 The Regents of the University of California. All rights reserved.");
37#endif /* not lint */ 37#endif /* not lint */
38 38
39#ifndef lint 39#ifndef lint
40#if 0 40#if 0
41static char sccsid[] = "@(#)man.c 8.17 (Berkeley) 1/31/95"; 41static char sccsid[] = "@(#)man.c 8.17 (Berkeley) 1/31/95";
42#else 42#else
43__RCSID("$NetBSD: man.c,v 1.46 2013/07/18 04:02:31 uwe Exp $"); 43__RCSID("$NetBSD: man.c,v 1.47 2013/07/18 04:05:32 uwe Exp $");
44#endif 44#endif
45#endif /* not lint */ 45#endif /* not lint */
46 46
47#include <sys/param.h> 47#include <sys/param.h>
48#include <sys/queue.h> 48#include <sys/queue.h>
49#include <sys/stat.h> 49#include <sys/stat.h>
50#include <sys/utsname.h> 50#include <sys/utsname.h>
51 51
52#include <ctype.h> 52#include <ctype.h>
53#include <err.h> 53#include <err.h>
54#include <errno.h> 54#include <errno.h>
55#include <fcntl.h> 55#include <fcntl.h>
56#include <fnmatch.h> 56#include <fnmatch.h>
@@ -104,27 +104,27 @@ struct manstate { @@ -104,27 +104,27 @@ struct manstate {
104 size_t pagerlen; /* length of the above */ 104 size_t pagerlen; /* length of the above */
105 const char *machine; /* machine */ 105 const char *machine; /* machine */
106 const char *machclass; /* machine class */ 106 const char *machclass; /* machine class */
107}; 107};
108 108
109/* 109/*
110 * prototypes 110 * prototypes
111 */ 111 */
112static void build_page(char *, char **, struct manstate *); 112static void build_page(char *, char **, struct manstate *);
113static void cat(char *); 113static void cat(char *);
114static const char *check_pager(const char *); 114static const char *check_pager(const char *);
115static int cleanup(void); 115static int cleanup(void);
116static void how(char *); 116static void how(char *);
117static void jump(char **, const char *, const char *); 117static void jump(char **, char *, char *);
118static int manual(char *, struct manstate *, glob_t *); 118static int manual(char *, struct manstate *, glob_t *);
119static void onsig(int); 119static void onsig(int);
120static void usage(void) __attribute__((__noreturn__)); 120static void usage(void) __attribute__((__noreturn__));
121static void addpath(struct manstate *, const char *, size_t, const char *); 121static void addpath(struct manstate *, const char *, size_t, const char *);
122static const char *getclass(const char *); 122static const char *getclass(const char *);
123static void printmanpath(struct manstate *); 123static void printmanpath(struct manstate *);
124 124
125/* 125/*
126 * main function 126 * main function
127 */ 127 */
128int 128int
129main(int argc, char **argv) 129main(int argc, char **argv)
130{ 130{
@@ -888,27 +888,27 @@ check_pager(const char *name) @@ -888,27 +888,27 @@ check_pager(const char *name)
888 char *newname; 888 char *newname;
889 (void)asprintf(&newname, "%s %s", p, "-s"); 889 (void)asprintf(&newname, "%s %s", p, "-s");
890 name = newname; 890 name = newname;
891 } 891 }
892 892
893 return name; 893 return name;
894} 894}
895 895
896/* 896/*
897 * jump -- 897 * jump --
898 * strip out flag argument and jump 898 * strip out flag argument and jump
899 */ 899 */
900static void 900static void
901jump(char **argv, const char *flag, const char *name) 901jump(char **argv, char *flag, char *name)
902{ 902{
903 char **arg; 903 char **arg;
904 904
905 argv[0] = name; 905 argv[0] = name;
906 for (arg = argv + 1; *arg; ++arg) 906 for (arg = argv + 1; *arg; ++arg)
907 if (!strcmp(*arg, flag)) 907 if (!strcmp(*arg, flag))
908 break; 908 break;
909 for (; *arg; ++arg) 909 for (; *arg; ++arg)
910 arg[0] = arg[1]; 910 arg[0] = arg[1];
911 execvp(name, argv); 911 execvp(name, argv);
912 err(EXIT_FAILURE, "Cannot execute `%s'", name); 912 err(EXIT_FAILURE, "Cannot execute `%s'", name);
913} 913}
914 914