slash = path + strlen (path) - 1;
/* First, skip trailing slashes. */
- while (slash != path) {
- if (*slash != '/')
- break;
-
+ while (slash != path && *slash == '/')
--slash;
- }
/* Then, find a slash. */
- while (slash != path) {
- if (*slash == '/')
- break;
-
+ while (slash != path && *slash != '/') {
if (basename)
*basename = slash;
}
/* Finally, skip multiple slashes. */
- while (slash != path) {
- if (*(slash - 1) != '/')
- break;
-
+ while (slash != path && *(slash - 1) == '/')
--slash;
- }
if (slash == path) {
if (directory)