dmitry Wed Jan 21 19:11:50 2009 UTC
Modified files:
/TSRM tsrm_virtual_cwd.c
/php-src/ext/standard/tests/file fopen_variation10-win32.phpt
fopen_variation11-win32.phpt
Log:
Fixed realpath() behavior to support "c:dir" as "c:\dir", and "\dir" on UNC
CWD
http://cvs.php.net/viewvc.cgi/TSRM/tsrm_virtual_cwd.c?r1=1.132&r2=1.133&diff_format=u
Index: TSRM/tsrm_virtual_cwd.c
diff -u TSRM/tsrm_virtual_cwd.c:1.132 TSRM/tsrm_virtual_cwd.c:1.133
--- TSRM/tsrm_virtual_cwd.c:1.132 Wed Dec 31 11:12:28 2008
+++ TSRM/tsrm_virtual_cwd.c Wed Jan 21 19:11:48 2009
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: tsrm_virtual_cwd.c,v 1.132 2008/12/31 11:12:28 sebastian Exp $ */
+/* $Id: tsrm_virtual_cwd.c,v 1.133 2009/01/21 19:11:48 dmitry Exp $ */
#include <sys/types.h>
#include <sys/stat.h>
@@ -755,7 +755,27 @@
#ifdef TSRM_WIN32
if (IS_SLASH(path[0])) {
- state_cwd_length = 2;
+ if (state->cwd[1] == ':') {
+ /* Copy only the drive name */
+ state_cwd_length = 2;
+ } else if (IS_UNC_PATH(state->cwd,
state->cwd_length)) {
+ /* Copy only the share name */
+ state_cwd_length = 2;
+ while
(IS_SLASH(state->cwd[state_cwd_length])) {
+ state_cwd_length++;
+ }
+ while (state->cwd[state_cwd_length] &&
+
!IS_SLASH(state->cwd[state_cwd_length])) {
+ state_cwd_length++;
+ }
+ while
(IS_SLASH(state->cwd[state_cwd_length])) {
+ state_cwd_length++;
+ }
+ while (state->cwd[state_cwd_length] &&
+
!IS_SLASH(state->cwd[state_cwd_length])) {
+ state_cwd_length++;
+ }
+ }
}
#endif
if (path_length + state_cwd_length + 1 >= MAXPATHLEN-1)
{
@@ -767,7 +787,16 @@
path_length += state_cwd_length + 1;
}
} else {
- memcpy(resolved_path , path, path_length + 1);
+#ifdef TSRM_WIN32
+ if (path_length > 2 && path[1] == ':' && !IS_SLASH(path[2])) {
+ resolved_path[0] = path[0];
+ resolved_path[1] = ':';
+ resolved_path[2] = DEFAULT_SLASH;
+ memcpy(resolved_path + 3, path + 2, path_length - 1);
+ path_length++;
+ } else
+#endif
+ memcpy(resolved_path, path, path_length + 1);
}
#ifdef TSRM_WIN32
@@ -824,6 +853,7 @@
path_length = tsrm_realpath_r(resolved_path, start, path_length, &ll,
&t, use_realpath, 0, NULL TSRMLS_CC);
if (path_length < 0) {
+ errno = ENOENT;
return 1;
}
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/fopen_variation10-win32.phpt?r1=1.2&r2=1.3&diff_format=u
Index: php-src/ext/standard/tests/file/fopen_variation10-win32.phpt
diff -u php-src/ext/standard/tests/file/fopen_variation10-win32.phpt:1.2
php-src/ext/standard/tests/file/fopen_variation10-win32.phpt:1.3
--- php-src/ext/standard/tests/file/fopen_variation10-win32.phpt:1.2 Wed Nov
26 17:48:40 2008
+++ php-src/ext/standard/tests/file/fopen_variation10-win32.phpt Wed Jan
21 19:11:50 2009
@@ -112,11 +112,7 @@
Warning: fclose() expects parameter 1 to be resource, boolean given in %s on
line %d
--c:fopen10.tmpdirTwo--
-
-Warning: fopen(c:fopen10.tmpdirTwo\fopen_variation10.tmp): failed to open
stream: No such file or directory in %s on line %d
-file not opened for read
-
-Warning: fclose() expects parameter 1 to be resource, boolean given in %s on
line %d
+file in fopen10.tmpdirTwo
--c:adir--
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/fopen_variation11-win32.phpt?r1=1.2&r2=1.3&diff_format=u
Index: php-src/ext/standard/tests/file/fopen_variation11-win32.phpt
diff -u php-src/ext/standard/tests/file/fopen_variation11-win32.phpt:1.2
php-src/ext/standard/tests/file/fopen_variation11-win32.phpt:1.3
--- php-src/ext/standard/tests/file/fopen_variation11-win32.phpt:1.2 Wed Nov
26 17:48:41 2008
+++ php-src/ext/standard/tests/file/fopen_variation11-win32.phpt Wed Jan
21 19:11:50 2009
@@ -111,11 +111,7 @@
Warning: fclose() expects parameter 1 to be resource, boolean given in %s on
line %d
--c:fopen11.tmpdirTwo--
-
-Warning: fopen(c:fopen11.tmpdirTwo\fopen_variation11.tmp): failed to open
stream: No such file or directory in %s on line %d
-file not opened for read
-
-Warning: fclose() expects parameter 1 to be resource, boolean given in %s on
line %d
+file in fopen11.tmpdirTwo
--c:adir--
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php