Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [commit] Strip DOS drive letter in openp
@ 2010-04-14 21:27 Doug Evans
  2010-04-14 21:52 ` Mark Kettenis
  0 siblings, 1 reply; 3+ messages in thread
From: Doug Evans @ 2010-04-14 21:27 UTC (permalink / raw)
  To: gdb-patches

Hi.

I've checked in this patch which strips a DOS drive spec if present
before concatenating string with the search path.

This is in reference to this thread:
http://sourceware.org/ml/gdb-patches/2010-04/msg00110.html
and in particular:
http://sourceware.org/ml/gdb-patches/2010-04/msg00277.html

2010-04-14  Doug Evans  <dje@google.com>

	* source.c (openp): Strip DOS drive letter if present before
	concatenating string to search path.

Index: source.c
===================================================================
RCS file: /cvs/src/src/gdb/source.c,v
retrieving revision 1.109
diff -u -p -r1.109 source.c
--- source.c	8 Apr 2010 21:08:39 -0000	1.109
+++ source.c	14 Apr 2010 21:18:59 -0000
@@ -724,6 +724,10 @@ openp (const char *path, int opts, const
 	    goto done;
     }
 
+  /* For dos paths, d:/foo -> /foo, and d:foo -> foo.  */
+  if (HAS_DRIVE_SPEC (string))
+    string = STRIP_DRIVE_SPEC (string);
+
   /* /foo => foo, to avoid multiple slashes that Emacs doesn't like. */
   while (IS_DIR_SEPARATOR(string[0]))
     string++;


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

* Re: [commit] Strip DOS drive letter in openp
  2010-04-14 21:27 [commit] Strip DOS drive letter in openp Doug Evans
@ 2010-04-14 21:52 ` Mark Kettenis
  2010-04-14 22:06   ` Doug Evans
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Kettenis @ 2010-04-14 21:52 UTC (permalink / raw)
  To: dje; +Cc: gdb-patches

> Date: Wed, 14 Apr 2010 14:27:45 -0700 (PDT)
> From: dje@google.com (Doug Evans)
> 
> Hi.
> 
> I've checked in this patch which strips a DOS drive spec if present
> before concatenating string with the search path.
> 
> This is in reference to this thread:
> http://sourceware.org/ml/gdb-patches/2010-04/msg00110.html
> and in particular:
> http://sourceware.org/ml/gdb-patches/2010-04/msg00277.html
> 
> 2010-04-14  Doug Evans  <dje@google.com>
> 
> 	* source.c (openp): Strip DOS drive letter if present before
> 	concatenating string to search path.
> 
> Index: source.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/source.c,v
> retrieving revision 1.109
> diff -u -p -r1.109 source.c
> --- source.c	8 Apr 2010 21:08:39 -0000	1.109
> +++ source.c	14 Apr 2010 21:18:59 -0000
> @@ -724,6 +724,10 @@ openp (const char *path, int opts, const
>  	    goto done;
>      }
>  
> +  /* For dos paths, d:/foo -> /foo, and d:foo -> foo.  */
> +  if (HAS_DRIVE_SPEC (string))
> +    string = STRIP_DRIVE_SPEC (string);
> +

Eh, where does HAS_DRIVE_SPEC come from?


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

* Re: [commit] Strip DOS drive letter in openp
  2010-04-14 21:52 ` Mark Kettenis
@ 2010-04-14 22:06   ` Doug Evans
  0 siblings, 0 replies; 3+ messages in thread
From: Doug Evans @ 2010-04-14 22:06 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: gdb-patches

On Wed, Apr 14, 2010 at 2:52 PM, Mark Kettenis <mark.kettenis@xs4all.nl> wrote:
>> Date: Wed, 14 Apr 2010 14:27:45 -0700 (PDT)
>> From: dje@google.com (Doug Evans)
>>
>> Hi.
>>
>> I've checked in this patch which strips a DOS drive spec if present
>> before concatenating string with the search path.
>>
>> This is in reference to this thread:
>> http://sourceware.org/ml/gdb-patches/2010-04/msg00110.html
>> and in particular:
>> http://sourceware.org/ml/gdb-patches/2010-04/msg00277.html
>>
>> 2010-04-14  Doug Evans  <dje@google.com>
>>
>>       * source.c (openp): Strip DOS drive letter if present before
>>       concatenating string to search path.
>>
>> Index: source.c
>> ===================================================================
>> RCS file: /cvs/src/src/gdb/source.c,v
>> retrieving revision 1.109
>> diff -u -p -r1.109 source.c
>> --- source.c  8 Apr 2010 21:08:39 -0000       1.109
>> +++ source.c  14 Apr 2010 21:18:59 -0000
>> @@ -724,6 +724,10 @@ openp (const char *path, int opts, const
>>           goto done;
>>      }
>>
>> +  /* For dos paths, d:/foo -> /foo, and d:foo -> foo.  */
>> +  if (HAS_DRIVE_SPEC (string))
>> +    string = STRIP_DRIVE_SPEC (string);
>> +
>
> Eh, where does HAS_DRIVE_SPEC come from?
>

It's new, in {gcc,src}/include/filenames.h.  Already approved and checked in.
Sorry for not including it, and noting that you need to update src/include.

HEADS UP EVERYONE: You need to update src/include.

2010-04-14  Doug Evans  <dje@google.com>

	* filenames.h (HAS_DRIVE_SPEC, STRIP_DRIVE_SPEC): New macros.

Index: filenames.h
===================================================================
RCS file: /cvs/src/src/include/filenames.h,v
retrieving revision 1.5
diff -u -p -r1.5 filenames.h
--- filenames.h	21 Mar 2008 23:40:18 -0000	1.5
+++ filenames.h	12 Apr 2010 17:19:32 -0000
@@ -5,7 +5,7 @@
    use forward- and back-slash in path names interchangeably, and
    some of them have case-insensitive file names.

-   Copyright 2000, 2001, 2007 Free Software Foundation, Inc.
+   Copyright 2000, 2001, 2007, 2010 Free Software Foundation, Inc.

 This file is part of BFD, the Binary File Descriptor library.

@@ -37,17 +37,27 @@ extern "C" {
 #endif

 #define IS_DIR_SEPARATOR(c)	((c) == '/' || (c) == '\\')
+
+#define HAS_DRIVE_SPEC(f)	(((f)[0]) && ((f)[1] == ':'))
+
+/* Remove the drive spec from F, assuming HAS_DRIVE_SPEC (f).
+   The result is a pointer to the remainder of F.  */
+#define STRIP_DRIVE_SPEC(f)	((f) + 2)
+
 /* Note that IS_ABSOLUTE_PATH accepts d:foo as well, although it is
    only semi-absolute.  This is because the users of IS_ABSOLUTE_PATH
    want to know whether to prepend the current working directory to
    a file name, which should not be done with a name like d:foo.  */
-#define IS_ABSOLUTE_PATH(f)	(IS_DIR_SEPARATOR((f)[0]) || (((f)[0]) &&
((f)[1] == ':')))
+#define IS_ABSOLUTE_PATH(f)	(IS_DIR_SEPARATOR((f)[0]) || HAS_DRIVE_SPEC(f))

 #else  /* not DOSish */

 #define IS_DIR_SEPARATOR(c)	((c) == '/')
 #define IS_ABSOLUTE_PATH(f)	(IS_DIR_SEPARATOR((f)[0]))

+#define HAS_DRIVE_SPEC(f)	(0)
+#define STRIP_DRIVE_SPEC(f)	(f)
+
 #endif /* not DOSish */

 extern int filename_cmp (const char *s1, const char *s2);


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

end of thread, other threads:[~2010-04-14 22:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-14 21:27 [commit] Strip DOS drive letter in openp Doug Evans
2010-04-14 21:52 ` Mark Kettenis
2010-04-14 22:06   ` Doug Evans

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