Re: DOS/Windows-specific code: exec.c and symfile.c

Elena Zannoni
2001-05-08T07:43:00Z

Eli Zaretskii writes:
>
> * exec.c:exec_file_attach()
>
> scratch_chan = openp (getenv ("PATH"), 1, filename,
> write_files ? O_RDWR | O_BINARY : O_RDONLY | O_BINARY, 0,
> &scratch_pathname);
> #if defined(__GO32__) || defined(_WIN32) || defined(__CYGWIN__)
> if (scratch_chan < 0)
> {
> char *exename = alloca (strlen (filename) + 5);
> strcat (strcpy (exename, filename), ".exe");
> scratch_chan = openp (getenv ("PATH"), 1, exename, write_files ?
> O_RDWR | O_BINARY : O_RDONLY | O_BINARY, 0, &scratch_pathname);
> }
> #endif
>
> This snippet wants to find `foo.exe' when `foo' is being specified.
> Should we add a #define for executable extensions (defaulting to an
> empty string on Unix)?
>

This seems like a good candidate for inclusion in filenames.h.

Elena

>
> * symfile.c:symfile_bfd_open()
>
> /* Look down path for it, allocate 2nd new malloc'd copy. */
> desc = openp (getenv ("PATH"), 1, name, O_RDONLY | O_BINARY, 0, &absolute_name);
> #if defined(__GO32__) || defined(_WIN32)
> if (desc < 0)
> {
> char *exename = alloca (strlen (name) + 5);
> strcat (strcpy (exename, name), ".exe");
> desc = openp (getenv ("PATH"), 1, exename, O_RDONLY | O_BINARY,
> 0, &absolute_name);
> }
> #endif
>
> This is the same issue as in exec.c:exec_file_attach() above, and
> should be solved in the same way.
>