This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


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

Re: VAX PATCH: remove FILE_NAME_NONDIRECTORY


> 
> John David Anglin wrote:-
> 
> > > This is what mkdeps.c used to use, before I pushed for use to use basename
> > > instead (we dropped VMS support since no-one was prepared to fix the bit
> > > rot at the time):
> > 
> > Having looked some more at the pros and cons of using basename, I believe
> > it is not portable.  Thus, I would prefer not to use it.
> 
> But you're effectively writing your routine to do basename the VMS way, so
> I cannot understand your point.
> 
> It may be that you need to change basename()'s interface so that it
> returns a malloc-ed string which the caller is reponsible for freeing;
> I would prefer that to giving up on creating shared portable code.

As far as I can tell, for DOS and UNIX the method in libiberty and 
the method in the patch are functionaly equivalent.  After scanning
toplev.c, I found two other implementations.  They both scan from the
end of the string.  Frankly, the algorithm doesn't matter since this
isn't a key area for performance improvement.

I wouldn't mind puting this routine and possibly others to manage
file specifications into libiberty.  What I don't want to do is muck
with basename in libiberty or use it when a system doesn't provide
it.   Basename is non portable.  For example, this is the description of
basename for hpux:

      char *basename(char *path);

      basename() takes the path name pointed to by path and returns a
      pointer to the final component of the path name, deleting any trailing
      '/' characters.  If the string consists entirely of '/' characters,
      basename() returns a pointer to the string "/".  If path is a null
      pointer or points to the empty string, basename() returns a pointer to
      the string ".".

This is different from what is in libiberty.  Note that basename returns
the last component of a path.  The argument to basename is is const on
some systems and not on others.  Linux has two versions XPG and GNU.
And so on.

What is required here is given a string containing a file specifation to
return a string with the file name stripped of directory and other garbage.
I don't think we want a directory string back.

The comments in vax/xm-vms.h indicate that the returned file name needs
to be in lower case.  This isn't something that should be in basename.

The routine as it stands is not perfect.  I have nothing against trying
to develop a portable routine suitable to our needs and putting it where
it is easily accessible.  Am I being too picky?

Dave
-- 
J. David Anglin                                  dave.anglin@nrc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)


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