| @@ -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 |
41 | static char sccsid[] = "@(#)man.c 8.17 (Berkeley) 1/31/95"; | | 41 | static 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 | */ |
112 | static void build_page(char *, char **, struct manstate *); | | 112 | static void build_page(char *, char **, struct manstate *); |
113 | static void cat(char *); | | 113 | static void cat(char *); |
114 | static const char *check_pager(const char *); | | 114 | static const char *check_pager(const char *); |
115 | static int cleanup(void); | | 115 | static int cleanup(void); |
116 | static void how(char *); | | 116 | static void how(char *); |
117 | static void jump(char **, const char *, const char *); | | 117 | static void jump(char **, char *, char *); |
118 | static int manual(char *, struct manstate *, glob_t *); | | 118 | static int manual(char *, struct manstate *, glob_t *); |
119 | static void onsig(int); | | 119 | static void onsig(int); |
120 | static void usage(void) __attribute__((__noreturn__)); | | 120 | static void usage(void) __attribute__((__noreturn__)); |
121 | static void addpath(struct manstate *, const char *, size_t, const char *); | | 121 | static void addpath(struct manstate *, const char *, size_t, const char *); |
122 | static const char *getclass(const char *); | | 122 | static const char *getclass(const char *); |
123 | static void printmanpath(struct manstate *); | | 123 | static void printmanpath(struct manstate *); |
124 | | | 124 | |
125 | /* | | 125 | /* |
126 | * main function | | 126 | * main function |
127 | */ | | 127 | */ |
128 | int | | 128 | int |
129 | main(int argc, char **argv) | | 129 | main(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 | */ |
900 | static void | | 900 | static void |
901 | jump(char **argv, const char *flag, const char *name) | | 901 | jump(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 | |