35 |
#endif |
#endif |
36 |
|
|
37 |
#define INSTALLPATHLEN (sizeof(INSTALLPATH) - 1) |
#define INSTALLPATHLEN (sizeof(INSTALLPATH) - 1) |
38 |
#define DEBUG 0 |
#ifndef DEBUG |
39 |
|
# define DEBUG 0 |
40 |
|
#endif |
41 |
|
|
42 |
extern "C" const char *program_name; |
extern "C" const char *program_name; |
43 |
|
|
84 |
// or if NAME is found in the current directory. |
// or if NAME is found in the current directory. |
85 |
if (!access (name, F_OK)) { |
if (!access (name, F_OK)) { |
86 |
path = new char[path_name_max()]; |
path = new char[path_name_max()]; |
87 |
|
#ifdef _WIN32 |
88 |
|
path = _fullpath(path, name, path_name_max()); |
89 |
|
#else |
90 |
path = realpath(name, path); |
path = realpath(name, path); |
91 |
|
#endif |
92 |
#if DEBUG |
#if DEBUG |
93 |
fprintf(stderr, "searchpath: found `%s'\n", path); |
fprintf(stderr, "searchpath: found `%s'\n", path); |
94 |
#endif |
#endif |
173 |
# if DEBUG |
# if DEBUG |
174 |
fprintf(stderr, "curr_prefix: %s\n", curr_prefix); |
fprintf(stderr, "curr_prefix: %s\n", curr_prefix); |
175 |
# endif /* DEBUG */ |
# endif /* DEBUG */ |
176 |
#else /* _WIN32 */ |
#else /* !_WIN32 */ |
177 |
curr_prefix = searchpath(program_name, getenv("PATH")); |
curr_prefix = searchpath(program_name, getenv("PATH")); |
178 |
if (!curr_prefix && !strchr(program_name, '.')) { // try with extensions |
if (!curr_prefix && !strchr(program_name, '.')) { // try with extensions |
179 |
pathextstr = strsave(getenv("PATHEXT")); |
pathextstr = strsave(getenv("PATHEXT")); |
184 |
} |
} |
185 |
if (!curr_prefix) |
if (!curr_prefix) |
186 |
return; |
return; |
187 |
#endif /* _WIN32 */ |
#endif /* !_WIN32 */ |
188 |
msw2posixpath(curr_prefix); |
msw2posixpath(curr_prefix); |
189 |
#if DEBUG |
#if DEBUG |
190 |
fprintf(stderr, "curr_prefix: %s\n", curr_prefix); |
fprintf(stderr, "curr_prefix: %s\n", curr_prefix); |