Skip to content

Commit cb23f95

Browse files
committed
try again
1 parent 3c1439f commit cb23f95

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

src/main.c

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,26 +71,33 @@ get_prefix(void)
7171
{
7272
if (!prefix_valid) {
7373
g_autofree char *basename = g_path_get_basename(main_argv0);
74-
g_autofree char *pathname = path_find_file(basename);
74+
g_autofree char *argv0_path = NULL;
7575

7676
const char *prefix;
7777

7878
prefix = vips_guess_prefix(main_argv0, "VIPSHOME");
7979

8080
if (!prefix ||
8181
!existsf("%s/share/nip4", prefix)) {
82-
/* the libvips guesser failed to find our install area ... try
83-
* using the path to our executable
82+
printf("getting prefix from PATH\n");
83+
84+
/* The libvips guesser failed to find our install area ... try
85+
* searching the path for our exe name.
8486
*
85-
* This can happon with homebrew, for example, where the
86-
* compile-time libvips prefix will not match the nip4 prefix
87+
* This can happen with homebrew, for example, where the
88+
* compile-time libvips prefix will not match the nip4 prefix.
8789
*/
90+
GSList *path = path_parse(g_getenv("PATH"));
91+
argv0_path =
92+
(char *) path_map(path, basename, (path_map_fn) g_strdup, NULL);
93+
g_slist_free_full(g_steal_pointer(&path), g_free);
94+
8895
g_autofree char *trailing = g_strjoin("/", "bin", basename, NULL);
89-
if (pathname &&
90-
is_postfix(pathname, trailing))
91-
pathname[strlen(pathname) - strlen(trailing)] = '\0';
96+
if (argv0_path &&
97+
is_postfix(argv0_path, trailing))
98+
argv0_path[strlen(argv0_path) - strlen(trailing)] = '\0';
9299

93-
prefix = pathname;
100+
prefix = argv0_path;
94101
}
95102

96103
if (!prefix ||

0 commit comments

Comments
 (0)