]> granicus.if.org Git - php/commitdiff
MFH: sync
authorJani Taskinen <jani@php.net>
Tue, 6 Nov 2007 17:11:57 +0000 (17:11 +0000)
committerJani Taskinen <jani@php.net>
Tue, 6 Nov 2007 17:11:57 +0000 (17:11 +0000)
ext/standard/file.c
ext/standard/link.c
ext/standard/tests/file/fgetc_variation2.phpt
ext/standard/tests/file/readlink_realpath_error.phpt
ext/standard/tests/file/symlink_link_linkinfo_is_link_error1.phpt
ext/standard/tests/file/symlink_link_linkinfo_is_link_error2.phpt

index 4e7ddc1848434760f5891177a0119d72081c92cd..d2874d8cbb8c681bd5570d25a10e17ff12331dc5 100644 (file)
@@ -2358,16 +2358,15 @@ out:
    Return the resolved path */
 PHP_FUNCTION(realpath)
 {
-       zval **path;
+       char *filename;
+       int filename_len;
        char resolved_path_buff[MAXPATHLEN];
 
-       if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(ZEND_NUM_ARGS(), &path) == FAILURE) {
-               WRONG_PARAM_COUNT;
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &filename_len) == FAILURE) {
+               return;
        }
 
-       convert_to_string_ex(path);
-
-       if (VCWD_REALPATH(Z_STRVAL_PP(path), resolved_path_buff)) {
+       if (VCWD_REALPATH(filename, resolved_path_buff)) {
                if (PG(safe_mode) && (!php_checkuid(resolved_path_buff, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
                        RETURN_FALSE;
                }
index ebda3100a4584f5e9fc315ea28094553a444e559..9b54018db0e564e8bea34dbcb8f222b945ad89be 100644 (file)
    Return the target of a symbolic link */
 PHP_FUNCTION(readlink)
 {
-       zval **filename;
+       char *link;
+       int link_len;
        char buff[MAXPATHLEN];
        int ret;
 
-       if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &filename) == FAILURE) {
-               WRONG_PARAM_COUNT;
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &link, &link_len) == FAILURE) {
+               return;
        }
-       convert_to_string_ex(filename);
 
-       if (PG(safe_mode) && !php_checkuid(Z_STRVAL_PP(filename), NULL, CHECKUID_CHECK_FILE_AND_DIR)) {
+       if (PG(safe_mode) && !php_checkuid(link, NULL, CHECKUID_CHECK_FILE_AND_DIR)) {
                RETURN_FALSE;
        }
 
-       if (php_check_open_basedir(Z_STRVAL_PP(filename) TSRMLS_CC)) {
+       if (php_check_open_basedir(link TSRMLS_CC)) {
                RETURN_FALSE;
        }
 
-       ret = readlink(Z_STRVAL_PP(filename), buff, MAXPATHLEN-1);
+       ret = readlink(link, buff, MAXPATHLEN-1);
 
        if (ret == -1) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", strerror(errno));
@@ -88,16 +88,16 @@ PHP_FUNCTION(readlink)
    Returns the st_dev field of the UNIX C stat structure describing the link */
 PHP_FUNCTION(linkinfo)
 {
-       zval **filename;
+       char *link;
+       int link_len;
        struct stat sb;
        int ret;
 
-       if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &filename) == FAILURE) {
-               WRONG_PARAM_COUNT;
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &link, &link_len) == FAILURE) {
+               return;
        }
-       convert_to_string_ex(filename);
 
-       ret = VCWD_LSTAT(Z_STRVAL_PP(filename), &sb);
+       ret = VCWD_LSTAT(link, &sb);
        if (ret == -1) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", strerror(errno));
                RETURN_LONG(-1L);
@@ -111,18 +111,17 @@ PHP_FUNCTION(linkinfo)
    Create a symbolic link */
 PHP_FUNCTION(symlink)
 {
-       zval **topath, **frompath;
+       char *topath, *frompath;
+       int topath_len, frompath_len;
        int ret;
        char source_p[MAXPATHLEN];
        char dest_p[MAXPATHLEN];
 
-       if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &topath, &frompath) == FAILURE) {
-               WRONG_PARAM_COUNT;
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &topath, &topath_len, &frompath, &frompath_len) == FAILURE) {
+               return;
        }
-       convert_to_string_ex(topath);
-       convert_to_string_ex(frompath);
 
-       if (!expand_filepath(Z_STRVAL_PP(frompath), source_p TSRMLS_CC) || !expand_filepath(Z_STRVAL_PP(topath), dest_p TSRMLS_CC)) {
+       if (!expand_filepath(frompath, source_p TSRMLS_CC) || !expand_filepath(topath, dest_p TSRMLS_CC)) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "No such file or directory");
                RETURN_FALSE;
        }
@@ -151,7 +150,7 @@ PHP_FUNCTION(symlink)
        }
 
 #ifndef ZTS
-       ret = symlink(Z_STRVAL_PP(topath), Z_STRVAL_PP(frompath));
+       ret = symlink(topath, frompath);
 #else 
        ret = symlink(dest_p, source_p);
 #endif 
@@ -168,18 +167,17 @@ PHP_FUNCTION(symlink)
    Create a hard link */
 PHP_FUNCTION(link)
 {
-       zval **topath, **frompath;
+       char *topath, *frompath;
+       int topath_len, frompath_len;
        int ret;
        char source_p[MAXPATHLEN];
        char dest_p[MAXPATHLEN];
 
-       if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &topath, &frompath) == FAILURE) {
-               WRONG_PARAM_COUNT;
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &topath, &topath_len, &frompath, &frompath_len) == FAILURE) {
+               return;
        }
-       convert_to_string_ex(topath);
-       convert_to_string_ex(frompath);
 
-       if (!expand_filepath(Z_STRVAL_PP(frompath), source_p TSRMLS_CC) || !expand_filepath(Z_STRVAL_PP(topath), dest_p TSRMLS_CC)) {
+       if (!expand_filepath(frompath, source_p TSRMLS_CC) || !expand_filepath(topath, dest_p TSRMLS_CC)) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "No such file or directory");
                RETURN_FALSE;
        }
@@ -208,7 +206,7 @@ PHP_FUNCTION(link)
        }
 
 #ifndef ZTS
-       ret = link(Z_STRVAL_PP(topath), Z_STRVAL_PP(frompath));
+       ret = link(topath, frompath);
 #else 
        ret = link(dest_p, source_p);   
 #endif 
index d733c290927dcaec813a70ffbb93ec8814fbb4e1..75ac3488b42d1fa5617ea3dfb49b3bbdc917c0f0 100644 (file)
@@ -50,16 +50,3 @@ Notice: Undefined variable: file_handle in %s on line %d
 Warning: fgetc(): supplied argument is not a valid stream resource in %s on line %d
 bool(false)
 Done
---UEXPECTF--
-*** Testing fgetc() : usage variations ***
--- Testing fgetc() with closed handle --
-
-Warning: fgetc(): 6 is not a valid stream resource in %s on line %d
-bool(false)
--- Testing fgetc() with unset handle --
-
-Notice: Undefined variable: file_handle in %s on line %d
-
-Warning: fgetc(): supplied argument is not a valid stream resource in %s on line %d
-bool(false)
-Done
index f568601a9fa26b93c7e7eb2ec6bc7cc960f0a808..dc042bfff592cea42763d922775d0097014f7d21 100644 (file)
@@ -40,10 +40,10 @@ echo "Done\n";
 --EXPECTF--
 *** Testing readlink(): error conditions ***
 
-Warning: Wrong parameter count for readlink() in %s on line %d
+Warning: readlink() expects exactly 1 parameter, 0 given in %s on line %d
 NULL
 
-Warning: Wrong parameter count for readlink() in %s on line %d
+Warning: readlink() expects exactly 1 parameter, 2 given in %s on line %d
 NULL
 
 *** Testing readlink() on a non-existent link ***
@@ -62,10 +62,10 @@ Warning: readlink(): Invalid argument in %s on line %d
 bool(false)
 *** Testing realpath(): error conditions ***
 
-Warning: Wrong parameter count for realpath() in %s on line %d
+Warning: realpath() expects exactly 1 parameter, 0 given in %s on line %d
 NULL
 
-Warning: Wrong parameter count for realpath() in %s on line %d
+Warning: realpath() expects exactly 1 parameter, 2 given in %s on line %d
 NULL
 
 *** Testing realpath() on a non-existent file ***
index 2d393b2e4d5f93ca04d623022c779e39fc9ff205..8aae9b3bca15d77f09c8636d4286b0c15ecae239 100644 (file)
@@ -6,7 +6,7 @@ if (substr(PHP_OS, 0, 3) == 'WIN') {
     die('skip no symlinks on Windows');
 }
 if (substr(PHP_OS, 0, 3) == 'SUN') {
-    die('skip Not valid for Sun Solaris');
+  die('skip Not valid for Sun Solaris');
 }
 if (PHP_INT_SIZE != 4) {
   die("skip this test is for 32bit platform only");
@@ -72,10 +72,10 @@ unlink(dirname(__FILE__)."/symlink_link_linkinfo_is_link_error1.tmp");
 --EXPECTF--
 *** Testing symlink() for error conditions ***
 
-Warning: Wrong parameter count for symlink() in %s on line %d
+Warning: symlink() expects exactly 2 parameters, 0 given in %s on line %d
 NULL
 
-Warning: Wrong parameter count for symlink() in %s on line %d
+Warning: symlink() expects exactly 2 parameters, 3 given in %s on line %d
 NULL
 
 Warning: symlink(): %s in %s on line %d
@@ -98,10 +98,10 @@ bool(false)
 
 *** Testing linkinfo() for error conditions ***
 
-Warning: Wrong parameter count for linkinfo() in %s on line %d
+Warning: linkinfo() expects exactly 1 parameter, 0 given in %s on line %d
 NULL
 
-Warning: Wrong parameter count for linkinfo() in %s on line %d
+Warning: linkinfo() expects exactly 1 parameter, 2 given in %s on line %d
 NULL
 
 Warning: linkinfo(): %s in %s on line %d
index b8b233ab606dfb60cff6c972f3722bcda7da5146..3bee688d87f13cb99d7ce5d69e1a449577de5038 100644 (file)
@@ -5,7 +5,7 @@ Test symlink(), linkinfo(), link() and is_link() functions : error conditions -
 if (substr(PHP_OS, 0, 3) == 'WIN') {
     die('skip no symlinks on Windows');
 }
-if (PHP_INT_SIZE != 4) {
+if (PHP_INT_SIZE != 4 ) {
   die("skip this test is for 32bit platform only");
 }
 ?>
@@ -69,10 +69,10 @@ unlink(dirname(__FILE__)."/symlink_link_linkinfo_is_link_error2.tmp");
 --EXPECTF--
 *** Testing link() for error conditions ***
 
-Warning: Wrong parameter count for link() in %s on line %d
+Warning: link() expects exactly 2 parameters, 0 given in %s on line %d
 NULL
 
-Warning: Wrong parameter count for link() in %s on line %d
+Warning: link() expects exactly 2 parameters, 3 given in %s on line %d
 NULL
 
 Warning: link(): %s in %s on line %d