* src/emacs.c (find_emacs_executable): If the executable name
contains a slash, use the same optimization for symlink resolution
that we already use when the executable name has no slash.
(cherry picked from commit
d59fe6dad5667720b296569d2f6fe1b84d42fd0a)
eassert (argv0);
if (strchr (argv0, DIRECTORY_SEP))
{
- char *real_name = realpath (argv0, NULL);
-
- if (real_name)
- {
- *candidate_size = strlen (real_name) + 1;
- return real_name;
- }
-
- char *val = xstrdup (argv0);
+ char *val = (readlink (argv0, linkbuf, sizeof linkbuf) < 0
+ ? NULL
+ : realpath (argv0, NULL));
+ if (!val)
+ val = xstrdup (argv0);
*candidate_size = strlen (val) + 1;
return val;
}