Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [patch] IS_ABSOLUTE_PATH to handle both DOS and POSIX path styles
@ 2008-01-04 19:03 Aleksandar Ristovski
  2008-01-05 14:19 ` Eli Zaretskii
  0 siblings, 1 reply; 2+ messages in thread
From: Aleksandar Ristovski @ 2008-01-04 19:03 UTC (permalink / raw)
  To: gdb-patches; +Cc: Daniel Jacobowitz, Joel Brobecker, Ryan Mansfield

This patch introduces new IS_DIR_SEPARATOR_? And IS_ABSOLUTE_PATH_? Macros.

Old macros IS_DIR_SEPARATOR and IS_ABSOLUTE_PATH continue to be configured
host dependent.

Please see http://sourceware.org/ml/gdb/2008-01/msg00021.html for details on
why this patch.

---
Aleksandar Ristovski
QNX Software Systems


ChangeLog:
2008-01-04  Aleksandar Ristovski  <aristovski@qnx.com>

        * filenames.h (IS_DIR_SEPARATOR_DOS): New macro.
        (IS_ABSOLUTE_PATH_DOS): New macro.
        (IS_DIR_SEPARATOR_X): New macro.
        (IS_ABSOLUTE_PATH_X): New macro.
        (IS_DIR_SEPARATOR_ANY): New macro.
        (IS_ABSOLUTE_PATH_ANY): New macro.



Index: include/filenames.h
===================================================================
RCS file: /cvs/src/src/include/filenames.h,v
retrieving revision 1.4
diff -u -3 -p -r1.4 filenames.h
--- include/filenames.h	29 Mar 2007 21:03:43 -0000	1.4
+++ include/filenames.h	4 Jan 2008 18:36:09 -0000
@@ -26,6 +26,23 @@ Foundation, Inc., 51 Franklin Street - F
 #ifndef FILENAMES_H
 #define FILENAMES_H
 
+/* For DOS style paths. Note that these macros do not recognize
+  path starting with '/' as an absolute path.  */
+
+#define IS_DIR_SEPARATOR_DOS(c)	  ((c) == '/' || (c) == '\\')
+#define IS_ABSOLUTE_PATH_DOS(c)	  (((f)[0]) && ((f)[1] == ':'))
+
+/* For POSIX style paths.  */
+
+#define IS_DIR_SEPARATOR_X(c)	  ((c) == '/')
+#define IS_ABSOLUTE_PATH_X(c)	  (IS_DIR_SEPARATOR_X((f)[0]))
+
+/* Universal macros, to be used on paths that could be either
+   POSIX or DOS.  */
+
+#define IS_DIR_SEPARATOR_ANY(c)	  IS_DIR_SEPARATOR_DOS(c)
+#define IS_ABSOLUTE_PATH_ANY(c)	  (IS_ABSOLUTE_PATH_X(c) ||
IS_ABSOLUTE_PATH_DOS(c))
+
 #if defined(__MSDOS__) || defined(_WIN32) || defined(__OS2__) || defined
(__CYGWIN__)
 
 #ifndef HAVE_DOS_BASED_FILE_SYSTEM


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [patch] IS_ABSOLUTE_PATH to handle both DOS and POSIX path styles
  2008-01-04 19:03 [patch] IS_ABSOLUTE_PATH to handle both DOS and POSIX path styles Aleksandar Ristovski
@ 2008-01-05 14:19 ` Eli Zaretskii
  0 siblings, 0 replies; 2+ messages in thread
From: Eli Zaretskii @ 2008-01-05 14:19 UTC (permalink / raw)
  To: Aleksandar Ristovski; +Cc: gdb-patches, drow, brobecker, RMansfield

> From: Aleksandar Ristovski <ARistovski@qnx.com>
> Cc: Daniel Jacobowitz <drow@false.org>, Joel Brobecker 	 <brobecker@adacore.com>, Ryan Mansfield <RMansfield@qnx.com>
> Date: Fri, 4 Jan 2008 14:02:30 -0500
> 
> +#define IS_DIR_SEPARATOR_X(c)	  ((c) == '/')
> +#define IS_ABSOLUTE_PATH_X(c)	  (IS_DIR_SEPARATOR_X((f)[0]))

I think _X is not appropriate here.  How about _POSIX?

> +
> +/* Universal macros, to be used on paths that could be either
> +   POSIX or DOS.  */

What would be the use of these _ANY predicates?  We always run on a
platform that is either DOS or Posix, but never both, right?

A minor nit: your ChangeLog entry

2008-01-04  Aleksandar Ristovski  <aristovski@qnx.com>

        * filenames.h (IS_DIR_SEPARATOR_DOS): New macro.
        (IS_ABSOLUTE_PATH_DOS): New macro.
        (IS_DIR_SEPARATOR_X): New macro.
        (IS_ABSOLUTE_PATH_X): New macro.
        (IS_DIR_SEPARATOR_ANY): New macro.
        (IS_ABSOLUTE_PATH_ANY): New macro.

has two problems:

 . It uses leading spaces instead of a single TAB (maybe due to your
   mailer's munging of whitespace).

 . You could rewrite it as a much more compact single entry:

2008-01-04  Aleksandar Ristovski  <aristovski@qnx.com>

	* filenames.h (IS_DIR_SEPARATOR_DOS, IS_ABSOLUTE_PATH_DOS)
	(IS_DIR_SEPARATOR_X, IS_ABSOLUTE_PATH_X, IS_DIR_SEPARATOR_ANY)
	(IS_ABSOLUTE_PATH_ANY): New macros.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-01-05 14:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-04 19:03 [patch] IS_ABSOLUTE_PATH to handle both DOS and POSIX path styles Aleksandar Ristovski
2008-01-05 14:19 ` Eli Zaretskii

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox