Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Eli Zaretskii <eliz@is.elta.co.il>
To: ac131313@cygnus.com
Cc: danny_r_smith_2001@yahoo.co.nz, gdb@sources.redhat.com,
	mingw-users@lists.sourceforge
Subject: [RFA] Remove OS-specific defines (was: _WIN32?)
Date: Mon, 07 May 2001 09:09:00 -0000	[thread overview]
Message-ID: <200105071610.TAA24144@is.elta.co.il> (raw)
In-Reply-To: <3AF1DAA0.3060702@cygnus.com>

I'm seeking approval for the following patches.  They remove all the
DOS- and Windows-specific #ifdef's like "#ifdef _WIN32" and use the
portable macros from filenames.h instead.  In addition, they convert
code which used macros private to GDB, such as SLASH_P and ROOTED_P,
to use the macros from filenames.h instead.


2001-05-07  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".


--- gdb/cli/cli-cmds.c~0	Thu Mar 29 01:42:22 2001
+++ gdb/cli/cli-cmds.c	Mon May  7 18:08:40 2001
@@ -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)

--- gdb/completer.c~5	Sun May  6 13:10:30 2001
+++ gdb/completer.c	Mon May  7 17:21:02 2001
@@ -66,7 +66,7 @@ static char *gdb_completer_command_word_
    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*|\"';?><@";

--- gdb/defs.h~0	Sat Mar 24 02:00:36 2001
+++ gdb/defs.h	Mon May  7 18:08:48 2001
@@ -1330,34 +1330,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
-
 /* On some systems, PIDGET is defined to extract the inferior pid from
    an internal pid that has the thread id and pid in seperate bit
    fields.  If not defined, then just use the entire internal pid as

--- gdb/solib.c~0	Tue Mar  6 10:41:56 2001
+++ gdb/solib.c	Mon May  7 18:11:24 2001
@@ -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 **fo
 {
   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 **fo
 
 	  /* 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.  */

--- gdb/source.c~0	Tue Mar 27 22:57:04 2001
+++ gdb/source.c	Mon May  7 18:26:20 2001
@@ -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_pa
 	  }
       }
 
-      if (!(SLASH_P (*name) && p <= name + 1)	/* "/" */
-#if defined(_WIN32) || defined(__MSDOS__)
+      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_pa
 	      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_pa
 
       if (name[0] == '~')
 	name = tilde_expand (name);
-#if defined(_WIN32) || defined(__MSDOS__)
-      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, ch
   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, ch
       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, ch
 	}
 
       /* 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);
 	}


  parent reply	other threads:[~2001-05-07  9:09 UTC|newest]

Thread overview: 111+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200105010009.RAA12115@tully.CS.Berkeley.EDU>
2001-05-03  1:24 ` [Mingw-users] Re: _WIN32? Paul Hilfinger
2001-05-03 13:41   ` Andrew Cagney
2001-05-03 14:15     ` Danny Smith
2001-05-03 15:24       ` Andrew Cagney
2001-05-03 15:54         ` Christopher Faylor
2001-05-03 16:11           ` Andrew Cagney
2001-05-04  2:17             ` Eli Zaretskii
2001-05-04  2:19         ` Eli Zaretskii
2001-05-04  8:45           ` Christopher Faylor
2001-05-04 10:18             ` Eli Zaretskii
2001-05-04 12:04               ` Christopher Faylor
2001-05-07  9:08         ` Eli Zaretskii
2001-05-08  4:38           ` DOS/Windows-specific code (was: _WIN32?) Eli Zaretskii
2001-05-08  4:40           ` DOS/Windows-specific code: cli-cmds.c Eli Zaretskii
2001-05-08  5:07             ` Registers are not available in Cygwin leonp
2001-05-08  7:16             ` DOS/Windows-specific code: cli-cmds.c Christopher Faylor
2001-05-08 17:51               ` Andrew Cagney
2001-05-08 17:53                 ` Christopher Faylor
2001-05-09  3:02                 ` Eli Zaretskii
2001-05-10  8:33                   ` Andrew Cagney
2001-05-08 17:56             ` Andrew Cagney
2001-05-09  3:03               ` Eli Zaretskii
2001-05-09  9:10                 ` Andrew Cagney
2001-05-08  4:42           ` DOS/Windows-specific code: exec.c and symfile.c Eli Zaretskii
2001-05-08  7:43             ` Elena Zannoni
2001-05-08 17:58             ` Andrew Cagney
2001-05-09  3:03               ` Eli Zaretskii
2001-05-09  7:07                 ` Christopher Faylor
2001-05-08  4:43           ` DOS/Windows-specific code: inflow.c Eli Zaretskii
2001-05-08  7:54             ` Christopher Faylor
2001-05-08 11:15               ` Eli Zaretskii
2001-05-09 13:10                 ` Christopher Faylor
2001-05-08  4:46           ` DOS/Windows-specific code: main.c Eli Zaretskii
2001-05-08  7:58             ` Christopher Faylor
2001-05-08  8:17               ` Keith Seitz
2001-05-08  8:19                 ` Christopher Faylor
2001-05-08  4:46           ` DOS/Windows-specific code: maint.c Eli Zaretskii
2001-05-08 23:40             ` Kevin Buettner
2001-05-09  3:22               ` Eli Zaretskii
2001-05-10  8:33             ` Andrew Cagney
2001-05-10  8:53               ` Eli Zaretskii
2001-05-08  4:47           ` DOS/Windows-specific code: source.c Eli Zaretskii
2001-05-08  9:30             ` DJ Delorie
2001-05-08 11:18               ` Christopher Faylor
2001-05-08 12:23                 ` Eli Zaretskii
2001-05-08 14:00                   ` DJ Delorie
2001-05-09  3:05                     ` Eli Zaretskii
2001-05-09  7:08                       ` Christopher Faylor
2001-05-08 11:14             ` Christopher Faylor
2001-05-08 12:25               ` Eli Zaretskii
2001-05-08 12:33                 ` Christopher Faylor
2001-05-09  3:05                   ` Eli Zaretskii
2001-05-08  4:48           ` DOS/Windows-specific code: sparcl-tdep.c Eli Zaretskii
2001-05-08 23:47             ` Kevin Buettner
2001-05-09  3:14               ` Eli Zaretskii
2001-05-10  8:33               ` Andrew Cagney
2001-05-08  4:48           ` DOS/Windows-specific code: terminal.h Eli Zaretskii
2001-05-08 11:18             ` Christopher Faylor
2001-05-08  4:50           ` DOS/Windows-specific code: top.c Eli Zaretskii
2001-05-08  7:46             ` Elena Zannoni
2001-05-08  4:51           ` DOS/Windows-specific code: utils.c Eli Zaretskii
2001-05-08 11:26             ` Christopher Faylor
2001-05-08  4:52           ` DOS/Windows-specific code: ser-tcp.c Eli Zaretskii
2001-05-08  5:56             ` Russ Allbery
2001-05-08  6:01             ` Christopher Faylor
2001-05-08  8:09               ` Eli Zaretskii
2001-05-08  8:20                 ` Christopher Faylor
2001-05-08 10:30                   ` Eli Zaretskii
2001-05-08 11:03                     ` Christopher Faylor
2001-05-08 23:53             ` Kevin Buettner
2001-05-09  6:59               ` DOS/Windows-specific code: ser-tcp.c [need ruling from Andrew] Christopher Faylor
2001-05-09  9:29                 ` Andrew Cagney
2001-05-08  4:52           ` DOS/Windows-specific code: sh-tdep.c and sh3-rom.c Eli Zaretskii
2001-05-08  7:49             ` Elena Zannoni
2001-05-08 11:17               ` Eli Zaretskii
2001-05-08 11:40                 ` Elena Zannoni
2001-05-08 12:36                   ` Christopher Faylor
2001-05-08 12:35               ` Christopher Faylor
2001-05-08 18:17                 ` Andrew Cagney
2001-05-08 19:35                   ` Christopher Faylor
2001-05-08 23:55             ` Kevin Buettner
2001-05-09  3:20               ` Eli Zaretskii
2001-05-09  7:49                 ` Elena Zannoni
2001-05-08  4:53           ` DOS/Windows-specific code: values.c Eli Zaretskii
2001-05-08 23:58             ` Kevin Buettner
2001-05-09  7:01               ` Christopher Faylor
2001-05-10  8:33               ` Andrew Cagney
2001-05-08  4:54           ` DOS/Windows-specific code in sim/ Eli Zaretskii
2001-05-08  9:30             ` DJ Delorie
2001-05-08 11:04               ` Eli Zaretskii
2001-05-10  8:33               ` Andrew Cagney
2001-05-08  4:55           ` DOS/Windows-specific code: all the rest Eli Zaretskii
2001-05-08  5:12             ` leonp
2001-05-08  7:59               ` Christopher Faylor
2001-05-08  9:45             ` DJ Delorie
2001-05-08 10:53               ` Eli Zaretskii
2001-05-08 12:08                 ` DJ Delorie
2001-05-07  9:09         ` Eli Zaretskii [this message]
2001-05-07 10:39           ` [RFA] Remove OS-specific defines (was: _WIN32?) Kevin Buettner
2001-05-07 11:23             ` Eli Zaretskii
2001-05-07 11:37               ` Andrew Cagney
2001-05-03 23:58     ` [Mingw-users] Re: _WIN32? Paul Hilfinger
2001-05-04  9:04       ` Andrew Cagney
2001-05-04  0:20     ` Eli Zaretskii
2001-05-07 11:36 [RFA] Remove OS-specific defines (was: _WIN32?) David Taylor
  -- strict thread matches above, loose matches on Subject: below --
2001-03-21 15:59 MACROS in gdb ??? Aditya Chugh
2001-03-21 15:59 ` Eli Zaretskii
     [not found]   ` <eliz@is.elta.co.il>
2001-03-21 15:59     ` Kevin Buettner
2001-03-21 15:59       ` Eli Zaretskii
2001-03-21 15:59 ` Daniel Berlin
2001-03-21 15:59 ` J.T. Conklin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200105071610.TAA24144@is.elta.co.il \
    --to=eliz@is.elta.co.il \
    --cc=ac131313@cygnus.com \
    --cc=danny_r_smith_2001@yahoo.co.nz \
    --cc=gdb@sources.redhat.com \
    --cc=mingw-users@lists.sourceforge \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox