For Review: Sanitise Use of DIR_SEPARATOR in the Front-End

Andrew Haley aph@redhat.com
Wed Jan 29 11:58:00 GMT 2003


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.


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /