diff options
Diffstat (limited to 'miscutils/man.c')
| -rw-r--r-- | miscutils/man.c | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/miscutils/man.c b/miscutils/man.c index 6fa1fbfdc..38c1b9aa3 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 | } |
| @@ -260,11 +259,24 @@ int man_main(int argc UNUSED_PARAM, char **argv) | |||
| 260 | int count_mp; | 259 | int count_mp; |
| 261 | int opt, not_found; | 260 | int opt, not_found; |
| 262 | char *token[2]; | 261 | char *token[2]; |
| 262 | #if ENABLE_PLATFORM_MINGW32 | ||
| 263 | char **ptr; | ||
| 264 | char *relpath; | ||
| 265 | const char *mpl[] = { "/usr/man", "/usr/share/man", NULL, NULL }; | ||
| 266 | #endif | ||
| 263 | 267 | ||
| 264 | INIT_G(); | 268 | INIT_G(); |
| 265 | 269 | ||
| 266 | opt = getopt32(argv, "^+" "aw" "\0" "-1"/*at least one arg*/); | 270 | opt = getopt32(argv, "^+" "aw" "\0" "-1"/*at least one arg*/); |
| 267 | argv += optind; | 271 | argv += optind; |
| 272 | #if ENABLE_PLATFORM_MINGW32 | ||
| 273 | /* add system drive prefix to filenames, if necessary */ | ||
| 274 | for (ptr = argv; *ptr; ++ptr) { | ||
| 275 | if (strchr(*ptr, '/') || strchr(*ptr, '\\')) | ||
| 276 | *ptr = xabsolute_path(*ptr); | ||
| 277 | } | ||
| 278 | chdir_system_drive(); | ||
| 279 | #endif | ||
| 268 | 280 | ||
| 269 | conf_sec_list = xstrdup("0p:1:1p:2:3:3p:4:5:6:7:8:9"); | 281 | conf_sec_list = xstrdup("0p:1:1p:2:3:3p:4:5:6:7:8:9"); |
| 270 | 282 | ||
| @@ -302,11 +314,24 @@ int man_main(int argc UNUSED_PARAM, char **argv) | |||
| 302 | } | 314 | } |
| 303 | config_close(parser); | 315 | config_close(parser); |
| 304 | 316 | ||
| 317 | #if ENABLE_PLATFORM_MINGW32 | ||
| 318 | /* allow man pages to be stored relative to the executable */ | ||
| 319 | relpath = exe_relative_path("man"); | ||
| 320 | |||
| 321 | if (!man_path_list) { | ||
| 322 | mpl[2] = relpath; | ||
| 323 | man_path_list = (char**)mpl; | ||
| 324 | } | ||
| 325 | else { | ||
| 326 | man_path_list = add_MANPATH(man_path_list, &count_mp, relpath); | ||
| 327 | } | ||
| 328 | #else | ||
| 305 | if (!man_path_list) { | 329 | if (!man_path_list) { |
| 306 | static const char *const mpl[] ALIGN_PTR = { "/usr/man", "/usr/share/man", NULL }; | 330 | static const char *const mpl[] ALIGN_PTR = { "/usr/man", "/usr/share/man", NULL }; |
| 307 | man_path_list = (char**)mpl; | 331 | man_path_list = (char**)mpl; |
| 308 | /*count_mp = 2; - not used below anyway */ | 332 | /*count_mp = 2; - not used below anyway */ |
| 309 | } | 333 | } |
| 334 | #endif | ||
| 310 | 335 | ||
| 311 | { | 336 | { |
| 312 | /* environment overrides setting from man.config */ | 337 | /* environment overrides setting from man.config */ |
