Index: gcc/include/filenames.h =================================================================== --- gcc.orig/include/filenames.h 2011-02-28 19:16:35.000000000 +0100 +++ gcc/include/filenames.h 2011-03-08 11:11:10.909109700 +0100 @@ -75,6 +75,8 @@ extern int filename_cmp (const char *s1, extern int filename_ncmp (const char *s1, const char *s2, size_t n); +extern char *filename_dirchr (const char *p); +extern char *filename_dirrchr (const char *p); #ifdef __cplusplus } Index: gcc/libiberty/filename_cmp.c =================================================================== --- gcc.orig/libiberty/filename_cmp.c 2011-02-28 19:16:35.000000000 +0100 +++ gcc/libiberty/filename_cmp.c 2011-03-08 11:43:32.797198100 +0100 @@ -125,3 +125,70 @@ filename_ncmp (const char *s1, const cha return 0; #endif } + +/* + +@deftypefn Extension int filename_dirchr (const char *@var{p}) + +The returned value is similar to what @code{strchr} would return for +searching for a directory separator. + +This function does not normalize file name. However, it does handle +the fact that on DOS-like file systems, forward and backward slashes +are directory separators. + +@end deftypefn + +*/ + +char * +filename_dirchr (const char *p) +{ + char *r; +#ifdef HAVE_DOS_BASED_FILE_SYSTEM + char *r2; +#endif + if (!p) + return NULL; + r = strchr (p, '/'); +#ifdef HAVE_DOS_BASED_FILE_SYSTEM + r2 = strchr (p, '\\'); + if (!r || (r2 && r2 < r)) + r = r2; +#endif + return r; +} + +/* + +@deftypefn Extension int filename_dirrchr (const char *@var{p}) + +The returned value is similar to what @code{strrchr} would return for +searching for a directory separator. + +This function does not normalize file name. However, it does handle +the fact that on DOS-like file systems, forward and backward slashes +are directory separators. + +@end deftypefn + +*/ + +char * +filename_dirrchr (const char *p) +{ + char *r; +#ifdef HAVE_DOS_BASED_FILE_SYSTEM + char *r2; +#endif + + if (!p) + return NULL; + r = strrchr (p, '/'); +#ifdef HAVE_DOS_BASED_FILE_SYSTEM + r2 = strrchr (p, '\\'); + if (!r || (r2 && r2 > r)) + r = r2; +#endif + return r; +} Index: gcc/libiberty/functions.texi =================================================================== --- gcc.orig/libiberty/functions.texi 2011-02-28 19:16:35.000000000 +0100 +++ gcc/libiberty/functions.texi 2011-03-08 11:43:42.314406700 +0100 @@ -296,6 +296,30 @@ and backward slashes are equal. @end deftypefn +@c filename_cmp.c:131 +@deftypefn Extension int filename_dirchr (const char *@var{p}) + +The returned value is similar to what @code{strchr} would return for +searching for a directory separator. + +This function does not normalize file name. However, it does handle +the fact that on DOS-like file systems, forward and backward slashes +are directory separators. + +@end deftypefn + +@c filename_cmp.c:164 +@deftypefn Extension int filename_dirrchr (const char *@var{p}) + +The returned value is similar to what @code{strrchr} would return for +searching for a directory separator. + +This function does not normalize file name. However, it does handle +the fact that on DOS-like file systems, forward and backward slashes +are directory separators. + +@end deftypefn + @c filename_cmp.c:81 @deftypefn Extension int filename_ncmp (const char *@var{s1}, const char *@var{s2}, size_t @var{n})