state->cwd = (char *) realloc(state->cwd, state->cwd_length+ptr_length+1+1);
#ifdef TSRM_WIN32
/* Windows 9x will consider C:\\Foo as a network path. Avoid it. */
- if (state->cwd[state->cwd_length-1]!='\\' && state->cwd[state->cwd_length-1]!='/') {
+ if ((state->cwd[state->cwd_length-1]!='\\' && state->cwd[state->cwd_length-1]!='/') ||
+ IsDBCSLeadByte(state->cwd[state->cwd_length-2])) {
state->cwd[state->cwd_length++] = DEFAULT_SLASH;
}
#else
#define DEFAULT_SLASH '\\'
#define DEFAULT_DIR_SEPARATOR ';'
#define IS_SLASH(c) ((c) == '/' || (c) == '\\')
+#define IS_SLASH_P(c) (*(c) == '/' || \
+ (*(c) == '\\' && !IsDBCSLeadByte(*(c-1))))
#define COPY_WHEN_ABSOLUTE 2
#define IS_ABSOLUTE_PATH(path, len) \
(len >= 2 && isalpha(path[0]) && path[1] == ':')
#endif
#define IS_SLASH(c) ((c) == '/')
+#define IS_SLASH_P(c) (*(c) == '/')
#endif
/* strip trailing slashes */
while (*c == '/'
#ifdef PHP_WIN32
- || *c == '\\'
+ || (*c == '\\' && !IsDBCSLeadByte(*(c-1)))
#endif
)
c--;
if ((c = strrchr(s, '/'))
#ifdef PHP_WIN32
- || (c = strrchr(s, '\\'))
+ || ((c = strrchr(s, '\\')) && !IsDBCSLeadByte(*(c-1)))
#endif
) {
ret = estrdup(c + 1);
}
/* Strip trailing slashes */
- while (end >= path && IS_SLASH(*end)) {
+ while (end >= path && IS_SLASH_P(end)) {
end--;
}
if (end < path) {
}
/* Strip filename */
- while (end >= path && !IS_SLASH(*end)) {
+ while (end >= path && !IS_SLASH_P(end)) {
end--;
}
if (end < path) {
}
/* Strip slashes which came before the file name */
- while (end >= path && IS_SLASH(*end)) {
+ while (end >= path && IS_SLASH_P(end)) {
end--;
}
if (end < path) {