diff options
Diffstat (limited to 'miscutils/man.c')
-rw-r--r-- | miscutils/man.c | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/miscutils/man.c b/miscutils/man.c index 61086612a..6724b4b5d 100644 --- a/miscutils/man.c +++ b/miscutils/man.c | |||
@@ -199,8 +199,7 @@ static char **add_MANPATH(char **man_path_list, int *count_mp, char *path) | |||
199 | if (path) while (*path) { | 199 | if (path) while (*path) { |
200 | char *next_path; | 200 | char *next_path; |
201 | char **path_element; | 201 | char **path_element; |
202 | 202 | next_path = strchr(path, PATH_SEP); | |
203 | next_path = strchr(path, ':'); | ||
204 | if (next_path) { | 203 | if (next_path) { |
205 | if (next_path == path) /* "::"? */ | 204 | if (next_path == path) /* "::"? */ |
206 | goto next; | 205 | goto next; |
@@ -223,7 +222,7 @@ static char **add_MANPATH(char **man_path_list, int *count_mp, char *path) | |||
223 | if (!next_path) | 222 | if (!next_path) |
224 | break; | 223 | break; |
225 | /* "path" may be a result of getenv(), be nice and don't mangle it */ | 224 | /* "path" may be a result of getenv(), be nice and don't mangle it */ |
226 | *next_path = ':'; | 225 | *next_path = PATH_SEP; |
227 | next: | 226 | next: |
228 | path = next_path + 1; | 227 | path = next_path + 1; |
229 | } | 228 | } |
@@ -249,11 +248,24 @@ int man_main(int argc UNUSED_PARAM, char **argv) | |||
249 | int count_mp; | 248 | int count_mp; |
250 | int opt, not_found; | 249 | int opt, not_found; |
251 | char *token[2]; | 250 | char *token[2]; |
251 | #if ENABLE_PLATFORM_MINGW32 | ||
252 | char **ptr; | ||
253 | char *exepath, *relpath; | ||
254 | const char *mpl[] = { "/usr/man", "/usr/share/man", NULL, NULL }; | ||
255 | #endif | ||
252 | 256 | ||
253 | INIT_G(); | 257 | INIT_G(); |
254 | 258 | ||
255 | opt = getopt32(argv, "^+" "aw" "\0" "-1"/*at least one arg*/); | 259 | opt = getopt32(argv, "^+" "aw" "\0" "-1"/*at least one arg*/); |
256 | argv += optind; | 260 | argv += optind; |
261 | #if ENABLE_PLATFORM_MINGW32 | ||
262 | /* add system drive prefix to filenames, if necessary */ | ||
263 | for (ptr = argv; *ptr; ++ptr) { | ||
264 | if (strchr(*ptr, '/') || strchr(*ptr, '\\')) | ||
265 | *ptr = xabsolute_path(*ptr); | ||
266 | } | ||
267 | chdir_system_drive(); | ||
268 | #endif | ||
257 | 269 | ||
258 | sec_list = xstrdup("0p:1:1p:2:3:3p:4:5:6:7:8:9"); | 270 | sec_list = xstrdup("0p:1:1p:2:3:3p:4:5:6:7:8:9"); |
259 | 271 | ||
@@ -291,11 +303,25 @@ int man_main(int argc UNUSED_PARAM, char **argv) | |||
291 | } | 303 | } |
292 | config_close(parser); | 304 | config_close(parser); |
293 | 305 | ||
306 | #if ENABLE_PLATFORM_MINGW32 | ||
307 | /* allow man pages to be stored relative to the executable */ | ||
308 | exepath = xstrdup(bb_busybox_exec_path); | ||
309 | relpath = concat_path_file(dirname(exepath), "man"); | ||
310 | |||
311 | if (!man_path_list) { | ||
312 | mpl[2] = relpath; | ||
313 | man_path_list = (char**)mpl; | ||
314 | } | ||
315 | else { | ||
316 | man_path_list = add_MANPATH(man_path_list, &count_mp, relpath); | ||
317 | } | ||
318 | #else | ||
294 | if (!man_path_list) { | 319 | if (!man_path_list) { |
295 | static const char *const mpl[] = { "/usr/man", "/usr/share/man", NULL }; | 320 | static const char *const mpl[] = { "/usr/man", "/usr/share/man", NULL }; |
296 | man_path_list = (char**)mpl; | 321 | man_path_list = (char**)mpl; |
297 | /*count_mp = 2; - not used below anyway */ | 322 | /*count_mp = 2; - not used below anyway */ |
298 | } | 323 | } |
324 | #endif | ||
299 | 325 | ||
300 | { | 326 | { |
301 | /* environment overrides setting from man.config */ | 327 | /* environment overrides setting from man.config */ |