Re: DOS/Windows-specific code: main.c

Christopher Faylor
2001-05-08T07:58:00Z

On Tue, May 08, 2001 at 02:48:05PM +0300, Eli Zaretskii wrote:
>
> * main.c:
>
> #ifdef __CYGWIN__
> #include <windows.h> /* for MAX_PATH */
> #include <sys/cygwin.h> /* for cygwin32_conv_to_posix_path */
> #endif
>
>See the next snippet.
>
> * main.c:captured_main()
>
> /* Read and execute $HOME/.gdbinit file, if it exists. This is done
> *before* all the command line arguments are processed; it sets
> global parameters, which are independent of what file you are
> debugging or what directory you are in. */
> #ifdef __CYGWIN32__
> {
> char *tmp = getenv ("HOME");
>
> if (tmp != NULL)
> {
> homedir = (char *) alloca (MAX_PATH + 1);
> cygwin32_conv_to_posix_path (tmp, homedir);
> }
> else
> homedir = NULL;
> }
> #else
> homedir = getenv ("HOME");
> #endif
>
>What does cygwin32_conv_to_posix_path do? Does it convert the
>drive-letter braindamage to the /cygdrive/d/foo thingy?

Yes.

>If so, why is that needed? Doesn't Cygwin support the native Windows
>file names with drive letters?

Actually CYGWIN converts the HOME environment variable to "posix" format
well before the code ever reaches here. I believe that this code is
to accomodate gdbtk which might change the environment variable back
to MS-DOS format explicitly. I remember trying to get rid of this
years ago. Keith Seitz told me that I couldn't do that.

Maybe the solution is to create a "gethome ()" function which is either
a macro or a call to a function in win32-nat.c?

Or, maybe this isn't needed anymore. Keith do you remember this? I
think it may have been the first piece of email we ever exchanged.

>In any case, this could use FILENAME_MAX instead of MAX_PATH, and then
>the previous snippet would not need <windows.h>, since stdio.h is
>already included by defs.h.

Yep.

cgf