Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Doug Evans <dje@google.com>
To: Mark Kettenis <mark.kettenis@xs4all.nl>
Cc: gdb-patches@sourceware.org
Subject: Re: [commit] Strip DOS drive letter in openp
Date: Wed, 14 Apr 2010 22:06:00 -0000	[thread overview]
Message-ID: <r2ie394668d1004141506m81fe0f5bwda545a887739c855@mail.gmail.com> (raw)
In-Reply-To: <201004142152.o3ELqWUG014091@glazunov.sibelius.xs4all.nl>

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);


      reply	other threads:[~2010-04-14 22:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-14 21:27 Doug Evans
2010-04-14 21:52 ` Mark Kettenis
2010-04-14 22:06   ` Doug Evans [this message]

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=r2ie394668d1004141506m81fe0f5bwda545a887739c855@mail.gmail.com \
    --to=dje@google.com \
    --cc=gdb-patches@sourceware.org \
    --cc=mark.kettenis@xs4all.nl \
    /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