Deleted Added
full compact
manpage.c (275432) manpage.c (279527)
1/* $Id: manpage.c,v 1.9 2014/08/17 03:24:47 schwarze Exp $ */
1/* $Id: manpage.c,v 1.10 2015/02/10 08:05:30 schwarze Exp $ */
2/*
3 * Copyright (c) 2012 Kristaps Dzonsons <kristaps@bsd.lv>
4 * Copyright (c) 2013 Ingo Schwarze <schwarze@openbsd.org>
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *

--- 92 unchanged lines hidden (view full) ---

102 return(EXIT_FAILURE);
103 } else if (1 == sz && term) {
104 i = 1;
105 goto show;
106 } else if (NULL == res)
107 return(EXIT_FAILURE);
108
109 for (i = 0; i < sz; i++) {
2/*
3 * Copyright (c) 2012 Kristaps Dzonsons <kristaps@bsd.lv>
4 * Copyright (c) 2013 Ingo Schwarze <schwarze@openbsd.org>
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *

--- 92 unchanged lines hidden (view full) ---

102 return(EXIT_FAILURE);
103 } else if (1 == sz && term) {
104 i = 1;
105 goto show;
106 } else if (NULL == res)
107 return(EXIT_FAILURE);
108
109 for (i = 0; i < sz; i++) {
110 printf("%6zu %s: %s\n",
110 printf("%6zu %s: %s\n",
111 i + 1, res[i].names, res[i].output);
112 free(res[i].names);
113 free(res[i].output);
114 }
115
116 if (0 == term) {
117 for (i = 0; i < sz; i++)
118 free(res[i].file);

--- 24 unchanged lines hidden (view full) ---

143 for (i = 0; i < sz; i++)
144 free(res[i].file);
145 free(res);
146
147 show(cmd, buf);
148 /* NOTREACHED */
149usage:
150 fprintf(stderr, "usage: %s [-C conf] "
111 i + 1, res[i].names, res[i].output);
112 free(res[i].names);
113 free(res[i].output);
114 }
115
116 if (0 == term) {
117 for (i = 0; i < sz; i++)
118 free(res[i].file);

--- 24 unchanged lines hidden (view full) ---

143 for (i = 0; i < sz; i++)
144 free(res[i].file);
145 free(res);
146
147 show(cmd, buf);
148 /* NOTREACHED */
149usage:
150 fprintf(stderr, "usage: %s [-C conf] "
151 "[-M paths] "
151 "[-M paths] "
152 "[-m paths] "
153 "[-S arch] "
154 "[-s section] "
152 "[-m paths] "
153 "[-S arch] "
154 "[-s section] "
155 "expr ...\n",
155 "expr ...\n",
156 progname);
157 return(EXIT_FAILURE);
158}
159
160static void
161show(const char *cmd, const char *file)
162{
163 int fds[2];

--- 5 unchanged lines hidden (view full) ---

169 }
170
171 if (-1 == (pid = fork())) {
172 perror(NULL);
173 exit(EXIT_FAILURE);
174 } else if (pid > 0) {
175 dup2(fds[0], STDIN_FILENO);
176 close(fds[1]);
156 progname);
157 return(EXIT_FAILURE);
158}
159
160static void
161show(const char *cmd, const char *file)
162{
163 int fds[2];

--- 5 unchanged lines hidden (view full) ---

169 }
170
171 if (-1 == (pid = fork())) {
172 perror(NULL);
173 exit(EXIT_FAILURE);
174 } else if (pid > 0) {
175 dup2(fds[0], STDIN_FILENO);
176 close(fds[1]);
177 cmd = NULL != getenv("MANPAGER") ?
177 cmd = NULL != getenv("MANPAGER") ?
178 getenv("MANPAGER") :
178 getenv("MANPAGER") :
179 (NULL != getenv("PAGER") ?
179 (NULL != getenv("PAGER") ?
180 getenv("PAGER") : "more");
181 execlp(cmd, cmd, (char *)NULL);
182 perror(cmd);
183 exit(EXIT_FAILURE);
184 }
185
186 dup2(fds[1], STDOUT_FILENO);
187 close(fds[0]);
188 execlp(cmd, cmd, file, (char *)NULL);
189 perror(cmd);
190 exit(EXIT_FAILURE);
191}
180 getenv("PAGER") : "more");
181 execlp(cmd, cmd, (char *)NULL);
182 perror(cmd);
183 exit(EXIT_FAILURE);
184 }
185
186 dup2(fds[1], STDOUT_FILENO);
187 close(fds[0]);
188 execlp(cmd, cmd, file, (char *)NULL);
189 perror(cmd);
190 exit(EXIT_FAILURE);
191}