This is the mail archive of the
gdb-patches@sourceware.cygnus.com
mailing list for the GDB project.
[eliz@is.elta.co.il: Directory- and filename-related problems in top.c]
- To: gdb-patches@sourceware.cygnus.com
- Subject: [eliz@is.elta.co.il: Directory- and filename-related problems in top.c]
- From: DJ Delorie <dj@delorie.com>
- Date: Sun, 27 Jun 1999 13:48:19 -0400
------- Start of forwarded message -------
Date: Sun, 27 Jun 1999 18:56:07 +0300 (IDT)
From: Eli Zaretskii <eliz@is.elta.co.il>
X-Sender: eliz@is
To: DJ Delorie <dj@delorie.com>
Subject: Directory- and filename-related problems in top.c
Content-Type: TEXT/PLAIN; charset=US-ASCII
1999-06-26 Eli Zaretskii <eliz@is.elta.co.il>
* top.c (gdb_init) [__MSDOS__]: Arrange for GDB to return to the
original directory before exiting.
(cd_command) [_WIN32 || __MSDOS__]: Canonicalize the new directory
name explicitly. Handle "d:/" names correctly.
(init_history) [__MSDOS__]: Use _gdb_history as the default GDB
history file name.
*** ./gdb/top.c~1 Fri Jan 29 09:46:02 1999
- --- ./gdb/top.c Sat Jun 5 16:38:46 1999
***************
*** 656,661 ****
- --- 656,667 ----
getcwd (gdb_dirbuf, sizeof (gdb_dirbuf));
current_directory = gdb_dirbuf;
+ #ifdef __MSDOS__
+ /* Make sure we return to the original directory upon exit, come
+ what may, since the OS doesn't do that for us. */
+ make_final_cleanup ((make_cleanup_func) chdir, strsave (current_directory));
+ #endif
+
init_cmd_lists (); /* This needs to be done first */
initialize_targets (); /* Setup target_terminal macros for utils.c */
initialize_utils (); /* Make errors and warnings possible */
***************
*** 3051,3063 ****
if (chdir (dir) < 0)
perror_with_name (dir);
len = strlen (dir);
! dir = savestring (dir, len - (len > 1 && SLASH_P(dir[len-1])));
if (ROOTED_P(dir))
current_directory = dir;
else
{
! if (SLASH_P (current_directory[0]) && current_directory[1] == '\0')
current_directory = concat (current_directory, dir, NULL);
else
current_directory = concat (current_directory, SLASH_STRING, dir, NULL);
- --- 3057,3087 ----
if (chdir (dir) < 0)
perror_with_name (dir);
+ #if defined(_WIN32) || defined(__MSDOS__)
+ /* There's too much mess with DOSish names like "d:", "d:.",
+ "d:./foo" etc. Instead of having lots of special #ifdef'ed code,
+ simply get the canonicalized name of the current directory. */
+ dir = getcwd (gdb_dirbuf, sizeof (gdb_dirbuf));
+ #endif
len = strlen (dir);
! if (SLASH_P (dir[len-1]))
! {
! /* Remove the trailing slash unless this is a root directory
! (including a drive letter on non-Unix systems). */
! if (!(len == 1) /* "/" */
! #if defined(_WIN32) || defined(__MSDOS__)
! && !(!SLASH_P (*dir) && ROOTED_P (dir) && len <= 3) /* "d:/" */
! #endif
! )
! len--;
! }
!
! dir = savestring (dir, len);
if (ROOTED_P(dir))
current_directory = dir;
else
{
! if (SLASH_P (current_directory[strlen (current_directory) - 1]))
current_directory = concat (current_directory, dir, NULL);
else
current_directory = concat (current_directory, SLASH_STRING, dir, NULL);
***************
*** 3442,3448 ****
- --- 3466,3477 ----
/* We include the current directory so that if the user changes
directories the file written will be the same as the one
that was read. */
+ #ifdef __MSDOS__
+ /* No leading dots in file names are allowed on MSDOS. */
+ history_filename = concat (current_directory, "/_gdb_history", NULL);
+ #else
history_filename = concat (current_directory, "/.gdb_history", NULL);
+ #endif
}
read_history (history_filename);
}
------- End of forwarded message -------