static char *php_mb_rfc1867_basename(const zend_encoding *encoding, char *filename TSRMLS_DC) /* {{{ */
{
- char *s, *tmp;
+ char *s, *s2, *tmp;
const size_t filename_len = strlen(filename);
/* The \ check should technically be needed for win32 systems only where
* the user does basename() they get a bogus file name. Until IE's user base drops
* to nill or problem is fixed this code must remain enabled for all systems. */
s = php_mb_safe_strrchr_ex(filename, '\\', filename_len, (const mbfl_encoding *)encoding);
- if ((tmp = php_mb_safe_strrchr_ex(filename, '/', filename_len, (const mbfl_encoding *)encoding)) > s) {
- s = tmp;
- }
- if (s) {
- return s + 1;
+ s2 = php_mb_safe_strrchr_ex(filename, '/', filename_len, (const mbfl_encoding *)encoding);
+
+ if (s && s2) {
+ if (s > s2) {
+ return ++s;
+ } else {
+ return ++s2;
+ }
+ } else if (s) {
+ return ++s;
+ } else if (s2) {
+ return ++s2;
} else {
return filename;
}
static char *php_ap_basename(const zend_encoding *encoding, char *path TSRMLS_DC)
{
char *s = strrchr(path, '\\');
- if (s) {
- char *tmp = strrchr(path, '/');
- if (tmp && tmp > s) {
- s = tmp + 1;
+ char *s2 = strrchr(path, '/');
+
+ if (s && s2) {
+ if (s > s2) {
+ ++s;
} else {
- s++;
+ s = ++s2;
}
- } else {
- s = path;
+ return s;
+ } else if (s) {
+ return ++s;
+ } else if (s2) {
+ return ++s2;
}
- return s;
+ return path;
}
/*