This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: For Review: Sanitise Use of DIR_SEPARATOR in the Front-End
- From: Andrew Haley <aph at redhat dot com>
- To: tromey at redhat dot com
- Cc: Ranjit Mathew <rmathew at hotmail dot com>, java at gcc dot gnu dot org
- Date: Wed, 29 Jan 2003 11:58:13 +0000 (GMT)
- Subject: Re: For Review: Sanitise Use of DIR_SEPARATOR in the Front-End
- References: <b16iok$ku1$1@main.gmane.org><8765s9vtuz.fsf@fleche.redhat.com>
Tom Tromey writes:
> >>>>> "Ranjit" == Ranjit Mathew <rmathew@hotmail.com> writes:
>
> Ranjit> If any of this looks pathetic to you, do be nice enough to point
> Ranjit> out a better way of achieving the same. (The strcasecmp( ) thing
> Ranjit> makes the code look ugly - perhaps we can use a function pointer
> Ranjit> there?)
>
> You could just have a new function-style define:
>
> #ifdef ...
> #define COMPARE_FILENAMES(..) strcasecmp(..)
> ...
>
> I'd prefer that to having more #ifs in the body of the code.
> Maybe there is already such a define somewhere.
>
> Ranjit> In addition, I found a small issue with assuming a
> Ranjit> case-sensitive filesystem while scanning the classpath for ZIP
> Ranjit> or JAR files, and have included the fix for the same.
>
> What part of the patch is it? If it is independent it should go in as
> a separate fix.
>
> Ranjit> /* Get the name of the directory. */
> Ranjit> sep = strrchr (filename, DIR_SEPARATOR);
> Ranjit> +#ifdef DIR_SEPARATOR_2
> Ranjit> + if (! sep)
> Ranjit> + sep = strrchr (filename, DIR_SEPARATOR_2);
> Ranjit> +#endif
>
> Code like this should be rewritten. This isn't reliable if a path
> contains both `\' and `/'. I don't know if that is a valid situation.
> libiberty must have a directory-name-finding function...? That way
> "someone else" can worry about the details.
I don't understand why we can't just normalize the whole string before
scanning it. We don't want more than one directory separator.
Andrew.