This is the mail archive of the binutils@sourceware.cygnus.com mailing list for the binutils project.


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

Re: (Fwd) Re: Absolute paths in BFD


> Date: Wed, 3 May 2000 18:07:46 +1000 (EST)
> From: Alan Modra <alan@linuxcare.com.au>
> 
> On Sat, 29 Apr 2000, Eli Zaretskii wrote:
> 
> > Could you please look at the patches I submitted and tell what else
> > should I do to get them accepted?
> 
> Here are some problems.

Thank you for your comments.

> 1) I think your test for the file name part of a path has a bug.  A path
> like "abc\\def/ghi" will not be handled correctly.  Change the code to
> something like this example for the first hunk in bfd/archive.c.  This
> needs fixing in many places.
> 
>   char *filename = strrchr (file, '/');
> 
> #ifdef DOSISH_FILENAMES
>   {
>     char *filename2 = strrchr (file, '\\');
>     if (filename2 > filename)
>       filename = filename2;
>     if (filename == NULL && file[0] != '\0' && file[1] == ':')
>       filename = file + 1;
>   }
> #endif

I'm not sure I see why my code (reproduced below) has a bug.  It seems
to be functionally equivalent to yours.  I tested my version,
including on your "abc\\def/ghi" example, and it seems to work
correctly.  Can you tell where you see a problem?

	filename = strrchr (file, '/');
      #ifdef DOSISH_FILENAMES
        /* We could have foo/bar\\baz, or foo\\bar, or d:bar.  */
        if (!filename || strchr (filename, '\\'))
          {
            filename = strrchr (filename ? filename : file, '\\');
            if (!filename && *file && file[1] == ':')
      	filename = file + 1;
          }
      #endif


> 2) IS_ABSOLUTE in include/filename.h should test for a slash after the
> colon.  a:zzz is not an absolute file.

I beg to disagree.  Strictly speaking, a:zzz is neither absolute nor
relative.  However, the purpose for which IS_ABSOLUTE was introduced
is to DTRT in code which prepends a directory name to file names which
aren't absolute.  You certainly don't want to prepend a directory to a
name like a:zzz!

In my experience, names like a:zzz are much closer to absolute than to
relative names.  However, to be sure, I just rechecked all the places
where IS_ABSOLUTE is used in my patches, and all of them precede code
that prepends a directory to non-absolute file names.  So I believe
the definition I suggested was a correct one.

> You also need some parentheses to keep gcc quiet.

Will do.

> 3) Satisfy Ian's concerns about O_BINARY and setmode.

Yep, working on that.

> 4) Your test for .exe suffix in binutils/objcopy.c should test that the
> length is > 4 first.

Well, in this case we *know* that the name is longer that 4
characters, especially since on DOS/Windows argv[0] includes the full
path, but I guess it's safer to check the length.  Thanks for pointing
this out.

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