diff options
-rw-r--r-- | gdb/ChangeLog | 21 | ||||
-rw-r--r-- | gdb/cli/cli-cmds.c | 22 | ||||
-rw-r--r-- | gdb/completer.c | 2 | ||||
-rw-r--r-- | gdb/defs.h | 22 | ||||
-rw-r--r-- | gdb/solib.c | 11 | ||||
-rw-r--r-- | gdb/source.c | 29 |
6 files changed, 58 insertions, 49 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 3a850a9..30121c1 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,26 @@ 2001-06-04 Eli Zaretskii <eliz@is.elta.co.il> + * source.c (mod_path, openp): Use HAVE_DOS_BASED_FILE_SYSTEM + instead of system-specific define's like _WIN32 and __MSDOS__. + Use IS_DIR_SEPARATOR and IS_ABSOLUTE_PATH instead of SLASH_P and + ROOTED_P. + (top-level): #include "filenames.h". + + * solib.c (solib_open): Use IS_DIR_SEPARATOR and IS_ABSOLUTE_PATH + instead of SLASH_CHAR, ROOTED_P and SLASH_P. + (top-level): #include "filenames.h". + + * defs.h (SLASH_P, SLASH_CHAR, ROOTED_P): Remove definitions. + (SLASH_STRING): Define only for _WIN32. + + * completer.c: Use HAVE_DOS_BASED_FILE_SYSTEM instead of + __MSDOS_. + + * cli/cli-cmds.c (cd_command): Use IS_DIR_SEPARATOR and + IS_ABSOLUTE_PATH instead of SLASH_P and ROOTED_P. Replace + system-specific ifdefs with HAVE_DOS_BASED_FILE_SYSTEM. + (top-level): #include "filenames.h". + * go32-nat.c (go32_wait): Change the return value to ptid_t. * config/djgpp/fnchange.lst: Add two new files in the diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index c1c5f7b..ca700ed 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -23,6 +23,7 @@ #include "target.h" /* For baud_rate, remote_debug and remote_timeout */ #include "gdb_wait.h" /* For shell escape implementation */ #include "gnu-regex.h" /* Used by apropos_command */ +#include "filenames.h" /* for DOSish file names */ #ifdef UI_OUT #include "ui-out.h" @@ -292,7 +293,7 @@ cd_command (char *dir, int from_tty) if (chdir (dir) < 0) perror_with_name (dir); -#if defined(_WIN32) || defined(__MSDOS__) +#if HAVE_DOS_BASED_FILE_SYSTEM /* 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. */ @@ -300,24 +301,24 @@ cd_command (char *dir, int from_tty) #endif len = strlen (dir); - if (SLASH_P (dir[len - 1])) + if (IS_DIR_SEPARATOR (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:/" */ +#if HAVE_DOS_BASED_FILE_SYSTEM + && !(len == 3 && dir[1] == ':') /* "d:/" */ #endif ) len--; } dir = savestring (dir, len); - if (ROOTED_P (dir)) + if (IS_ABSOLUTE_PATH (dir)) current_directory = dir; else { - if (SLASH_P (current_directory[strlen (current_directory) - 1])) + if (IS_DIR_SEPARATOR (current_directory[strlen (current_directory) - 1])) current_directory = concat (current_directory, dir, NULL); else current_directory = concat (current_directory, SLASH_STRING, dir, NULL); @@ -329,17 +330,18 @@ cd_command (char *dir, int from_tty) found_real_path = 0; for (p = current_directory; *p;) { - if (SLASH_P (p[0]) && p[1] == '.' && (p[2] == 0 || SLASH_P (p[2]))) + if (IS_DIR_SEPARATOR (p[0]) && p[1] == '.' + && (p[2] == 0 || IS_DIR_SEPARATOR (p[2]))) strcpy (p, p + 2); - else if (SLASH_P (p[0]) && p[1] == '.' && p[2] == '.' - && (p[3] == 0 || SLASH_P (p[3]))) + else if (IS_DIR_SEPARATOR (p[0]) && p[1] == '.' && p[2] == '.' + && (p[3] == 0 || IS_DIR_SEPARATOR (p[3]))) { if (found_real_path) { /* Search backwards for the directory just before the "/.." and obliterate it and the "/..". */ char *q = p; - while (q != current_directory && !SLASH_P (q[-1])) + while (q != current_directory && !IS_DIR_SEPARATOR (q[-1])) --q; if (q == current_directory) diff --git a/gdb/completer.c b/gdb/completer.c index 57aced8..90f428c 100644 --- a/gdb/completer.c +++ b/gdb/completer.c @@ -64,7 +64,7 @@ static char *gdb_completer_command_word_break_characters = break characters any characters that are commonly used in file names, such as '-', '+', '~', etc. Otherwise, readline displays incorrect completion candidates. */ -#ifdef __MSDOS__ +#if HAVE_DOS_BASED_FILE_SYSTEM /* MS-DOS and MS-Windows use colon as part of the drive spec, and most programs support @foo style response files. */ static char *gdb_completer_file_name_break_characters = " \t\n*|\"';?><@"; @@ -1364,34 +1364,14 @@ extern int use_windows; #define DIRNAME_SEPARATOR ':' #endif -#ifndef SLASH_P -#if defined(__GO32__)||defined(_WIN32) -#define SLASH_P(X) ((X)=='\\') -#else -#define SLASH_P(X) ((X)=='/') -#endif -#endif - -#ifndef SLASH_CHAR -#if defined(__GO32__)||defined(_WIN32) -#define SLASH_CHAR '\\' -#else -#define SLASH_CHAR '/' -#endif -#endif - #ifndef SLASH_STRING -#if defined(__GO32__)||defined(_WIN32) +#ifdef _WIN32 #define SLASH_STRING "\\" #else #define SLASH_STRING "/" #endif #endif -#ifndef ROOTED_P -#define ROOTED_P(X) (SLASH_P((X)[0])) -#endif - /* Provide default definitions of PIDGET, TIDGET, and MERGEPID. The name ``TIDGET'' is a historical accident. Many uses of TIDGET in the code actually refer to a lightweight process id, i.e, diff --git a/gdb/solib.c b/gdb/solib.c index 8a5a904..dfcca0c 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -39,6 +39,7 @@ #include "language.h" #include "gdbcmd.h" #include "completer.h" +#include "filenames.h" /* for DOSish file names */ #include "solist.h" @@ -101,10 +102,14 @@ solib_open (char *in_pathname, char **found_pathname) { int found_file = -1; char *temp_pathname = NULL; + char *p = in_pathname; - if (strchr (in_pathname, SLASH_CHAR)) + while (*p && !IS_DIR_SEPARATOR (*p)) + p++; + + if (*p) { - if (! ROOTED_P (in_pathname) || solib_absolute_prefix == NULL) + if (! IS_ABSOLUTE_PATH (in_pathname) || solib_absolute_prefix == NULL) temp_pathname = in_pathname; else { @@ -112,7 +117,7 @@ solib_open (char *in_pathname, char **found_pathname) /* Remove trailing slashes from absolute prefix. */ while (prefix_len > 0 - && SLASH_P (solib_absolute_prefix[prefix_len - 1])) + && IS_DIR_SEPARATOR (solib_absolute_prefix[prefix_len - 1])) prefix_len--; /* Cat the prefixed pathname together. */ diff --git a/gdb/source.c b/gdb/source.c index c96202a..fdb6859 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -40,6 +40,7 @@ #include "annotate.h" #include "gdbtypes.h" #include "linespec.h" +#include "filenames.h" /* for DOSish file names */ #ifdef UI_OUT #include "ui-out.h" #endif @@ -330,12 +331,12 @@ mod_path (char *dirname, char **which_path) } } - if (!(SLASH_P (*name) && p <= name + 1) /* "/" */ -#if defined(_WIN32) || defined(__MSDOS__) || defined(__CYGWIN__) + if (!(IS_DIR_SEPARATOR (*name) && p <= name + 1) /* "/" */ +#if HAVE_DOS_BASED_FILE_SYSTEM /* On MS-DOS and MS-Windows, h:\ is different from h: */ - && !(!SLASH_P (*name) && ROOTED_P (name) && p <= name + 3) /* d:/ */ + && !(p == name + 3 && name[1] == ':') /* "d:/" */ #endif - && SLASH_P (p[-1])) + && IS_DIR_SEPARATOR (p[-1])) /* Sigh. "foo/" => "foo" */ --p; *p = '\0'; @@ -348,7 +349,7 @@ mod_path (char *dirname, char **which_path) name = current_directory; goto append; } - else if (p > name + 1 && SLASH_P (p[-2])) + else if (p > name + 1 && IS_DIR_SEPARATOR (p[-2])) { if (p - name == 2) { @@ -370,11 +371,11 @@ mod_path (char *dirname, char **which_path) if (name[0] == '~') name = tilde_expand (name); -#if defined(_WIN32) || defined(__MSDOS__) || defined(__CYGWIN__) - else if (ROOTED_P (name) && p == name + 2) /* "d:" => "d:." */ +#if HAVE_DOS_BASED_FILE_SYSTEM + else if (IS_ABSOLUTE_PATH (name) && p == name + 2) /* "d:" => "d:." */ name = concat (name, ".", NULL); #endif - else if (!ROOTED_P (name) && name[0] != '$') + else if (!IS_ABSOLUTE_PATH (name) && name[0] != '$') name = concat (current_directory, SLASH_STRING, name, NULL); else name = savestring (name, p - name); @@ -530,7 +531,7 @@ openp (char *path, int try_cwd_first, char *string, int mode, int prot, mode |= O_BINARY; #endif - if (try_cwd_first || ROOTED_P (string)) + if (try_cwd_first || IS_ABSOLUTE_PATH (string)) { int i; filename = string; @@ -538,12 +539,12 @@ openp (char *path, int try_cwd_first, char *string, int mode, int prot, if (fd >= 0) goto done; for (i = 0; string[i]; i++) - if (SLASH_P (string[i])) + if (IS_DIR_SEPARATOR (string[i])) goto done; } /* ./foo => foo */ - while (string[0] == '.' && SLASH_P (string[1])) + while (string[0] == '.' && IS_DIR_SEPARATOR (string[1])) string += 2; alloclen = strlen (path) + strlen (string) + 2; @@ -581,7 +582,7 @@ openp (char *path, int try_cwd_first, char *string, int mode, int prot, } /* Remove trailing slashes */ - while (len > 0 && SLASH_P (filename[len - 1])) + while (len > 0 && IS_DIR_SEPARATOR (filename[len - 1])) filename[--len] = 0; strcat (filename + len, SLASH_STRING); @@ -597,14 +598,14 @@ done: { if (fd < 0) *filename_opened = (char *) 0; - else if (ROOTED_P (filename)) + else if (IS_ABSOLUTE_PATH (filename)) *filename_opened = savestring (filename, strlen (filename)); else { /* Beware the // my son, the Emacs barfs, the botch that catch... */ *filename_opened = concat (current_directory, - SLASH_P (current_directory[strlen (current_directory) - 1]) + IS_DIR_SEPARATOR (current_directory[strlen (current_directory) - 1]) ? "" : SLASH_STRING, filename, NULL); } |