exit (1);
}
+/* Return the real filename following symlinks in case.
+ The caller should deallocate the returned buffer. */
+
+static char *
+real_filename (char *filename)
+{
+ char *real_name;
+#ifdef WINDOWSNT
+ /* w32_my_exename resolves symlinks internally, so no need to
+ call realpath. */
+ real_name = xmalloc (strlen (filename));
+ strcpy (real_name, filename);
+ return real_name;
+#else
+ real_name = realpath (filename, NULL);
+ if (!real_name)
+ fatal ("could not resolve realpath of \"%s\": %s",
+ filename, strerror (errno));
+ return real_name;
+#endif
+}
+
/* Set `invocation-name' `invocation-directory'. */
static void
if (! NILP (handler))
raw_name = concat2 (slash_colon, raw_name);
+ char *filename = real_filename (SSDATA (raw_name));
+ raw_name = build_unibyte_string (filename);
+ xfree (filename);
+
Vinvocation_name = Ffile_name_nondirectory (raw_name);
Vinvocation_directory = Ffile_name_directory (raw_name);
the dump in the hardcoded location. */
if (dump_file && *dump_file)
{
-#ifdef WINDOWSNT
- /* w32_my_exename resolves symlinks internally, so no need to
- call realpath. */
-#else
- char *real_exename = realpath (dump_file, NULL);
- if (!real_exename)
- fatal ("could not resolve realpath of \"%s\": %s",
- dump_file, strerror (errno));
+ char *real_exename = real_filename (dump_file);
xfree (dump_file);
dump_file = real_exename;
-#endif
ptrdiff_t exenamelen = strlen (dump_file);
#ifndef WINDOWSNT
bufsize = exenamelen + 1;