This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC]: Solib search (Was: Re: Cross solib support; continued)


Eli Zaretskii wrote:
> 
> > Date: Wed, 28 Nov 2001 11:00:09 +0100
> > From: Orjan Friberg <orjan.friberg@axis.com>
> 
> > That will only get rid of the first dir separator.
> 
> But that's what your original code did on Unix: it would test if the
> first character is a slash, and if so, step over that one slash.  Did
> I miss something?

No, you didn't miss anything ;) .  I forgot to explain something.

> Since we are under the if clause, we _know_ that the file name begins
> with either "/foo" or "d:/foo".  In the first case, IS_DIR_SEPARATOR
> returns 1, so the while loop is terminated immediately, but
> in_pathname was already bumped to point after the slash--that's what
> your original code did.  In the second code, the loop will march over
> the drive letter and the colon and terminate on the slash that
> follows, and again in_pathname will be incremented by the last
> iteration to point right after the slash.

I was trying to address the situation where in_pathname contains several
leading slashes; then your suggested code (and my original code also)
would terminate too early.  I guess we don't normally care about
multiple leading slashes since it's a valid path, but in this case we
need to get rid of all of them to make it a relative path.

This code should cut it:

  if (found_file < 0 && IS_ABSOLUTE_PATH (in_pathname))
    {
      /* First, get rid of any drive letters etc.  */
      while (!IS_DIR_SEPARATOR (*in_pathname))
        in_pathname++;

      /* Next, get rid of all leading dir separators.  */
      while (IS_DIR_SEPARATOR (*in_pathname))
        in_pathname++;
    }

(The first while loop could have been written like your original
suggestion, to have it consume the first dir separator also, but for
consistency I did them both in the same style.)

-- 
Orjan Friberg
Axis Communications AB


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]