aboutsummaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2014-12-14 14:20:56 +0000
committerRon Yorston <rmy@pobox.com>2014-12-14 14:20:56 +0000
commit6d6d18d45c145899fce3a39553771cf0af671f30 (patch)
tree1936d18cbf61b9e0989464aad0a11c52cbeff7b7 /miscutils
parent0c204dc07b718244c360e0b84df66ce0a012e14f (diff)
parentacb8be721768b54075a51d1859d390904a0f1f6c (diff)
downloadbusybox-w32-6d6d18d45c145899fce3a39553771cf0af671f30.tar.gz
busybox-w32-6d6d18d45c145899fce3a39553771cf0af671f30.tar.bz2
busybox-w32-6d6d18d45c145899fce3a39553771cf0af671f30.zip
Merge branch 'busybox' into merge
Conflicts: archival/libarchive/open_transformer.c libbb/lineedit.c miscutils/man.c
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/flashcp.c2
-rw-r--r--miscutils/man.c96
2 files changed, 56 insertions, 42 deletions
diff --git a/miscutils/flashcp.c b/miscutils/flashcp.c
index b526566a4..9bc588d14 100644
--- a/miscutils/flashcp.c
+++ b/miscutils/flashcp.c
@@ -21,7 +21,7 @@
21 21
22#define OPT_v (1 << 0) 22#define OPT_v (1 << 0)
23 23
24#define BUFSIZE (8 * 1024) 24#define BUFSIZE (4 * 1024)
25 25
26static void progress(int mode, uoff_t count, uoff_t total) 26static void progress(int mode, uoff_t count, uoff_t total)
27{ 27{
diff --git a/miscutils/man.c b/miscutils/man.c
index 0e0b1cba6..3f389b435 100644
--- a/miscutils/man.c
+++ b/miscutils/man.c
@@ -147,15 +147,55 @@ static int show_manpage(const char *pager, char *man_filename, int man, int leve
147 return run_pipe(pager, man_filename, man, level); 147 return run_pipe(pager, man_filename, man, level);
148} 148}
149 149
150static char **add_MANPATH(char **man_path_list, int *count_mp, char *path)
151{
152 if (path) while (*path) {
153 char *next_path;
154 char **path_element;
155
156#if ENABLE_PLATFORM_MINGW32
157 next_path = next_path_sep(path);
158#else
159 next_path = strchr(path, ':');
160#endif
161 if (next_path) {
162 if (next_path == path) /* "::"? */
163 goto next;
164 *next_path = '\0';
165 }
166 /* Do we already have path? */
167 path_element = man_path_list;
168 if (path_element) while (*path_element) {
169 if (strcmp(*path_element, path) == 0)
170 goto skip;
171 path_element++;
172 }
173 man_path_list = xrealloc_vector(man_path_list, 4, *count_mp);
174 man_path_list[*count_mp] = xstrdup(path);
175 (*count_mp)++;
176 /* man_path_list is NULL terminated */
177 /* man_path_list[*count_mp] = NULL; - xrealloc_vector did it */
178 skip:
179 if (!next_path)
180 break;
181 /* "path" may be a result of getenv(), be nice and don't mangle it */
182 *next_path = ':';
183 next:
184 path = next_path + 1;
185 }
186 return man_path_list;
187}
188
150int man_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 189int man_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
151int man_main(int argc UNUSED_PARAM, char **argv) 190int man_main(int argc UNUSED_PARAM, char **argv)
152{ 191{
153 parser_t *parser; 192 parser_t *parser;
154 const char *pager = ENABLE_LESS ? "less" : "more"; 193 const char *pager = ENABLE_LESS ? "less" : "more";
155 char **man_path_list;
156 char *sec_list; 194 char *sec_list;
157 char *cur_path, *cur_sect; 195 char *cur_path, *cur_sect;
158 int count_mp, cur_mp; 196 char **man_path_list;
197 int count_mp;
198 int cur_mp;
159 int opt, not_found; 199 int opt, not_found;
160 char *token[2]; 200 char *token[2];
161 201
@@ -164,14 +204,20 @@ int man_main(int argc UNUSED_PARAM, char **argv)
164 argv += optind; 204 argv += optind;
165 205
166 sec_list = xstrdup("0p:1:1p:2:3:3p:4:5:6:7:8:9"); 206 sec_list = xstrdup("0p:1:1p:2:3:3p:4:5:6:7:8:9");
167 /* Last valid man_path_list[] is [0x10] */ 207
168 count_mp = 0; 208 count_mp = 0;
169 man_path_list = xzalloc(0x11 * sizeof(man_path_list[0])); 209 man_path_list = add_MANPATH(NULL, &count_mp,
170 man_path_list[0] = getenv("MANPATH"); 210 getenv("MANDATORY_MANPATH"+10) /* "MANPATH" */
171 if (!man_path_list[0]) /* default, may be overridden by /etc/man.conf */ 211 );
212 if (!man_path_list) {
213 /* default, may be overridden by /etc/man.conf */
214 man_path_list = xzalloc(2 * sizeof(man_path_list[0]));
172 man_path_list[0] = (char*)"/usr/man"; 215 man_path_list[0] = (char*)"/usr/man";
173 else 216 /* count_mp stays 0.
174 count_mp++; 217 * Thus, man.conf will overwrite man_path_list[0]
218 * if a path is defined there.
219 */
220 }
175 221
176 /* Parse man.conf[ig] or man_db.conf */ 222 /* Parse man.conf[ig] or man_db.conf */
177 /* man version 1.6f uses man.config */ 223 /* man version 1.6f uses man.config */
@@ -193,39 +239,7 @@ int man_main(int argc UNUSED_PARAM, char **argv)
193 if (strcmp("MANDATORY_MANPATH"+10, token[0]) == 0 /* "MANPATH"? */ 239 if (strcmp("MANDATORY_MANPATH"+10, token[0]) == 0 /* "MANPATH"? */
194 || strcmp("MANDATORY_MANPATH", token[0]) == 0 240 || strcmp("MANDATORY_MANPATH", token[0]) == 0
195 ) { 241 ) {
196 char *path = token[1]; 242 man_path_list = add_MANPATH(man_path_list, &count_mp, token[1]);
197 while (*path) {
198 char *next_path;
199 char **path_element;
200
201#if ENABLE_PLATFORM_MINGW32
202 next_path = next_path_sep(path);
203#else
204 next_path = strchr(path, ':');
205#endif
206 if (next_path) {
207 *next_path = '\0';
208 if (next_path++ == path) /* "::"? */
209 goto next;
210 }
211 /* Do we already have path? */
212 path_element = man_path_list;
213 while (*path_element) {
214 if (strcmp(*path_element, path) == 0)
215 goto skip;
216 path_element++;
217 }
218 man_path_list = xrealloc_vector(man_path_list, 4, count_mp);
219 man_path_list[count_mp] = xstrdup(path);
220 count_mp++;
221 /* man_path_list is NULL terminated */
222 /*man_path_list[count_mp] = NULL; - xrealloc_vector did it */
223 skip:
224 if (!next_path)
225 break;
226 next:
227 path = next_path;
228 }
229 } 243 }
230 if (strcmp("MANSECT", token[0]) == 0) { 244 if (strcmp("MANSECT", token[0]) == 0) {
231 free(sec_list); 245 free(sec_list);